Skip to content

Commit 14d2950

Browse files
Fixed one-tailed correlation bug
Also added one-tailed correlation demo
1 parent 318df1b commit 14d2950

File tree

2 files changed

+13
-3
lines changed

2 files changed

+13
-3
lines changed

demos/fwe_control.m

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,16 @@
4141
fp(i) = sum(pcorr_pos(:)<.05)+sum(pcorr_neg(:)<.05);
4242
end
4343
sum(fp)/nsim % false positive rate
44+
%% correlation, one-sided
45+
nsim = 1000;
46+
fp = NaN(nsim,1);
47+
for i = 1:nsim
48+
imgs = randn(4,4,4,20);
49+
covariate = randn(20,1);
50+
pcorr = matlab_tfce('correlation',1,imgs,[],covariate);
51+
fp(i) = sum(pcorr(:)<.05)+sum(pcorr(:)<.05);
52+
end
53+
sum(fp)/nsim % false positive rate
4454

4555
%% correlation, two-sided
4656
nsim = 1000;

matlab_tfce_correlation.m

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,7 @@
33
% individual difference correlation between a covariate and brain activity.
44
%
55
% Arguments:
6-
% imgs -- a 4D (x,y,z,subject) matrix of images. Like tfce_permutation,
7-
% these should have had tfce_transform applied already.
6+
% imgs -- a 4D (x,y,z,subject) matrix of images.
87
% covariate -- a vector of length = number of subjects containing values
98
% to be correlated with brain activity
109
% tails -- 1 or 2 tailed test
@@ -54,6 +53,7 @@
5453
trueimg(implicitmask) = truestat;
5554
trueimg = transform(trueimg,H,E,C,dh);
5655
tfcestat = trueimg(implicitmask);
56+
cvals = tfcestat;
5757
if tails == 2
5858
cvals = abs(tfcestat);
5959
end
@@ -96,7 +96,7 @@
9696
pcorr_neg(pos) = 1;
9797
end
9898

99-
% assigne output to varargout
99+
% assign output to varargout
100100
if tails == 1
101101
varargout{1} = pcorr;
102102
else

0 commit comments

Comments
 (0)