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

Marcel van den Velde marcel.van.den.velde at gmail.com
Thu May 7 13:38:37 CEST 2020


Dear Mathijs,

Thank you for your reply. I will run this check to be sure.

Best regards,
Marcel

On Thu, May 7, 2020 at 10:11 AM Schoffelen, J.M. (Jan Mathijs) <
jan.schoffelen at donders.ru.nl> wrote:

> Dear Marcel,
>
> This looks good, indeed. To be sure about this, you can check the first
> elements in each of the trials’ corresponding time vectors. These now
> should be the negative of the trial specific reaction time: data.time{i}(1)
> ~= -movement_rt_inseconds(i); (give or take a sample)
>
> Best wishes,
> Jan-Mathijs
>
>
>
>
> On 7 May 2020, at 01:50, Marcel van den Velde <
> marcel.van.den.velde at gmail.com> wrote:
>
> 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
> _______________________________________________
> fieldtrip mailing list
> https://mailman.science.ru.nl/mailman/listinfo/fieldtrip
> https://doi.org/10.1371/journal.pcbi.1002202
>
>
> _______________________________________________
> 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/20200507/fa326487/attachment.htm>


More information about the fieldtrip mailing list