Visual Artifact Rejection

Introduction

This tutorial makes use of the preprocessed data from Preprocessing - Trigger based trial selection. Run the script from that section in order to produce the single trial data structure, or download it from ftp://ftp.fcdonders.nl/pub/fieldtrip/tutorial/rejectvisual/PreprocData.mat. Load the data with the following command:

load PreprocData dataFIC

Before further analysis in any of the other tutorials, it is best to have artifact free data. Within FieldTrip you can choose to do visual/manual or automatic artifact detection and rejection.

Background

For a successful analysis of EEG or MEG signals, “clean” data is required. That means that you should try to reduce the amount of variance in the data due to factors that you cannot influence. One of the factors that is difficult to control are the presence of artifacts in the data. These artifact are physiological or can result from the acquisition electronics. The strongest physiological artifacts stem from eye blinks, eye movements and head movements. Muscle artifact from swallowing and neck contractraction can be a problem as well. Artifacts related to the electronics are 'SQUID jumps' or spikes seen in several channels. To start with, it is best to avoid those artifacts during the recording. You can instruct the subject not to blink during the trial, but instead give him some well-defined time between the trials in which he is allowed to blink. But of course there will always be some artifacts in the raw data.

While detecting artifacts by visual inspection, keep in mind that it is a subjective descision to reject certain trials and keep other trials. Which type of artifacts should be rejected depends on the analysis you would like to do on the clean data. If you would like to do a time-frequency analysis of power in the gamma band it is important to reject all trials with muscle artifacts, but for a ERF analysis it is more important to reject trials with drifts and eye artifacts.

Procedure

The following steps are taken to do visual artifact rejection:

Manual artifact rejection - display one trial at a time

The function ft_rejectvisual provides various ways of identifying trials contaminated with artifacts.

The configuration option cfg.method provides the possibility of browsing through the data channel by channel (cfg.method= 'channel'), trial by trial (cfg.method = 'trial') or displaying all the data at once (cfg.method = 'summary'). The field cfg.latency determines the time window of interest with respect to the trigger signals. In the example below the whole trial is inspected (i.e. cfg.latency is per default assigned to the whole trial).

The scaling of the plots is automatically adjusted according to the maximum amplitude over all channels. The scaling can be set using cfg.alim. For EOG/EEG channels cfg.alim=5e-5 (50 micro Volt) is a useful scale and for the MEG channels cfg.alim=1e-12 (10 fT/cm).

To browse through the data trial by trial while viewing all channels write:

cfg          = [];
cfg.method   = 'trial';
cfg.alim     = 1e-12; 
dummy        = ft_rejectvisual(cfg,dataFIC);

Click through the trials using the > button to inspect each trial.

If your dataset contains MEG and EEG channels (like this dataset), the MEG and EEG channels are scaled differently when using only cfg.alim (the EEG channels show up as big black bars on the screen). One of the reasons to record EOG, EMG or ECG is to check these channels while identifying eye, muscle and hart artifacts. The following code can be used to scale MEG and EEG channels both properly:

cfg          = [];
cfg.method   = 'trial';
cfg.alim     = 1e-12; 
cfg.megscale = 1;
cfg.eogscale = 5e-8;
dummy        = ft_rejectvisual(cfg,dataFIC);

In trial 15 notice the slower drift observed over a larger group of sensors. This is most likely due to a head movement.

Trial 84 shows an artifact which is caused by the electronics. Notice the jump in sensor MLT41:

By browsing through the trials, related artifacts become evident (trial 15, 36, 39, 42, 43, 45 ,49, 50, 81, 82 and 84). They should be marked as 'bad'. After pressing the 'quit' button the trials marked 'bad' are now removed from the data structure.

If you would like to keep track of which trials you reject, keep in mind that the trialnumbers change when you call ft_rejectvisual more than once. An example: There are 87 trials in your data and first you reject trial 15, 36 and 39. Then trial number 87 becomes trial number 84. Later when you also want to reject trials 42, 43, 45 ,49, 50, 81, 82 and 84 you should be very careful and subtract 3 from all the old trial numbers. If you would like to know which trials you rejected, it is best to call rejectvisual only once.

Manual artifact rejection - display one channel at a time

It can also be convenient to view data from one channel at a time. This can be particularly relevant for the EOG channel. To do so write:

cfg          = [];
cfg.method   = 'channel';
cfg.alim     = 1e-12; 
cfg.megscale = 1;
cfg.eogscale = 5e-8;
dummy        = ft_rejectvisual(cfg,dataFIC);

Click through the data using the > button. While clicking through all the trials you see that channels MLO12 and MLP31 contain a lot of artifacts (see the figure below ). They should be marked as 'bad'. After pressing the 'quit' button the trials marked 'bad' are now removed from the data structure.

Manual artifact rejection - display a summary

To produce an overview of the data choose the cfg.method 'summary':

cfg          = [];
cfg.method   = 'summary';
cfg.alim     = 1e-12; 
cfg.megscale = 1;
cfg.eogscale = 5e-8; 
dummy        = ft_rejectvisual(cfg,dataFIC); 

This gives you a plot with the variance for each channel and trial.

The command window allows for toggling trials and channels on and off. The first option is on toggling trials. Enter either a trial number or enter 0 (zero). This allows for using the mouse to toggle trials by clicking in the lower left window. After pressing <Enter> the same options are available with respect to channels. Pressing <Enter> again gives the option for plotting the data for a selection of trials. After pressing <Enter> again the last option is to finish the selection. After finishing, the trials/channels will be rejected from the data set. The options appear as follows:

toggle the following trials [number, 0=interactive]:  
toggle the following channels [number, 0=interactive]:
select the trials to be plotted separately [number, 0=interactive]:
are you finished with your selection [Y, n]: y
87 trials marked as GOOD, 0 trials marked as BAD 
152 channels marked as GOOD, 0 channels marked as BAD

Now toggle trial 84 (with the jump artifact) and see the change in the plot with the variance for each channel and trial. Now it becomes easier to see which other trials could contain artifacts.

When using cfg.method='summary' usually the EEG channels explain a lot of the variance. Therefore toggling them could change the plot with the variance per trial (second row, left) a lot. Then you only see the variance in each trial in the MEG channels.


You can repeat this for the initially congruent (IC) condition. To detect all the artifacts use ft_rejectvisual with all 3 methods (trial, channel and summary) like in the examples above.

clear all
load PreprocData dataIC
 
cfg          = [];
cfg.method   = 'trial'; % also try cfg.method = 'channel' and cfg.method = 'summary'
cfg.alim     = 1e-12; 
cfg.megscale = 1;
cfg.eogscale = 5e-8; 
dummy        = ft_rejectvisual(cfg,dataIC);

Trials 1, 2, 3, 4, 14, 15, 16, 17, 20, 35, 39, 40, 47, 78, 79, 80, 86 contain various artifacts, classify these as 'BAD'. Also reject the channels MLO12 and MLP31.


Repeat the procedure for the fully congruent condition (FC):

clear all
load PreprocData dataFC

cfg          = [];
cfg.method   = 'trial'; % also try cfg.method = 'channel' and cfg.method = 'summary'
cfg.alim     = 1e-12; 
cfg.megscale = 1;
cfg.eogscale = 5e-8; 
dummy        = ft_rejectvisual(cfg,dataFC);

Trials 2, 3, 4, 30, 39, 40, 41, 45, 46, 47, 51, 53, 59, 77, 85 contain various artifacts, classify these as 'BAD'. Also reject the channels MLO12 and MLP31.

Summary

Per condition, the following trials contain artifacts:

  • FIC: 15, 36, 39, 42, 43, 49, 50, 81, 82, 84
  • IC: 1, 2, 3, 4, 14, 15, 16, 17, 20, 35, 39, 40, 47, 78, 79, 80, 86
  • FC: 2, 3, 4, 30, 39, 40, 41, 45, 46, 47, 51, 53, 59, 77, 85

Channels MLO12 and MLP31 are removed because of artifacts.

This tutorial was last tested with version 20090330 of FieldTrip.

tutorial/rejectvisual.txt · Last modified: 2010/04/07 17:20 by robert
Back to top
chimeric.de = chi`s home Creative Commons License Valid CSS Driven by DokuWiki do yourself a favour and use a real browser - get firefox!! Recent changes RSS feed Valid XHTML 1.0