ENIGMA-DTI Skeletonization
1、将每个文件夹下的dti_FA.nii.gz重命名为subject*_FA.nii.gz,代码如下:
for subj in {1..89} do mv ./subject${subj}/dti_FA.nii.gz ./subject${subj}/subject${subj}_FA.nii.gz done
2、在与subject*同一目录下新建一个文件夹/TBSS/run_tbss,并将个subject中的FA数据复制到run_tbss中,代码如下:
for subj in {1..89} do cp ./subject*/subject*_FA.nii.gz ./TBSS/run_tbss/ done
3、erode images
进入到run_tbss目录下,在终端输入tbss_1_preproc *.nii.gz(目的是erode images),这一步将会在run_tbss目录下新建两个文件夹:
- FA:存放经过处理的数据
- origdata:存放原始数据
4、配准到模板
(1)在TBSS目录下新建一个文件夹,命名为ENIGMA_targets,下载下面链接中的文件,并存放在ENIGMA_targets中:http://enigma.ini.usc.edu/wp-content/uploads/2013/02/enigmaDTI.zip。该压缩文件共包含5个nii.gz文件:
- ENIGMA_DTI_FA.nii.gz
- ENIGMA_DTI_FA_mask.nii.gz
- ENIGMA_DTI_FA_skeleton.nii.gz
- ENIGMA_DTI_FA_skeleton_mask.nii.gz
- ENIGMA_DTI_FA_skeleton_mask_dst.nii.gz
(2)将ENIGMA_DTI_FA.nii.gz文件复制到run_tbss目录下,并进入到该目录,在终端输入以下两条命令:
tbss_2_reg –t ENIGMA_DTI_FA.nii.gz tbss_3_postreg -S
第一条命令主要是将FA文件夹下的数据与ENIGMA模板进行配准,每个数据需要5到10分钟时间。
第二条命令:The tbss_3_postreg script applies these registrations to take all subjects into 1x1x1mm standard space. Next, all subjects‘ standard space nonlinearly aligned images are merged into a single 4D image file called all_FA, created in a new subdirectory called stats. The mean of all FA images is created, called mean_FA, and this is then fed into the FA skeletonisation program to create mean_FA_skeleton. 将会在run_tbss目录下新建一个stats文件夹,文件夹内包含4个文件:
- all_FA.nii.gz
- mean_FA.nii.gz
- mean_FA_mask
- mean_FA_skeleton.nii.gz
5、为每个subject生成masked_FAskel.nii.gz
(1)在run_tbss下新建一个文件夹命名为FA_individ,并在FA_individ下建立文件夹subject1...subjectN,每个subject再新建一个FA文件夹和stats文件夹,将FA文件夹下的nii.gz文件复制到新建立的每个subject下的FA文件夹中,可用如下代码实现:
for subj in {1..89} do mkdir -p ./FA_individ/subject${subj}/stats/ mkdir -p ./FA_individ/subject${subj}/FA/ cp ./FA/subject${subj}_*.nii.gz ./FA_individ/subject${subj}/FA/ ####[optional/recommended]#### ${FSLDIR}/bin/fslmaths ./FA_individ/subject${subj}/FA/subject${subj}_*FA_to_target.nii.gz -mas ENIGMA_DTI_FA.nii.gz ./FA_individ/subject${subj}/FA/subject${subj}_masked_FA.nii.gz done
(2)Skeletonize images
for subj in {1..89} do ${FSLDIR}/bin/tbss_skeleton -i ./FA_individ/subject${subj}/FA/subject${subj}_masked_FA.nii.gz -p 0.049 ENIGMA_DTI_FA_skeleton_mask_dst.nii.gz LowerCingulum_1mm.nii.gz ./FA_individ/subject${subj}/FA /subject${subj}_masked_FA.nii.gz ./FA_individ/subject${subj}/stats/subject${subj}_masked_FAskel.nii.gz -s ENIGMA_DTI_FA_skeleton_mask.nii.gz done
其中,FSLDIR是在安装fsl时设置的变量。运行完上述脚本后将在每个subject的stats文件夹下生成一个subject*_masked_FAskel.nii.gz文件(此时,该文件夹下只有这一个文件)。
PS:由于数据量大,经常需要修改文件名,下面的命令用于将同一文件夹下的文件的文件名中的subject89字符串替换为subject87字符串。该命令为Ubuntu下的命令形式,有别于其他linux系统。
rename ‘s/subject89/subject87/‘ subject89*