[FieldTrip] redefining data set

Julian Keil julian.keil at gmail.com
Mon Jan 14 18:53:39 CET 2019

Dear Martin,

I’m not quite sure what you have in the previous…-fields, but cfg.trials need trial indices (e.g. „swim“ is trial [1, 3, 5, 7, 23]).
You could use something like find(cfg.previous…{1,1} == 1) to get the indices where your eventvalue matches your category.
Please keep in mind though that these „previous“-fields might not get updated if you throw out trials (e.g. due to artefacts), so you need to double-check if the trial selection matches your number of trials in data_ref.

Alternatively, you can store condition information in the „trialinfo“-field. This gets updated if you throw out trials, so you don’t have to worry about this.

I hope this helps.



> Am 14.01.2019 um 18:29 schrieb Martin Rosenfelder <martin.rosenfelder at uni-ulm.de>:
> Dear Fieldtrip community,
> I have preprocessed a single dataset with two different conditions ('Swim', 'Rest'). The conditions are stored in the 'eventvalue' field of the cfg as 1x2 cell array. The event values are stored in the 'data_ref.cfg.previous.previous.previous{1,1}.previous.previous.trialdef.eventvalue' field of the data set. 
> Having done the preprocessing I now would like to do ft_timelockanalysis and ft_freqanalysis on the data. Afterwards I statistically compare the two conditions using ft_timelockstatistics and ft_freqstatistics.
> How can I split the data set according to the event values ('Swim', 'Rest')? I need the event values to split the data set into the two trial classes in the ft_timelockanalysis / ft_freqanalysis and to compare these two conditions.
> I tried ft_redefinetrial, but do not know how to define the cfg.trials field of this function. 
>         % trial redefinition
>        % containing only trials in the 'swim' condition
>         cfg.trials = (1, data_ref.cfg.previous.previous.previous{1,1}.previous.previous.trialdef.eventvalue(1,1));
>         swim = ft_redefinetrial(cfg,data_ref);
>        % containing only trials in the 'resting' condition
>         cfg.trials = (1, data_ref.cfg.previous.previous.previous{1,1}.previous.previous.trialdef.eventvalue(1,2));
>         rest = ft_redefinetrial(cfg,data_ref);
> I hope the description was quite clear. In case, I can provide some more lines of code to clarify the issue.
> Thank you very much in advance for your advice!
> Best regards,
> Martin
> -- 
> M.Sc.-Psych. Martin Rosenfelder
> Wissenschaftlicher Mitarbeiter
> Klinische und Biologische Psychologie
> Universität Ulm
> Raum 47.2.259
> +49 731-50 26592
> martin.rosenfelder at uni-ulm.de
> _______________________________________________
> 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