diff --git a/demos/fwe_control.m b/demos/fwe_control.m index 83b93d4..05a18f1 100644 --- a/demos/fwe_control.m +++ b/demos/fwe_control.m @@ -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; diff --git a/matlab_tfce_correlation.m b/matlab_tfce_correlation.m index f2ca171..7c2d63c 100644 --- a/matlab_tfce_correlation.m +++ b/matlab_tfce_correlation.m @@ -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 @@ -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 @@ -96,7 +96,7 @@ pcorr_neg(pos) = 1; end -% assigne output to varargout +% assign output to varargout if tails == 1 varargout{1} = pcorr; else