[FieldTrip] ft_freqanalysis after zero-padding

Carolina Ogawa carolyogawa at gmail.com
Fri Aug 30 16:50:27 CEST 2019


Dear community,

I zero-padded my already epoched data using the following code:
    trl         = 1;
    padtype     = 'zero';
    padlength   = 500; % n. of samples to be padded before and after the
data
    zeroPadData = cell(1,size(data_SL.trial,2));
    while trl <= size(data_SL.trial,2)
        zeroPadData{trl} = ft_preproc_padding(data_SL.trial{trl}, padtype,
padlength);
        trl = trl + 1;
    end
    data_SL.trial = zeroPadData;
    clear zeroPadData; clear trl; clear padlength; clear padtype;

After zero-padding, I'm trying to run "ft_frequanalysis" using the
following parameters:
        cfg              = [];
        cfg.output       = 'pow';
        cfg.method       = 'mtmconvol';
        cfg.taper        = 'hanning';
        cfg.foi          = 4:1:50;
        cfg.t_ftimwin    = ones(length(cfg.foi),1).*.2;   % length of time
window = 0.2 sec
        cfg.toi          = -1:0.05:1.5;   % time window "slides" from -1.0
to 1.5 sec in steps of 0.05 sec
        TFRhann          = ft_freqanalysis(cfg, data_SL);

However, I get the following error:

Error using ft_datatype_raw (line 83)
inconsistent number of samples in trial 1

Error in ft_checkdata (line 268)
  data = ft_datatype_raw(data, 'hassampleinfo',
  hassampleinfo);

Error in ft_freqanalysis (line 212)
data = ft_checkdata(data, 'datatype', {'raw',
'raw+comp', 'mvar'}, 'feedback', cfg.feedback,
'hassampleinfo', 'yes');


Before the zero-padding, each trial had 1500 data points, whereas after
zero-padding, each trial got extra 1000 zeros (500 zeros at the beginning
and 500 zeros at the end of the trial), totaling 2500 data points.

I'm not sure whether I'm zero-padding the data correctly.  The
"ft_preproc_padding" function seems not to accept the whole data structure
("data_SL"), but just a specific part of it ("data_SL.trial"), so that the
only way that I've found to make it work was as shown above. Consequently,
the other parts of the data structure are not updated, creating
inconsistencies (which I suspect are causing the error).

Can anyone help me with this?


Thank you all in advance!

Best,
Carolina Ogawa
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.science.ru.nl/pipermail/fieldtrip/attachments/20190830/ab9facb5/attachment.html>


More information about the fieldtrip mailing list