redefinetrial_offset option

Natalia Grion grion at SISSA.IT
Fri Apr 16 13:09:28 CEST 2010

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
 Any help will be welcome!

elseif ~isempty(cfg.offset)
% shift the time axis from each trial
offset = cfg.offset(:);
  if length(cfg.offset)==1
    offset = repmat(offset, Ntrial, 1);
  for i=1:Ntrial
    data.time{i} = data.time{i} + offset(i)/data.fsample;

  % also correct the trial definition
  if ~isempty(trl)
    trl(:,3) = trl(:,3) + offset;

  SISSA Webmail
  Powered by SquirrelMail

  SISSA Webmail
  Powered by SquirrelMail

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 and

More information about the fieldtrip mailing list