Tutorial 1: Anatomy

We have two MRI scans for the patient we are processing in this tutorial: before and after the sEEG implantation. The second one shows artifacts around the contacts of the depth electrodes and can be used to identify their positions. In order to use the volumes simultaneously, we use SPM to register them together, then normalize them to the MNI space.


Download the example dataset for the ImaGIN tutorial:

You will need SPM and ImaGIN to follow this tutorial:

Start ImaGIN to get all the folders of the toolbox added to your Matlab path:

  • Start MATLAB, go to the ImaGIN2 folder
  • Run script: ImaGIN.m

Registration script

We will use a MATLAB script that generates and executes a SPM batch to process the anatomical scans of the patient:

The inputs and outputs are described in the header of the script. We will use it in a similar way to what is done in the fully automated script we provide for this tutorial. You can simply copy-paste the following lines in your MATLAB command window (after changing the path to the tutorial dataset):

% Folder in which you unzipped the tutorial dataset
Root = 'C:\Users\username\Documents\Epilpesy';
% Name of the patient, which must corresponds to subfolder in Root directory Patient{1}.Name = 'tutorial_epimap';
% Patient anatomy: pre- and post-implantation MRI scans
Patient{1}.MRI.pre  = fullfile(Root, Patient{1}.Name, 'anat', 'MRI', '3DT1pre_deface.nii');
Patient{1}.MRI.post = fullfile(Root, Patient{1}.Name, 'anat', 'MRI', '3DT1post_deface.nii');
Patient{1}.MRI.ref  = 'pre';
Patient{1}.MRI.out  = fullfile(Root, Patient{1}.Name, 'anat', 'MRI');
% MNI normalization: Set to 1 for results in MNI space, 0 for results in patient space isNormalize = 1;
% Co-registration, segmentation and normalization of the MRI scans
ImaGIN_anat_spm(Patient, isNormalize);

The new files in the output folder tutorial_epimap/anat/MRI that we will use in the following tutorials:

  • BrainPre.nii: Registered pre-implantation MRI
  • BrainPost.nii: Registered post-implantation MRI
  • wBrainPre.nii: Registered pre-implantation MRI, normalized in MNI space
  • wBrainPost.nii: Registered post-implantation MRI, normalized in MNI space
  • y_3DT1pre_deface.nii : Deformation fields from subject space to MNI space (pre-implentation MRI)
  • y_3DT1post_deface.nii : Deformation fields from subject space to MNI space (post-implentation MRI)

SPM batch editor

The script ImaGIN_anat_spm.m generates a SPM batch, that is executed with the SPM job manager. The batch is saved in the anatomy folder before execution (ImaGIN_spm_batch.mat) and can be loaded in the SPM batch editor. This section is for reference only, you don't actually have to follow these instructions.

  • In your MATLAB command window, type: spm fmri
  • At the bottom of the SPM menu figure, click on [Batch]
  • In the batch editor, select the menu File > Load batch.
  • Select the batch file: tutorial_epimap / anat / MRI / ImaGIN_spm_batch.mat

Next tutorial: Tutorial 2: Electrodes positions