[FieldTrip] Possible bug in mtmconvol padding option

Schoffelen, J.M. (Jan Mathijs) jan.schoffelen at donders.ru.nl
Thu Feb 27 10:25:17 CET 2020


Hi Mireia,

There was a typo in my pseudo-code, the value to be used for cfg.pad would of course be 1.
Best,
JM


On 27 Feb 2020, at 09:29, Schoffelen, J.M. (Jan Mathijs) <jan.schoffelen at donders.ru.nl<mailto:jan.schoffelen at donders.ru.nl>> wrote:

Hi Mireia,

Indeed the cfg.pad parameter operates on the full epoch length, not on the sliding window length. This is per design, and it is not a bug.

Although I don’t fully understand the deeper reason of why you want to do what you want to do, one way to get there would be to handcraft your own procedure, and create the TFRs in a computationally inefficient for-loop. This would require a lot of data bookkeeping on your end.

Procedurally:

for k = 1:the-number-of-time-point-onto-which-you-want-to-estimate-your-tfr

  cfg = [];
  cfg.latency = timepoint(k)+[-0.25 0.25-1./data.fsample];
  tmpdata = ft_selectdata(cfg, data);

  cfg = [];
  cfg.pad = 0.5;
  cfg.method = ‘mtmfft’;
  cfg….
  tmpfreq(k) = ft_freqanalysis(cfg, tmpdata);

end

freq = tmpfreq(1);
freq.powspctrm = cat( 3-or-4-depending-on-whether-you-did-cfg.keeptrials=‘yes’-previously, tmpfreq.powspctrm);
freq.time = timepoint;
freq.dimord = (‘rpt_)chan_freq_time’;


Sounds like an overkill to me, though.

Best wishes, and good luck,

Jan-Mathijs

PS: Please feel free to suggest an update to the help-section of the ft_freqanalysis function, to explain better the cfg.pad parameter. We look forward to a PR!



On 24 Feb 2020, at 18:17, TORRALBA CUELLO, MIREIA <mireia.torralba at upf.edu<mailto:mireia.torralba at upf.edu>> wrote:

Hi,
I am a Fieldtrip user and I came across this error

ft_error('the specified padding is too short');

when calculating power spectrum using this code:

 cfg=[];
    cfg.method='mtmconvol';
    cfg.foi=2:1:40;
    cfg.t_ftimwin=0.5*ones(length(cfg.foi),1);
    cfg.pad=1;
cfg.taper='hanning';
fLast=ft_freqanalysis(cfg,dataLast);

As I see it, the padding should work in each of my time windows (0.5 seconds length each) and therefore the error should not appear, but when I inspected which is the segment padded by the function I saw
that what is being padded to 1 is the whole segment. I think this is not right, as what I would like is to increase my frequency resolution by padding each of the timewindows where I calculate the spectrum. The problem I have is that I want to use as a baseline another segment which has 0.5 seconds length, and as the frequency extracted by mtmconvol depends on the length of the segment, I am getting different frequency resolutions for the baseline and the target data.

Can anyone help me?
Thanks and best regards.

Mireia



Mireia Torralba Cuello
Multisensory Research Group
Center for Brain and Cognition, Universitat Pompeu Fabra
Address: Edifici Mercè Rodoreda 24.313
        c\ Ramon Trias Fargas, 25-27
        08005 Barcelona
http://www.mrg.upf.edu<http://www.mrg.upf.edu/>
Tel +34 935422745

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

_______________________________________________
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/20200227/e68e7ce1/attachment.htm>


More information about the fieldtrip mailing list