[FieldTrip] Technical issue with cluster based selection of electrodes (ft_freqstatistics)

Schoffelen, J.M. (Jan Mathijs) jan.schoffelen at donders.ru.nl
Fri Sep 11 17:19:18 CEST 2020


my line 79 in ft_freqstatistics (i.e. the one that is reported in your error stack) reads: ft_preamble loadvar varargin not ft_preamble help.
Have you by accident edited this file? Please fix it, and try to run it again.

JM


On 11 Sep 2020, at 16:51, Tertikas, Georgios <georgios.tertikas at kcl.ac.uk<mailto:georgios.tertikas at kcl.ac.uk>> wrote:

Hi Jan-Mathijs,

Thank you once again for your fast response.

I have actually called it as such  ([stat] = ft_freqstatistics(cfg,CA_11_TFR{:} ,CA_12_TFR{:})
But then I receive this error message:

Error using nargin
You can only call nargin/nargout from within a MATLAB function.

Error in ft_preamble_help (line 26)
if nargin==0

Error in ft_preamble (line 54)
  evalin('caller', ['ft_preamble_' cmd]);

Error in ft_freqstatistics (line 79)
ft_preamble help

Error in Grand_average_Cluster_based_electrode_selection (line 268)
[stat] = ft_freqstatistics(cfg,CA_11_TFR{:} ,CA_12_TFR{:})

From my understanding this might be related to a mismatch between the number of inputs and the number of outputs. After reading through the specifics of ft_freqstatistics it seems I need to have a single variable or is that not the case?

Thank you once again for all your help,

George


Από: fieldtrip <fieldtrip-bounces at science.ru.nl<mailto:fieldtrip-bounces at science.ru.nl>> για λογαριασμό του "Schoffelen, J.M. (Jan Mathijs)" <jan.schoffelen at donders.ru.nl<mailto:jan.schoffelen at donders.ru.nl>>
Απάντηση σε: FieldTrip discussion list <fieldtrip at science.ru.nl<mailto:fieldtrip at science.ru.nl>>
Ημερομηνία: Παρασκευή, 11 Σεπτεμβρίου 2020 - 15:25
Προς: FieldTrip discussion list <fieldtrip at science.ru.nl<mailto:fieldtrip at science.ru.nl>>
Θέμα: Re: [FieldTrip] Technical issue with cluster based selection of electrodes (ft_freqstatistics)

That depends on with what syntax you called ft_freqstatistics: if your data argument is an 1XN cell-array of data structures you need to call it like ft_freqstatistics(cfg, data1{:}, data2{:}), i.e. with the explicit bracket expansion.



On 11 Sep 2020, at 15:01, Tertikas, Georgios <georgios.tertikas at kcl.ac.uk<mailto:georgios.tertikas at kcl.ac.uk>> wrote:

Hi Jan-Mathijs,

Thank you very much for your fast reply and your input. I apologize for the format of the data, I will keep in mind your advice for the future.

Unfortunately I tried to put non-grand averaged input ( cell {12,1} containing one structure of TFR data from each participant) and the input I got was:

Error using ft_checkdata (line 529)
This function requires freq data as input, see ft_datatype_freq.

Error in ft_freqstatistics (line 97)
  varargin{i} = ft_checkdata(varargin{i}, 'datatype', 'freq', 'feedback', 'no');

Would you happen to know an alternative?

Thank you once again,

George

Από: fieldtrip <fieldtrip-bounces at science.ru.nl<mailto:fieldtrip-bounces at science.ru.nl>> για λογαριασμό του "Schoffelen, J.M. (Jan Mathijs)" <jan.schoffelen at donders.ru.nl<mailto:jan.schoffelen at donders.ru.nl>>
Απάντηση σε: FieldTrip discussion list <fieldtrip at science.ru.nl<mailto:fieldtrip at science.ru.nl>>
Ημερομηνία: Παρασκευή, 11 Σεπτεμβρίου 2020 - 13:41
Προς: FieldTrip discussion list <fieldtrip at science.ru.nl<mailto:fieldtrip at science.ru.nl>>
Θέμα: Re: [FieldTrip] Technical issue with cluster based selection of electrodes (ft_freqstatistics)

Hi Georgios,

The issue you are facing, is that you input grandaveraged data into ft_freqstatistics, which does not contain the individual subject estimates anymore. So indeed, as you already suspected yourself, there’s something wrong with the input into the function. Once the individual subject dimension is gone, it is impossible to compute a group-level T-statistic, let alone a corresponding critical value for clustering.

Indeed, once I managed to download the wetransfer files and load in one of the files, which nearly crashed my matlab because of its uncompressed size, it looks as if you are using the wrong variable as input to the statistics function.

Just for future reference, please only save (and upload) the variables that are needed to reproduce your problem, rather than your full matlab workspace).

Best wishes,
Jan-Mathijs




On 11 Sep 2020, at 11:56, Tertikas, Georgios <georgios.tertikas at kcl.ac.uk<mailto:georgios.tertikas at kcl.ac.uk>> wrote:

Hi List,

I am currently analyzing EEG data looking at alpha band frequencies.

I am analyzing TFR sequences from 12 participants for left and right stimuli (2 conditions) and I want to isolate the electrodes that show differential activation between the two conditions. As such I have been trying to perform cluster based selection of electrodes but I receive the following error message when using ft_freqstatistics:

Error using ft_statistics_montecarlo (line 242)
could not determine the parametric critical value for clustering

Error in ft_freqstatistics (line 193)
  [stat, cfg] = statmethod(cfg, dat, design);

Could someone aid me in that? I am also not entirely sure whether grand averaged data will be useful in my case but that is what is suggested in the official site.

My code up to this point is the following:

%% compute the cluster based statistics
cfg = [];

cfg.channel          = {'Fp1';'Fz';'F3';'FT9';'FC5';'FC1';'C3';'T7';'TP9';'CP5';'CP1';'Pz';'P3';'P7';'O1';'Oz';'O2';'P4';'P8';'TP10';'CP6';'CP2';'C4';'T8';'FT10';'FC6';'FC2';'F4';'F8';'AFz';'F1';'F5';'FT7';'FC3';'C1';'C5';'TP7';'CP3';'P1';'P5';'PO7';'PO3';'POz';'PO4';'PO8';'P6';'P2';'CPz';'CP4';'TP8';'C6';'C2';'FC4';'FT8';'F6';'AF4';'F2';'FCz'};
cfg.latency          = [0.8 1.15];
cfg.frequency        = 'all';
cfg.method           = 'montecarlo';
cfg.statistic        = 'ft_statfun_depsamplesT';
cfg.correctm         = 'cluster';
cfg.clusteralpha     = 0.05;
cfg.clusterstatistic = 'maxsum';
cfg.minnbchan        = 2;
cfg.tail             = 0;
cfg.clustertail      = 0;
cfg.alpha            = 0.025;
cfg.numrandomization = 1000;
% specifies with which sensors other sensors can form clusters

cfg.neighbours       = neighbours

subj = 12;
design = zeros(2,2*subj);
for i = 1:subj
  design(1,i) = i;
end
for i = 1:subj
  design(1,subj+i) = i;
end
design(2,1:subj)        = 1;
design(2,subj+1:2*subj) = 2;

cfg.design   = design;
cfg.uvar     = 1;
cfg.ivar     = 2;

[stat] = ft_freqstatistics(cfg,grand_averaged_11_TFR ,grand_averaged_12_TFR)


And the output that I receive is:

cfg =

  struct with fields:

             channel: {58×1 cell}
             latency: [0.8000 1.1500]
           frequency: 'all'
              method: 'montecarlo'
           statistic: 'ft_statfun_depsamplesT'
            correctm: 'cluster'
        clusteralpha: 0.0500
    clusterstatistic: 'maxsum'
           minnbchan: 2
                tail: 0
         clustertail: 0
               alpha: 0.0250
    numrandomization: 1000
          neighbours: [1×66 struct]

the call to "ft_selectdata" took 1 seconds and required the additional allocation of an estimated 22 MB
using specified neighbours for the channels
there are on average 6.8 neighbours per channel
the call to "ft_prepare_neighbours" took 0 seconds and required the additional allocation of an estimated 5 MB
using "ft_statistics_montecarlo" for the statistical testing
using "ft_statfun_depsamplesT" for the single-sample statistics
constructing randomized design
total number of measurements     = 2
total number of variables        = 24
number of independent variables  = 1
number of unit variables         = 1
number of within-cell variables  = 0
number of control variables      = 0
using a permutation resampling approach
repeated measurement in variable 1 over 1 levels
number of repeated measurements in each level is 2
the maximum number of unique permutations is 2
Warning: cfg.numrandomization is larger than the maximum number of unique permutations, better use 'all'
generated 1000 random permutations
computing a parametric threshold for clustering
Error using ft_statfun_depsamplesT (line 83)
The data must contain at least two units of observation (trials or subjects).
Error using ft_statistics_montecarlo (line 242)
could not determine the parametric critical value for clustering

Error in ft_freqstatistics (line 193)
  [stat, cfg] = statmethod(cfg, dat, design);


This is a wetransfer link with my data and with a mat file that I have created for the specific electrode array that I have (acticap_64).

https://we.tl/t-Jqn4HBFNzf<https://eur03.safelinks.protection.outlook.com/?url=https%3A%2F%2Fwe.tl%2Ft-Jqn4HBFNzf&data=01%7C01%7Cgeorgios.tertikas%40kcl.ac.uk%7C97c606cc538d45f31baa08d8565e8ed0%7C8370cf1416f34c16b83c724071654356%7C0&sdata=IDuubeok32fvn%2BIQWXTQQC1FXkTamuddQLK7lWYbE5w%3D&reserved=0>

Thank you very much in advance for your help.



_______________________________________________
fieldtrip mailing list
https://mailman.science.ru.nl/mailman/listinfo/fieldtrip<https://eur03.safelinks.protection.outlook.com/?url=https%3A%2F%2Fmailman.science.ru.nl%2Fmailman%2Flistinfo%2Ffieldtrip&data=01%7C01%7Cgeorgios.tertikas%40kcl.ac.uk%7C97c606cc538d45f31baa08d8565e8ed0%7C8370cf1416f34c16b83c724071654356%7C0&sdata=CzQogLCYxquZbqE0jamUY%2FyXvrxo%2B6X49OYwJsTEg%2Bw%3D&reserved=0>
https://doi.org/10.1371/journal.pcbi.1002202<https://eur03.safelinks.protection.outlook.com/?url=https%3A%2F%2Fdoi.org%2F10.1371%2Fjournal.pcbi.1002202&data=01%7C01%7Cgeorgios.tertikas%40kcl.ac.uk%7C97c606cc538d45f31baa08d8565e8ed0%7C8370cf1416f34c16b83c724071654356%7C0&sdata=yVbT3g9GpsvMfPBEGS6%2BrwtTKqvrmu2ag7wxAbzOCY4%3D&reserved=0>

_______________________________________________
fieldtrip mailing list
https://mailman.science.ru.nl/mailman/listinfo/fieldtrip<https://eur03.safelinks.protection.outlook.com/?url=https%3A%2F%2Fmailman.science.ru.nl%2Fmailman%2Flistinfo%2Ffieldtrip&data=01%7C01%7Cgeorgios.tertikas%40kcl.ac.uk%7C97c606cc538d45f31baa08d8565e8ed0%7C8370cf1416f34c16b83c724071654356%7C0&sdata=CzQogLCYxquZbqE0jamUY%2FyXvrxo%2B6X49OYwJsTEg%2Bw%3D&reserved=0>
https://doi.org/10.1371/journal.pcbi.1002202<https://eur03.safelinks.protection.outlook.com/?url=https%3A%2F%2Fdoi.org%2F10.1371%2Fjournal.pcbi.1002202&data=01%7C01%7Cgeorgios.tertikas%40kcl.ac.uk%7C97c606cc538d45f31baa08d8565e8ed0%7C8370cf1416f34c16b83c724071654356%7C0&sdata=yVbT3g9GpsvMfPBEGS6%2BrwtTKqvrmu2ag7wxAbzOCY4%3D&reserved=0>

_______________________________________________
fieldtrip mailing list
https://mailman.science.ru.nl/mailman/listinfo/fieldtrip
https://doi.org/10.1371/journal.pcbi.1002202

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.science.ru.nl/pipermail/fieldtrip/attachments/20200911/23387d83/attachment.htm>


More information about the fieldtrip mailing list