[FieldTrip] Error in correlation analysis with ft_freqstatistics
jan-mathijs schoffelen
jan.schoffelen at donders.ru.nl
Tue Jan 25 21:16:38 CET 2011
Dear Rodolphe,
The trick here is not to specify cfg.statistic = 'indepsamplesF';
You need to specify cfg.statistic = 'yourownfunction', and create an m-
file 'statfun_yourownfunction.m' that computes a correlation. That
could look like
function s = statfun_yourownfunction(cfg, dat, design)
% mean subtract
mdat = mean(dat,2);
dat = dat - mdat(:,ones(1,size(dat,2)));
mdesign = mean(design);
design = design - mean(design);
% covariance
covdat = dat*design';
% variance
vdat = sum(dat.^2,2);
vdes = sum(design.^2);
% correlation
s.stat = covdat./sqrt(vdat.*vdes);
This is just typed down in half a minute so don't take it for granted.
Best,
Jan-Mathijs
On Jan 25, 2011, at 9:02 PM, Rodolphe Nenert wrote:
> Dear Fieldtrip Users,
>
> im actually trying to do a correlation analysis between frequency
> power and behavioral results.
> The problem is when i change the design matrix containing the
> classical independent variables to behavioral scores, as indicate in
> the walktrough section of the fieldtrip website :
>
> cfg.design = [ .1 .2 .4 .3 etc...];
> cfg.ivar = 1;
>
> Then, Matlab gives me the following errors:
>
> ??? Error using ==> statfun_indepsamplesF at 55
> Invalid specification of the independent variable in the design array.
>
> Error in ==> statistics_montecarlo at 241
> [statobs, cfg] = statfun(cfg, dat, design);
>
> Error in ==> statistics_wrapper at 285
> [stat, cfg] = statmethod(cfg, dat, cfg.design,
> 'issource',issource);
>
> Error in ==> ft_freqstatistics at 127
> [stat, cfg] = statistics_wrapper(cfg, varargin{:});
>
> Does anyone have an example of a script for such analysis that works?
>
> Thanks,
>
> Rodolphe.
> _______________________________________________
> fieldtrip mailing list
> fieldtrip at donders.ru.nl
> http://mailman.science.ru.nl/mailman/listinfo/fieldtrip
Dr. J.M. (Jan-Mathijs) Schoffelen
Donders Institute for Brain, Cognition and Behaviour,
Centre for Cognitive Neuroimaging,
Radboud University Nijmegen, The Netherlands
J.Schoffelen at donders.ru.nl
Telephone: 0031-24-3614793
More information about the fieldtrip
mailing list