Tutorial XX: Frequency filters
Authors: Francois Tadel, Elizabeth Bock, John C Mosher, Sylvain Baillet
From Auditory
Detect and remove artifacts
Spectral evaluation
- One of the typical pre-processing steps consist in getting rid of the contamination due to the power lines (50 Hz or 60Hz). Let's start with the spectral evaluation of this file.
Drag ALL the "Link to raw file" to the Process1 box, or easier, just drag the node "Subject01", it will select recursively all the files in it.
Run the process "Frequency > Power spectrum density (Welch)":
Time window: [All file], Window length: 4s, Overlap: 50%, Sensor types: MEG
- Note that you need at least 8Gb of RAM to run the PSD on the entire file. If you don't or if you get "Out of memory" errors, you can try running the PSD on a shorter time window.
Click on [Edit] and select option "Save individual PSD values (for each trial)".
- Double-click on the new PSD files to display them.
Observations for Run01:
Peaks related with the power lines: 60Hz, 120Hz, 180Hz (240Hz and 300Hz could be observed as well depending on the window length used for the PSD)
The drop after 600Hz corresponds to the low-pass filter applied at the acquisition time.
One channel indicates a higher noise than the others in high frequencies: MLO52 (in red).
Observations for Run02:
Same peaks related with the power lines: 60Hz, 120Hz, 180Hz
Same drop after 600Hz.
Same noisy channel: MLO52.
Additionally, we observe higher level of noise in frequencies in the range of 30Hz to 100Hz on many occipital sensors. This is probably due to some tension in the neck due to an uncomfortable position. We will see later whether those channels need to be tagged as bad.
Power line contamination
Put ALL the "Link to raw file" into the Process1 box (or directly the Subject01 folder)
Run the process: Pre-process > Notch filter
Select the frequencies: 60, 120, 180 Hz
Sensor types or names: MEG
- The higher harmonics are too high to bother us in this analysis, plus they are not clearly visible in all the recordings.
- In output, this process creates new .ds folders in the same folder as the original files, and links the new files to the database.
Run again the PSD process "Frequency > Power spectrum density (Welch)" on those new files, with the same parameters, to evaluate the quality of the correction.
- Double-click on the new PSD files to open them.
- Zoom in with the mouse wheel to observe what is happening around 60Hz (before / after).
To avoid the confusion later, delete the links to the original files: Select the folders containing the original unfiltered files and press the Delete key (or right-click > File > Delete).
From Continuous
It is common to have portions of recordings contaminated by events coming from the subject (eye blinks, movements, heartbeats, teeth clenching, implanted stimulators...) or from the environment (stimulation equipment, elevators, cars, trains, building vibrations...). Some occur at specific frequencies and can be removed using frequency filters, as introduced in the first chapter of this tutorial. Some other artifacts have more complex frequency patterns but are well defined, reproducible and can be removed efficiently using Signal Space Projections (SSP). This tutorial shows how to apply this technique to correct for the cardiac and ocular artifacts.
We are going to use the protocol TutorialRaw created in the previous tutorial ?Review continuous recordings and edit markers. If you have not followed this tutorial yet, please do it now.
Power line contamination
Notch filters are adapted to remove some well identified contaminations from oscillating systems, such as the power lines 50Hz or 60Hz. Here is an example of how to evaluate and correct fixed frequency artifacts. Important notes:
Usually you would prefer to apply the frequency filters before the SSP correction.
This approach is limited to CTF and Elekta-Neuromag recordings for now, other file formats will be developed on demand. An alternative approach for other file formats is described in the EEG/Epilepsy tutorial.
Identify the unwanted frequencies
Drag and drop the "Link to raw file" in the Process1 tab, click on the button [Run] to open the Pipeline editor window and select the process "Frequency > Power spectrum density (Welch)". This will estimate the power spectrum of the signal using the Welch method. Set the time window to process to [0,50]s, and the window length to 4 sec, with an overlap of 50%, this will be more than enough to get a good estimate of the spectrum (average of the Fourier transform of 24 windows of 4800 samples each). Leave the other options to the default values.
Double click on the "Power (MEG)" file that was created under the "Link to raw file" in the database explorer. This shows the estimate of the power spectrum for the first 50 seconds of the continuous file, for all the sensors, with a logarithmic scale. You can identify four peaks at the following frequencies: 60Hz, 120Hz, 180Hz and 300Hz. The first three are related with the power lines (acquisition in Canada, where the electricity is delivered at 60Hz, plus the harmonics), and are expected to be coming from pure sinusoidal components in the signal. The last one is an artifact of the low-pass filter at 300Hz that was applied on the recordings at the acquisition time. We are going to ignore this one, as it is probably more complex and spanning over several frequency bins.
Remove: 60Hz and harmonics
Leave the file "Link to raw file" in the Process1 list and now run "Pre-process > Notch filter".
Enter the frequencies to remove (60Hz, 120Hz and 180Hz) and leave the other options to the default values.
The operation creates a new "Link to raw file" entry in the database, pointing to a new CTF dataset in the same folder as the original continuous file. To check where this file was created: right-click on the file "Raw | notch(60Hz 120Hz 180Hz)" > File > Show in file explorer. This file has the exact same properties as the original file, including the SSP projectors, only the values of the MEG sensors were updated.
Alternatives
If the notch filter is not giving satisfying result, you can use two other processes:
Sinusoid removal: This process can do a better job at removing precise frequencies by identifying the sinusoidal components and then subtracting them from the signals in time domain (not a frequency filter).
Band-stop filter: This process can be useful for removing larger segments of the spectrum, in case the power line peaks are spread over numerous frequency bins or for suppressing other types of artifacts.
Evaluate the results
Now run the same frequency analysis: process "Frequency > Power spectrum density (Welch)", time window = [0,50]s, window length = 4000ms, overlap = 50%. Double click on the new "Power (MEG)" file. As expected, the three first peaks due to the power lines are gone.
You can run a few other pre-processing operations directly on the continuous files, including a band-pass filter. Frequency filters and sinusoid removals are operations that you should apply at very early stages of the analysis, before epoching the recordings. Those operations do not perform well next to the beginning and the end of the signals, they may generate important artifacts. It is therefore much more accurate to filter the entire recordings from the original continuous file at once, rather than filtering small epochs after importing them in the database.
From now on, we are only going to work on this clean file "Raw | notch(60Hz 120Hz 180Hz)".