Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
example:align_eeg_electrode_positions_to_bem_headmodel [2016/09/17 13:38]
165.112.44.179 [Matlab script]
example:align_eeg_electrode_positions_to_bem_headmodel [2017/08/17 11:21] (current)
Line 5: Line 5:
 ===== Description ===== ===== Description =====
  
-In order to use headmodels for EEG data created of individual ​MRIs (e.g. BEM), it is necessary to fit the individual ​electrode positions ​to the same coordinate system as the individual ​MRI. This script ​allows transforming ​electrode ​coordinates ​to the individual ​MRI space using the 3 fiducial points '​nasion',​ '​preauricular left' and '​preauricular right', given in the electrode ​coordinates ​structure. Furthermore,​ it is necessary to provide the voxel coordinates of the same fiducial points in the MRI. Typically the MRI is aligned to MNI space, thus the resulting electrode positions are as well aligned to MNI space.+To use accurate individual volume conduction models of the head (or "head models"​) in inverse source reconstruction of EEG data, we construct a head model from the individual ​MRIFurthermore, it is necessary to express ​the electrode positions ​in the same coordinate system ​and units as the MRI and head model. 
 + 
 +This script ​demonstrates how to transform ​electrode ​positions ​to the individuals ​MRI space using the 3 fiducial points '​nasion',​ '​preauricular left' and '​preauricular right'. In the example below the position of these three anatomical marker locations is specified ​in the electrode structure ​as if they were normal electrodes 
 + 
 +Furthermore,​ it is necessary to provide the voxel coordinates of the same fiducial points in the MRI. Typically the MRI is aligned to MNI space, thus the resulting electrode positions are as well aligned to MNI space.
  
  
Line 15: Line 19:
 % fiducials (nasion, left & right preauricular points) in both systems % fiducials (nasion, left & right preauricular points) in both systems
  
-% provide electrode coordinates,​ mri structure, and fiducials in mri  +% ensure ​that the electrode coordinates are in mm
- +
- +
-% ensure electrode coordinates are in mm+
 elec = ft_convert_units(elec,'​mm'​);​ % should be the same unit as MRI elec = ft_convert_units(elec,'​mm'​);​ % should be the same unit as MRI
  
-provide fiducial coordinates ​in electrodespace+these are expressed ​in the coordinate system of the electrode position capture device
 Nas = elec.chanpos(strcmp(elec.label,​ '​nasion'​),:​);​ Nas = elec.chanpos(strcmp(elec.label,​ '​nasion'​),:​);​
 Lpa = elec.chanpos(strcmp(elec.label,​ '​left'​),:​);​ Lpa = elec.chanpos(strcmp(elec.label,​ '​left'​),:​);​
 Rpa = elec.chanpos(strcmp(elec.label,​ '​right'​),:​);​ Rpa = elec.chanpos(strcmp(elec.label,​ '​right'​),:​);​
  
-provide fiducials (in voxelspace, e.g. [57,​127,​15]) ​of individual MRI+determine the same marker locations ​in voxel coordinates, e.g. [57,​127,​15])
 % find fiducials e.g. by using ft_sourceplot(cfg,​ mri) which plots a figure in which  % find fiducials e.g. by using ft_sourceplot(cfg,​ mri) which plots a figure in which 
 % you can interactively select slices of the mri % you can interactively select slices of the mri
Line 37: Line 38:
 vox2head = mri.transform;​ % transformation matrix of individual MRI vox2head = mri.transform;​ % transformation matrix of individual MRI
  
-% transform voxel indices ​of individual MRI to headcoordinates in mm+% transform voxel indices to MRI head coordinates
 head_Nas ​         = warp_apply(vox2head,​ vox_Nas, '​homogenous'​);​ % nasion ​ head_Nas ​         = warp_apply(vox2head,​ vox_Nas, '​homogenous'​);​ % nasion ​
 head_Lpa ​         = warp_apply(vox2head,​ vox_Lpa, '​homogenous'​);​ % Left preauricular head_Lpa ​         = warp_apply(vox2head,​ vox_Lpa, '​homogenous'​);​ % Left preauricular
 head_Rpa ​         = warp_apply(vox2head,​ vox_Rpa, '​homogenous'​);​ % Right preauricular head_Rpa ​         = warp_apply(vox2head,​ vox_Rpa, '​homogenous'​);​ % Right preauricular
  
-elec_mni.chanpos = [+elec_mri.chanpos = [
   head_Nas   head_Nas
   head_Lpa   head_Lpa
   head_Rpa   head_Rpa
   ];   ];
-elec_mni.label = {'​nasion',​ '​left',​ '​right'​};​ +elec_mri.label = {'​nasion',​ '​left',​ '​right'​};​ 
-elec_mni.unit  = '​mm';​+elec_mri.unit  = '​mm';​
  
-align using fiducials+coregister the electrodes to the MRI using fiducials
 cfg = []; cfg = [];
 cfg.method ​  = '​fiducial';​ cfg.method ​  = '​fiducial';​
-cfg.template = elec_mni;+cfg.template = elec_mri;
 cfg.elec ​    = elec; cfg.elec ​    = elec;
 cfg.fiducial = {'​nasion',​ '​left',​ '​right'​};​ cfg.fiducial = {'​nasion',​ '​left',​ '​right'​};​
 elec_new = ft_electroderealign(cfg);​ elec_new = ft_electroderealign(cfg);​
  
- +interactively coregister the electrodes ​to the BEM head model  
-align interactive ​to surface of headmodel stored in vol.bnd+% this is a visual check and refinement step 
 cfg = []; cfg = [];
 cfg.method ​   = '​interactive';​ cfg.method ​   = '​interactive';​