[FieldTrip] Error with ft_artifact_threshold on a dataset with overlapping Trials
giulio piperno
giuliopiperno at hotmail.it
Thu Nov 25 17:35:24 CET 2021
Dear Fieldtrip Community,
my name is Giulio Piperno, and I am working as Ph.D. Student in Cognitive Neuroscience at La Sapienza University of Rome.
I am new to Fieldtrip, and I am currently using it to analyze the data of an ERP experiment. After the filtering, the segmentation, and the baseline correction, I encounter a problem with the automatic artifact detection, using the function ft_artifact_threshold
More specifically, I receive thefollowing error messages:
Error using ft_fetch_data (line 165)
some of the requested samples occur twice in the data and have conflicting values
Error in ft_artifact_threshold (line 183)
dat = ft_fetch_data(data, 'header', hdr, 'begsample', trl(trlop,1), 'endsample', trl(trlop,2),
'chanindx', chanindx, 'checkboundary', strcmp(cfg.continuous, 'no'));
I suspect the problem is related to the presence of overlapping trials. The interval between the triggers is 550 ms, and the error message appears only when I try to take segments longer than 550 ms in the segmentation process (E.g. form 250 ms before the trigger up to 400 ms after the stimuli). If I reduce the length of the epochs, I receive no error. Unfortunatly, I need to take long segments, because I am interested in both prestimulus (around 250 ms) activity and a peak occurring around 200-400 ms after the stimulus
However the problem could be rather something related to the baseline correction step: If I run ft_artifact_threshold on the data before the baseline correction, I receive no error (even when I take segments with -250 400 ms interval and therefore I have overlapping trials)
I tried to insert the command cfg.allowerlap = "yes" in the preprocessing but it didn't work
Could someone tell me if there is something wrong with the cfg settings I 'am using or if I am doing something wrong at any other place? Is there a way to perform both baseline correction and automatic artifact detection on a dataset with partially overlapping trials?
Here I leave the code I am using:
%%% FILTERING %%%
cfg = [];
cfg.bpfilter = 'yes';
cfg.bpfiltord = 3 ;
cfg.bpfreq = [0.1 30];
data_cleaned_filtered = ft_preprocessing(cfg, data )
%%% SEGMENTATION %%%
filename= 'C01.cnt'
cfg = [];
cfg.dataset = filename
cfg.trialdef.eventtype = 'trigger';
cfg.trialdef.eventvalue = 1:1:37;
cfg.trialdef.prestim = 0.25; % in seconds
cfg.trialdef.poststim = 0.4; % in seconds
cfg.trialfun = 'ft_trialfun_general';
data_trl= ft_definetrial(cfg);
data_trl.trl=round(data_trl.trl)
cfg = [];
cfg.trl = data_trl.trl;
data_segmented = ft_redefinetrial(cfg, data_cleaned_filtered);
%%% BASELINE CORRECTION %%%
cfg = [];
cfg.demean = 'yes'; %
cfg.baselinewindow = [-.25 -.15];
data_baseline = ft_preprocessing(cfg, data_segmented);
%%% AUTOMATIC ARTIFACT DETECTION %%%
cfg = [];
cfg.continuous = 'no';
cfg.artfctdef.threshold.channel = 'EEG';
cfg.artfctdef.threshold.bpfilter = 'no';
cfg.artfctdef.threshold.max = 100; %value in uV or T, default inf
cfg.artfctdef.threshold.min = -100; %value in uV or T, default -inf
[cfg, artifact_EEG] = ft_artifact_threshold(cfg, data_baseline);
Thanks in advance for your help!
Best Regards
Giulio Piperno
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.science.ru.nl/pipermail/fieldtrip/attachments/20211125/2ed6bf89/attachment.htm>
More information about the fieldtrip
mailing list