-
Notifications
You must be signed in to change notification settings - Fork 0
/
filterData.m
35 lines (30 loc) · 1.04 KB
/
filterData.m
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
31
32
33
34
function [filteredData] = filterData(AllData_indi,windowsize)
%% this function smooths data.
%implementation of a gaussian smoothning filter:
% if strcmp(type,'gaussian')
% wght=normpdf(linspace(-2,2,windowsize*2));wght=wght(windowsize:end);
% normalize=(1/sum(wght));
% elseif strcmp(type,'boxcar')
% wght=ones(1,windowsize);
% normalize=1/windowsize;
% end
% b=normalize*wght;
% a=1;
sz=size(AllData_indi);
filteredData=NaN*ones(sz);
for chano=1:sz(1)
for finger=1:sz(2)
for movt=1:sz(3)
for trl=1:sz(5)
currdata=AllData_indi(chano,finger,movt,:,trl);
currdata=reshape(currdata,sz(4),[]);
currdata=currdata(~isnan(currdata));
%filtereddat=filter(b,a,currdata);
filtereddat=smooth(currdata,windowsize,'lowess');
filtereddat=reshape(filtereddat,1,1,1,length(filtereddat),1);
filteredData(chano,finger,movt,1:length(filtereddat),trl)=filtereddat;
end
end
end
end
end