Authors: Francois Tadel
The open-source software FreeSurfer can be used to extract the cortical envelope from a T1 MRI. It also registers the individual cortex surfaces to surface-based anatomical atlases (Desikan-Killiany, Destrieux, Brodmann). The process is fully automatic and the results can be imported in Brainstorm with just a few mouse clicks.
Important note: Whether you are using FreeSurfer for the T1 segmentation, the cortical atlases or the FSAverage subject default: please register on their website (registration page) and cite the appropriate references.
Downloading and installing FreeSurfer is very easy. It just takes some time because the distribution package is huge (get ready to download several Gb). You have two options: you have a Linux system and you want to install FreeSurfer, or you don't and you want to run FreeSurfer in a Linux virtual machine.
Just follow the instructions: http://surfer.nmr.mgh.harvard.edu/fswiki/DownloadAndInstall
Set up the FreeSurfer in a csh/tcsh environment: run the following lines, or add them at the end of your $HOME/.cshrc script for permanent change. If you're not sure what csh is: type "echo $SHELL" to know what is the name of the shell that you use. If it says "/bin/tcsh" or "/bin/csh", this is for you.
setenv FREESURFER_HOME /.../local/freesurfer setenv SUBJECTS_DIR /.../data/freesurfer/subjects setenv FUNCTIONALS_DIR /.../data/freesurfer/sessions source /.../local/freesurfer/FreeSurferEnv.csh
Set up the FreeSurfer environment in a bash environment (add these lines at the end of your $HOME/.bashrc script):
export FREESURFER_HOME=/.../local/freesurfer export SUBJECTS_DIR=/.../data/ftadel/freesurfer export FUNCTIONALS_DIR=/.../data/ftadel/freesurfer source $FREESURFER_HOME/FreeSurferEnv.sh
- Run the reconstruction:
recon-all -i <mri_file> -subjid <subject_id> recon-all -all -subjid <subject_id>
- Go home, come back the next day. The process is fully automatic, but quite resource-consuming.
Done. Everything is ready to be imported in Brainstorm. The results are usually good, but depending on the quality of the structural MR, it may fail. Because of this unpredictable behavior, you always need to check visually the final surfaces. The FreeSurfer wiki suggests that you check all the steps with FreeSurfer. We suggest instead that you load it all in Brainstorm and go back to the manual checking/editing only if it looks bad.
More detailed instructions for setting up the environment and tuning the reconstruction here:
Importing the results in Brainstorm
- Switch to the anatomy side of the database explorer
- Create a new subject, set the default anatomy option to "No, use individual anatomy"
Right-click on the subject > Import anatomy folder...
Select the file format "FreeSurfer folder" and select the top folder of your subject <subject_id> (/.../data/freesurfer/subjects/subject_id)
To import the cortical thickness maps at the same time, you can select the format "FreeSurfer folder + Thickness maps" instead.
Then you're prompted for the number of vertices you want in the final cortex surface. This will by extension define the number of dipoles to estimate during the source estimation process. By default we set this value to 15000 for the entire brain (it means 7500 for each hemisphere).
The MRI Viewer appears, and a help window asks you to validate the orientation of the MRI and to define the 6 fiducial points. If something doesn't look right at this step, for instance if the MRI is not presented with a correct orientation, you should stop this automatic import process and follow the manual instructions in the basic tutorial pages.
Place the six fiducials. If you need help, refer to this page: CoordinateSystems
- Click on Save to keep your modifications, and the automatic import will go on.
- The files that are imported from the subject_id folder are the following:
/mri/T1.mgz (T1 MRI volume)
/mri/aseg.mgz (segmentation of subcortical structures)
/surf/?h.pial (grey/csf interface)
/surf/?h.white (grey/white matter interface)
/surf/?h.sphere.reg (registered parametrized sphere, for subject co-registration)
/label/?h.*.annot (cortical surface-based atlases)
/surf/?h.thickness (cortical thickness map)
- The successive steps that are automatically performed by Brainstorm:
- Import all the surfaces (left/right, white/pial)
- Load all the atlases available for each surface (note that the .pial and .white surfaces are matching point-to-point, so the same annotation files are imported for both surface types)
- Load the registered spheres for the the left and right hemispheres
- Downsample each hemisphere to the number specified in the options (by default 7500, half of the total default number 15000)
- Merge left and right hemispheres for the two surface types: white matter and cortex envelope
- Delete all the unnecessary surfaces
- Generate a head surface from the MRI
- Read the sub-cortical atlas aseg.mgz as a set of labelled surfaces
- Read the cortical thickness maps
The files you can see in the database explorer at the end:
MRI: The T1 MRI of the subject, imported from the MGH file format (.mgz)
head mask (10000,0,2): Scalp surface generated by Brainstorm. The numbers indicate the parameters that were automatically used for this head: vertices=10000, erode factor=0, fill holes=2 (these are detailed later)
cortex_300000V: High-resolution cortex surface that was generated by FreeSurfer, that contains usually between 200,000 and 300,000 vertices.
cortex_15000V: Low-resolution cortex surface, downsampled using the reducepatch function from Matlab (it keeps a meaningful subset of vertices from the original surface). It appears in green in the database explorer, ie. it is going to be used as the default by the processes that require a cortex surface.
white_300000V: High-resolution white matter envelope from FreeSurfer
white_15000V: Low-resolution white matter, processed with reducepatch
aseg atlas: Atlas of subcortical regions
A figure is automatically shown at the end of the process, to check visually that the low-resolution cortex and head surfaces were properly generated and imported. If it doesn't look like the following picture, do not go any further in your source analysis, fix the anatomy first.
How to check the quality of the result
It's hard to estimate what would be a good cortical reconstruction. What you are trying to spot at this level is mostly the obvious errors, like when the early stages of the brain extraction didn't perform well, just with a visual inspection. Play with the Smooth slider in the Surface tab. If it looks like a brain (two separate hemispheres) in both smooth and original views, it is probably ok.
Display the cortex surface on top of the MRI slices, to make sure that they are well aligned, that the surface follows well the folds, and that left and right were not flipped: right-click on the low-resolution cortex > MRI registration > Check MRI/surface registration...
The cortex looks bad
It is critical to get a good cortex surface for source estimation. If the final cortex surface looks bad, it means that something didn't work well somewhere along the FreeSurfer pipeline. You can refer to the following page to fix the problems manually:
The head surface looks bad
It is not mandatory to have a perfect head surface to use any of the Brainstorm features: you don't necessarily have to recognize the face (for the anonymity of the figures, it can be even better if you don't).
The head surface is important mostly for the alignment of the MEG sensors and the MRI. If you digitized the head shape with a Polhemus device, you can automatically align the head surface (hence the MRI) with the MEG sensors (in the same referential as the Polhemus points). The quality of this automatic registrations depends on the quality of both surfaces: the Polhemus head shape (green points) and the head surface from the MRI (grey surface). If you placed lots of points on the nose but your head surface doesn't have a nose, these points are not going to help. Except for that, a nice head shape is mainly useful for producing nicer figures.
If the default head surface looks bad, you can try generating another one: right-click on the subject folder > Generate head surface. The options are:
Number of vertices: Number of points that are kept from the initial isosurface computed from the MRI. Increasing this number may increase the quality of the final surface.
Erode factor: Number of pixels to erode after the first binary threshold of the MRI. Increasing this number removes small components that are connected to the head.
Fill holes factor: Number of dimensions in which the holes should be identified and closed. Increasing this number removes more of the cavities of the head surface (0=no correction, 1=removes holes inside the surface, 3=closes all the features that make the surface non-convex)
The default analysis pipeline in FreeSurfer implements an automatic parcellation of the cortical surface in anatomical regions. The description of this feature is available here:
With FreeSurfer >= 5.3, 4 atlases are available on all the individual brains:
Destrieux atlas (?h.aparc.a2009s.annot): more information
Desikan-Killiany atlas (?h.aparc.annot): more information
Mindboggle (?h.aparc.DKTatlas40.annot): more information
Brodmann areas (?h.BA.annot and ?h.BA.thresh.annot): more information
Additional 3rd-party atlases are loaded automatically by Brainstorm when available:
PALS-B12 (?h.PALS_B12_*.annot): more information
Yeo2011 (?h.Yeo2011_7Networks_N1000, ?h.Yeo2011_17Networks_N1000): more information
Lausanne 2008 (?h.myaparc_*.annot): more information
These atlases are imported in Brainstorm as scouts (cortical regions of interest), and saved directly in the surface files. To check where they are saved: right-click on the low-resolution cortex file > File > View file contents. You can see that 4 structures "Atlas" are available, the first one that has Name='User scouts', and the second one Name='Destrieux'.
To access them from the interface: Double-click on the cortex and go to the Scout tab, and click on the drop-down list to select another Atlas (ie group of scouts):
Displayed respectively in: FreeSurfer, Brainstorm (high-resolution) and Brainstorm (15000 vertices)
Displayed in Brainstorm with the original scouts colors (left) or classified in 6 regions (right): pre-frontal, frontal, central, parietal, temporal, occipital, occipital. You can switch between the two views with the button "Identify regions with colors" in the toolbar on the right of the scouts list.
Subcortical structures: aseg atlas
The file aseg.mgz contains a volume atlas of 40 subcortical regions. Brainstorm reads these volume labels and tesselates some of these regions, groups all the meshes in a large surface file where the regions are identified in an atlas called "Structures". It identifies: 8 bialateral structures (accumbens, amygdala, caudate, hippocampus, pallidum, putamen, thalamus, cerebellum) and 1 central structure (brainstem).
You can easily extract one structure (for example the brainstem or the cerebellum) by selecting the corresponding entries in the scouts list and selecting the menu Scout > Edit surface > Keep only selected scouts. It creates a new surface with only the selected regions. If you want to remove one or several structures, use the menu "Remove selected scouts" instead.
Read more about the FreeSurfer subcortical atlas on the software wiki:
The registered sphere is saved in each surface file in the field Reg.Sphere.Vertices. There is nothing that can be done with this information at this point, but it will become helpful when projecting the source results from the individual brains to the default anatomy of the protocol, for a group analysis of the results: Subject coregistration.
Read more about the FreeSurfer registration process on the software wiki:
The cortical thickness can be saved as a cortical map in the database (a "results" file). This result is generated when using the file format "FreeSurfer folder + Thickness maps" in the Import anatomy folder selection.
Instead of the MNI ICBM152 brain, you can use the FreeSurfer average subject "FSAverage" as your default anatomy in Brainstorm. This template is an average of 40 subjects using a spherical averaging described in (Fischl et al. 1999).
To change the default, right-click on "(Default anatomy)" > Use template > FSAverage. If it is not available on your computer yet, it will be automatically downloaded from the server to your user folder: $HOME/.brainstorm/templates/anatomy.
If you are using the FSAverage template but not a regular user of FreeSurfer, please register on their website: registration page.
Running the folder import as a process
You can import the FreeSurfer folders from scripts, but you have to provide manually the position for all the fiducial points: process Import > Import anatomy > Import anatomy folder.
The corresponding process function is: brainstorm3/toolbox/process/functions/process_import_anatomy.m
Manual import of the anatomy
In case you need to import the MRI, surfaces and atlases separately instead of using the menu "Import anatomy folder", here is the sequence of operations to perform to get to the same result:
From the Anatomy side of the database explorer: create a subject.
Right-click on the subject folder > Import MRI > Select "mri/T1.mgz"
- Set the 6 fiducial points, save
Right-click on the subject folder > Import surfaces > Select the FreeSurfer file format > Select simultaneously from the "surf" folder: lh.pial, lh.white, rh.pial, rh.white
Double-click on lh.pial toi display it. In the scout tab: Atlas > Load atlas > select all the lh.*.annot files available in the label folder. Close the figure.
- Repeat for the other surfaces: lh.white, rh.pial, rh.white
Right-click on lh.pial > MRI registration > Load FreeSurfer sphere > Select "surf/lh.sphere.reg"
- Repeat with the other surfaces (use rh.sphere.reg for the right hemisphere, white and pial surfaces)
Select all the surfaces, right-click > Less vertices > 7500 vertices > Select the first option "Matlab reducepatch"
Select lh.pial, rh.pial, right-click > Merge surfaces: Generates a surface cortex_250000V
Select lh.white, rh.white, right-click > Merge surfaces: Generates a surface white_250000V
Select lh.pial_7500V, rh.pial_7500V, right-click > Merge surfaces: Generates a surface cortex_15000V
Select lh.white_7500V, rh.white_7500V, right-click > Merge surfaces: Generates a surface white_15000V
- Delete all the separate hemispheres: ?h.pial, ?h.white
- Double-click on cortex_15000V to set it as the default cortex
Right-click on the subject folder > Import surfaces > Select the file format "Volume mask of atlas" > Select the file mri/aseg.mgz
Go to the functional view of the protocol, create a condition "FreeSurfer". Leave your mouse for a second over the new folder, an note the study index (iStudy).
- From the Matlab command window, you can import the thickness maps with the following call:
ThickFile = import_sources(iStudy, CortexHiFile, ThickLhFile, ThickRhFile, 'FS');
CortexHiFile = full path to the high-res cortex file (right-click > File > Copy file path to clipboard)
ThickLhFile = full path to the surf/lh.thickness file
ThickRhFile = full path to the surf/rh.thickness file