1. 将数据转换为Nifti格式
a. 用MRICro的MRIConvert进行数据格式的转换
b. 用FreeSurfer’的 mri_convert函数,
鉴于大多数的scanner格式默认为DICOM,这里我们介绍怎样将DICOM格式转换为Nifiti格式。
首先需要确认文件夹的结构,假设dicom文件存放在一个名为raw_data的文件夹内,其结构类型如下:
raw_dicom |-- sub001 | |-- t1w_3d_MPRAGE | | |-- 00001.dcm | | |-- ... | | |-- 00176.dcm | |-- fmri_run1_long | | |-- 00001.dcm | | |-- ... | | |-- 00240.dcm | |-- fmri_run2_long | |-- ... |-- sub0.. |-- sub010
批量进行格式转换的代码如下:
TUTORIAL_DIR=~/nipype_tutorial # location of experiment folder RAW_DIR=$TUTORIAL_DIR/raw_dicom # location of raw data folder T1_FOLDER=t1w_3d_MPRAGE # dicom folder containing anatomical scan FUNC_FOLDER1=fmri_run1_long # dicom folder containing 1st functional scan FUNC_FOLDER2=fmri_run2_long # dicom folder containing 2nd functional scan DATA_DIR=$TUTORIAL_DIR/data # location of output folder for id in $(seq -w 1 10) do mkdir -p $DATA_DIR/sub0$id mri_convert $RAW_DIR/sub0$id/$T1_FOLDER/00001.dcm $DATA_DIR/sub0$id/struct.nii.gz mri_convert $RAW_DIR/sub0$id/$FUNC_FOLDER1/00001.dcm $DATA_DIR/sub0$id/run001.nii.gz mri_convert $RAW_DIR/sub0$id/$FUNC_FOLDER2/00001.dcm $DATA_DIR/sub0$id/run002.nii.gz done
原文地址:miykael.github.io/nipype-beginner-s-guide/prepareData.html#make-the-dataset-ready-for-nipype