[FieldTrip] Using ft_redefinetrial with minlength and begsample/endsample option
Schoffelen, J.M. (Jan Mathijs)
jan.schoffelen at donders.ru.nl
Tue Sep 19 08:02:53 CEST 2017
Dear Nir Ofir,
Thanks for reporting this. It seems that you have also identified a possible solution, which would be to do the ‘too short trial removal’, only after the realignment of the time axis of the trials.
I think the best way to proceed would be that you try to implement this fix in your own local version of the FieldTrip git repository, and initiate a pull request once you are sure it works well. We will then review the suggested fix, and merge it into Fieldtrip’s code base, so that everyone can benefit from your efforts.
Best wishes,
Jan-Mathijs
> On 14 Sep 2017, at 14:10, Nir Ofir <nirofir2 at gmail.com> wrote:
>
> 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
> _______________________________________________
> fieldtrip mailing list
> fieldtrip at donders.ru.nl
> https://mailman.science.ru.nl/mailman/listinfo/fieldtrip
More information about the fieldtrip
mailing list