Skip to content

Commit

Permalink
Fixed one-tailed correlation bug
Browse files Browse the repository at this point in the history
Also added one-tailed correlation demo
  • Loading branch information
markallenthornton committed Apr 6, 2016
1 parent 318df1b commit 14d2950
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
10 changes: 10 additions & 0 deletions demos/fwe_control.m
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,16 @@
fp(i) = sum(pcorr_pos(:)<.05)+sum(pcorr_neg(:)<.05);
end
sum(fp)/nsim % false positive rate
%% correlation, one-sided
nsim = 1000;
fp = NaN(nsim,1);
for i = 1:nsim
imgs = randn(4,4,4,20);
covariate = randn(20,1);
pcorr = matlab_tfce('correlation',1,imgs,[],covariate);
fp(i) = sum(pcorr(:)<.05)+sum(pcorr(:)<.05);
end
sum(fp)/nsim % false positive rate

%% correlation, two-sided
nsim = 1000;
Expand Down
6 changes: 3 additions & 3 deletions matlab_tfce_correlation.m
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@
% individual difference correlation between a covariate and brain activity.
%
% Arguments:
% imgs -- a 4D (x,y,z,subject) matrix of images. Like tfce_permutation,
% these should have had tfce_transform applied already.
% imgs -- a 4D (x,y,z,subject) matrix of images.
% covariate -- a vector of length = number of subjects containing values
% to be correlated with brain activity
% tails -- 1 or 2 tailed test
Expand Down Expand Up @@ -54,6 +53,7 @@
trueimg(implicitmask) = truestat;
trueimg = transform(trueimg,H,E,C,dh);
tfcestat = trueimg(implicitmask);
cvals = tfcestat;
if tails == 2
cvals = abs(tfcestat);
end
Expand Down Expand Up @@ -96,7 +96,7 @@
pcorr_neg(pos) = 1;
end

% assigne output to varargout
% assign output to varargout
if tails == 1
varargout{1} = pcorr;
else
Expand Down

0 comments on commit 14d2950

Please sign in to comment.