[FieldTrip] TFR zero padding duration?

Schoffelen, J.M. (Jan Mathijs) jan.schoffelen at donders.ru.nl
Fri Jun 28 08:32:32 CEST 2019


From the ‘help’ section of ft_freqanalysis:


%   cfg.pad         = number, 'nextpow2', or 'maxperlen' (default), length
%                      in seconds to which the data can be padded out. The
%                      padding will determine your spectral resolution. If you
%                      want to compare spectra from data pieces of different
%                      lengths, you should use the same cfg.pad for both, in
%                      order to spectrally interpolate them to the same
%                      spectral resolution.  The new option 'nextpow2' rounds
%                      the maximum trial length up to the next power of 2.  By
%                      using that amount of padding, the FFT can be computed
%                      more efficiently in case 'maxperlen' has a large prime
%                      factor sum.

Thus, the number you give in will be the total length of the vector after padding. This number should therefore be at least as long as the longest trial in your data. Which is also what the error message reflects.

Best wishes,
Jan-Mathijs



On 28 Jun 2019, at 00:08, Ioanna Zioga <i.zioga at qmul.ac.uk<mailto:i.zioga at qmul.ac.uk>> wrote:

Dear Fieldtrip community!

I would like to ask for your advice on zero padding when doing TFR analysis.

I'm analysing trials of different lengths, so I loop over the trials to run ft_freqanalysis.
I read in the tutorials that the padding length should be >= to the length of the trial.

Therefore, I prepared these parameters:

cfg = [];
cfg.method = 'wavelet';
cfg.output = 'pow';
cfg.foi = [2:1:40];
cfg.width = 6;
cfg.keeptrials = 'yes';
cfg.toi = data.time{1};
cfg.pad = round(length(data.time{1}(1,:))/500)+5; % duration of trial plus 5 seconds
% my sampling rate is 500
res = ft_freqanalysis(cfg,data);

Even if I add 5 seconds more to the length of the cfg.pad, SOMETIMES (and I
cannot figure out a pattern..), I get this error:
Error using ft_specest_wavelet (line 60)
the padding that you specified is shorter than the data

Error in ft_freqanalysis (line 505)
        [spectrum,foi,toi] = ft_specest_wavelet(dat, time, 'timeoi', cfg.toi, 'width', cfg.width, 'gwidth', cfg.gwidth,options{:},
        'feedback', fbopt);

The length of the above trial was 20 seconds (+5 secs padding).
Do you have any idea what is the problem?

Freqanalysis runs smoothly in trials with other trials with smaller or longer duration, and I can't find a pattern of when this error comes up..

Any idea would be extremely helpful, thanks so so much in advance!

Best,
Ioanna

_______________________________________________
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/20190628/43366f80/attachment-0002.html>
-------------- next part --------------
_______________________________________________
fieldtrip mailing list
https://mailman.science.ru.nl/mailman/listinfo/fieldtrip
https://doi.org/10.1371/journal.pcbi.1002202


More information about the fieldtrip mailing list