美文网首页
FreeSurfer-Introduction

FreeSurfer-Introduction

作者: SnorlaxSE | 来源:发表于2019-10-31 15:40 被阅读0次

    【摘要】FreeSurfer - Cortical surface and subcortical modelling 皮层表面和皮质下建模

    Installation

    • FreeSurfer Download and Install
      Linux:tar -C /usr/local -xzvf freesurfer-Linux-centos6_x86_64-stable-pub-v6.0.0.tar.gz

    • 解决Freesurfer的license问题:可以在官网注册,邮箱会收到license.txt文件,拷贝至FreeSurfer解压目录。比如,我的license已经注册并下载,放在~/Downloads文件夹下。可以执行如下命令拷贝:参考于FSL/FreeSurfer安装教程

      ~/Downloads$ sudo cp license.txt /usr/local/freesurfer/
      
    • 更改subjects文件夹权限

      $ sudo chmod -R 777 /usr/local/freesurfer/subjects
      

    Test your FreeSurfer Installation

    • Example 1: Convert the sample-001.mgz to nifti format.

      $> cp $FREESURFER_HOME/subjects/sample-001.mgz .
      $> mri_convert sample-001.mgz sample-001.nii.gz
      ...
      reading from sample-001.mgz...
      TR=7.25, TE=3.22, TI=600.00, flip angle=7.00
      i_ras = (-0, -1, -0)
      j_ras = (-0, 0, -1)
      k_ras = (-1, 0, 0)
      writing to sample-001.nii.gz...
      
    • Example 2: Perform a full recon-all on the nifti file.

      $> export SUBJECTS_DIR=<path to subject directory> # SUBJECTS_DIR变量为存储数据的目录
      $> recon-all -i sample-001.nii.gz -s bert -all (creates a folder called bert in SUBJECTS_DIR)
      
      ...
      Started at 2019年 07月 17日 星期三 20:54:07 CST 
      Ended   at 2019年 07月 18日 星期四 02:37:36 CST
      #@#%# recon-all-run-time-hours 5.725
      recon-all -s bert finished without error at 2019年 07月 18日 星期四 02:37:36 CST
      done
      
      • Process your own data with a command such as this:
      
      recon-all \
        -i  <one slice in the anatomical dicom series> \
        -s  <subject id that you make up> \
        -sd <directory to put the subject folder in> \
        -all
      

      where the input (-i) file is a single file representing a T1-weighted data set. If you have DICOM images, you must find a file in the T1 series to pass. You can do this with the dcmunack command.

    • Example 3: Perform a full recon-all on a pre-existing subject folder

      $> export SUBJECTS_DIR=<path to subject directory>
      $> recon-all -s bert -all
      
      ...
      Started at 2019年 07月 17日 星期三 21:38:11 CST 
      Ended   at 2019年 07月 18日 星期四 02:40:42 CST
      #@#%# recon-all-run-time-hours 5.042
      recon-all -s bert finished without error at 2019年 07月 18日 星期四 02:40:42 CST
      done
      
    • Example 4: View the output volumes, surfaces and subcortical segmentation of the fully recon-ed subject bert.

      $> cd $SUBJECTS_DIR
      $> freeview -v \
          bert/mri/T1.mgz \
          bert/mri/wm.mgz \
          bert/mri/brainmask.mgz \
          bert/mri/aseg.mgz:colormap=lut:opacity=0.2 \
          -f \
          bert/surf/lh.white:edgecolor=blue \
          bert/surf/lh.pial:edgecolor=red \
          bert/surf/rh.white:edgecolor=blue \
          bert/surf/rh.pial:edgecolor=red
      
      Some notes on the above command line:
      
      - bert is the name of the subject
      - The flag -v is used to open some of `the most commonly used volumes` including:
        - brainmask.mgz : skull-stripped volume primarily used for troubleshooting 头骨剥离的卷主要用于故障排除  T1去除颅骨 ➜ brainmask (voxel intensities)
        - wm.mgz : white matter mask also used for troubleshooting 白质掩膜也用于故障排除
        - aseg.mgz : subcortical segmentation loaded with its corresponding color table and at a low opacity. For more information on the subcortical segmentation, see [here](https://surfer.nmr.mgh.harvard.edu/fswiki/SubcorticalSegmentation).皮质下分割加载了相应的颜色表并且低不透明度。 有关皮质下分割的更多信息,请参见此处。 brainmask上色(`遵循皮质下强度边界`) ➜ aseg (labeled structures) 显示皮下结构的分割情况
      
      - The flag -f is used to load surfaces (`遵循灰质和白质边界`)
            - white & pial(软膜的) surfaces are loaded for each hemisphere(半球) & with color indicated by 'edgecolor'
            The `white surface` (blue line) is used to `calculate total white matter volume` and should accurately `follow the boundary between white matter and gray matter`. The `pial surface` (red line) is used to `calculate cortical gray matter volume and should accurately `follow the boundary between the gray matter and the CSF`.
      
      • freeview.bin: error while loading shared libraries: libpng12.so.0: cannot open shared object file: No such file or directory:Download the shared library from https://packages.ubuntu.com/xenial/amd64/libpng12-0/download

        sudo dpkg -i libpng12-0_1.2.54-1ubuntu1.1_amd64.deb
        
      • freeview.bin: error while loading shared libraries: libjpeg.so.62: cannot open shared object file: No such file or directory

        sudo apt install libjpeg62
        
      • .nii文件 同理查看

        $> freeview -v sample-001.nii.gz
        

    FreeSurfer Tutorials

    • Preparation

    • FreeSurfer Tutorial Datasets

    • Introduction to FreeSurfer Output:熟悉freeview界面(快捷键)

      为了帮助验证准确度,请调整亮度和对比度,以便轻松识别灰色和白色物质之间的强度变化。要执行此操作,请在按住“Shift”键的同时左键单击图像并拖动鼠标(Make sure the brainmask volume is highlighted in the left menu in order for this to work.)

      .white和.pial分别可用于计算白质和灰质体积;aseg用于计算皮质下体积的测量

    • we mean wm voxels have an intensity value of somewhere between 100 and 110. And wm voxels are between a value of 85 and 100. In the TroubleshootingData tutorial, we'll go over what to do if there is an intensity normalization error.

    • WM卷:FreeSurfer对白质的初始分割(以灰色显示),并添加了自动拓扑定位器(白色)。

    • 3D view:绿色区域是回旋区域,红色区域是凹陷区域。

    • Notice that all subcortical gray matter is not a part of the surface labels (because again, those areas do not count towards the cortical surface measures).注意,所有皮质下灰质不是表面标签的一部分(因为这些区域不再计入皮质表面测量)。

    基本指令说明

    $ recon-all

    详解

    USAGE: recon-all
    
     Required Arguments:
       -subjid <subjid>
       -<process directive>
    
     Fully-Automated Directive:
      -all           : performs all stages of cortical reconstruction
      -autorecon-all : same as -all
    
     Manual-Intervention Workflow Directives:
      -autorecon1    : process stages 1-5 (see below)  # no-use-gpu: about 10 min
      -autorecon2    : process stages 6-23
                       after autorecon2, check white surfaces:
                         a. if wm edit was required, then run -autorecon2-wm
                         b. if control points added, then run -autorecon2-cp
                         c. proceed to run -autorecon3
      -autorecon2-cp : process stages 12-23 (uses -f w/ mri_normalize, -keep w/ mri_seg)
      -autorecon2-wm : process stages 15-23
      -autorecon2-inflate1 : 6-18
      -autorecon2-perhemi : tess, sm1, inf1, q, fix, sm2, inf2, finalsurf, ribbon
      -autorecon3    : process stages 24-34
                         if edits made to correct pial, then run -autorecon-pial
      -hemi ?h       : just do lh or rh (default is to do both)
    
      Autorecon Processing Stages (see -autorecon# flags above):
        1.  Motion Correction and Conform  # 运动校正和一致
        2.  NU (Non-Uniform intensity normalization)  # 非均匀强度归一化
        3.  Talairach transform computation  #  Talairach变换计算
        4.  Intensity Normalization 1  # 强度归一化
        5.  Skull Strip  # 颅骨去除   
    
        6.  EM Register (linear volumetric registration)  # EM寄存器(线性体积配准)
        7.  CA Intensity Normalization  # CA强度归一化
        8.  CA Non-linear Volumetric Registration  # CA非线性体积配准
        9.  Remove neck  # 去除颈部
        10. EM Register, with skull  # EM注册,带头骨
        11. CA Label (Aseg: Volumetric Labeling) and Statistics  # CA标签(Aseg:体积标签)和统计
    
        12. Intensity Normalization 2 (start here for control points) # 强度归一化2(从控制点开始)
        13. White matter segmentation  # 白质细分
        14. Edit WM With ASeg  # 使用ASeg编辑WM
        15. Fill (start here for wm edits)  # 填充(从这里开始编辑wm)
        16. Tessellation (begins per-hemisphere operations)  # 曲面细分(每半球操作开始)
        17. Smooth1
        18. Inflate1
        19. QSphere
        20. Automatic Topology Fixer  # 自动拓扑修复器
        21. White Surfs (start here for brain edits for pial surf)  # 白色Surfs(从这里开始用于脑部冲浪的大脑编辑)
        22. Smooth2
        23. Inflate2
    
        24. Spherical Mapping  # 球面映射
        25. Spherical Registration  # 球形配准
        26. Spherical Registration, Contralater hemisphere  # 球面配准,Contralater半球
        27. Map average curvature to subject  # 将平均曲率映射到主题
        28. Cortical Parcellation (Labeling)  # 皮质分割(标签)
        29. Cortical Parcellation Statistics  # 皮质分割统计
        30. Pial Surfs  # Pial Surfs
        31. WM/GM Contrast  # WM / GM对比
        32. Cortical Ribbon Mask  # 皮质功能掩膜
        33. Cortical Parcellation mapped to ASeg  # Cortical Parcellation映射到ASeg
        34  Brodmann and exvio EC labels  # Brodmann和exvio EC标签
    
     Step-wise Directives
      See -help
        ...
    

    $ mri_convert

    mri_convert.bin 
                    Help
    
    NAME
        mri_convert
    
    SYNOPSIS
        mri_convert [options] <in volume> <out volume>
    
    DESCRIPTION
        mri_convert is a general purpose utility for converting between 
        different file formats. The file type can be specified in two ways. 
        First, mri_convert will try to figure it out on its own from the 
        format of the file name (eg, files that end in .img are assumed to be 
        in spm analyze format). Second, the user can explicity set the type of
        file using --in_type and/or --out_type.
        
        Legal values for --in_tye (-it) and --out_type (-ot) are listed under 
        optional flagged arguments.
    

    $ preproc-cess

    FS-FAST Preprocessing

    USAGE: preproc-sess
    
      -per-run : motion cor and reg to middle TP of each run
      -per-session : motion cor and reg to 1st TP of 1st run
      -fwhm FWHM : smoothing level (mm)
    
      -update        : only run a stage if input is newer than output (default)
      -force         : force reprocessing of all stages (turns off -update)
      -no-update     : same as -force
      -sliceorder so : turn on slice timing correction (STC) with the given slice order
      -ngroups nSliceGroups : number of SMS slice groups for STC
      -surface subject hemi : set hemi to lhrh to do both
      -mni305-2mm    : sample raw data to mni305 at 2mm (same as -mni305)  # useful
      -mni305-1mm    : sample raw data to mni305 at 1mm
      -cvs : sample raw data to cvs_avg35_inMNI152 at 2mm (not with -mni305)
    
    Session Arguments (some combination required)
      -sf sessidfile  ...
      -df srchdirfile ...
      -s  sessid      ...
      -d  srchdir     ...
      -fsd    fsd <bold>
      -rlf    rlf  : run list file (default all runs)
    
      -init-fsl : use fsl to initialize bbr registration
      -init-spm : use spm to initialize bbr registration (needs matlab)
      -init-header : use geometry to initialize bbr registration
      -bbr-int ifsd istem : use intermediate volume in sess/ifsd/RRR/istem
    
    Other options (probably not too useful)
    
      -nomc     : don't do motion correction
      -nostc    : don't do slice-timing correction
      -nosmooth : don't do smoothing
      -nomask   : don't create brain mask
      -noreg    : don't do registration
      -noinorm  : don't do inorm
      -no-subcort-mask : do not apply subcortical masking
    
      -mcin   mcinstem    : stem to use as input  to MC
      -mcout  mcoutstem   : stem to use as output of MC
      -stcin  stcinstem   : stem to use as input  to STC 
      -stcout stcoutstem  : stem to use as output of STC 
      -smin   sminstem    : stem to use as input  to smoothing 
      -smout  sminstem    : stem to use as output of smoothing 
      -mask   maskstem    : <brain>
    
      -i    instem    : stem to use as overal input <f>
        
        -regfile regfile   : registration file for use with -surf-fwhm (register.dat)
      -projfrac frac : projection fraction for use with -surf-fwhm (0.5)
      -projfrac-avg  : average over ribbon (not with -projfrac)
      -no-cortex-label : do not use cortex label for masking surfaces
    

    Once the data have been arranged in the proper directory structure and naming convention, they are ready to be preprocessed. Preprocessing includes:

    1. Template Creation
    2. Brain Mask Creation
    3. Registration with FreeSurfer Anatomical
    4. Motion Correction
    5. Slice Timing Correction (if using)
    6. Spatial Normalization
    7. Masking
    8. Spatial Smoothing   # useful
    

    扩展阅读

    Fixing a bad skull strip

    FsFastTutorialV6.0

    mris_ca_train 从一组带注释的主题创建地图集、mris_ca_label 对于单个主题,生成一个注释文件,其中每个皮质表面顶点都分配有一个神经解剖标签、mris_sample_parc 采样

    应用场景

    颅骨去除

    • mri_watershed (运行时长短,约11s,Recommend)

      $ mri_watershed sample-001.nii.gz output.nii.gz
      # or
      $ mri_watershed sample-001.nii.gz output.nii    # 过程参数有细微差别,轮廓效果基本一致
      

      i. 输入输出维度保持一致.

      ii.freeview -v output.nii 仅显示黑白轮廓图,freeview -v output.nii.gz 会显示内部纹理细节

    Linux Freesurfer脑数据分割

    mri_watershed -T1 -t 20 input_file output_file
    

    命令行,经过试验,加入-T1会避免由于原图的灰度值范围不对导致的报错,也可以更干净地去除脑壳,阈值选20(加入-T1比不加去得更干净),但可能会误剔除,需测试后再进行批处理操作。

    • recon-all 方法(运行时间长,约10min) 可参考:比较FSL/FreeSurfer/ANTs的脑提取工具

      $ export SUBJECTS_DIR=~/Desktop/subjects
      $ recon-all -i input.nii.gz -s testFreeSurfer -autorecon1
      $ mri_convert --out_orientation RAS -rt nearest --reslice_like input.nii.gz \
       -it mgz ${SUBJECTS_DIR}/testFreeSurfer/mri/brainmask.mgz \
       -ot nii output_brain.nii.gz
      

      数据默认放在 SUBJECTS_DIR 这个变量指定的目录下,FreeSurfer 的输出格式是 mgz,可以使用
      mri_convert 转换成 nifti 格式。同时 mri_convert 也可以改变朝向,如果朝向发生了变化的话。

      输入输出维度保持一致.

    对比:两种方法效果基本一致,recon-all提取的输出细节更细腻一点

    预处理分割

    after-autorecon1, -autorecon2 includes 白质分割、皮下组织分割

    Multimodal Integration

    • Multimodal Registration perform multi-modal integration in FreeSurfer using fMRI and dMRI analysis. 可进行手动配准;亦可使用配准文件(例register.lta)进行自动配准

    FAQ

    • Runtime is so long. Can we use GPU accelerate? -use-gpu

      $ recon-all -i sample-001.nii.gz -s SkullStrip_FreeSurfer -autorecon1 -use-gpu
      
      Testing for CUDA device:
      /usr/local/freesurfer/bin/mri_em_register_cuda: error while loading shared libraries: libcudart.so.5.0: cannot open shared object file: No such file or directory
      Linux captain-System-Product-Name 4.15.0-29-generic #31-Ubuntu SMP Tue Jul 17 15:39:52 UTC 2018 x86_64 x86_64 x86_64 GNU/Linux
      
      recon-all -s SkullStrip_FreeSurfer exited with ERRORS at 2019年 07月 18日 星期四 18:23:50 CST
      
      For more details, see the log file 
      To report a problem, see http://surfer.nmr.mgh.harvard.edu/fswiki/BugReporting
      

    相关文章

      网友评论

          本文标题:FreeSurfer-Introduction

          本文链接:https://www.haomeiwen.com/subject/qvjtbctx.html