[FieldTrip] Question about ft_definetrial

Schoffelen, J.M. (Jan Mathijs) jan.schoffelen at donders.ru.nl
Wed Aug 26 08:50:26 CEST 2020


Dear Yan,

The relevant code section for you (which also explains why it does not work) is l 215-223 (in the current FT master branch on github, but very likely the same line numbers apply to any sufficiently up-to-date FT version) of ft_trialfun_general:


        if isnumeric(event(i).value)
        val = [val; event(i).value];
        elseif ischar(event(i).value) && numel(event(i).value)>1 && (event(i).value(1)=='S'|| event(i).value(1)=='R')
        % on brainvision these are called 'S 1' for stimuli or 'R 1' for responses
        val = [val; str2double(event(i).value(2:end))];
        else
        val = [val; nan];
        end



In your case event(i).value looks like ’11’, i.e. the code does not get past the ‘if’ and ‘elseif’, causing the variable nan to be all ’NaN’. As a consequence, the val variable will not make it into the trialinfo field.

Given the fact that it is reasonable to expect that an eventvalue that represents a meaningful number as a string ends up in the trialinfo, another ‘elseif’ statement might need to be added to the code, which handles your use case.

Perhaps you could try and come up with a possible solution yourself, and submit this as a pull request on github?

Looking forward to your contribution.

Best wishes,
Jan-Mathijs




On 26 Aug 2020, at 04:07, liyy90 <liyy90 at 163.com<mailto:liyy90 at 163.com>> wrote:

Dear List,

When I use the following code to define trials and preprocess my data, I got no trialinfo in my data structure.
I need the trialinfo to extract different condition epochs in the following ERP analysis and I have no idea how to fix it.
Hope anyone can help.

cfg = [];
cfg.dataset             = 'raw_data/sample_data.set';
cfg.trialfun           = 'ft_trialfun_general';
cfg.trialdef.eventtype = 'trigger';
cfg.trialdef.eventvalue = {'11', '12', '13', '14'};
cfg.trialdef.prestim = 0.2;
cfg.trialdef.poststim = 0.8;
cfg      = ft_definetrial(cfg);

data        = ft_preprocessing(cfg);

And the result in data structure:
<image.png>

Many thanks.
Yan
_______________________________________________
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/20200826/0143f5c9/attachment.htm>


More information about the fieldtrip mailing list