Pipeline-ILCB

MarsAtlas Step by Step on Linux

MarsAtlas is a model of cortical parcellation developped by the meca team directed by Olivier Coulon in collaboration with Andrea Brovelli and Guillaume Auzias at INT. It has the particularity of responding to a cortical organization in terms of sulcal lines (see here for more details). In this web page, we propose to install all the tools necessary for the use of MarsAtlas to segment  human anatomical MRI into parcels. We assume that you have an Ubuntu exploitation system (tested on version 16.04)

 

Step 1: Install the updates for Ubuntu
Step 2: Install Matlab
Step 3: Install SPM12
Step 4: Install FreeSurfer
Step 5: Install FSL
Step 6: Install BrainVISA
Step 7: Prepare anatomical MRI for denoising
Step 8: Segmentation using FreeSurfer
Step 9: Import results From FreeSurfer to BrainVISA

 

Step 1: Install the updates for Ubuntu

Before adding any tools, you should first install the updates for Ubuntu. Run the following commands at the terminal.

sudo apt-get update 
sudo apt-get upgrade

Step2: Install matlab

Download Matlab installation here and follow the detailed instructions of the page.

cd /usr/local/MATLAB/R2018a/bin
./matlab

Step3: Install SPM12

Download spm12.zip

Start MATLAB and add SPM into your path, either using File > Set Path > Add Folder… or typing in MATLAB’s workspace.

sudo unzip ~/Downloads/spm12.zip -d /usr/loca
addpath /usr/local/spm12 

Add supplementary toolboxes (nifti and cat12) for spm12

sudo unzip ~/Downloads/NIfTI_20140122.zip -d /usr/local/spm12/toolbox sudo unzip ~/Downloads/cat12_latest.zip -d /usr/local/spm12/toolbox

Step 4: Install FreeSurfer

Download Freesurfer installation using the following command at the terminal (see here for more details)

sudo wget ftp://surfer.nmr.mgh.harvard.edu/pub/dist/freesurfer/6.0.0/freesurfer-Linux-centos6_x86_64-stable-pub-v6.0.0.tar.gz

 Install it at /usr/local/ so let’s extract it to that directory

sudo tar -xzf freesurfer-Linux-centos6_x86_64-stable-pub-v6.0.0.tar.gz -C /usr/local/

Allow yourself to edit or create files in that folder

sudo chmod a+rwX -R  /usr/local/freesurfer

Obtain the FreeSurfer Licence here. Once you have the license emailed to you, copy the contents (4 lines) and create a license.txt file.

sudo nano /usr/local/freesurfer/license.txt

Copy 4 lines ant type the 3 commands to write and exit
Ctrl 0, Enter and Ctrl X

Copy paths in bashrc file with these commands

## bash 
export FREESURFER_HOME=/usr/local/freesurfer
export SUBJECTS_DIR=/usr/local/freesurfer/subjects
source $FREESURFER_HOME/SetUpFreeSurfer.sh
Test your FreeSurfer Installation

FreeSurfer comes with two sample data files (sample-001.mgz and sample-002.mgz) as well as a fully recon-ed subject named bert. These data files can be used to test that your FreeSurfer installation was done properly. To test your installation, try the following example:

Copy the sample-001.mgz to your current folder

cp $FREESURFER_HOME/subjects/sample-001.mgz ~ 

Convert the sample-001.mgz to nifti format.

mri_convert sample-001.mgz sample-001.nii.gz

Compare the results on your terminal console

## recon-all -i <mri_file> -subjid <subject_id>
## recon-all -all -subjid <subject_id>

## $> recon-all -i sample-001.nii.gz -s bert 
## -all (creates a folder called bert in
## SUBJECTS_DIR)
## sudo apt-get install tcsh 

recon-all -i sample-001.nii.gz -s bert 
recon-all -all -s bert


##sudo apt-get install libjpeg62 if necessary

Step 5: Install FSL

Download the FSL installation here

cd ~/Downloads
python fslinstaller.py

Check that your environment is correct by typing:

echo $FSLDIR

Check that your path is correct by typing:

flirt -version

Step 6 : Install Brainvisa

To integrate the cerebellum in human atlas, we propose you to install the version 4.5.0 of Brainvisa. We tested the ‘brainvisa_installer-4.5.0-linux64-glibc-2.15-online’

download here

Get some librairies before installing Brainvisa…

cd ~/Downloads

sudo chmod a+rwX -R brainvisa_installer-4.5.0-linux64-glibc-2.6-online ./brainvisa_installer-4.5.0-linux64-glibc-2.6-online

Follow the BrainVisa Suite Wizard Setup. Choose the default folder for installation ‘/home/chanoine/brainvisa-4.5.0-glibc2.15’ and click on the button ‘Finish’

Download the file ‘SubcorticalFromFreesurferToMarsAtlas.py‘ to change it on the BrainVISA distribution 4.5. This file was modified per courtesy by Guillaume Auzias in order to add the cerebellum volume to human MarsAtlas atlas.

sudo rm ~/Downloads/SubcorticalFromFreesurferToMarsAtlas.py 
/home/chanoine/brainvisa-4.5.0-glibc2.15/brainvisa/toolboxes/cortical_surface/processes/anatomy/tools

Start Brainvisa

cd /home/chanoine/brainvisa-4.5.0-glibc2.15/bin

./brainvisa

## sudo apt-get install libgstreamer0.10-dev libgstreamer-plugins-base0.10-dev if necessary

Click on the button ‘Open Preference’ and complete ‘ user Level’ and ‘textEditor’ fields as in the following dialog.

Preference Dialog

You have to create a database for storing your files: you can select the menu BrainVISA > Databases> db_brainvisa to do it.

You could create a root folder called ‘databases’ and 3 sub-folders as below before adding the paths in BrainVISA.                                    

Add Database: db_brainvisa and modify the field ‘ontology’

Add Database: db_freesurfer and modify the field ‘ontology’            

Save and Update the paths from the database dialogs.

Step 7: Prepare anatomical Image for Denoising

To facilitate the anatomical image (T1 MRI) segmentation step, it is recommended to use a denoising algorithm available on SPM12 CAT toolbox. (click here to get the example of the SPM batch) .

Once images are denoised (or not) they must be imported in a BrainVISA database using the Morphologist -> Import T1 image process.

Modify the paths on the dialog’ Import T1 MRI’ as below.

warning after Run

 

Step 8: Segmentation using FreeSurfer

export SUBJECT=sub-01
export ILCB_DATABASE=/home/chanoine/Documents/Gloups/databases
export SUBJECTS_DIR=$ILCB_DATABASE/db_freesurfer

recon-all -i $ILCB_DATABASE/db_brainvisa/subjects/$SUBJECT/$SUBJECT.nii -s $SUBJECT
 
# Run step 1
recon-all -cw256 -autorecon1 -wsless -s $SUBJECT

# Clean dura from brain
recon-all -skullstrip -clean-bm -gcut -subjid $SUBJECT
 
# Continue Steps 2 and 3
recon-all -autorecon2 -autorecon3 -subjid $SUBJECT

# Create output file with permissions
mkdir $SUBJECTS_DIR/$SUBJECT/bem/ 
touch $SUBJECTS_DIR/$SUBJECT/bem/output_vols.mgz
sudo chmod a+rwX -R $SUBJECTS_DIR/$SUBJECT/bem # Watershed algorithm to make BEM surf mri_watershed -useSRAS -atlas -less -surf $SUBJECTS_DIR/$SUBJECT/bem/ $SUBJECTS_DIR/$SUBJECT/mri/T1.mgz $SUBJECTS_DIR/$SUBJECT/bem/output_vols.mgz # Copy results mv $SUBJECTS_DIR/$SUBJECT/bem/_inner_skull_surface $SUBJECTS_DIR/$SUBJECT/bem/inner_skull.surf mv $SUBJECTS_DIR/$SUBJECT/bem/_outer_skull_surface $SUBJECTS_DIR/$SUBJECT/bem/outer_skull.surf mv $SUBJECTS_DIR/$SUBJECT/bem/_outer_skin_surface $SUBJECTS_DIR/$SUBJECT/bem/outer_skin.surf

Check & update databases; in BrainVISA go to: Data Management-> Update databases (double click)-> Update

Step 9: Import results from FreeSurfer to BrainVISA 

In BrainVISA go to: Freesurfer-> Tools-> Freesurfer output to BrainVisa conversion pipeline

  • Click the database symbol near the “anat” field, then select $ILCB_DATABASE/db_freesurfer./db_freesurfer in the “Database” field
  • On your right, select the subject file on which you want to perform the conversion and click Ok and then Run (as you can see the other fields are automatically filled)

UNDER CONSTRUCTION

./usr/local/freesurfer/SetUpFreeSurfer.sh

Step 6. Import results from Freesurfer to BrainVISA 

  • In BrainVISA go to: Freesurfer-> Tools-> Freesurfer output to BrainVisa conversion pipeline
    • Click the database symbol near the “anat” field, then select /hpc/group/surname.n/databases/db_freesurfer/meg_te in the “Database” field
    • On your right, select the subject file on which you want to perform the conversion and click Ok and then Run (as you can see the other fields are automatically filled)
  • Update databases; in BrainVISA go to: Data Management-> Update databases-> Update
  • In BrainVISA go to: Freesurfer-> Import-> Import FreeSurfer gray/white segmentation to Morphologist
    • Click the database symbol near the “T1_orig” field, and select /hpc/group/surname.n/databases/db_freesurfer/meg_te, then choose the subject on the right and click Ok
    • Click the database symbol near the “T1_output” fields,  and fill this fields as follow: 
      • Database: /hpc/group/surname.n/databases/db_brainvisa; 
      • Data type: Raw T1 MRI; 
      • File format: gz compressed NIFTI-1 image; 
      • subject: subject_01 (e.g.). 
      • Click Ok and Run
  • Open Morphologist
  • Check results and correct import in Morphologist. Don’t run it, just open the file that you want to examine from the bd_database and then click on the eye icons to check if all is correct, especially you can visualize if the “Sulci Recognition” is done.

Step 7. Create MarsAtlas 

  • In BrainVISA go to: Cortical surface-> anatomy-> HIP HOP cortical parametrization
    • Choose subject from brainvisa_db and Run
  • Troubleshooting: How to correct manually the cingular pole if MarsAtlas is not correct:
    • Open cingular pole file on Anatomist by clicking on the green icon in HIPHOP
    • Open the PaintSurf toolbox: the icon is the color palette
    • Get the color from the cortex using the syringe
    • Draw the contour using the free (unconstrained) or sulci based contour: the icon is the brain with a colored line
    • Select all points that are outside the correct cingular mask using the magic stick
    • Click on the green tick to change color texture of the selected surface
    • Save the file once happy by rewriting old file name *_pole_cingular.gii
    • Use Cortical Surface -> Anatomy -> Tools -> Cingular Pole From Manual to correctly transform the texture. Select the subject and Run
    • Rerun HIPHOP without the first two steps
  • In BrainVISA go to: Cortical surface-> low-level-> 2D parcellation to 3D parcellation
    • Choose the db_brainvisa, the subject and then, on the right, the “left hemisphere marsAtlas parcellation texture”
  • In BrainVISA go to: Cortical surface -> anatomy -> tools -> Subcortical From Freesurfer to MarsAtlas Parcellation. 
    • Manually change the path within the freesurfer_database area, writing the right  directory: “/hpc/group/surname.n/databases/db_freesurfer/meg_te” 
    • If an error occurs, quit BrainVISA and  try these three different solutions: 
      • Go to the terminal and type “freesurfer_setup”, then open BrainVISA in the same terminal and try again
      • Go to the terminal and type:
        “export BASH=/hpc/soft/freesurfer/freesurfer_5.3.0/bin/:$BASH”,
        then open BrainVISA in the same terminal and try again
      • Go to the terminal and type:
        “export PATH=$PATH:/hpc/soft/freesurfer/freesurfer/bin”,
        then open BrainVISA in the same terminal and try again
  • Create decimated surfaced 
    • Place the directory with the directory containing the 138 MarsAtlas parcellation somewhere such as:
      • /hpc/comco/basanisi.r/Databases/db_brainvisa/hiphop138-multiscale
      • This directory can be downloaded here
      • This directory contains all the decimated surfaces
    • Cortical surface -> anatomy -> tools -> spherical_mesh_from_HIPHOP_parameterization
    • Cortical surface -> anatomy ->group -> Remesh_From_Sphere 
      • Here you need to specify the spherical template the you want to use with the desired resolution.
      • Example of file for the « spherical template” « /hpc/comco/brovelli.a/Code/Brainvisa/hiphop138-multiscale/Decimated/4K/hiphop138_Lwhite_dec_4K_spherical.gii
    • Redo it for the other hemisphere
Rechercher dans OpenEdition Search

Vous allez être redirigé vers OpenEdition Search