-
Notifications
You must be signed in to change notification settings - Fork 0
/
cfcdiff_wilx.m
52 lines (45 loc) · 1.09 KB
/
cfcdiff_wilx.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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
function [varargout]=cfcdiff_wilx(a,b,amask,bmask)
% Wilcoxon signed-rank test on normalized difference in CFC
%
% [stat,p]=cfcdiff_wilx(a,b)
% [stat,p]=cfcdiff_wilx(a,b,amask,bmask)
% [stat,p,d]=cfcdiff_wilx(...)
%
% normalized difference=(b-a)/(b+a). If logical matrices amask and bmask
% are supplied, then they are used to mask a and b to zero, respectivley.
% Copyright 2014, Benjamin Voloh
% Distributed under a GNU GENERAL PUBLIC LICENSE
%inputs
if nargin>2
%logic check
if ~islogical(amask) || ~islogical(bmask)
error('amask and bmask must be logical')
else
surrMask=1;
end
else
surrMask=0;
end
%mask non-significant values to zero
if surrMask
a(~amask)=0;
b(~bmask)=0;
end
%calculate normalized difference
d=normdiff(a,b);
%statistical testing for each freq-freq pair
for n=1:size(d,1)
for m=1:size(d,2)
[p(n,m),~,tmp]=signrank(squeeze(d(n,m,:)));
stat(n,m)=tmp.signedrank; %OR .zval
end
end
% FDR correction
alpha=0.05;
[p,~]=bonf_holm(p,alpha);
%output
varargout{1}=stat;
varargout{2}=p;
if nargout>2
varargout{3}=d;
end