[FieldTrip] Cluster based permutation test for single channel, ft_freqstatistics

Schoffelen, J.M. (Jan Mathijs) janmathijs.schoffelen at donders.ru.nl
Tue Aug 8 19:36:24 CEST 2023

Hi Stephanie,

I think that there is something wrong with what you want to achieve (at least what I think you want to achieve), and the way you try to achieve it.

If you want to make a comparison between the onset/choice/outcome segments of your data, you should NOT artificially represent them as different channels. Rather, you’d need to represent each of the individual (sub-)segments of the individual trials (if you want to use the trials as a unit of observation) as separate data matrices, or the average per (sub-)segment across trials for each patient (if you want to use the patient as a unit of observation). Then, if you want to use a(n in)dependent T-statistic as the test statistic, you can only do a pairwise comparison, and this means that the specified design should contains 1’s and 2’s.

I would expect you to create 3 data structures, one for each part of the trial onset/choice/outcome, which can be either compared in a pairwise fashion using (in)depsamplesT, or in a single shot, using an F-statistic. Note, that given the presence of a time dimension, there’s a hard requirement that the time axes for each of the conditions has the same number of time points (and that the corresponding time axis should be faked to be numerically identical across the three conditions) in order for the FT-machinery to work. I think it would make sense to collapse across time in the first instance, because my hunch is that 1) the condition that I mentioned in the previous sentence is not met in your data, and 2) I don’t know whether there is a specific physiological reason to assume that it is meaningful to compare in a pairwise fashion -say- the power at x ms after task onset with the power at exact x ms after choice onset.

Good luck,

On 7 Aug 2023, at 20:46, Brener, Stephanie via fieldtrip <fieldtrip at science.ru.nl<mailto:fieldtrip at science.ru.nl>> wrote:

Hi fieldtrippers,

I am trying to perform cluster-based permutation testing on a single channel of DBS electrode data to cluster in time/frequency rather than spatially. I have already pre-processed, cleaned, and separated time-locked events for the data outside of fieldtrip, leaving me with measures of baseline-corrected power in a data array with these dimensions: (50 frequencies x 500 time samples x 180 trials x 3 events).

The dimensions can be described by:

  *   50 Morlet wavelets from 0 to 50Hz --> power at 50 frequencies
  *   500 samples = 1 second before and after time locked event in the task (at 250Hz sampling rate)
  *   180 trials of the task
  *   3 events/epochs - onset of task, choice taken in task, outcome of task

If I were to plot the average power across all trials for the onset event, I can see how power changes on a spectrogram plot. My goal is to find the significant clusters that show up on the spectrogram as a first step to finding interesting frequency bands. To do so for one subject (with a single DBS lead), I reorganized the data to have these dimensions (180 trials x 3 events x 50 freqs x 500 time) and put it into a fieldtrip struct as follows:

data_ft = [];
data_ft.dimord = 'rpt_chan_freq_time';
data_ft.label = {'Onset','Choice','Outcome'}';
data_ft.freq = linspace(1, 50, 50);
data_ft.time = linspace(-1, 1, 500);
data_ft.powspctrm = data;

where I am using the events as the "channels" so I can choose one at a time.

The cfg for ft_freqstatistics looks like this:
cfg = [];
cfg.method = 'montecarlo';
cfg.statistic = 'indepsamplesT';
cfg.correctm = 'cluster';
cfg.clusteralpha = 0.05;
cfg.clustertail = 0;
cfg.clusterstatistic = 'maxsum';
cfg.tail = 0;
cfg.alpha = 0.025;
cfg.numrandomization = 1000;
cfg.design = ones(size(data_ft.powspctrm, 1), 1); % size = 180 x 1
cfg.ivar = 1;
cfg.channel = {'Onset'};
cfg.neighbours = [];

[stat] = ft_freqstatistics(cfg, data_ft);

following other fieldtrip threads noting that the neighbours field should be left blank to denote clustering in time/frequency rather than spatially across channels. When I run ft_freqstatistics, I get the following error:

Error using findcluster
invalid dimension of spatdimneighbstructmat

Error in clusterstat (line 214)
  posclusobs = findcluster(tmp, connmat, cfg.minnbchan);

Error in ft_statistics_montecarlo (line 364)
  [stat, cfg] = clusterstat(cfg, statrand, statobs);

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

The dimension of spatdimneighbstructmat is given by connmat, which is 0 in this case since I didn't specify a neighboring scheme. Is there any other way to cluster in time/frequency and not spatially when looking at only a single channel of data?

Thank you,
Stephanie Brener
UC San Francisco
fieldtrip mailing list

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.science.ru.nl/pipermail/fieldtrip/attachments/20230808/25bb106e/attachment.htm>

More information about the fieldtrip mailing list