-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added missing data preprocessing script
- Loading branch information
1 parent
e91bb64
commit 59931a6
Showing
1 changed file
with
46 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
function [whtndfiltdata, whtndstd, TFtotal]=segdatacond(segdata, PSD, sampFreq, tidxs) | ||
|
||
fmin = 30; | ||
% sampfreq = 4096; | ||
|
||
filtdata = segdata; | ||
|
||
datalen = length(filtdata)/sampFreq; | ||
|
||
N = length(filtdata); | ||
Tsig = N/sampFreq; | ||
timeVec = (0:N-1)*(1/sampFreq); | ||
|
||
%Highpass Filter the data and handle NaN-regions | ||
% [filtdata, PSD, nanchunk_start_idxs, nanchunk_end_idxs] = nanhandle(data, sampFreq, fmin, tstart, seglen, winlen); | ||
|
||
%Create Transfer Function | ||
TF = 1./sqrt(PSD); | ||
|
||
%Set Values of TF below fmin to 0 | ||
TF(1:fmin*datalen) = 0; | ||
|
||
%Create entire Transfer Function vector | ||
negFStrt = 1-mod(N,2); | ||
kNyq = floor(N/2)+1; | ||
|
||
TFtotal = [TF, TF((kNyq-negFStrt):-1:2)]; | ||
|
||
%Whiten Filter Data with Transfer Function | ||
%Window data before FFT with a Tukey-window with a 0.5 seconds rolloff | ||
|
||
rolloff = 0.5; %Roll-off in seconds | ||
winfiltdata = filtdata.*tukeywin(length(filtdata), rolloff*sampFreq/N)'; | ||
|
||
fftfiltdata = fft(winfiltdata); | ||
|
||
whtndfftfiltdata = fftfiltdata.*TFtotal; | ||
|
||
whtndfiltdata = ifft(whtndfftfiltdata); | ||
|
||
%Divide by variance of whitened strain so that final whitened vector has | ||
%unit strain | ||
tstart = tidxs(1); | ||
tend = tidxs(2); | ||
whtndstd = std(whtndfiltdata(tstart: tend)); | ||
whtndfiltdata = whtndfiltdata/whtndstd; |