FreeSurferToFieldTrip
From WikiMEG
The FreeSurfer software provides a good automatic segmentation of T1 images. It includes utilities to generate BEM surfaces that can be used to construct a head model for FieldTrip.
The following assumes you've run FreeSurfer on your T1.
Post-recon steps in the shell
Generate BEM surfaces (brain, inner/outer skull & outer skin)
SUBJECTS_DIR=~/mris-tms/fs SUBJECT=anattms_50 mne_watershed_bem
Convert T1 to nifti
mri_convert fs/anattms_50/mri/T1.mgz fs/anattms_50/mri/T1.mgz.nii
Obtain transform from T1 voxels to BEM surface space
mri_info --vox2raw-tkr fs/anattms_50/mri/T1.mgz > fs/anattms_50/transforms/t1-vox2ras-tkr.xfm
In MATLAB
Read the Nifti
t1 = ft_read_mri('fs/anattms_50/mri/T1.mgz.nii')
Read the BEM surfaces (this function is given below)
bems = read_bem_surfs('fs/', 'anattms_50');
Plot the two together
ft_determine_coordsys(t1, 'interactive', 'no') hold on plot_bem_surfs(bems);