redefinetrial_offset option
jan-mathijs schoffelen
jan.schoffelen at DONDERS.RU.NL
Fri Apr 16 15:02:07 CEST 2010
Hi Natalia,
The 'offset'-column in a trl-matrix tells you how many points you have
to move away from t=0, to get to the begin of the trial. In other
words, for a given trial, if the offset value is negative, this means
that you have to move X samples to the right to get to time point t=0.
Consequently, the first value of the corresponding time-axis is
negative. Important to keep in mind is that the third column of the
trl-matrix defines the 'local time axis' of your epoch of interest,
whereas the first two columns represent the begin and end sample of
the epoch, fixed to the 'absolute recording time'. This means that if
you only want to shift the local time axis, those first columns should
not change.
Now, if you want to realign the time axes of your epochs of interest
according to the vector you described (a negative value of -51 meaning
that the sub-event occurred before the trigger event) this implies
that the newly defined t=0 moves to the left, and that implies that
you have to add 51 samples to the third element in the trl-row.
Hope this helps,
Jan-Mathijs
On Apr 16, 2010, at 2:42 PM, Natalia Grion wrote:
> Hi Michael,
> When I wrote possible solution i meant: -(abs(trl(:,3))+(-51)) =
> -5958,
> which is conceptually different from -6060.
> In "definetrial" function when declaring trl(:,3)= - 6009 means that
> 1)trial start before trigger event (negative sign) and 2)the offset of
> trigger is 6009 samples away with respect to the "begining" of the
> trial:
> in sum: that the trial starts 6009 steps before trigger. If the sub-
> event
> to which i want to realign happens 51 steps before trigger, then
> number of
> steps with respect to t=0 are "-" 51, and this is applied when
> defining
> data.time in the code of redefinetrial. But when redefining trl(:,3),
> trigger should get "closer" to beginning of trial, as beginning of
> trial
> is still the old one. If what i' saying is correct, then also trl(:,
> 1) and
> (:,2) has to be modified relative to the new "sub-event".
> Any reply will be great.
> Natalia
>
>
>> Hi Natalie,
>>
>> may be I am missing something but the shift by 51 samples implied by
>>
>> (-)6009 +(-51)
>>
>> is always to the "left" as you call it - irrespective of the sign of
> "6009":
>>
>> 6009 +(-51) = 5958 < 6009 (left shift)
>>
>> -6009 +(-51) = -6060 < -6009 (left shift)
>>
>>
>> Michael
>>
>> -----Ursprüngliche Nachricht-----
>> Von: Natalia Grion <grion at SISSA.IT>
>> Gesendet: Apr 16, 2010 1:09:28 PM
>> An: FIELDTRIP at NIC.SURFNET.NL
>> Betreff: [FIELDTRIP] redefinetrial_offset option
>>
>>> Hi all,
>>> When inspecting in detail "redefinetrial" function I found a
>>> striking point, I think there is an error on the code that could be
> easily solved but maybe i'm missing something:
>>> My trials are of fixed length: they go from -3sec to +3sec with 1
>>> trigger
>>> event as t=0. I want to realign the trials to a new (sub)event, so I
> defined offset as: Nxsamples relative to t=0. For each trial, offset
> has
> different signs as the event happened either before trigger event
> (-#samples) or after it (+#samples).
>>> In the code: when having for example -51 (samples relative to
>>> trigger)
> data.time is shifted to the left, and this would be correct. But when
> correcting "trial definition" this offset is summed to trl(:,3); the
>>> point
>>> is: my trl(:,3) is negative since is indicating that the trial
>>> begins
> before the trigger, (-)6009 +(-51) results in shifting the offset of
> trigger to the right which is not the case: (possible solution:
>>> abs(trl(:,3))+(-51).). Then: trl(:,1),trl(:,2) correction is
>>> omitted,
>>> why?
>>> as "event" changed, shouldn't beg and ensample follow this change?
> sticking to +/-3sec defined as star/end of trial? In fact, data.time
> was
> shift. In the rest of the code i don't see any line related to this
> change.
>>> Any help will be welcome!
>>> Natalia
>>> .............................
>>> elseif ~isempty(cfg.offset)
>>> %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
>>> %%%%%%%%%%%
>>> % shift the time axis from each trial
>>> %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
>>> %%%%%%%%%%%
>>> offset = cfg.offset(:);
>>> if length(cfg.offset)==1
>>> offset = repmat(offset, Ntrial, 1);
>>> end
>>> for i=1:Ntrial
>>> data.time{i} = data.time{i} + offset(i)/data.fsample;
>>> end
>>> % also correct the trial definition
>>> if ~isempty(trl)
>>> trl(:,3) = trl(:,3) + offset;
>>> end
>>> ........................................
>>> ----------------------------------------------------------------
>>> SISSA Webmail https://webmail.sissa.it/
>>> Powered by SquirrelMail http://www.squirrelmail.org/
>>> ----------------------------------------------------------------
>>> SISSA Webmail https://webmail.sissa.it/
>>> Powered by SquirrelMail http://www.squirrelmail.org/
>>> ----------------------------------
>>> The aim of this list is to facilitate the discussion between users
>>> of
> the
>>> FieldTrip toolbox, to share experiences and to discuss new ideas
>>> for
> MEG
>>> and EEG analysis. See also
>>> http://listserv.surfnet.nl/archives/fieldtrip.html and
>>> http://www.ru.nl/neuroimaging/fieldtrip.
>>
>> ----------------------------------
>> The aim of this list is to facilitate the discussion between users of
> the
>> FieldTrip toolbox, to share experiences and to discuss new ideas for
> MEG
>> and EEG analysis. See also
>> http://listserv.surfnet.nl/archives/fieldtrip.html and
>> http://www.ru.nl/neuroimaging/fieldtrip.
>
>
> ----------------------------------------------------------------
> SISSA Webmail https://webmail.sissa.it/
> Powered by SquirrelMail http://www.squirrelmail.org/
>
>
>
>
>
> ----------------------------------------------------------------
> SISSA Webmail https://webmail.sissa.it/
> Powered by SquirrelMail http://www.squirrelmail.org/
>
> ----------------------------------
> The aim of this list is to facilitate the discussion between users
> of the FieldTrip toolbox, to share experiences and to discuss new
> ideas for MEG and EEG analysis. See also http://listserv.surfnet.nl/archives/fieldtrip.html
> and http://www.ru.nl/neuroimaging/fieldtrip.
Dr. J.M. (Jan-Mathijs) Schoffelen
Donders Institute for Brain, Cognition and Behaviour,
Centre for Cognitive Neuroimaging,
Radboud University Nijmegen, The Netherlands
J.Schoffelen at donders.ru.nl
Telephone: 0031-24-3668063
----------------------------------
The aim of this list is to facilitate the discussion between users of the FieldTrip toolbox, to share experiences and to discuss new ideas for MEG and EEG analysis. See also http://listserv.surfnet.nl/archives/fieldtrip.html and http://www.ru.nl/neuroimaging/fieldtrip.
More information about the fieldtrip
mailing list