[FieldTrip] Cluster based permutation plot

Stephen Whitmarsh stephen.whitmarsh at gmail.com
Wed Aug 14 09:15:41 CEST 2019


Dear Luca,

You seem to be trying to use ft_selectdata for averaging over repetitions
(i.e. trials/epochs), but are providing data-structures of *patients*.
Easy mistake, and probably because in the tutorials you were looking at
within-subject statistics was explained.

To average across subjects use ft_timelockgrandaverage or
ft_freqgrandaverage. You should be able to proceed in a similar fashion.
To average/select data within a single datastructure, use ft_selectdata.

hope this helps,
Stephen








Op di 13 aug. 2019 om 12:20 schreef Luca Moretti <luca-moretti at hotmail.it>:

> Dear all,
>
>
>
> I am having some problems with plotting the results of a cluster based
> permutation test.
>
>
>
> I am running a within subjects’ experiment with 8 conditions combined in a
> 2X2X2 design. Theta and Alpha power are used as dependent variables. I
> would like to test some main effects and interactions, but first of all I
> have tried to compare two conditions ignoring the others (just as a
> practice before combining the conditions for a more theoreticaly relevant
> comparison).
>
>
>
> To this aim, I have created a cell array in which I have stored the
> normalized frequency power for each of the 20 participants. In this way I
> get a cell array with 8 conditions, each containing 20 cells (one per
> participant).
>
>
>
> Here is what I did:
>
>
>
> cfg = [];
>
> cfg.layout=layout;
>
> cfg.method = 'template';
>
> cfg.template = 'C:\Fieldtrip\template\neighbours\easycapM1_neighb.mat';
>
> cfg.feedback = 'yes';
>
> cfg.elecfile = 'C:\Fieldtrip\template\electrode\easycap-M1.txt';
>
> neighbours = ft_prepare_neighbours(cfg);
>
>
>
> subj = 20;
>
> 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 = [];
>
> cfg.channel          = {'all'};
>
> cfg.frequency        = [4 12];
>
> cfg.latency          = [0 1.5];
>
> cfg.method           = 'montecarlo';
>
> cfg.statistic        = 'depsamplesT';
>
> cfg.correctm         = 'cluster';
>
> cfg.clusteralpha     = 0.05;
>
> cfg.clusterstatistic = 'maxsum';
>
> cfg.minnbchan        = 2;
>
> cfg.tail             = 0;
>
> cfg.clustertail      = 0;
>
> cfg.alpha            = 0.05;
>
> cfg.numrandomization = 500;
>
> cfg.design   = design;
>
> cfg.ivar     = 2;
>
> cfg.uvar = 1;
>
> cfg.neighbours = neighbours;
>
>
>
> stat1 = ft_freqstatistics(cfg,  normalized{1,1}{:}, normalized{1,2}{:});
>
>
>
> So far so good. Following the online tutorial I have tried to execute the
> following code:
>
>
>
> sigposmask = (stat1.posclusterslabelmat==1) & stat1.mask;
>
> signegmask = (stat1.negclusterslabelmat==1) & stat1.mask;
>
>
>
> cfg = [];
>
> cfg.frequency  = [4 12];
>
> cfg.avgoverrpt = 'yes';
>
> cfg.parameter  = {'powspctrm','powspctrm_b'};
>
> WDW_avg = ft_selectdata(cfg, normalized{1,1}{:});
>
> CDW_avg = ft_selectdata(cfg,  normalized{1,2}{:});
>
>
>
> WDW_avg.mask = signegmask;
>
> CDW_avg.mask = signegmask;
>
>
>
> cfg = [];
>
> cfg.elec          = elec;
>
> cfg.colorbar      = 'no';
>
> cfg.maskparameter = 'mask';  % use the thresholded probability to mask the
> data
>
> cfg.maskstyle     = 'box';
>
> cfg.parameter     = 'powspctrm_b';
>
> cfg.maskfacealpha = 0.5;
>
>
>
> figure; ft_multiplotER(cfg, WDW_avg, CDW_avg);
>
>
>
> However, when I try to run the line:
>
>
>
> WDW_avg = ft_selectdata(cfg, normalized{1,1}{:});
>
> there are no repetitions, so averaging is not possible
>
>
>
> I have therefore tried to remove the {:}, but still:
>
>
>
> WDW_avg = ft_selectdata(cfg, normalized{1,1};
>
> Invalid input argument of type 'cell'. Input must be a structure or a Java
> or COM object
>
>
>
> I do understand the errors, but I don’t see how the data should have been
> stored if not in a cell array. Can someone help?
>
>
>
> Thank you in advance,
>
> Luca
>
>
>
> Inviato da Posta <https://go.microsoft.com/fwlink/?LinkId=550986> per
> Windows 10
>
>
> _______________________________________________
> 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/20190814/bc917d1a/attachment.html>


More information about the fieldtrip mailing list