This is a collaborative space. In order to contribute, send an email to maximilien.chaumon@icm-institute.org
On any page, type the letter L on your keyboard to add a "Label" to the page, which will make search easier.

Detect and mark bad data segments

There is nothing either good or bad, but thinking makes it so.
William Shakespeare; Hamlet

Prerequisite

As you get here, you have just recorded a raw data file. If you are analysing MEG data, you may have also run maxfilter to remove artifacts originating from outside the helmet (see the appropriate tutorial).

Goal of this tutorial

In the following, you will review the data to check that no extremely bad data segments get included in the analysis pipeline.

How to do it

Marking bad data segments with MNEpython

If you are using MNE python, you should take a look at this page.

The data that you recorded most probably contain some signal that you are not interested in. These signals are called artifacts and are due essentially to non-neural activity (electronic dysfunction, muscular contractions, eye movements, heart beats...). These artifacts are particularly problematic because they are of tremendous amplitude, compared to the brain signals that you are interested in, and can contaminate the data by altering the signal-to-noise ratio. There are two different complementary strategies to clean the data of these artifacts: artifact rejection (removing the affected data) or artifact correction (through e.g. Independent Component Analysis, or interpolation). In this section, we will learn how to find and mark artifacts (for later rejection or correction).

In 2019, it is still recommended to review all recorded data "with the naked eye", using a software to plot the time courses of all recorded channels, then marking bad segments for later rejection.

We will do this with the following commands in a terminal:

Code to run only the first time. Click on the right to show. ====>
echo "# added to use muse_review
export PATH=\"\$PATH:/network/lustre/iss01/cenir/analyse/meeg/00_max/share:\"" >> ~/.bashrc
source ~/.bashrc
/network/lustre/iss01/cenir/analyse/meeg/00_max/share/muse_add_templates
review with muse
muse_review your_file.fif

This will open two windows similar to these ones:

These correspond to magnetometers (here on the left, 102 channels), and gradiometers (here on the right, 204 channels).

We can also change the scale of the display by holding the Ctrl key while spinning the mouse wheel.

It is a good idea to synchronize display across these two windows. For this, right click anywhere in the region where the time axis is defined and select "Synchro with..." and click on the first "Plot" item

Now we will navigate through the file using the big arrows at the top, or the page-up and page-down keys on the keyboard.

Next we want to mark bad periods of time.

Use the middle mouse button to mark the beginning of a bad period of time. Hold the middle mouse button pressed, press Ctrl, move the mouse to the end of the bad period, release everything.

The period you selected is marked as a bad segment, which you will be able to reject at later stages.

In some case, you may want to create other markers. To do this, press Ctrl+M to open the Marker Manager. In the "Edition" dropdown menu, select BAD, close the dialog.