[FieldTrip] problems with ft_redefinetrial - data seem inconsistent afterwards (sample info - timepoints problem?)

Schoffelen, J.M. (Jan Mathijs) jan.schoffelen at donders.ru.nl
Tue Sep 1 08:00:52 CEST 2020


Dear Cecilia,

The error is clear. As per the error message, the variable tmptrial(i,:,begsmp(i):endsmp(i)) has a different size than the guilty data.trial{i}.

The most likely reason for this is that you did not consider the fact that after redefining your trials to the response (i.e. by subtracting the trial specific reaction time from the trial specific time axis) you did not account for the fact that this resulted in trial specific time axes that are arbitrarily shifted with fractional sampling intervals. In other words, across trials, the time points at which the data are sampled are not fixed, but are slightly shifted with respect to another. As an example, consider two trials, of which the original time axis was defined in, say, 20 ms time steps as follows:  [-0.1 -0.08 …. 0 … 0.02 … 0.5]. The RT in trial 1 was 300 ms, and in trial 2 it was 294 ms. The resulting time axes now (after response locking):

[-0.3 -0.28 … 0 … 0.3], and [-0.306 -0.286 … -0.006 … 0.014 … 0.294]. Now, there’s no way that this is going to nicely fit on a ‘common’ time axis that you implicitly ask ft_timelockanalysis to create. Fieldtrip tries to be a little bit tolerant for these types of errors, but there are limits to its flexibility.

The best solution to this would be to ensure that the RTs are adjust to correspond to an integer number of sample intervals, prior to the call to ft_redefinetrial.

Since I would assume that this is an issue that more people might (have) run into, could I ask you to make a Frequently Asked Question out of this on the FieldTrip website?

Thanks and with best wishes,
Jan-Mathijs




On 31 Aug 2020, at 10:33, Mazzetti, C. (Cecilia) <C.Mazzetti at donders.ru.nl<mailto:C.Mazzetti at donders.ru.nl>> wrote:

Hello everyone,
I am facing a problem when running ft_timelockanalysis on preprocessed MEG data, whose onset have that has been re-defined with ft_redefinetrial (with option cfg.offset). Specifically, stimulus locked data were re-defined to be response locked.
Now, I have to run time lock analysis to later apply LCMV beamformer.
Unfortunately, for some subjects (inexplicably, to me) I encounter the following error:

when running:
cfg                       = [ ];
cfg.covariance     = 'yes';
cfg.keeptrials       = 'yes';
tmlock_resp         = ft_timelockanalysis(cfg, megresp);


the input is raw data with 270 channels and 235 trials
the call to "ft_selectdata" took 1 seconds and required the additional allocation of an estimated 2 MB
Unable to perform assignment because the size of the left side is 1-by-270-by-2348 and the size of the right side is 270-by-2349.
Error in ft_checkdata>raw2timelock (line 1527)
    tmptrial(i,:,begsmp(i):endsmp(i)) = data.trial{i};
Error in ft_checkdata (line 468)
      data = raw2timelock(data);
Error in ft_timelockanalysis (line 144)
  datacov      = ft_checkdata(datacov, 'datatype', 'timelock');


I know this seems to be something related to the number of trials, or timing (in those datasets, I also cannot seem to cut epochs to get shorter time windows) but I checked the data and sample info, and everything seems ok (I also don't know what that 2348 - 2349 refers to)

Someone knows what this error refers to? Maybe how to fix it or where to look into?
Importantly, if I do not redefine those data everything goes fine (meaning if they stay stimulus locked).
Is something going on during ft_redefinetrial?


Thanks in advance to all a lot!





All the best,
Cecilia

Cecilia Mazzetti, Postdoc Researcher
Department of Basic Neurosciences
University of Geneva
Chemin des Mines 9,
1202 Genève, Switzerland


_______________________________________________
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/20200901/1a8258d5/attachment.htm>


More information about the fieldtrip mailing list