[FieldTrip] define response onset as 0 point, looking back

Marcel van den Velde marcel.van.den.velde at gmail.com
Thu May 7 01:50:39 CEST 2020


Dear all,

I am doing a MEG analysis on hand movement preparation: subjects are
presented with visual stimuli (coded in the trigger channel) and have to
respond by moving their hand. The study requires that I investigate the
ERFs prior to the movement onset (but not capturing anything pre-stimulus).
How can I best move the 0 point from stimulus onset to movement onset and
look back?

What I have now is the following, but I am not sure whether this is correct:

First a trial definition calling an own function and an own added field to
assign the response time (cfg.trialdef.rt)

        % trial definition
        cfg = [];
        cfg.dataset = subject_meg_data;
        cfg.trialfun = ‘trialfun_move’;                           % <— own
function
        cfg.trialdef.rt = movement_rt_inseconds;       % <— own field, to
pass RTs on
        cfg.trialdef.eventtype  = 'UPPT001';
        cfg.trialdef.eventvalue = [1:32];
        cfg = ft_definetrial(cfg);

With as function:

function [trl, event] = trialfun_move(cfg)

        % read header information and events from dataset
        hdr   = ft_read_header(cfg.dataset);
        event = ft_read_event(cfg.dataset);

        % search for events of interest, get value and sample
        value  = [event(find(strcmp(cfg.trialdef.eventtype,
{event.type}))).value]';
        sample = [event(find(strcmp(cfg.trialdef.eventtype,
{event.type}))).sample]';

        % define trial: starts at picture onset, stops at movement onset
(response)
        trl_begin = sample;
        trl_end   = sample + round(cfg.trialdef.rt * hdr.Fs);
        offset    = repmat(0, numel(value), 1);
        trl       = [trl_begin trl_end offset value cfg.trialdef.rt];

end % end function

The trial definition block is then followed by preprocessing and moving the
0 time point from picture onset to movement onset using ft_redefinetrial:

        % preprocessing
        cfg.channel = {'MEG'};
        cfg.continuous = 'yes';
        cfg.bpfilter = 'yes';
        cfg.bpfreq = [1 30];
        data = ft_preprocessing(cfg);

        % shift 0 time point from picture to movement onset
        cfg = [];
        cfg.offset = - round(movement_rt_inseconds * data.fsample);
        data = ft_redefinetrial(cfg, data);

Is this a correct approach, and am I correct in assuming that with this
last step, the 0 time point is now correctly shifted from picture onset to
movement onset, as the first sample is defined to be minus RT earlier than
the 0 time point? Is there a way to check this in the data structure?
Thanks for any help.

Best regards,
Marcel
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.science.ru.nl/pipermail/fieldtrip/attachments/20200507/ad7da4d2/attachment.htm>


More information about the fieldtrip mailing list