[FieldTrip] Electrode alignment to standard MRI template

Annika Thierfelder athierfelder at tuebingen.mpg.de
Tue Aug 21 18:21:00 CEST 2018


Hello everyone,

I started using fieldtrip last week to do EEG source analysis and I 
experienced some issues when trying to align the EEG to the MRI. Since 
we don't have MRI scans for our subjects, I used the standard_mri from 
the template folder.

The solution that works "best" until now is to align the electrodes with 
the MRI fiducials and compute the BEM from the MRI seperately (I used 
bemcp for that since I work on windows, so dipoli doesn't run). However, 
when I plot the aligned electrodes together with the BEM head surface, 
the electrodes are in the correct orientation but they have an offset 
along the z-axis. I put the code I used below and uploaded the picture 
of the electrodes and the head model on google drive: 
https://drive.google.com/open?id=1b7Q3YGWGyzaa5oXeE-PfOOHNIDoFaLO1

There are two things I'm wondering about now:

Why are the nasion head coordinates in the MRI template [1, 0, 0] and 
not [100, 0, 0], which would make more sense (at least in my opinion) 
since the units are in mm and I thought the nasion is not supposed to be 
inside the head? The LPA and RPA values are [0, 83, 0] and [0, -117, 0] 
respectively, which seems perfectly fine to me.

I have the feeling that the problem arises because the two coordinate 
systems of the data do not have the same origin. Can I shift the 
coordinate system of the electrode space before aligning them? I only 
found ways how to change the coordinate system of the MRI. I also tried 
to change the MRI coordinate system first before aligning the 
electrodes, but I found that I cannot create the BEM model with 'bemcp' 
anymore. It seems to throw an error if I give it an MRI with any 
coordinate system that is not 'spm'. So I kind of have the feeling that 
I need to get the electrodes into the 'spm' coordinates to match the MRI 
and BEM head.

Thank you a lot in advance for your support!

Annika

PS: I know there has been a similar problem once in this mailing list, 
but I checked the suggestions and they did not work for me, also it 
seemed as if in the end it came down to fitting the electrodes manually 
there, and I suppose there can be another solution for this.

==================================================================================

Code for the electrode alignment:

%This is my how my electrode data looks like:
disp(chanlocs_124)
       label: {124×1 cell}
     elecpos: [124×3 double]
        unit: 'mm'

% get fiducials from the MRI template
vox_Nas = mri_spm.hdr.fiducial.mri.nas;
vox_Lpa = mri_spm.hdr.fiducial.mri.lpa;
vox_Rpa = mri_spm.hdr.fiducial.mri.rpa;

% I know I can skip this step because I can directly use the 
head-coordinates given in the MRI template
% I kept it because it doesn't make a difference
vox2head = mri_spm.hdr.transformMRI2Head;
head_Nas = ft_warp_apply(vox2head, vox_Nas, 'homogeneous'); % nasion
head_Lpa = ft_warp_apply(vox2head, vox_Lpa, 'homogeneous'); % Left 
preauricular
head_Rpa = ft_warp_apply(vox2head, vox_Rpa, 'homogeneous'); % Right 
preauricular

% save the MRI fiducials as target structure for the realignment
% in our data set, the LPA is named TTP9 and the RPA is TTP10, so I 
renamed them
elec_mri.elecpos(1,:) = head_Nas;
elec_mri.elecpos(2,:) = head_Lpa;
elec_mri.elecpos(3,:) = head_Rpa;
elec_mri.label = {'Nz', 'TTP9', 'TTP10'};
elec_mri.unit  = 'mm';

% coregister the electrodes to the MRI using fiducials
cfg = [];
cfg.method   = 'fiducial';
cfg.target   = elec_mri;
cfg.elec     = chanlocs_124;
cfg.fiducial = {'Nz', 'TTP9', 'TTP10'};
chanlocs_124_spm = ft_electroderealign(cfg);

===================================================================================================
Just in case this is also of interest, this is how I compute the BEM 
headmodel from the same MRI template:

% segments the MRI into three different tissue parts
% creates binary masks for each point and tissue part
cfg = [];
cfg.output    = {'brain','skull','scalp'};
segmented_mri  = ft_volumesegment(cfg, mri_spm);

%% create mesh with different tissues
cfg=[];
cfg.tissue={'brain','skull','scalp'};
cfg.numvertices = [3000 2000 1000];
bnd=ft_prepare_mesh(cfg,segmented_mri);

% compute headmodel
cfg        = [];
cfg.tissue={'brain','skull','scalp'};
cfg.method ='bemcp';
vol        = ft_prepare_headmodel(cfg, bnd);




More information about the fieldtrip mailing list