[FieldTrip] Correction for MCP using ft_statfun_correlationT

Schoffelen, J.M. (Jan Mathijs) janmathijs.schoffelen at donders.ru.nl
Thu Nov 23 15:35:25 CET 2023


Hi Pia,

In order to debug this further I would like to suggest that you put a breakpoint in ft_statistics_montecarlo, at line 247 (which in my latest fieldtrip version reads: cfg.clustercritval    = getfield(statfun(tmpcfg, dat, design), 'critval');)
Then, you need to execute the following function call on the matlab command line: s=statfun(tmpcfg, dat, design);
I that results in an error, you may want to investigate why this is the case, otherwise you may want to inspect the output variable s, which should contain a field called critval.
Best wishes,
Jan-Mathijs


On 20 Nov 2023, at 11:36, Pia Reinfeld via fieldtrip <fieldtrip at science.ru.nl<mailto:fieldtrip at science.ru.nl>> wrote:

Hi Jan-Mathijs,

thank you for your quick response!
I did specify this option, but I forgot to include it in the code-snipped, sorry for that!
So it looks like that:

        cfg = [];
        cfg.channel          = {'all', '-ECG'};
        cfg.statistic        = 'ft_statfun_correlationT';
        cfg.method           = 'montecarlo';
        cfg.computestat      = 'yes';
        cfg.computecritval   = 'yes';
        cfg.computeprob      = 'yes';
        cfg.alpha            = 0.05;
        cfg.tail             = 0;
        cfg.correcttail      = 'alpha';
        cfg.numrandomization = 10000;
        cfg.correctm         = 'cluster';
        cfg.clusterstatistic = 'maxsum';
        cfg.alpha            = 0.025;
        cfg.clustertail      = 0;
        cfg.clusteralpha     = 0.05;
        cfg.neighbours       = neighbours;
        design = [];
        n1 = length(target);    % number of subjects
        design(1,1:n1)       = fraction_ES_N;
        cfg.design           = design;
        cfg.ivar             = 1;

        stat = ft_timelockstatistics(cfg, diff{:});

The complete error is:
Error using ft_statfun_correlationT
P-values can only be calculated if the test statistics are calculated.
Error using ft_statistics_montecarlo could not determine the parametric critical value for clustering
Error in ft_timelockstatistics (line 185) [stat, cfg] = statmethod(cfg, dat, design);

So I found in line 66 of ft_statfun_correlationT.m, where it checks if the test stats are calculated, so that the probability can be calculated:

if strcmp(cfg.computeprob, 'yes') && strcmp(cfg.computestat, 'no')
  ft_error('P-values can only be calculated if the test statistics are calculated.');
end

But this if statement should be false, because as you can see in my configuration I defined both as ‘yes’. So my configuration might be overwritten within in the scripts or am I wrong?

Thank you again and all the best,
Pia

Von: fieldtrip <fieldtrip-bounces at science.ru.nl<mailto:fieldtrip-bounces at science.ru.nl>> Im Auftrag von Schoffelen, J.M. (Jan Mathijs) via fieldtrip
Gesendet: Samstag, 18. November 2023 17:56
An: FieldTrip discussion list <fieldtrip at science.ru.nl<mailto:fieldtrip at science.ru.nl>>
Cc: Schoffelen, J.M. (Jan Mathijs) <janmathijs.schoffelen at donders.ru.nl<mailto:janmathijs.schoffelen at donders.ru.nl>>
Betreff: Re: [FieldTrip] Correction for MCP using ft_statfun_correlationT

Hi Pia,


On 17 Nov 2023, at 17:55, Pia Reinfeld via fieldtrip <fieldtrip at science.ru.nl<mailto:fieldtrip at science.ru.nl>> wrote:

Dear community,

I am currently working on statistically testing the correlation between EEG data (dependent variable) and quantitative data (independent variable).

I'm using the ft_statfun_correlationT function to correlate and test the quantitative independent variable (e.g. reaction time), which is one value per subject, with the subject's averaged ERP data (31channelx500timepoints) (~100 subjects). I used this configuration from the tutorial and it worked well:

% compute statistics with correlationT
cfg = [];
cfg.statistic        = 'ft_statfun_correlationT';
cfg.method           = 'montecarlo';
cfg.numrandomization = 1000;

n1 = 99;
design(1,1:n1)       = qualitative_variable; % e.g. [0.25, 0.22, …]
cfg.design           = design;
cfg.ivar             = 1;

stat = ft_freqstatistics(cfg, data_brain{:});

I saw that the t-values are calculated by using this:
tstat = rho*(sqrt(nrepl-2))./sqrt((1-rho.^2))

I'm afraid I don't know much about statistics. But wouldn't it be appropriate to correct for the multiple comparison problem by using a cluster-based approach?

Yes, that should be possible.


So I tried to add this to my configuration:

cfg.alpha = 0.025;
cfg.correcttail = 'alpha';
cfg.correctm = 'cluster';
cfg.clustertail = 0;
cfg.clusteralpha = 0.05;
cfg.clusterstatistic = 'maxsum';
cfg.neighbours = neighbours;

I get the error:
Error using ft_statistics_montecarlo could not determine the parametric critical value for clustering
Error in ft_timelockstatistics (line 185)
[stat, cfg] = statmethod(cfg, dat, design);

The error is caused by the fact that the function that is used under the hood for the computation of the (t-scored) correlation value - i.e. ft_statfun_correlationT did not properly compute the corresponding parametric p-value. This is due to the fact that most likely, you did not specify cfg.computeprob = ‘yes’, which is needed to overrule the default value for this parameter (which happens to be ’no’).

I hope that this helps.

Best wishes,
Jan-Mathijs


Is there already a correction for MCP and am I thinking wrongly by using a cluster based approach?
How is the cfg.numrandomization implemented in this statistic? I may have missed something, but it didn't look like random permutation was being used at all.

Any help would be highly appreciated.

Thank you very much and all the best,
Pia
_______________________________________________
fieldtrip mailing list
https://mailman.science.ru.nl/mailman/listinfo/fieldtrip<https://eur01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fmailman.science.ru.nl%2Fmailman%2Flistinfo%2Ffieldtrip&data=05%7C01%7Cfieldtrip%40science.ru.nl%7C0e55a93d18e24c90844708dbec316e41%7C084578d9400d4a5aa7c7e76ca47af400%7C1%7C0%7C638363469266588288%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=QKiJVLCcv7Q1wTKehmzFj6fo03FbybsSCuFeF%2FeJcnU%3D&reserved=0>
https://doi.org/10.1371/journal.pcbi.1002202<https://eur01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fdoi.org%2F10.1371%2Fjournal.pcbi.1002202&data=05%7C01%7Cfieldtrip%40science.ru.nl%7C0e55a93d18e24c90844708dbec316e41%7C084578d9400d4a5aa7c7e76ca47af400%7C1%7C0%7C638363469266588288%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=%2BAq0RiVN3hc5a27eQw5SwEI%2FQP3IWiDYAu3yMaxnbBw%3D&reserved=0>

_______________________________________________
fieldtrip mailing list
https://mailman.science.ru.nl/mailman/listinfo/fieldtrip<https://eur01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fmailman.science.ru.nl%2Fmailman%2Flistinfo%2Ffieldtrip&data=05%7C01%7Cfieldtrip%40science.ru.nl%7C0e55a93d18e24c90844708dbec316e41%7C084578d9400d4a5aa7c7e76ca47af400%7C1%7C0%7C638363469266588288%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=QKiJVLCcv7Q1wTKehmzFj6fo03FbybsSCuFeF%2FeJcnU%3D&reserved=0>
https://doi.org/10.1371/journal.pcbi.1002202<https://eur01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fdoi.org%2F10.1371%2Fjournal.pcbi.1002202&data=05%7C01%7Cfieldtrip%40science.ru.nl%7C0e55a93d18e24c90844708dbec316e41%7C084578d9400d4a5aa7c7e76ca47af400%7C1%7C0%7C638363469266588288%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=%2BAq0RiVN3hc5a27eQw5SwEI%2FQP3IWiDYAu3yMaxnbBw%3D&reserved=0>

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.science.ru.nl/pipermail/fieldtrip/attachments/20231123/73d2c0a4/attachment.htm>


More information about the fieldtrip mailing list