[FieldTrip] Using ft_redefinetrial with minlength and begsample/endsample option

Nir Ofir nirofir2 at gmail.com
Thu Sep 14 14:10:46 CEST 2017


Hi fieldtrip users,

I have a data structure containing MEG trials which are aligned to stimulus
onset. I now want to realign them to the target onset, as well as removing
trials which are too short. I thought the easiest way to do this would be
to use ft_redefinetrial in the following way:

offset = dat.trialinfo(:,5); % this column contains the duration of the
stimulus-target intervel
cfg = [];
cfg.minlength = -dat.time{1}(1)+cfgx.pretarget+0.5; % prestim defined by
dat sructure + 0.5 s ERF + cfgx.pretarget
cfg.begsample = round((offset - cfgx.pretarget)*1000);
cfg.endample = round(offset*1000);
dat = ft_redefinetrial(cfg, dat);

When I run this, I get the following error:

Index exceeds matrix dimensions.

Error in ft_redefinetrial (line 209)
    data.trial{i} = data.trial{i}(:, begsample(i):endsample(i));

So I looked into ft_redefinetrials a bit, and it seems like when minlength
is defined, the trials themselves are removed, but the begample/endsample
vector are not cut to contain only the relevant trials. For now I moved to
a 2-step solution (first removing trials, than realigning), but it seems
like this could have a relatively simple fix. Suggestions?

Thanks!
Nir Ofir
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.science.ru.nl/pipermail/fieldtrip/attachments/20170914/b9c1bc9a/attachment.html>


More information about the fieldtrip mailing list