[FieldTrip] Issue with partial artifact rejection in sleep EEG data visualization

Schubert, E.S. (Sophie) E.S.Schubert at umcutrecht.nl
Mon Jun 24 17:45:02 CEST 2024


Dear FieldTrip Support Team,

Currently, I am working with sleep EEG data and facing an issue with visualizing artifact-rejected data after employing partial rejection methods.

I have developed a custom script to define trials, which reads PSG signals from an EDF file and event annotations from a CSV file. This script calculates trial segments (trl) by specifying start and end points relative to event times, ensuring that each trial fits within the dataset's limits. The trl matrix records the start and end samples of each trial, along with its offset and associated event value. This precise trial definition is crucial for subsequent data analysis steps, including artifact rejection and sleep stage classification.

For artifact detection, I utilize automatic methods within FieldTrip to partially reject artifacts based on segments, specifically targeting EOG and EMG artifacts. The eog_artifacts.EOG_eye and combined_muscle_artifacts structures contain pairs of sample indices indicating the start and end of detected artifact segments, highlighting where artifacts were identified during the detection process.

I am able to visualize marked artifacts using the following code snippet:

%% Visualization of the signal with marked artifacts

cfg = [];

cfg.channel = 'all'; % All channels

cfg.viewmode = 'vertical'; % Or 'butterfly', depending on preference

cfg.artfctdef.eog.artifact = eog_artifacts_high.EOG_eye;

cfg.artfctdef.muscle.artifact = combined_muscle_artifacts;

ft_databrowser(cfg, data_segmented);

Here is a simplified version of the code snippet I use to reject artifact segments:

%% Reject artifacts partially within trials

cfg = [];

cfg.artfctdef.reject = 'partial'; % Partial rejection within trials

cfg.artfctdef.eog.artifact = eog_artifacts.EOG_eye; % EOG artifacts

cfg.artfctdef.muscle.artifact = combined_muscle_artifacts; % Combined muscle artifacts



data_clean_artifactfree = ft_rejectartifact(cfg, data_segmented);



cfg = [];

cfg.channel = 'all'; % All channels

cfg.viewmode = 'vertical'; % Visualization mode

ft_databrowser(cfg, data_clean_artifactfree);

During artifact rejection using ft_rejectartifact, I encounter the following warning messages: "The input is raw data with 14 channels and 1 trial. Warning: Original data has trialinfo, using user-specified trialinfo instead. Warning: correcting numerical inaccuracy in the time axes". Despite these warnings, the artifact rejection process completes successfully. However, when attempting to visualize the cleaned data (second part of the code), I observe fragmented signals where rejected artifact segments are displayed as white spaces, indicating signal removal. This fragmentation makes it challenging to assess the artifact-free data as a continuous signal and to detect any discontinuities or abrupt transitions in the data.

Ultimately, my objective is to use ft_redefinetrial to concatenate segments and visualize the entire continuous signal (while preserving the event markers – so that the information about the sleep stages is still accessible). Could you please provide guidance on how to seamlessly visualize the cleaned data after partial artifact rejection? Specifically, I would appreciate insights into any additional parameters or configurations that might be necessary to achieve a continuous visualization of the artifact-free EEG signal, ensuring proper data handling and analysis.

Thank you in advance for your assistance.

Best regards,

Sophie Schubert


------------------------------------------------------------------------------

De informatie opgenomen in dit bericht kan vertrouwelijk zijn en is
uitsluitend bestemd voor de geadresseerde. Indien u dit bericht onterecht
ontvangt, wordt u verzocht de inhoud niet te gebruiken en de afzender direct
te informeren door het bericht te retourneren. Het Universitair Medisch
Centrum Utrecht is een publiekrechtelijke rechtspersoon in de zin van de W.H.W.
(Wet Hoger Onderwijs en Wetenschappelijk Onderzoek) en staat geregistreerd bij
de Kamer van Koophandel voor Midden-Nederland onder nr. 30244197.

Denk s.v.p aan het milieu voor u deze e-mail afdrukt.

------------------------------------------------------------------------------

This message may contain confidential information and is intended exclusively
for the addressee. If you receive this message unintentionally, please do not
use the contents but notify the sender immediately by return e-mail. University
Medical Center Utrecht is a legal person by public law and is registered at
the Chamber of Commerce for Midden-Nederland under no. 30244197.

Please consider the environment before printing this e-mail.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.science.ru.nl/pipermail/fieldtrip/attachments/20240624/d9a2122e/attachment.htm>


More information about the fieldtrip mailing list