Neuromag tutorial


0. Download

The same MEG data can be downloaded also from Amazon S3 by the following command.

$ aws s3 cp --no-sign-request s3:// . --recursive

For installing Amazon Web Service Command Line Interface (AWS CLI), go to its tutorial page.

1. Introduction

1.1. Scenario

VBMEG can import MEG data recorded by Elekta Neuromag as well as Yokogawa system. This tutorial guides through the procedure from importing Neuromag MEG data to group analyses of source currents. All the procedures will be conducted with scripts.


1.2. Neuromag MEG data

We use an open MEG/EEG dataset containing 16 subjects' evoked responses to face stimuli (OpenNEURO ds000117-v1.0.1, Wakeman and Henson, 2015). In their experiment, three types of face stimuli were presented:

  • Famous,
  • Unfamiliar,
  • Scrambled.

During the experiment, MEG and EEG were simultaneously recorded with an Elekta Neuromag Vectorview 306 system (Helsinki, FI).

2. Starting tutorial

2.1. Setting environment

This tutorial was developed using MATLAB 2013b with Signal Processing Toolbox on Linux.

(1) Download and put the Neuromag MEG data into $data_dir
(2) Download, unzip, and put the tutorial programs and prepared results into $tutorial_dir
(5) Start MATLAB and change current directory to $tutorial_dir/program
(6) Open make_all.m by typing

>> open make_all

2.2. Adding path

Thereafter, we will sequentially execute the commands in make_all.m from the top.

We add paths to necessary directories.

>> addpath(path_of_VBMEG);
>> vbmeg
>> addpath(path_of_SPM8);

You need to modify path_of_VBMEG and path_of_SPM8 for your environment.

2.3. Creating project

We set the file and directory names, and set the parameters for analyzing the MEG data.

>> data_root = $data_dir;
>> tutorial_root = $tutorial_dir;
>> sub_number = 1;
>> p = create_project(data_root, tutorial_root, sub_number);

Results will be saved in $tutorial_dir/result.

3. Modeling brain

First of all, we construct a cortical surface model from T1 image and define current sources on it.

3.1. Importing T1 image

We unzip T1 image, and convert its coordinate system to those of VBMEG (direction: RAS, origin: center of T1 image). The coordinates of fiducials are also converted.

>> import_T1(p)

The following files will be saved.

  • $tutorial_dir/result/sub-01/struct/Subject.nii (converted T1 image)
  • $tutorial_dir/result/sub-01/struct/fiducial.mat (converted coordinates of fiducials)

3.2. Correcting bias in T1 image

Using SPM8, we correct bias in the T1 image (User manual).

>> correct_bias_in_T1(p)

The following file will be saved.

  • $tutorial_dir/result/sub-01/struct/mSubject.nii

3.3. Segmenting T1 image

Using SPM8, we extract a gray matter image from the T1 image.

>> segment_T1(p)

The following files will be saved.

  • $tutorial_dir/result/sub-01/struct/c1mSubject.nii (Gray matter)
  • $tutorial_dir/result/sub-01/struct/mSubject_seg_sn.mat (Normalization)

The gray matter image will be used in Preparing leadfield, and the normalization file will be used in 4. Importing fMRI activity.

3.4. Constructing brain model from cortical surface model

Using FreeSurfer, we constructed a polygon model of a cortical surface from the T1 image (User manual). By importing the cortical surface model, we construct a brain model, in which current sources are defined (vb_job_brain.m).

>> construct_brain_model(p)

The following files will be saved.

  • $tutorial_dir/result/sub-01/brain/Subject.brain.mat (Brain model)
  • $tutorial_dir/result/sub-01/brain/Subject.png
  • $tutorial_dir/result/sub-01/brain/Subject.act.mat

Subject.png shows the constructed brain model on the T1 image. In Subject.act.mat, fMRI activity will be stored (Importing fMRI activity).

3.5 Checking brain model

We check the constructed brain model by plotting the current sources on the T1 image.

>> check_brain_model(p)

The following figure will be saved.

  • $tutorial_dir/result/figure/check_brain_model/sub-01.png

4. Importing fMRI activity

VBMEG estimates source currents from EEG/MEG data using fMRI activity as prior information on the source current variance distribution. The fMRI result is assumed to be obtained using SPM8 (User manual, vb_job_fmri.m).

4.1. Importing fMRI activity

We import the statistical results of the fMRI data (SPM.mat).

>> import_fmri(p)

T-values and percent signal changes will be stored in

  • $tutorial_dir/result/sub-01/brain/Subject.act.mat.

4.2. Checking imported fMRI activity

We check the imported fMRI activities (vb_plot_cortex.m).

>> check_imported_fmri(p)

Figures will be saved in

  • $tutorial_dir/result/figure/check_imported_fmri/sub-01.

5. Preprocessing MEG data

We import Neuromag MEG data (.fif) and preprocess them for source imaging.

5.1. Importing MEG data

We convert Neuromag MEG files (.fif) into the VBMEG format (.meg.mat) (User manual, vb_job_meg.m) while converting the sensor positions into the VBMEG coordinate system (direction: RAS, origin: center of T1 image).

>> import_meg(p)

The imported MEG data will be saved in

  • $tutorial_dir/result/sub-01/meg/imported.

5.2. Checking sensor positions

We check the converted sensor positions by showing them with the head surface extracted from the T1 image.

>> check_pos(p)

Figures will be saved in

  • $tutorial_dir/result/figure/check_pos/sub-01.

5.3. Denoising MEG data

The MEG data include environmental noise, such as the line noise, and biological noise from heartbeats and eye movements. To remove these noises, we apply a low-pass filter, down-sampling, and a high-pass filter, and regress out ECG and EOG components

>> denoise_meg(p)

The denoised MEG data will be saved in

  • $tutorial_dir/result/sub-01/meg/denoised.

5.4. Making trial data

We segment the continuous MEG data into trials. First, we detect stimulus onsets from the trigger signals. Then, we segment the MEG data into trials by the detected stimulus onsets.

>> make_trial_data(p)

The following files will be saved.

  • $tutorial_dir/result/sub-01/meg/trial/run-{01-06}.meg.mat

5.5. Correcting baseline

For each channel and trial, we make the average of prestimulus MEG to 0.

>> correct_baseline(p)

The following files will be saved.

  • $tutorial_dir/result/sub-01/meg/trial/brun-{01-06}.meg.mat

5.6. Combining trials across runs

To handle all the trials collectively, we virtually combine the trials across all the runs.

>> combine_trial(p)

The following file will be saved.

  • $tutorial_dir/result/sub-01/meg/trial/

This file contains the information (e.g. file paths) to serve as the shortcut to these files.

  • $tutorial_dir/result/sub-01/meg/trial/brun-{01-06}.meg.mat

5.7. Rejecting bad channels

We detect noisy channels based on the amplitudes of the MEG data and reject them. The rejected channels will not be used in the following analyses.

>> reject_channel(p)

The following file will be saved.

  • $tutorial_dir/result/sub-01/meg/trial/

5.8. Rejecting bad trials

We reject the trials in which the subject blinked during the exposure to the visual stimulus. The rejected trials will not be used in the following analyses.

>> reject_trial(p)

The following file will be saved.

  • $tutorial_dir/result/sub-01/meg/trial/

5.10. Showing preprocessed MEG data

For each condition, we show the processed MEG data averaged across the trials (vb_plot_sensor_2d.m).

>> show_preprocessed_meg(p)

Figures will be saved in

  • $tutorial_dir/result/figure/show_preprocessed_meg/sub-01.

6. Estimating source current

We estimate source currents from the preprocessed MEG data.

6.1. Preparing leadfield

First, we construct a 1-shell (cerebrospinal fluid) head conductivity model (User manual, vb_job_head_3shell.m). Then, we make the leadfield matrix based on the 1-shell head conductivity model (User manual, vb_job_leadfield.m).

>> prepare_leadfield(p)

The following files will be saved.

  • $tutorial_dir/result/sub-01/meg/leadfield/Subject.head.mat (1-shell head conductivity model)
  • $tutorial_dir/result/sub-01/meg/leadfield/Subject.basis.mat (Leadfield matrix)

6.2. Estimating source currents

First, we estimate the current variance by integrating the fMRI activity and the MEG data (User manual, vb_job_vb.m). Then, we estimate source currents using the current variance (User manual, vb_job_current.m).

>> estimate_source_current(p)

The following files will be saved.

  • $tutorial_dir/result/sub-01/meg/leadfield/tcAll.bayes.mat (Current variance)
  • $tutorial_dir/result/sub-01/meg/leadfield/tcAll.curr.mat (Source current)

6.3. Showing estimated source currents

For each condition, we show the estimated source currents averaged across the trials (vb_plot_cortex.m).

>> show_source_current(p)

Figures will be saved in.

  • $tutorial_dir/result/figure/show_source_current/sub-01.

7. Starting group analysis

After estimating source currents for all the subjects, we perform a group analysis. We set directory paths and parameters for the group analysis.

>> pg = create_project_group(p);

8. Examining differences between conditions

We examine the differences of the source currents across the conditions using a statistical test.

8.1. Compare current amplitudes between Face and Scrambled conditions

For each subject, we normalize the source currents so that their prestimulus period have mean 0 and SD 1. Then, for each vertex and time, we compare the current amplitudes between Face and Scrambled conditions. This is the multiple comparison problem, which we solve by controlling the false discovery rate (FDR). The FDRs are estimated by the method of Storey and Tibshrani, 2003.

>> examine_diff_between_conds(pg)

The results will be saved in

  • $tutorial_dir/result/group/examine_diff_between_conds.

8.2. Showing differences of current amplitudes across conditions

We show the significant differences of the current amplitudes.

>> show_diff_between_conds(pg)

Figures will be saved in.

  • $tutorial_dir/result/figure/show_diff_between_conds.

Congratulations! You have successfully achieved the goal of this tutorial.