<div dir="ltr"><div>Dear Mathijs,</div><div><br></div><div>Thank you for your reply. I will run this check to be sure.</div><div><br></div><div>Best regards,</div><div>Marcel</div><div><br></div><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Thu, May 7, 2020 at 10:11 AM Schoffelen, J.M. (Jan Mathijs) <<a href="mailto:jan.schoffelen@donders.ru.nl">jan.schoffelen@donders.ru.nl</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
<div style="overflow-wrap: break-word;">
<font size="4">Dear Marcel,</font>
<div><font size="4"><br>
</font></div>
<div><font size="4">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)</font></div>
<div><font size="4"><br>
</font></div>
<div><font size="4">Best wishes,</font></div>
<div><font size="4">Jan-Mathijs</font></div>
<div><font size="4"><br>
</font></div>
<div><font size="4"><br>
</font></div>
<div><font size="4"><br>
</font>
<div><br>
<blockquote type="cite">
<div>On 7 May 2020, at 01:50, Marcel van den Velde <<a href="mailto:marcel.van.den.velde@gmail.com" target="_blank">marcel.van.den.velde@gmail.com</a>> wrote:</div>
<br>
<div>
<div dir="ltr">
<div>Dear all,<br>
<br>
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?<br>
<br>
What I have now is the following, but I am not sure whether this is correct:<br>
<br>
First a trial definition calling an own function and an own added field to assign the response time (cfg.trialdef.rt)<br>
<br>
% trial definition <br>
cfg = [];<br>
cfg.dataset = subject_meg_data;<br>
cfg.trialfun = ‘trialfun_move’; % <— own function<br>
cfg.trialdef.rt = movement_rt_inseconds; % <— own field, to pass RTs on<br>
cfg.trialdef.eventtype = 'UPPT001';<br>
cfg.trialdef.eventvalue = [1:32];<br>
cfg = ft_definetrial(cfg);<br>
<br>
With as function:<br>
<br>
function [trl, event] = trialfun_move(cfg)<br>
<br>
% read header information and events from dataset<br>
hdr = ft_read_header(cfg.dataset);<br>
event = ft_read_event(cfg.dataset);<br>
<br>
% search for events of interest, get value and sample<br>
value = [event(find(strcmp(cfg.trialdef.eventtype, {event.type}))).value]';<br>
sample = [event(find(strcmp(cfg.trialdef.eventtype, {event.type}))).sample]';<br>
<br>
% define trial: starts at picture onset, stops at movement onset (response)<br>
trl_begin = sample;<br>
trl_end = sample + round(cfg.trialdef.rt * hdr.Fs);<br>
offset = repmat(0, numel(value), 1);<br>
trl = [trl_begin trl_end offset value cfg.trialdef.rt];<br>
<br>
end % end function<br>
<br>
The trial definition block is then followed by preprocessing and moving the 0 time point from picture onset to movement onset using ft_redefinetrial:<br>
<br>
% preprocessing<br>
cfg.channel = {'MEG'}; <br>
cfg.continuous = 'yes'; <br>
cfg.bpfilter = 'yes'; <br>
cfg.bpfreq = [1 30];<br>
data = ft_preprocessing(cfg);<br>
<br>
% shift 0 time point from picture to movement onset<br>
cfg = [];<br>
cfg.offset = - round(movement_rt_inseconds * data.fsample);<br>
data = ft_redefinetrial(cfg, data);<br>
<br>
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.<br>
<br>
Best regards,<br>
</div>
<div></div>
<div>Marcel</div>
</div>
_______________________________________________<br>
fieldtrip mailing list<br>
<a href="https://mailman.science.ru.nl/mailman/listinfo/fieldtrip" target="_blank">https://mailman.science.ru.nl/mailman/listinfo/fieldtrip</a><br>
<a href="https://doi.org/10.1371/journal.pcbi.1002202" target="_blank">https://doi.org/10.1371/journal.pcbi.1002202</a><br>
</div>
</blockquote>
</div>
<br>
</div>
</div>
_______________________________________________<br>
fieldtrip mailing list<br>
<a href="https://mailman.science.ru.nl/mailman/listinfo/fieldtrip" rel="noreferrer" target="_blank">https://mailman.science.ru.nl/mailman/listinfo/fieldtrip</a><br>
<a href="https://doi.org/10.1371/journal.pcbi.1002202" rel="noreferrer" target="_blank">https://doi.org/10.1371/journal.pcbi.1002202</a><br>
</blockquote></div></div>