[FieldTrip] Error using indepsamplesZcoh function for calculating coherence differences
Schoffelen, J.M. (Jan Mathijs)
jan.schoffelen at donders.ru.nl
Tue May 18 16:21:58 CEST 2021
Hi Bushra,
Thank you for your reply. I am stuck with this for couple of days now.
Welcome to science.
>Can you please specify the cfg to ft_freqstatistics as well? Otherwise, we don’t know what you did exactly.
cfg = [];
cfg.method = 'montecarlo';
cfg.statistic = 'indepsamplesZcoh';
cfg.design(1,1:148)=1;
cfg.design(1,149:296)=2;
cfg.numrandomization = 1000;
cfg.correctm = 'cluster';
cfg.neighbours=[];
cfg.parameter='crsspctrm';
cfg.alpha = 0.05;
cfg.clusteralpha = 0.05;
stat=ft_freqstatistics(cfg,freq_coh);
Sorry I didnt follow this point. I am calling freqstatistics with above cfg parameters
To reiterate, you need to use cfg.parameter = ‘fourierspctrm’, and (cfg.output = ‘fourier’ when calling ft_freqanalysis). The low-level ft_statfun_indepsamplesZcoh assumes that the input data are fourier coefficients.
Next, as a disclaimer: I think that indepsamplesZcoh has hardly been used recently, so it could very well be that it’s functional behavior has not been kept up-to-date with the state of the rest of the toolbox.
>Also, ft_freqstatistics with cfg.statistic = ’indepsamplesZcoh’ requires frequency data that has been computed with >‘fourier’ rather than ‘powandcsd’ as cfg.method for ft_freqanalysis
when freq_coh is calculated with fourier method, then above code give following error
Error using ft_freqstatistics (line 177)
the length of the design matrix (1) does not match the number of observations in the data (2072)
It seems as if the dimord for fourier data is not read correctly, rpttap_chan_freq is getting confused with rpt_chan_freq as 2072 are rpttap , number of repetitions are only 296
If you use multitaper spectral analysis, each ’trial’ (aka rpt) gets more than one taper assigned, in your case about 7. These are the number of columns in your data matrix, so that needs to be reflected in the design. Therefore, the design have 2072 columns. In addition, for the randomization to be done correctly, you need to specify in the design, which columns belong to the same trial. So you need to define a second column consisting of [1 1 … 1 2 2 .. 2 …296] coding the individual trials. Then you need to appropriately set the cfg.ivar=1, and cfg.wvar=2 -> please consult the documentation on the fieldtrip website for this.
In addition you may need to specify cfg.origdim = [1 numel(freq_coh.freq)], and cfg.connectivity = false; before calling ft_freqstatistics.
Moreover, you may need to comment out lines 127 and 150 in ft_statfun_indepsamplesZcoh.m
I hope that this will help you on your way, to get it resolved for you. Perhaps you could filie a Pull Request on our github repository with the required change to ft_statfun_indepsamplesZcoh. Also it would be superhelpful for the rest of the community, if your experiences will be solidified in an example script that can be hosted on: https://www.fieldtriptoolbox.org/example/
Best wishes,
Jan-Mathijs
The error can be reproduced by running following script
https://www.dropbox.com/s/7bupsr8gkdmy28c/testcode.m?dl=0<https://urldefense.com/v3/__https://www.dropbox.com/s/7bupsr8gkdmy28c/testcode.m?dl=0__;!!HJOPV4FYYWzcc1jazlU!og3YlDTnQJXpbwiNKFrIAwklgaHzW9Gkdlv-WeCI05whozlcD9pwXXXbKggQyxNDb85XDPxE$>
with this data
https://www.dropbox.com/s/6gfj97srttteawy/Coh_data.mat?dl=0<https://urldefense.com/v3/__https://www.dropbox.com/s/6gfj97srttteawy/Coh_data.mat?dl=0__;!!HJOPV4FYYWzcc1jazlU!og3YlDTnQJXpbwiNKFrIAwklgaHzW9Gkdlv-WeCI05whozlcD9pwXXXbKggQyxNDb1di9xyl$>
Thank you
Kind regards
Bushra Riaz
________________________________
From: fieldtrip <fieldtrip-bounces at science.ru.nl<mailto:fieldtrip-bounces at science.ru.nl>> on behalf of Schoffelen, J.M. (Jan Mathijs) <jan.schoffelen at donders.ru.nl<mailto:jan.schoffelen at donders.ru.nl>>
Sent: 18 May 2021 14:05
To: FieldTrip discussion list <fieldtrip at science.ru.nl<mailto:fieldtrip at science.ru.nl>>
Subject: Re: [FieldTrip] Error using indepsamplesZcoh function for calculating coherence differences
Hi Bushra,
Can you please specify the cfg to ft_freqstatistics as well? Otherwise, we don’t know what you did exactly.
Also, ft_freqstatistics with cfg.statistic = ’indepsamplesZcoh’ requires frequency data that has been computed with ‘fourier’ rather than ‘powandcsd’ as cfg.method for ft_freqanalysis
Best wishes,
Jan_Mathijs
On 14 May 2021, at 13:36, Bushra Riaz Syeda <bushra.riaz at gu.se<mailto:bushra.riaz at gu.se>> wrote:
Hello,
I am trying to do the analysis based on the paper "nonparametric statistical testing of coherence differences" in fieldtrip for comparing differences between two conditions on single subject level.
I am using the following code
cfg = [];
cfg.method = 'montecarlo';
cfg.statistic = 'indepsamplesZcoh';
cfg.design(1,1:148)=1;
cfg.design(1,149:296)=2;
cfg.numrandomization = 1000;
cfg.correctm = 'cluster';
cfg.neighbours=[];
cfg.parameter='crsspctrm';
cfg.alpha = 0.05;
cfg.clusteralpha = 0.05;
stat=ft_freqstatistics(cfg,freq_coh);
Where freq_coh is calculated as
cfg = [];
cfg.output = 'powandcsd';
cfg.method = 'mtmfft';
cfg.foilim = [1 40];
cfg.tapsmofrq = 2;
cfg.pad = 'nextpow2';
cfg.keeptrials = 'yes';
freq_coh = ft_freqanalysis(cfg, Coh_data);
I am getting the following error
Error using ft_statistics_montecarlo (line 250)
could not determine the parametric critical value for clustering
Error in ft_freqstatistics (line 194)
[stat, cfg] = statmethod(cfg, dat, design);
Sample data can be found at the following link
https://www.dropbox.com/s/6gfj97srttteawy/Coh_data.mat?dl=0<https://urldefense.com/v3/__https://www.dropbox.com/s/6gfj97srttteawy/Coh_data.mat?dl=0__;!!HJOPV4FYYWzcc1jazlU!rzdciE12ryfrSpIQp-4LAZj3EK_9U0i1XJby6k79PqsvZKuG4jrCMN-qjHXKDzonA-cj5upg$>
[https://www.dropbox.com/static/images/spectrum-icons/generated/content/content-unknown-large.png]<https://urldefense.com/v3/__https://www.dropbox.com/s/6gfj97srttteawy/Coh_data.mat?dl=0__;!!HJOPV4FYYWzcc1jazlU!rzdciE12ryfrSpIQp-4LAZj3EK_9U0i1XJby6k79PqsvZKuG4jrCMN-qjHXKDzonA-cj5upg$>
Coh_data.mat<https://urldefense.com/v3/__https://www.dropbox.com/s/6gfj97srttteawy/Coh_data.mat?dl=0__;!!HJOPV4FYYWzcc1jazlU!rzdciE12ryfrSpIQp-4LAZj3EK_9U0i1XJby6k79PqsvZKuG4jrCMN-qjHXKDzonA-cj5upg$>
Shared with Dropbox
www.dropbox.com<https://urldefense.com/v3/__http://www.dropbox.com__;!!HJOPV4FYYWzcc1jazlU!rzdciE12ryfrSpIQp-4LAZj3EK_9U0i1XJby6k79PqsvZKuG4jrCMN-qjHXKDzonA7PXFKq_$>
any help would be highly appreciated
Kind regards
Bushra Riaz
_______________________________________________
fieldtrip mailing list
https://mailman.science.ru.nl/mailman/listinfo/fieldtrip
https://urldefense.com/v3/__https://doi.org/10.1371/journal.pcbi.1002202__;!!HJOPV4FYYWzcc1jazlU!rzdciE12ryfrSpIQp-4LAZj3EK_9U0i1XJby6k79PqsvZKuG4jrCMN-qjHXKDzonA0G39K1J$
_______________________________________________
fieldtrip mailing list
https://mailman.science.ru.nl/mailman/listinfo/fieldtrip
https://urldefense.com/v3/__https://doi.org/10.1371/journal.pcbi.1002202__;!!HJOPV4FYYWzcc1jazlU!og3YlDTnQJXpbwiNKFrIAwklgaHzW9Gkdlv-WeCI05whozlcD9pwXXXbKggQyxNDbwSy0ZCd$
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.science.ru.nl/pipermail/fieldtrip/attachments/20210518/be18b5fa/attachment.htm>
More information about the fieldtrip
mailing list