-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathotss.R
30 lines (22 loc) · 829 Bytes
/
otss.R
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
##------------------ Subsample OpenTag sensor data----------##
# Use this function to subsample OpenTag sensor data (Loggerhead
# Instruments, loggerhead.com). For example, you can use this
# function to subsample your raw data collected at 100 Hz to 5 Hz.
# Reny Tyson, [email protected]
# 5 October 2016
##############################################################
otss <- function(d,w,order,Hz,ss){
require(signal)
# d is your raw data
# W should be at least half of your Nygest frequency
# order is the desired order of the butterworth filter
# Hz is the sampling frequency of your raw data
# ss is your desired sampling frequency
#Filter your data
bf <- butter(order,w,type='low')
filt <- filter(bf,d)
s.s <- seq(1,length(d),Hz/ss)
#subset your data
ssd <- d[s.s]
return(ssd)
}