Tutorial 11: Artifact detection
Authors: Francois Tadel, Elizabeth Bock, John C Mosher, Sylvain Baillet
The previous tutorial illustrated how to remove noise patterns occurring continuously and at specific frequencies. However, most of the events that contaminate the MEG/EEG recordings are not permanent, span over a large frequency range or overlap with the frequencies of the brain signals of interest. Frequency filters are not appropriate to correct for eye movements, breathing movements, heartbeats or other muscle activity.
Other approaches exist to correct for those artifacts, based on the spatial signature of the artifacts. If an event is very reproducible and occurs always at the same position (eg. eye blinks and heartbeats), the sensors will always record the same values when it occurs. We can identify the topographies corresponding to this artifact (ie spatial distributions of values at one time point) and remove them from the recordings. This spatial decomposition is the basic idea behind two widely used approaches: the SSP (Signal-Space Projection) and ICA (Independent Component Analysis) methods. We will describe those approaches in the next tutorial.
The SSP method is based on the spatial decomposition of the MEG/EEG recordings for a selection of time samples during which the artifact is present. Therefore we need to identify when each type of artifact is occurring in the recordings. This tutorial shows how to detect automatically some well defined artifacts: the blinks and the heartbeats.
Let's start by observing the type of contamination the blinks and heartbeats cause to the MEG recordings.
Run #01: Double-click on the link to show the MEG sensors.
Configuration: Page of 3 seconds, view in columns, selection of the "CTF LT" sensors (the left-temporal sensors will be a good example to show at the same time the two types of artifacts).
EOG: Right-click on the link > EOG > Display time series. Two channels are classified as EOG:
VEOG: Vertical electrooculogram (two electrodes placed below and above one eye)
HEOG: Horizontal electrooculogram (two electrodes placed on the temples of the subject)
- On those traces, there is not much happening for most of the recordings except for a few bumps. This subject is sitting very still and not blinking much. We can expect MEG recordings of a very good quality.
ECG: Right-click on the link > ECG > Display time series
The electrocardiogram was recorded with a bipolar montage of electrodes across the chest. On the green trace, you can recognize the typical shape of the electric activity of the heart (P, QRS and T waves).
Find a blink: Scroll through the recordings using the F3 shortcut until you see a large blink.
- Remember you can change the amplitude scale with many shortcuts (eg. right-click + move).
- To keep the scale fixed between to pages: Uncheck the button [AS] in the figure (auto-scale)
- For instance, you can observe a nice blink at 20.8s.
- On the same page, you should be able to observe the contamination due to a few heartbeats, corresponding to the peaks of the ECG signal (eg. 19.8s, 20.6s, 21.3s).
The additional data channels (ECG and EOG) contain precious information that we will use for the automatic detection of the blinks and heartbeats. We strongly recommend that you always record these signals in your own experiments, it helps a lot with the data analysis.
Automatic detection: ECG
Now do the same thing for the heartbeats. In the Record tab, select the menu "SSP > Detect heartbeats". Configure the process to use the channel EEG057 (name of the ECG channel), and leave the other options to the default values.
Click on Run. After the process stops, you can see a new event category "cardiac" in the Record tab, with 346 occurrences. You can check a few of them, to make sure that the "cardiac" markers really indicate the ECG peaks, and that there are not too many peaks that are skipped.
Automatic detection: VEOG
In the Record tab, select the menu: SSP > Detect eye blinks. It opens automatically the pipeline editor, with the process "Detect eye blinks" selected:
Channel name: Name of the channel that is used to perform the detection. Select or type "EEG058" as it is the name of the EOG channel
Time window: Time range that the algorithm should scan for the selected artifact. Leave the default values to process the entire file.
Event name: Name of the event group that is created for saving all the detected events. Leave the default "blink".
Click on Run. After the process stops, you can see two new event categories "blink" and "blink2" in the Record tab. You can review a few of them, to make sure that they really indicate the EOG events. In the Record tab, click on the "blink" event category, then on a time occurrence to jump to it in the MEG and Misc time series figures.
Two types of events are created because this algorithm not only detects specific events in a signal, it also classifies them by shape. If you go through all the events that were detected in the two categories, you would see that the "blink" are all round bumps, typical of the eye blinks. In the category "blink2", the morphologies don't look as uniform; it mixes small blinks, and ramps or step functions followed by sharp drops that could indicate eye saccades. The saccades can be observed on the vertical EOG, but if you want a better characterization of them you should also record the horizontal EOG. The detection of the saccades should be performed with a different set of parameters, using the process "Detect custom events", introduced later in this chapter.
Remove simultaneous blinks/hearbeats
SSP > Remove simultaneous > cardiac / blink / 250ms
Let's perform the same detection operations on Run #02, using this time the Process1 box.
- Select the two AEF runs in the Process1 box.
- Select successively the following processes, then click on [Run]:
Events > Detect heartbeats: Select channel ECG, check "All file", event name "cardiac".
Events > Detect eye blinks: Select channel VEOG, check "All file", event name "blink".
Events > Remove simultaneous: Remove "cardiac", too close to "blink", delay 250ms.
Automatic detection: Custom
Those two previous processes are shortcuts for a generic process "Detect custom events". We are not going to use it here, but it is interesting to introduce it to understand how the blinks and heartbeats detection work. The logic is the following:
- The channel to analyze is read from the continuous file, for a given time window.
Frequency band: The signal is filtered in a frequency band where the artifact is easy to detect. For EOG: 1.5-15Hz ; for ECG: 10-40Hz.
Threshold: An event of interest is detected if the absolute value of the filtered signal value goes over a given number of times the standard deviation. For EOG: 2xStd, for ECG: 4xStd
Minimum duration between two events: If the filtered signal crosses the threshold several times in relation with the same artifact (like it would be the case for muscular activity recordings on an EMG channel), we don't want to trigger several events but just one at the beginning of the activity. This parameter would indicate the algorithm to take only the maximum value over the given time window; it also prevents from detecting other events immediately after a successful detection. For the ECG, this value is set to 500ms, because it is very unlikely that the heart rate of the subject goes over 120 beats per minute.
Ignore the noisy segments: If this option is selected, the detection is not performed on the segments that are much noisier than the rest of the recordings.
Enable classification: If this option is selected, the events are classified by shape, based on correlation measure. In the end, only the categories that have more than 5 occurrences are kept, all the other successful detections are ignored.
In case of failure
If you cannot get your artifacts to be detected automatically, you can browse through the recordings and mark all the artifacts manually, as explained in the previous tutorial Event markers.