= MRI segmentation with FastSurfer = ''Authors: Francois Tadel '' The open-source software [[https://deep-mi.org/research/fastsurfer/|FastSurfer]] can be used to extract the cortical envelope from a T1 MRI and register it to an atlas. The process is fully automatic and '''much faster than FreeSurfer'''. The results are compatible with FreeSurfer and can be imported in Brainstorm with just a few mouse clicks. If you are using FastSurfer, please '''cite '''the appropriate references. Note that this software is available only for '''Linux and MacOS'''. <> == Install FastSurfer == The most complicated task will be to install FastSurfer. You can use the intructions given in the [[https://github.com/deep-mi/FastSurfer|GitHub repository]] of the software, or if you are using '''Ubuntu 20''', you may try the following procedure. === Install pyenv === In a terminal, execute: {{{ $ sudo apt-get install -y make build-essential libssl-dev zlib1g-dev \ libbz2-dev libreadline-dev libsqlite3-dev wget curl llvm libncurses5-dev \ libncursesw5-dev xz-utils tk-dev libffi-dev liblzma-dev python-openssl $ curl https://pyenv.run bash }}} Add at the end of file '''$HOME/.bashrc''': {{{ # FREESURFER export FREESURFER_HOME=/usr/local/freesurfer/7.2.0 source $FREESURFER_HOME/SetUpFreeSurfer.sh # Load pyenv-virtualenv automatically export PATH="$HOME/.pyenv/bin:$HOME/.pyenv/shims:$PATH" eval "$(pyenv init -)"eval "$(pyenv virtualenv-init -)" }}} Start a new terminal, install Python 3.6.15 and create a new virtual environment for FastSurfer: {{{ $ pyenv install 3.6.15 $ pyenv global 3.6.15 $ pyenv virtualenv fastsurfer }}} For complete and updated installation instruction, see the [[https://github.com/pyenv/pyenv-installer#installation--update--uninstallation|pyenv repository]]. === Install FreeSurfer === From a terminal, download and install FreeSurfer Debian package: {{{ $ wget https://surfer.nmr.mgh.harvard.edu/pub/dist/freesurfer/7.2.0/freesurfer_7.2.0_amd64.deb $ sudo dpkg -i freesurfer_7.2.0_amd64.deb $ sudo apt-get -f install }}} Obtain a license.txt file from [[https://surfer.nmr.mgh.harvard.edu/registration.html|this page]], and copy it to the installation folder: {{{ $ cp license.txt /usr/local/freesurfer/7.2.0/ }}} For complete and updated installation instructions, see the [[https://surfer.nmr.mgh.harvard.edu/fswiki/DownloadAndInstall|FreeSurfer wiki]]. === Install FastSurfer === From a terminal, execute: {{{ $ sudo apt install libblas-dev liblapack-dev libatlas-base-dev gfortran $ pip install -r requirements.txt }}} Execute FastSurfer manually: {{{ $ ./run_fastsurfer.sh --t1 /home/ftadel/segmentation/freesurfer_db/PD/mri/orig/001.mgz \ --sid PD --sd /home/ftadel/segmentation/fastsurfer_db --parallel --threads 4 }}}