[FieldTrip] Warning with redefining data

Marta Stojanović marta.stojanovic at student.uva.nl
Tue Mar 7 21:09:13 CET 2023


Hi Fieldtrip community,

I’m reaching out with a question about a warning I encountered when redefining trial length from resting-state MEG data using ft_definetrial and ft_redefine trial.

Namely, I redefined the length of input data from a resting-state MEG file from two-second trials to longer trials of 10-second length. I successfully used the ft_definetrial and ft_redefinetrial functions to do so, using the ‘trl’ field from the struct where I define the trial to input as a configuration for the ft_redefinetrial function.

With the two-second length I have 144 trials from the data, while with the ten-second length there are 28 trials.

The pipeline and structs look like the following:

%% define trials with 10-second length
clear ten_seconds;
cfg = [];
cfg.dataset = restfile;   % refers to resting-state file of a single subject
cfg.trialdef.beginning = 0; % start at the beginning of the recording
cfg.trialdef.length     = 10; % 10-second trial length
cfg.trialdef.overlap   = 0; % no overlap between trials
ten_seconds = ft_definetrial(cfg);


%% redefine trials to 10 seconds
clear redef_data;
cfg = [];
cfg.trl = ten_seconds.trl; % use trl from defined trial
redef_data = ft_redefinetrial(cfg,data);

%% preprocess redefined 10-second trials
clear ten_sec_trls;
cfg = [];
cfg.demean = 'yes';
cfg.baselinewindow = 'all';
% cfg.baselinewindow = [0 1018];
ten_sec_trls = ft_preprocessing(cfg,redef_data);


These are the associated structs with their fields:

redef_data =

fsample: 508.6275
grad: [1×1 struct]
label: {244×1 cell}
cfg: [1×1 struct]
hdr: [1×1 struct]
trial: {1×28 cell}
time: {1×28 cell}
trialinfo: [28×2 double]
sampleinfo: [28×2 double]

ten_sec_trls =

fsample: 508.6275
grad: [1×1 struct]
hdr: [1×1 struct]
trialinfo: [28×2 double]
trial: {1×28 cell}
time: {1×28 cell}
label: {244×1 cell}
cfg: [1×1 struct]

When I plug the redefined data (i.e., with redefined length, ten_sec_trls) into ft_timelockanalysis, I receive the following warning:

Warning: data contains NaN values
 In ft_preproc_polyremoval at line 75
 In ft_preproc_baselinecorrect at line 52
 In ft_timelockanalysis at line 174

the call to "ft_selectdata" took 0 seconds and required the additional allocation of an estimated 22 MB
Warning: inconsistent sampleinfo
 In makessense at line 115
 In ft_datatype_timelock at line 72
 In ft_checkdata at line 479
 In ft_timelockanalysis at line 207

I’ve run a loop over the trial field in the output of the ft_timelockanalysis as well as ft_preprocessing to check for NaNs in my 10-second data structs, but I didn’t find any when running this loop. I’ve checked the relevant lines from the Fieldtrip functions but couldn’t find a way to solve the warning from there. I’ve also checked the sampleinfo, but I sense the warning may be due to the sampleinfo in the configuration being inconsistent with the actual data due to the removal of non-MEG channels from the sampleinfo in the resting file.

The warning message might influence later analyses, so I’m wondering if anyone has faced the same and/or has an explanation.

Thanks a lot in advance!

All the best,
Marta
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.science.ru.nl/pipermail/fieldtrip/attachments/20230307/f99e191a/attachment.htm>


More information about the fieldtrip mailing list