<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
</head>
<body style="word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class="">
Hi Stephanie,
<div class=""><br class="">
</div>
<div class="">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.</div>
<div class=""><br class="">
</div>
<div class="">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.</div>
<div class=""><br class="">
</div>
<div class="">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.</div>
<div class=""><br class="">
</div>
<div class="">Good luck,</div>
<div class="">Jan-Mathijs</div>
<div class=""><br class="">
</div>
<div class="">
<div><br class="">
<blockquote type="cite" class="">
<div class="">On 7 Aug 2023, at 20:46, Brener, Stephanie via fieldtrip <<a href="mailto:fieldtrip@science.ru.nl" class="">fieldtrip@science.ru.nl</a>> wrote:</div>
<br class="Apple-interchange-newline">
<div class="">
<div class="elementToProof" style="font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none; font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt;">
<span class="x_elementToProof" style="font-size: 12pt; margin: 0px; background-color: rgb(255, 255, 255);"><span class="x_ContentPasted0 x_x_elementToProof ContentPasted0" style="margin: 0px; background-color: rgb(255, 255, 255);">Hi fieldtrippers,</span></span></div>
<div class="elementToProof" style="font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none; font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt;">
<div class="x_elementToProof" style="font-size: 12pt; margin: 0px; background-color: rgb(255, 255, 255);">
<div class="x_x_elementToProof" style="margin: 0px; background-color: rgb(255, 255, 255);">
<br class="x_ContentPasted0 ContentPasted0">
</div>
<div class="x_ContentPasted0 x_x_elementToProof ContentPasted0" style="margin: 0px; background-color: rgb(255, 255, 255);">
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: (<span class="x_ContentPasted0 ContentPasted0" style="margin: 0px;">50 frequencies x 500 time samples x 180 trials x 3 events).</span></div>
<div class="x_x_elementToProof" style="margin: 0px; background-color: rgb(255, 255, 255);">
<br class="x_ContentPasted0 ContentPasted0">
</div>
<div class="x_ContentPasted0 x_x_elementToProof ContentPasted0" style="margin: 0px; background-color: rgb(255, 255, 255);">
The dimensions can be described by:</div>
<div class="x_x_elementToProof" style="margin: 0px; background-color: rgb(255, 255, 255);">
<ul data-editing-info="{"orderedStyleType":1,"unorderedStyleType":2}" class="">
<li style="list-style-type: "- ";" class=""><span class="x_ContentPasted0 ContentPasted0" style="margin: 0px;">50 Morlet wavelets from 0 to 50Hz --> power at 50 frequencies</span></li><li style="list-style-type: "- ";" class=""><span class="x_ContentPasted0 ContentPasted0" style="margin: 0px;">500 samples = 1 second before and after time locked event in the task (at 250Hz sampling rate)</span></li><li style="list-style-type: "- ";" class=""><span class="x_ContentPasted0 ContentPasted0" style="margin: 0px;">180 trials of the task</span></li><li style="list-style-type: "- ";" class=""><span class="x_ContentPasted0 ContentPasted0" style="margin: 0px;">3 events/epochs - onset of task, choice taken in task, outcome of task</span></li></ul>
</div>
<div class="x_x_elementToProof" style="margin: 0px; background-color: rgb(255, 255, 255);">
<br class="x_ContentPasted0 ContentPasted0">
</div>
<div class="x_ContentPasted0 x_x_elementToProof ContentPasted0" style="margin: 0px; background-color: rgb(255, 255, 255);">
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:</div>
<div class="x_x_elementToProof x_x_ContentPasted0" style="margin: 0px; background-color: rgb(255, 255, 255);">
<br class="x_ContentPasted0 ContentPasted0">
</div>
<div class="x_ContentPasted0 x_x_elementToProof x_x_ContentPasted0 ContentPasted0 x_x_ContentPasted2" style="margin: 0px; background-color: rgb(255, 255, 255);">
data_ft = [];
<div class="x_ContentPasted0 x_x_ContentPasted0 ContentPasted0" style="margin: 0px;">
data_ft.dimord = 'rpt_chan_freq_time';</div>
<div class="x_ContentPasted0 x_x_ContentPasted0 ContentPasted0" style="margin: 0px;">
data_ft.label = {'Onset','Choice','Outcome'}';</div>
<div class="x_ContentPasted0 x_x_ContentPasted0 ContentPasted0" style="margin: 0px;">
data_ft.freq = linspace(1, 50, 50);</div>
<div class="x_ContentPasted0 x_x_ContentPasted0 ContentPasted0" style="margin: 0px;">
data_ft.time = linspace(-1, 1, 500);<br class="x_ContentPasted0 ContentPasted0">
</div>
data_ft.powspctrm = data;<br class="ContentPasted0 x_x_ContentPasted2 x_ContentPasted0">
<br class="x_ContentPasted0 ContentPasted0">
</div>
<div class="x_ContentPasted0 x_x_elementToProof x_elementToProof ContentPasted0" style="margin: 0px; background-color: rgb(255, 255, 255);">
where I am using the events as the "channels" so I can choose one at a time.</div>
<div class="x_x_elementToProof" style="margin: 0px; background-color: rgb(255, 255, 255);">
<br class="x_ContentPasted0 ContentPasted0">
</div>
<div class="x_ContentPasted0 x_x_elementToProof ContentPasted0" style="margin: 0px; background-color: rgb(255, 255, 255);">
The cfg for ft_freqstatistics looks like this:</div>
<div class="x_ContentPasted0 x_x_elementToProof x_x_ContentPasted1 ContentPasted0" style="margin: 0px; background-color: rgb(255, 255, 255);">
cfg = [];
<div class="x_ContentPasted0 x_elementToProof x_x_ContentPasted1 ContentPasted0" style="margin: 0px;">
cfg.method = 'montecarlo';</div>
<div class="x_x_ContentPasted1 x_ContentPasted0 ContentPasted0" style="margin: 0px;">
cfg.statistic = 'indepsamplesT';</div>
<div class="x_x_ContentPasted1 x_ContentPasted0 ContentPasted0" style="margin: 0px;">
cfg.correctm = 'cluster';</div>
<div class="x_x_ContentPasted1 x_ContentPasted0 ContentPasted0" style="margin: 0px;">
cfg.clusteralpha = 0.05;</div>
<div class="x_x_ContentPasted1 x_ContentPasted0 ContentPasted0" style="margin: 0px;">
cfg.clustertail = 0;</div>
<div class="x_x_ContentPasted1 x_ContentPasted0 ContentPasted0" style="margin: 0px;">
cfg.clusterstatistic = 'maxsum';</div>
<div class="x_x_ContentPasted1 x_ContentPasted0 ContentPasted0" style="margin: 0px;">
cfg.tail = 0;</div>
<div class="x_x_ContentPasted1 x_ContentPasted0 ContentPasted0" style="margin: 0px;">
cfg.alpha = 0.025;</div>
<div class="x_x_ContentPasted1 x_ContentPasted0 ContentPasted0" style="margin: 0px;">
cfg.numrandomization = 1000; </div>
<div class="x_x_ContentPasted1 x_ContentPasted0 ContentPasted0" style="margin: 0px;">
cfg.design = ones(size(data_ft.powspctrm, 1), 1); % size = 180 x 1</div>
<div class="x_x_ContentPasted1 x_ContentPasted0 ContentPasted0" style="margin: 0px;">
cfg.ivar = 1; </div>
<div class="x_x_ContentPasted1 x_ContentPasted0 ContentPasted0" style="margin: 0px;">
cfg.channel = {'Onset'};</div>
<div class="x_x_ContentPasted1 x_ContentPasted0 ContentPasted0" style="margin: 0px;">
cfg.neighbours = []; </div>
<div style="margin: 0px;" class=""><br class="x_ContentPasted0 ContentPasted0">
</div>
[stat] = ft_freqstatistics(cfg, data_ft);<br class="x_ContentPasted0 ContentPasted0">
</div>
<div class="x_x_ContentPasted1 x_x_elementToProof" style="margin: 0px; background-color: rgb(255, 255, 255);">
<br class="x_ContentPasted0 ContentPasted0">
</div>
<div class="x_ContentPasted0 x_x_elementToProof x_x_ContentPasted1 ContentPasted0" style="margin: 0px; background-color: rgb(255, 255, 255);">
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:</div>
<div class="x_x_ContentPasted1 x_x_elementToProof" style="margin: 0px; background-color: rgb(255, 255, 255);">
<br class="x_ContentPasted0 ContentPasted0">
</div>
<div class="x_ContentPasted0 x_x_elementToProof x_x_ContentPasted3 x_x_ContentPasted1 ContentPasted0" style="margin: 0px; background-color: rgb(255, 255, 255);">
Error using findcluster
<div class="x_ContentPasted0 x_x_ContentPasted3 ContentPasted0" style="margin: 0px;">
invalid dimension of spatdimneighbstructmat</div>
<div style="margin: 0px;" class=""><br class="x_ContentPasted0 x_x_ContentPasted3 ContentPasted0">
</div>
<div class="x_ContentPasted0 x_x_ContentPasted3 ContentPasted0" style="margin: 0px;">
Error in clusterstat (line 214)</div>
<div class="x_ContentPasted0 x_x_ContentPasted3 ContentPasted0" style="margin: 0px;">
posclusobs = findcluster(tmp, connmat, cfg.minnbchan);</div>
<div style="margin: 0px;" class=""><br class="x_ContentPasted0 x_x_ContentPasted3 ContentPasted0">
</div>
<div class="x_ContentPasted0 x_x_ContentPasted3 ContentPasted0" style="margin: 0px;">
Error in ft_statistics_montecarlo (line 364)</div>
<div class="x_ContentPasted0 x_x_ContentPasted3 ContentPasted0" style="margin: 0px;">
[stat, cfg] = clusterstat(cfg, statrand, statobs);</div>
<div style="margin: 0px;" class=""><br class="x_ContentPasted0 x_x_ContentPasted3 ContentPasted0">
</div>
<div class="x_ContentPasted0 x_x_ContentPasted3 ContentPasted0" style="margin: 0px;">
Error in ft_freqstatistics (line 194)</div>
[stat, cfg] = statmethod(cfg, dat, design);<br class="x_ContentPasted0 ContentPasted0">
</div>
<div class="x_x_ContentPasted1 x_x_elementToProof x_x_ContentPasted3" style="margin: 0px; background-color: rgb(255, 255, 255);">
<br class="x_ContentPasted0 ContentPasted0">
</div>
</div>
<div class="x_elementToProof" style="font-size: 12pt; margin: 0px; background-color: rgb(255, 255, 255);">
<span class="x_ContentPasted0 x_x_elementToProof x_x_ContentPasted3 x_x_ContentPasted1 ContentPasted0" style="margin: 0px; background-color: rgb(255, 255, 255);">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?</span><br class="ContentPasted0">
</div>
<div class="x_elementToProof" style="font-size: 12pt; margin: 0px; background-color: rgb(255, 255, 255);">
<span class="x_ContentPasted0 x_x_elementToProof x_x_ContentPasted3 x_x_ContentPasted1" style="margin: 0px; background-color: rgb(255, 255, 255);"><br class="ContentPasted0">
</span></div>
<div class="x_elementToProof" style="font-size: 12pt; margin: 0px; background-color: rgb(255, 255, 255);">
<span class="x_ContentPasted0 x_x_elementToProof x_x_ContentPasted3 x_x_ContentPasted1 ContentPasted0" style="margin: 0px; background-color: rgb(255, 255, 255);">Thank you,</span></div>
<div class="x_elementToProof" style="font-size: 12pt; margin: 0px; background-color: rgb(255, 255, 255);">
<span class="x_ContentPasted0 x_x_elementToProof x_x_ContentPasted3 x_x_ContentPasted1 ContentPasted0" style="margin: 0px; background-color: rgb(255, 255, 255);">Stephanie Brener</span></div>
<span class="x_elementToProof" style="font-size: 12pt; margin: 0px; background-color: rgb(255, 255, 255);"><span class="x_ContentPasted0 x_x_elementToProof x_x_ContentPasted3 x_x_ContentPasted1 ContentPasted0" style="margin: 0px; background-color: rgb(255, 255, 255);">UC
San Francisco</span></span><br class="">
</div>
<span style="caret-color: rgb(0, 0, 0); font-family: Helvetica; font-size: 14px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none; float: none; display: inline !important;" class="">_______________________________________________</span><br style="caret-color: rgb(0, 0, 0); font-family: Helvetica; font-size: 14px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none;" class="">
<span style="caret-color: rgb(0, 0, 0); font-family: Helvetica; font-size: 14px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none; float: none; display: inline !important;" class="">fieldtrip
mailing list</span><br style="caret-color: rgb(0, 0, 0); font-family: Helvetica; font-size: 14px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none;" class="">
<a href="https://mailman.science.ru.nl/mailman/listinfo/fieldtrip" style="font-family: Helvetica; font-size: 14px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px;" class="">https://mailman.science.ru.nl/mailman/listinfo/fieldtrip</a><br style="caret-color: rgb(0, 0, 0); font-family: Helvetica; font-size: 14px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none;" class="">
<a href="https://urldefense.com/v3/__https://doi.org/10.1371/journal.pcbi.1002202__;!!HJOPV4FYYWzcc1jazlU!6lvoYv-5AUVQgVqdkunLQW47GM9q2ZAfISkCDDLA_izYMc74Be5DxwaonX_MSWy1cdx5IUlflE2Mdlb_DmEgVJkDp15TAJ724jS-WQ$" style="font-family: Helvetica; font-size: 14px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px;" class="">https://doi.org/10.1371/journal.pcbi.1002202</a></div>
</blockquote>
</div>
<br class="">
</div>
</body>
</html>