1. 目的
2. JHU White-matter labels & tractography atlasでROI解析する方法
2.1. ディレクトリ構造
2.2. 実行方法
2.3. ソースコード
3. Desikan Killiany AtlasでROI解析する方法
3.1. 前提条件
3.2. ディレクトリ構造
3.3. 実行方法
3.4. ソースコード
4. FreeSurferのwm.seg.nii.gzをDWI空間に位置合わせする方法
4.1. 必要なファイル
4.2. ソースコード
5. 標準空間にあるROIを各被験者脳に位置合わせ
6. bertのwmparcをMNI空間に移動後、個人脳(Perfusion image)にレジストレーション
1. 目的
- JHU White-matter labels & tractography atlasでROI解析する方法
- Desikan Killiany AtlasでROI解析
- FreeSurferのwm.seg.nii.gzをDWI空間に位置合わせする方法
2. JHU White-matter labels & tractography atlasでROI解析する方法
標準空間(template (standard) space)にあるJHU-ICBM-labels-1mm.nii.gz、JHU-ICBM-tracts-maxprob-thr25-1mm.nii.gz をDWI空間に位置合わせしてROI解析するスクリプト。
2.1. ディレクトリ構造
最低限 FA.nii.gz は用意。
SUBJ1/ + map/ + FA.nii.gz + MD.nii.gz + AD.nii.gz : SUBJ2/ + map/ + FA.nii.gz + MD.nii.gz + AD.nii.gz :
2.2. 実行方法
cd SUBJ1 bash ../reg_FMRIB_to_FA.sh
2.3. ソースコード
function reg_FMRIB-Atlas_to_FA () { flirt -in map/FA -ref ${FSLDIR}/data/standard/FMRIB58_FA_1mm -omat FA_to_FMRIB.mat fnirt --in=map/FA --aff=FA_to_FMRIB.mat --config=FA_2_FMRIB58_1mm --cout=warp_FA_to_FMRIB invwarp -w warp_FA_to_FMRIB -o warp_FMRIB_to_FA -r map/FA applywarp --in=${FSLDIR}/data/atlases/JHU/JHU-ICBM-labels-1mm --ref=map/FA --warp=warp_FMRIB_to_FA --interp=nn --out=JHU-ICBM-labels_to_FA applywarp --in=${FSLDIR}/data/atlases/JHU/JHU-ICBM-tracts-maxprob-thr25-1mm --ref=map/FA --warp=warp_FMRIB_to_FA --interp=nn --out=JHU-ICBM-tracts-maxprob-thr25_to_FA } function split_JHU-ICBM-labels () { OUT_DIR=mask/JHU-ICBM-labels mkdir -p ${OUT_DIR} fslmaths JHU-ICBM-labels_to_FA -thr 1 -uthr 1 ${OUT_DIR}/01_Middle-cerebellar-peduncle fslmaths JHU-ICBM-labels_to_FA -thr 2 -uthr 2 ${OUT_DIR}/02_Pontine-crossing-tract fslmaths JHU-ICBM-labels_to_FA -thr 3 -uthr 3 ${OUT_DIR}/03_Genu-of-corpus-callosum fslmaths JHU-ICBM-labels_to_FA -thr 4 -uthr 4 ${OUT_DIR}/04_Body-of-corpus-callosum fslmaths JHU-ICBM-labels_to_FA -thr 5 -uthr 5 ${OUT_DIR}/05_Splenium-of-corpus-callosum fslmaths JHU-ICBM-labels_to_FA -thr 6 -uthr 6 ${OUT_DIR}/06_Fornix fslmaths JHU-ICBM-labels_to_FA -thr 7 -uthr 7 ${OUT_DIR}/07_Corticospinal-tract_R fslmaths JHU-ICBM-labels_to_FA -thr 8 -uthr 8 ${OUT_DIR}/08_Corticospinal-tract_L fslmaths JHU-ICBM-labels_to_FA -thr 9 -uthr 9 ${OUT_DIR}/09_Medial-lemniscus_R fslmaths JHU-ICBM-labels_to_FA -thr 10 -uthr 10 ${OUT_DIR}/10_Medial-lemniscus_L fslmaths JHU-ICBM-labels_to_FA -thr 11 -uthr 11 ${OUT_DIR}/11_Inferior-cerebellar-peduncle_R fslmaths JHU-ICBM-labels_to_FA -thr 12 -uthr 12 ${OUT_DIR}/12_Inferior-cerebellar-peduncle_L fslmaths JHU-ICBM-labels_to_FA -thr 13 -uthr 13 ${OUT_DIR}/13_Superior-cerebellar-peduncle_R fslmaths JHU-ICBM-labels_to_FA -thr 14 -uthr 14 ${OUT_DIR}/14_Superior-cerebellar-peduncle_L fslmaths JHU-ICBM-labels_to_FA -thr 15 -uthr 15 ${OUT_DIR}/15_Cerebral-peduncle_R fslmaths JHU-ICBM-labels_to_FA -thr 16 -uthr 16 ${OUT_DIR}/16_Cerebral-peduncle_L fslmaths JHU-ICBM-labels_to_FA -thr 17 -uthr 17 ${OUT_DIR}/17_Anterior-limb-of-internal-capsule_R fslmaths JHU-ICBM-labels_to_FA -thr 18 -uthr 18 ${OUT_DIR}/18_Anterior-limb-of-internal-capsule_L fslmaths JHU-ICBM-labels_to_FA -thr 19 -uthr 19 ${OUT_DIR}/19_Posterior-limb-of-internal-capsule_R fslmaths JHU-ICBM-labels_to_FA -thr 20 -uthr 20 ${OUT_DIR}/20_Posterior-limb-of-internal-capsule_L fslmaths JHU-ICBM-labels_to_FA -thr 21 -uthr 21 ${OUT_DIR}/21_Retrolenticular-part-of-internal-capsule_R fslmaths JHU-ICBM-labels_to_FA -thr 22 -uthr 22 ${OUT_DIR}/22_Retrolenticular-part-of-internal-capsule_L fslmaths JHU-ICBM-labels_to_FA -thr 23 -uthr 23 ${OUT_DIR}/23_Anterior-corona-radiata_R fslmaths JHU-ICBM-labels_to_FA -thr 24 -uthr 24 ${OUT_DIR}/24_Anterior-corona-radiata_L fslmaths JHU-ICBM-labels_to_FA -thr 25 -uthr 25 ${OUT_DIR}/25_Superior-corona-radiata_R fslmaths JHU-ICBM-labels_to_FA -thr 26 -uthr 26 ${OUT_DIR}/26_Superior-corona-radiata_L fslmaths JHU-ICBM-labels_to_FA -thr 27 -uthr 27 ${OUT_DIR}/27_Posterior-corona-radiata_R fslmaths JHU-ICBM-labels_to_FA -thr 28 -uthr 28 ${OUT_DIR}/28_Posterior-corona-radiata_L fslmaths JHU-ICBM-labels_to_FA -thr 29 -uthr 29 ${OUT_DIR}/29_Posterior-thalamic-radiation_R fslmaths JHU-ICBM-labels_to_FA -thr 30 -uthr 30 ${OUT_DIR}/30_Posterior-thalamic-radiation_L fslmaths JHU-ICBM-labels_to_FA -thr 31 -uthr 31 ${OUT_DIR}/31_Sagittal-stratum_R fslmaths JHU-ICBM-labels_to_FA -thr 32 -uthr 32 ${OUT_DIR}/32_Sagittal-stratum_L fslmaths JHU-ICBM-labels_to_FA -thr 33 -uthr 33 ${OUT_DIR}/33_External-capsule_R fslmaths JHU-ICBM-labels_to_FA -thr 34 -uthr 34 ${OUT_DIR}/34_External-capsule_L fslmaths JHU-ICBM-labels_to_FA -thr 35 -uthr 35 ${OUT_DIR}/35_Cingulum-cingulate-gyrus_R fslmaths JHU-ICBM-labels_to_FA -thr 36 -uthr 36 ${OUT_DIR}/36_Cingulum-cingulate-gyrus_L fslmaths JHU-ICBM-labels_to_FA -thr 37 -uthr 37 ${OUT_DIR}/37_Cingulum-hippocampus_R fslmaths JHU-ICBM-labels_to_FA -thr 38 -uthr 38 ${OUT_DIR}/38_Cingulum-hippocampus_L fslmaths JHU-ICBM-labels_to_FA -thr 39 -uthr 39 ${OUT_DIR}/39_Fornix-Stria-terminalis_R fslmaths JHU-ICBM-labels_to_FA -thr 40 -uthr 40 ${OUT_DIR}/40_Fornix-Stria-terminalis_L fslmaths JHU-ICBM-labels_to_FA -thr 41 -uthr 41 ${OUT_DIR}/41_Superior-longitudinal-fasciculus_R fslmaths JHU-ICBM-labels_to_FA -thr 42 -uthr 42 ${OUT_DIR}/42_Superior-longitudinal-fasciculus_L fslmaths JHU-ICBM-labels_to_FA -thr 43 -uthr 43 ${OUT_DIR}/43_Superior-fronto-occipital-fasciculus_R fslmaths JHU-ICBM-labels_to_FA -thr 44 -uthr 44 ${OUT_DIR}/44_Superior-fronto-occipital-fasciculus_L fslmaths JHU-ICBM-labels_to_FA -thr 45 -uthr 45 ${OUT_DIR}/45_Uncinate-fasciculus_R fslmaths JHU-ICBM-labels_to_FA -thr 46 -uthr 46 ${OUT_DIR}/46_Uncinate-fasciculus_L fslmaths JHU-ICBM-labels_to_FA -thr 47 -uthr 47 ${OUT_DIR}/47_Tapetum_R fslmaths JHU-ICBM-labels_to_FA -thr 48 -uthr 48 ${OUT_DIR}/48_Tapetum_L fsladd ${OUT_DIR}/51_Corticospinal-tract ${OUT_DIR}/07_Corticospinal-tract_R ${OUT_DIR}/08_Corticospinal-tract_L > /dev/null fsladd ${OUT_DIR}/52_Medial-lemniscus ${OUT_DIR}/09_Medial-lemniscus_R ${OUT_DIR}/10_Medial-lemniscus_L > /dev/null fsladd ${OUT_DIR}/53_Inferior-cerebellar-peduncle ${OUT_DIR}/11_Inferior-cerebellar-peduncle_R ${OUT_DIR}/12_Inferior-cerebellar-peduncle_L > /dev/null fsladd ${OUT_DIR}/54_Superior-cerebellar-peduncle ${OUT_DIR}/13_Superior-cerebellar-peduncle_R ${OUT_DIR}/14_Superior-cerebellar-peduncle_L > /dev/null fsladd ${OUT_DIR}/55_Cerebral-peduncle ${OUT_DIR}/15_Cerebral-peduncle_R ${OUT_DIR}/16_Cerebral-peduncle_L > /dev/null fsladd ${OUT_DIR}/56_Anterior-limb-of-internal-capsule ${OUT_DIR}/17_Anterior-limb-of-internal-capsule_R ${OUT_DIR}/18_Anterior-limb-of-internal-capsule_L > /dev/null fsladd ${OUT_DIR}/57_Posterior-limb-of-internal-capsule ${OUT_DIR}/19_Posterior-limb-of-internal-capsule_R ${OUT_DIR}/20_Posterior-limb-of-internal-capsule_L > /dev/null fsladd ${OUT_DIR}/58_Retrolenticular-part-of-internal-capsule ${OUT_DIR}/21_Retrolenticular-part-of-internal-capsule_R ${OUT_DIR}/22_Retrolenticular-part-of-internal-capsule_L > /dev/null fsladd ${OUT_DIR}/59_Anterior-corona-radiata ${OUT_DIR}/23_Anterior-corona-radiata_R ${OUT_DIR}/24_Anterior-corona-radiata_L > /dev/null fsladd ${OUT_DIR}/60_Superior-corona-radiata ${OUT_DIR}/25_Superior-corona-radiata_R ${OUT_DIR}/26_Superior-corona-radiata_L > /dev/null fsladd ${OUT_DIR}/61_Posterior-corona-radiata ${OUT_DIR}/27_Posterior-corona-radiata_R ${OUT_DIR}/28_Posterior-corona-radiata_L > /dev/null fsladd ${OUT_DIR}/62_Posterior-thalamic-radiation ${OUT_DIR}/29_Posterior-thalamic-radiation_R ${OUT_DIR}/30_Posterior-thalamic-radiation_L > /dev/null fsladd ${OUT_DIR}/63_Sagittal-stratum ${OUT_DIR}/31_Sagittal-stratum_R ${OUT_DIR}/32_Sagittal-stratum_L > /dev/null fsladd ${OUT_DIR}/64_External-capsule ${OUT_DIR}/33_External-capsule_R ${OUT_DIR}/34_External-capsule_L > /dev/null fsladd ${OUT_DIR}/65_Cingulum-cingulate-gyrus ${OUT_DIR}/35_Cingulum-cingulate-gyrus_R ${OUT_DIR}/36_Cingulum-cingulate-gyrus_L > /dev/null fsladd ${OUT_DIR}/66_Cingulum-hippocampus ${OUT_DIR}/37_Cingulum-hippocampus_R ${OUT_DIR}/38_Cingulum-hippocampus_L > /dev/null fsladd ${OUT_DIR}/67_Fornix-Stria-terminalis ${OUT_DIR}/39_Fornix-Stria-terminalis_R ${OUT_DIR}/40_Fornix-Stria-terminalis_L > /dev/null fsladd ${OUT_DIR}/68_Superior-longitudinal-fasciculus ${OUT_DIR}/41_Superior-longitudinal-fasciculus_R ${OUT_DIR}/42_Superior-longitudinal-fasciculus_L > /dev/null fsladd ${OUT_DIR}/69_Superior-fronto-occipital-fasciculus ${OUT_DIR}/43_Superior-fronto-occipital-fasciculus_R ${OUT_DIR}/44_Superior-fronto-occipital-fasciculus_L > /dev/null fsladd ${OUT_DIR}/70_Uncinate-fasciculus ${OUT_DIR}/45_Uncinate-fasciculus_R ${OUT_DIR}/46_Uncinate-fasciculus_L > /dev/null fsladd ${OUT_DIR}/71_Tapetum ${OUT_DIR}/47_Tapetum_R ${OUT_DIR}/48_Tapetum_L > /dev/null fsladd ${OUT_DIR}/81_Corpus-callosum ${OUT_DIR}/03_Genu-of-corpus-callosum ${OUT_DIR}/04_Body-of-corpus-callosum ${OUT_DIR}/05_Splenium-of-corpus-callosum > /dev/null fsladd ${OUT_DIR}/82_Internal-capsule ${OUT_DIR}/56_Anterior-limb-of-internal-capsule ${OUT_DIR}/57_Posterior-limb-of-internal-capsule ${OUT_DIR}/58_Retrolenticular-part-of-internal-capsule > /dev/null fsladd ${OUT_DIR}/83_Corona-radiata ${OUT_DIR}/59_Anterior-corona-radiata ${OUT_DIR}/60_Superior-corona-radiata ${OUT_DIR}/61_Posterior-corona-radiata > /dev/null } function split_JHU-ICBM-tracts-maxprob-thr25 () { OUT_DIR=mask/JHU-ICBM-tracts-maxprob-thr25 mkdir -p ${OUT_DIR} fslmaths JHU-ICBM-tracts-maxprob-thr25_to_FA -thr 1 -uthr 1 ${OUT_DIR}/01_Anterior-thalamic_Radiation_L fslmaths JHU-ICBM-tracts-maxprob-thr25_to_FA -thr 2 -uthr 2 ${OUT_DIR}/02_Anterior-thalamic_Radiation_R fslmaths JHU-ICBM-tracts-maxprob-thr25_to_FA -thr 3 -uthr 3 ${OUT_DIR}/03_Corticospinal-tract_L fslmaths JHU-ICBM-tracts-maxprob-thr25_to_FA -thr 4 -uthr 4 ${OUT_DIR}/04_Corticospinal-tract_R fslmaths JHU-ICBM-tracts-maxprob-thr25_to_FA -thr 5 -uthr 5 ${OUT_DIR}/05_Cingulum-cingulate-gyrus_L fslmaths JHU-ICBM-tracts-maxprob-thr25_to_FA -thr 6 -uthr 6 ${OUT_DIR}/06_Cingulum-cingulate-gyrus_R fslmaths JHU-ICBM-tracts-maxprob-thr25_to_FA -thr 7 -uthr 7 ${OUT_DIR}/07_Cingulum-hippocampus_L fslmaths JHU-ICBM-tracts-maxprob-thr25_to_FA -thr 8 -uthr 8 ${OUT_DIR}/08_Cingulum-hippocampus_R fslmaths JHU-ICBM-tracts-maxprob-thr25_to_FA -thr 9 -uthr 9 ${OUT_DIR}/09_Forceps-major fslmaths JHU-ICBM-tracts-maxprob-thr25_to_FA -thr 10 -uthr 10 ${OUT_DIR}/10_Forceps-minor fslmaths JHU-ICBM-tracts-maxprob-thr25_to_FA -thr 11 -uthr 11 ${OUT_DIR}/11_Inferior-fronto-occipital-fasciculus_L fslmaths JHU-ICBM-tracts-maxprob-thr25_to_FA -thr 12 -uthr 12 ${OUT_DIR}/12_Inferior-fronto-occipital-fasciculus_R fslmaths JHU-ICBM-tracts-maxprob-thr25_to_FA -thr 13 -uthr 13 ${OUT_DIR}/13_Inferior_Longitudinal-fasciculus_L fslmaths JHU-ICBM-tracts-maxprob-thr25_to_FA -thr 14 -uthr 14 ${OUT_DIR}/14_Inferior_Longitudinal-fasciculus_R fslmaths JHU-ICBM-tracts-maxprob-thr25_to_FA -thr 15 -uthr 15 ${OUT_DIR}/15_Superior_Longitudinal-fasciculus_L fslmaths JHU-ICBM-tracts-maxprob-thr25_to_FA -thr 16 -uthr 16 ${OUT_DIR}/16_Superior_Longitudinal-fasciculus_R fslmaths JHU-ICBM-tracts-maxprob-thr25_to_FA -thr 17 -uthr 17 ${OUT_DIR}/17_Uncinate-fasciculus_L fslmaths JHU-ICBM-tracts-maxprob-thr25_to_FA -thr 18 -uthr 18 ${OUT_DIR}/18_Uncinate-fasciculus_R fslmaths JHU-ICBM-tracts-maxprob-thr25_to_FA -thr 19 -uthr 19 ${OUT_DIR}/19_Superior_Longitudinal-fasciculus-temporal-part_L fslmaths JHU-ICBM-tracts-maxprob-thr25_to_FA -thr 20 -uthr 20 ${OUT_DIR}/20_Superior_Longitudinal-fasciculus-temporal-part_R fsladd ${OUT_DIR}/21_Anterior-thalamic_Radiation ${OUT_DIR}/01_Anterior-thalamic_Radiation_L ${OUT_DIR}/02_Anterior-thalamic_Radiation_R > /dev/null fsladd ${OUT_DIR}/22_Corticospinal-tract ${OUT_DIR}/03_Corticospinal-tract_L ${OUT_DIR}/04_Corticospinal-tract_R > /dev/null fsladd ${OUT_DIR}/23_Cingulum-cingulate-gyrus ${OUT_DIR}/05_Cingulum-cingulate-gyrus_L ${OUT_DIR}/06_Cingulum-cingulate-gyrus_R > /dev/null fsladd ${OUT_DIR}/24_Cingulum-hippocampus ${OUT_DIR}/07_Cingulum-hippocampus_L ${OUT_DIR}/08_Cingulum-hippocampus_R > /dev/null fsladd ${OUT_DIR}/25_Forceps ${OUT_DIR}/09_Forceps-major ${OUT_DIR}/10_Forceps-minor > /dev/null fsladd ${OUT_DIR}/26_Inferior-fronto-occipital-fasciculus ${OUT_DIR}/11_Inferior-fronto-occipital-fasciculus_L ${OUT_DIR}/12_Inferior-fronto-occipital-fasciculus_R > /dev/null fsladd ${OUT_DIR}/27_Inferior_Longitudinal-fasciculus ${OUT_DIR}/13_Inferior_Longitudinal-fasciculus_L ${OUT_DIR}/14_Inferior_Longitudinal-fasciculus_R > /dev/null fsladd ${OUT_DIR}/28_Superior_Longitudinal-fasciculus ${OUT_DIR}/15_Superior_Longitudinal-fasciculus_L ${OUT_DIR}/16_Superior_Longitudinal-fasciculus_R > /dev/null fsladd ${OUT_DIR}/29_Uncinate-fasciculus ${OUT_DIR}/17_Uncinate-fasciculus_L ${OUT_DIR}/18_Uncinate-fasciculus_R > /dev/null fsladd ${OUT_DIR}/30_Superior_Longitudinal-fasciculus-temporal-part ${OUT_DIR}/19_Superior_Longitudinal-fasciculus-temporal-part_L ${OUT_DIR}/20_Superior_Longitudinal-fasciculus-temporal-part_R > /dev/null } function output_results () { [[ -d results ]] && \rm -rf results mkdir -p results for MAP in $(\ls -1 map/*.nii.gz | xargs -i basename -s ".nii.gz" {}); do for MASK in $(\ls -1 mask/JHU-ICBM-labels/*.nii.gz); do fslstats map/${MAP} -k ${MASK} -M >> results/JHU-ICBM-labels_${MAP}_mean.txt & fslstats map/${MAP} -k ${MASK} -S >> results/JHU-ICBM-labels_${MAP}_sd.txt & wait done done for MAP in $(\ls -1 map/*.nii.gz | xargs -i basename -s ".nii.gz" {}); do for MASK in $(\ls -1 mask/JHU-ICBM-tracts-maxprob-thr25/*.nii.gz); do fslstats map/${MAP} -k ${MASK} -M >> results/JHU-ICBM-tracts-maxprob-thr25_${MAP}_mean.txt & fslstats map/${MAP} -k ${MASK} -S >> results/JHU-ICBM-tracts-maxprob-thr25_${MAP}_sd.txt & wait done done } reg_FMRIB-Atlas_to_FA split_JHU-ICBM-labels split_JHU-ICBM-tracts-maxprob-thr25 output_results
結果のまとめ方
ls |grep -v temp_ID|tr "\n" "\t" | sed -e 's/^/\t/' | sed -e 's/$/\n/'> temp_ID ls $(ls |head -n 1)/mask/JHU-ICBM-labels > temp_labels_name ls $(ls |head -n 1)/mask/JHU-ICBM-tracts-maxprob-thr25 > temp_tracts_name paste temp_labels_name */results/JHU-ICBM-labels_FA_mean.txt > temp_labels_value paste temp_tracts_name */results/JHU-ICBM-tracts-maxprob-thr25_FA_mean.txt > temp_tracts_value cat temp_ID temp_labels_value > labels_result.csv cat temp_ID temp_tracts_value > tracts_result.csv rm temp*
根本先生の解説
斎藤先生の紹介してくれたところを見てくださったらと思うのですが、ポイントは、FSLでは、
invwarp
というコマンドがあるんですね。
この inv は、inverse で、普段の warp は 患者空間 → MNI空間であるものを、invwarp
は、MNI空間 → 患者空間に戻します。
じゃ、最初の 患者空間 → MNI空間のパラメータをどうとるのかというところになるわけですが、斎藤先生のスクリプトの2行が肝になります。
flirt -in map/FA -ref ${FSLDIR}/data/standard/FMRIB58_FA_1mm -omat FA_to_FMRIB.mat
これは、患者のFA画像 (map/FA) を入力として、MNI空間に線形変換をし、パラメータを FA_to_FMRIB.mat で出力します。
fnirt --in=map/FA --aff=FA_to_FMRIB.mat --config=FA_2_FMRIB58_1mm --cout=warp_FA_to_FMRIB
こちらは、入力は同じですが、先程得られた線形変換のパラメータも利用し、
FSLでもともと準備されているFA画像をMNI空間に非線形変換するのに適した設定 (FA_2_FMRIB58_1mm) を利用して
非線形変換を行い、その変換に必要なパラメータを warp_FA_to_FMRIB
として出力します。
なので、出力されるものは画像ではなく、変形パラメータになります。
そして、
invwarp -w warp_FA_to_FMRIB -o warp_FMRIB_to_FA -r map/FA
で、非線形変換で得られた warp_FA_to_FMRIB の逆変換を計算して、warp_FMRIB_to_FA として保存します。
そして、最後に、
applywarp --in=${FSLDIR}/data/atlases/JHU/JHU-ICBM-labels-1mm --ref=map/FA --warp=warp_FMRIB_to_FA --interp=nn --out=JHU-ICBM-labels_to_FA applywarp --in=${FSLDIR}/data/atlases/JHU/JHU-ICBM-tracts-maxprob-thr25-1mm --ref=map/FA --warp=warp_FMRIB_to_FA --interp=nn --out=JHU-ICBM-tracts-maxprob-thr25_to_FA
で、2つのアトラス (JHU-ICBM-labels-1mm と JHU-ICBM-tracts-maxprob-thr25-1mm) に対して、その逆変換したパラメータをあてて、患者空間の(患者用の)アトラスを作成しています。
その後、各アトラスの個々の領域の値を求めています。
3. Desikan Killiany AtlasでROI解析する方法
T1WI空間にあるDesikan Killiany AtlasをDWI空間に位置合わせをしてROI解析するスクリプト。
3.1. 前提条件
「/opt/mrtrix3/share/mrtrix3/labelconvert/fs_default.txt」がある前提で走ります。
3.2. ディレクトリ構造
ディレクトリ構造は次の通り。
SUBJ_N ├── 3DT1.nii.gz ├── aparc+aseg.mgz ... FreeSurfer output ├── b0.nii.gz ... b0 (ex: `fslroi eddy_result b0 0 1`) ├── wm.seg.mgz ... FreeSurfer output └── map ├── FA.nii.gz ├── MD.nii.gz └── uFA.nii.gz $ ls -1 this_script.sh SUBJ_1 SUBJ_2 SUBJ_3
3.3. 実行方法
$ cd SUBJ_1 $ bash ../this_script.sh
3.4. ソースコード
#!/bin/bash # SUBJ_N # ├── 3DT1.nii.gz # ├── aparc+aseg.mgz ... FreeSurfer output # ├── b0.nii.gz ... b0 (ex: `fslroi eddy_result b0 0 1`) # ├── wm.seg.mgz ... FreeSurfer output # └── map # ├── FA.nii.gz # ├── MD.nii.gz # └── uFA.nii.gz # # $ ls -1 # this_script.sh # SUBJ_1 # SUBJ_2 # SUBJ_3 # : # $ cd SUBJ_1 # $ bash ../this_script.sh function create_nodes () { mkdir -p mask/DK fslreorient2std 3DT1 T1 bet T1 T1_brain -B -f 0.1 mri_label2vol --temp T1.nii.gz --seg aparc+aseg.mgz --regheader aparc+aseg.mgz --o aparc+aseg.nii.gz labelconvert aparc+aseg.nii.gz ${FREESURFER_HOME}/FreeSurferColorLUT.txt /opt/mrtrix3/share/mrtrix3/labelconvert/fs_default.txt nodes.nii.gz labelsgmfix nodes.nii.gz T1_brain.nii.gz /opt/mrtrix3/share/mrtrix3/labelconvert/fs_default.txt mask/nodes_sgmfixed.nii.gz -premasked } function split_nodes () { fslmaths mask/nodes_sgmfixed -thr 1 -uthr 1 mask/DK/01-lh-bankssts fslmaths mask/nodes_sgmfixed -thr 2 -uthr 2 mask/DK/02-lh-caudalanteriorcingulate fslmaths mask/nodes_sgmfixed -thr 3 -uthr 3 mask/DK/03-lh-caudalmiddlefrontal fslmaths mask/nodes_sgmfixed -thr 4 -uthr 4 mask/DK/04-lh-cuneus fslmaths mask/nodes_sgmfixed -thr 5 -uthr 5 mask/DK/05-lh-entorhinal fslmaths mask/nodes_sgmfixed -thr 6 -uthr 6 mask/DK/06-lh-fusiform fslmaths mask/nodes_sgmfixed -thr 7 -uthr 7 mask/DK/07-lh-inferiorparietal fslmaths mask/nodes_sgmfixed -thr 8 -uthr 8 mask/DK/08-lh-inferiortemporal fslmaths mask/nodes_sgmfixed -thr 9 -uthr 9 mask/DK/09-lh-isthmuscingulate fslmaths mask/nodes_sgmfixed -thr 10 -uthr 10 mask/DK/10-lh-lateraloccipital fslmaths mask/nodes_sgmfixed -thr 11 -uthr 11 mask/DK/11-lh-lateralorbitofrontal fslmaths mask/nodes_sgmfixed -thr 12 -uthr 12 mask/DK/12-lh-lingual fslmaths mask/nodes_sgmfixed -thr 13 -uthr 13 mask/DK/13-lh-medialorbitofrontal fslmaths mask/nodes_sgmfixed -thr 14 -uthr 14 mask/DK/14-lh-middletemporal fslmaths mask/nodes_sgmfixed -thr 15 -uthr 15 mask/DK/15-lh-parahippocampal fslmaths mask/nodes_sgmfixed -thr 16 -uthr 16 mask/DK/16-lh-paracentral fslmaths mask/nodes_sgmfixed -thr 17 -uthr 17 mask/DK/17-lh-parsopercularis fslmaths mask/nodes_sgmfixed -thr 18 -uthr 18 mask/DK/18-lh-parsorbitalis fslmaths mask/nodes_sgmfixed -thr 19 -uthr 19 mask/DK/19-lh-parstriangularis fslmaths mask/nodes_sgmfixed -thr 20 -uthr 20 mask/DK/20-lh-pericalcarine fslmaths mask/nodes_sgmfixed -thr 21 -uthr 21 mask/DK/21-lh-postcentral fslmaths mask/nodes_sgmfixed -thr 22 -uthr 22 mask/DK/22-lh-posteriorcingulate fslmaths mask/nodes_sgmfixed -thr 23 -uthr 23 mask/DK/23-lh-precentral fslmaths mask/nodes_sgmfixed -thr 24 -uthr 24 mask/DK/24-lh-precuneus fslmaths mask/nodes_sgmfixed -thr 25 -uthr 25 mask/DK/25-lh-rostralanteriorcingulate fslmaths mask/nodes_sgmfixed -thr 26 -uthr 26 mask/DK/26-lh-rostralmiddlefrontal fslmaths mask/nodes_sgmfixed -thr 27 -uthr 27 mask/DK/27-lh-superiorfrontal fslmaths mask/nodes_sgmfixed -thr 28 -uthr 28 mask/DK/28-lh-superiorparietal fslmaths mask/nodes_sgmfixed -thr 29 -uthr 29 mask/DK/29-lh-superiortemporal fslmaths mask/nodes_sgmfixed -thr 30 -uthr 30 mask/DK/30-lh-supramarginal fslmaths mask/nodes_sgmfixed -thr 31 -uthr 31 mask/DK/31-lh-frontalpole fslmaths mask/nodes_sgmfixed -thr 32 -uthr 32 mask/DK/32-lh-temporalpole fslmaths mask/nodes_sgmfixed -thr 33 -uthr 33 mask/DK/33-lh-transversetemporal fslmaths mask/nodes_sgmfixed -thr 34 -uthr 34 mask/DK/34-lh-insula fslmaths mask/nodes_sgmfixed -thr 35 -uthr 35 mask/DK/35-Left-Cerebellum-Cortex fslmaths mask/nodes_sgmfixed -thr 36 -uthr 36 mask/DK/36-Left-Thalamus-Proper fslmaths mask/nodes_sgmfixed -thr 37 -uthr 37 mask/DK/37-Left-Caudate fslmaths mask/nodes_sgmfixed -thr 38 -uthr 38 mask/DK/38-Left-Putamen fslmaths mask/nodes_sgmfixed -thr 39 -uthr 39 mask/DK/39-Left-Pallidum fslmaths mask/nodes_sgmfixed -thr 40 -uthr 40 mask/DK/40-Left-Hippocampus fslmaths mask/nodes_sgmfixed -thr 41 -uthr 41 mask/DK/41-Left-Amygdala fslmaths mask/nodes_sgmfixed -thr 42 -uthr 42 mask/DK/42-Left-Accumbens-area fslmaths mask/nodes_sgmfixed -thr 43 -uthr 43 mask/DK/43-Right-Thalamus-Proper fslmaths mask/nodes_sgmfixed -thr 44 -uthr 44 mask/DK/44-Right-Caudate fslmaths mask/nodes_sgmfixed -thr 45 -uthr 45 mask/DK/45-Right-Putamen fslmaths mask/nodes_sgmfixed -thr 46 -uthr 46 mask/DK/46-Right-Pallidum fslmaths mask/nodes_sgmfixed -thr 47 -uthr 47 mask/DK/47-Right-Hippocampus fslmaths mask/nodes_sgmfixed -thr 48 -uthr 48 mask/DK/48-Right-Amygdala fslmaths mask/nodes_sgmfixed -thr 49 -uthr 49 mask/DK/49-Right-Accumbens-area fslmaths mask/nodes_sgmfixed -thr 50 -uthr 50 mask/DK/50-rh-bankssts fslmaths mask/nodes_sgmfixed -thr 51 -uthr 51 mask/DK/51-rh-caudalanteriorcingulate fslmaths mask/nodes_sgmfixed -thr 52 -uthr 52 mask/DK/52-rh-caudalmiddlefrontal fslmaths mask/nodes_sgmfixed -thr 53 -uthr 53 mask/DK/53-rh-cuneus fslmaths mask/nodes_sgmfixed -thr 54 -uthr 54 mask/DK/54-rh-entorhinal fslmaths mask/nodes_sgmfixed -thr 55 -uthr 55 mask/DK/55-rh-fusiform fslmaths mask/nodes_sgmfixed -thr 56 -uthr 56 mask/DK/56-rh-inferiorparietal fslmaths mask/nodes_sgmfixed -thr 57 -uthr 57 mask/DK/57-rh-inferiortemporal fslmaths mask/nodes_sgmfixed -thr 58 -uthr 58 mask/DK/58-rh-isthmuscingulate fslmaths mask/nodes_sgmfixed -thr 59 -uthr 59 mask/DK/59-rh-lateraloccipital fslmaths mask/nodes_sgmfixed -thr 60 -uthr 60 mask/DK/60-rh-lateralorbitofrontal fslmaths mask/nodes_sgmfixed -thr 61 -uthr 61 mask/DK/61-rh-lingual fslmaths mask/nodes_sgmfixed -thr 62 -uthr 62 mask/DK/62-rh-medialorbitofrontal fslmaths mask/nodes_sgmfixed -thr 63 -uthr 63 mask/DK/63-rh-middletemporal fslmaths mask/nodes_sgmfixed -thr 64 -uthr 64 mask/DK/64-rh-parahippocampal fslmaths mask/nodes_sgmfixed -thr 65 -uthr 65 mask/DK/65-rh-paracentral fslmaths mask/nodes_sgmfixed -thr 66 -uthr 66 mask/DK/66-rh-parsopercularis fslmaths mask/nodes_sgmfixed -thr 67 -uthr 67 mask/DK/67-rh-parsorbitalis fslmaths mask/nodes_sgmfixed -thr 68 -uthr 68 mask/DK/68-rh-parstriangularis fslmaths mask/nodes_sgmfixed -thr 69 -uthr 69 mask/DK/69-rh-pericalcarine fslmaths mask/nodes_sgmfixed -thr 70 -uthr 70 mask/DK/70-rh-postcentral fslmaths mask/nodes_sgmfixed -thr 71 -uthr 71 mask/DK/71-rh-posteriorcingulate fslmaths mask/nodes_sgmfixed -thr 72 -uthr 72 mask/DK/72-rh-precentral fslmaths mask/nodes_sgmfixed -thr 73 -uthr 73 mask/DK/73-rh-precuneus fslmaths mask/nodes_sgmfixed -thr 74 -uthr 74 mask/DK/74-rh-rostralanteriorcingulate fslmaths mask/nodes_sgmfixed -thr 75 -uthr 75 mask/DK/75-rh-rostralmiddlefrontal fslmaths mask/nodes_sgmfixed -thr 76 -uthr 76 mask/DK/76-rh-superiorfrontal fslmaths mask/nodes_sgmfixed -thr 77 -uthr 77 mask/DK/77-rh-superiorparietal fslmaths mask/nodes_sgmfixed -thr 78 -uthr 78 mask/DK/78-rh-superiortemporal fslmaths mask/nodes_sgmfixed -thr 79 -uthr 79 mask/DK/79-rh-supramarginal fslmaths mask/nodes_sgmfixed -thr 80 -uthr 80 mask/DK/80-rh-frontalpole fslmaths mask/nodes_sgmfixed -thr 81 -uthr 81 mask/DK/81-rh-temporalpole fslmaths mask/nodes_sgmfixed -thr 82 -uthr 82 mask/DK/82-rh-transversetemporal fslmaths mask/nodes_sgmfixed -thr 83 -uthr 83 mask/DK/83-rh-insula fslmaths mask/nodes_sgmfixed -thr 84 -uthr 84 mask/DK/84-Right-Cerebellum-Cortex } function conbine_region () { # # Whole brain # fsladd mask/wholebrain $(imglob mask/DK/*) # # Cortical # # Frontal fsladd mask/cortical-frontal \ mask/DK/27-lh-superiorfrontal \ mask/DK/76-rh-superiorfrontal \ mask/DK/26-lh-rostralmiddlefrontal \ mask/DK/75-rh-rostralmiddlefrontal \ mask/DK/03-lh-caudalmiddlefrontal \ mask/DK/52-rh-caudalmiddlefrontal \ mask/DK/17-lh-parsopercularis \ mask/DK/66-rh-parsopercularis \ mask/DK/18-lh-parsorbitalis \ mask/DK/67-rh-parsorbitalis \ mask/DK/19-lh-parstriangularis \ mask/DK/68-rh-parstriangularis \ mask/DK/11-lh-lateralorbitofrontal \ mask/DK/13-lh-medialorbitofrontal \ mask/DK/60-rh-lateralorbitofrontal \ mask/DK/62-rh-medialorbitofrontal \ mask/DK/23-lh-precentral \ mask/DK/72-rh-precentral \ mask/DK/16-lh-paracentral \ mask/DK/65-rh-paracentral \ mask/DK/31-lh-frontalpole \ mask/DK/80-rh-frontalpole # Parietal fsladd mask/cortical-parietal \ mask/DK/28-lh-superiorparietal \ mask/DK/77-rh-superiorparietal \ mask/DK/07-lh-inferiorparietal \ mask/DK/56-rh-inferiorparietal \ mask/DK/30-lh-supramarginal \ mask/DK/79-rh-supramarginal \ mask/DK/21-lh-postcentral \ mask/DK/70-rh-postcentral \ mask/DK/24-lh-precuneus \ mask/DK/73-rh-precuneus # Temporal fsladd mask/cortical-temporal \ mask/DK/29-lh-superiortemporal \ mask/DK/78-rh-superiortemporal \ mask/DK/14-lh-middletemporal \ mask/DK/63-rh-middletemporal \ mask/DK/08-lh-inferiortemporal \ mask/DK/57-rh-inferiortemporal \ mask/DK/01-lh-bankssts \ mask/DK/50-rh-bankssts \ mask/DK/06-lh-fusiform \ mask/DK/55-rh-fusiform \ mask/DK/33-lh-transversetemporal \ mask/DK/82-rh-transversetemporal \ mask/DK/05-lh-entorhinal \ mask/DK/54-rh-entorhinal \ mask/DK/32-lh-temporalpole \ mask/DK/81-rh-temporalpole \ mask/DK/15-lh-parahippocampal \ mask/DK/64-rh-parahippocampal # Occipital fsladd mask/cortical-occipital \ mask/DK/10-lh-lateraloccipital \ mask/DK/59-rh-lateraloccipital \ mask/DK/12-lh-lingual \ mask/DK/61-rh-lingual \ mask/DK/04-lh-cuneus \ mask/DK/53-rh-cuneus \ mask/DK/20-lh-pericalcarine \ mask/DK/69-rh-pericalcarine # Cingulate fsladd mask/cortical-cingulate \ mask/DK/25-lh-rostralanteriorcingulate \ mask/DK/74-rh-rostralanteriorcingulate \ mask/DK/02-lh-caudalanteriorcingulate \ mask/DK/51-rh-caudalanteriorcingulate \ mask/DK/22-lh-posteriorcingulate \ mask/DK/71-rh-posteriorcingulate \ mask/DK/09-lh-isthmuscingulate \ mask/DK/58-rh-isthmuscingulate # Cortical fsladd mask/cortical \ mask/cortical-frontal \ mask/cortical-parietal \ mask/cortical-temporal \ mask/cortical-occipital \ mask/cortical-cingulate # # Subcortical # fsladd mask/subcortical \ mask/DK/36-Left-Thalamus-Proper \ mask/DK/37-Left-Caudate \ mask/DK/38-Left-Putamen \ mask/DK/39-Left-Pallidum \ mask/DK/42-Left-Accumbens-area \ mask/DK/43-Right-Thalamus-Proper \ mask/DK/44-Right-Caudate \ mask/DK/45-Right-Putamen \ mask/DK/46-Right-Pallidum \ mask/DK/49-Right-Accumbens-area # # Gray matter # fsladd mask/graymatter mask/cortical mask/subcortical # # White matter # mri_label2vol --temp T1.nii.gz --seg wm.seg.mgz --regheader wm.seg.mgz --o wm.seg.nii.gz fslmaths wm.seg -bin mask/whitematter } function reg_maps_to_T1 () { bet b0 b0_brain -f 0.1 -m epi_reg --epi=b0_brain --t1=T1 --t1brain=T1_brain --out=BBR_DWI-to-T1 for map in $(imglob map/* | sed "s|map/||g" | tr " " "\n"); do flirt -in map/${map} -ref T1 -out ${map}_T1 -init BBR_DWI-to-T1.mat -applyxfm done } function out_results () { [[ -d results ]] && rm -fr results mkdir results for map in $(imglob map/* | sed "s|map/||g" | tr " " "\n"); do for mask in $(imglob mask/DK/*); do fslstats ${map}_T1 -k ${mask} -M >> results/DK_${map}_mean.txt & fslstats ${map}_T1 -k ${mask} -S >> results/DK_${map}_sd.txt & wait done for mask in wholebrain graymatter whitematter cortical subcortical \ cortical-frontal cortical-parietal cortical-temporal cortical-occipital cortical-cingulate; do fslstats ${map}_T1 -k mask/${mask} -M >> results/DK_${map}_mean.txt & fslstats ${map}_T1 -k mask/${mask} -S >> results/DK_${map}_sd.txt & wait done done } create_nodes split_nodes conbine_region reg_maps_to_T1 out_results
4. FreeSurferのwm.seg.nii.gzをDWI空間に位置合わせする方法
T1WI空間にあるFreeSurferのwm.seg.nii.gzををDWI空間に位置合わせするスクリプト。
4.1. 必要なファイル
- dwi.nii.gz (DWI 画像)
- orig.mgz (T1 画像; T1空間)
- wm.seg.mgz (White matter ラベル; T1空間)
4.2. ソースコード
# mgz を nii.gz に変換 mrconvert orig.mgz orig.nii.gz mrconvert wm.seg.mgz wm.seg.nii.gz fslmaths wm.seg.nii.gz -bin wm.seg.nii.gz # reorient fslreorient2std dwi.nii.gz dwi.nii.gz fslreorient2std orig.nii.gz orig.nii.gz fslreorient2std wm.seg.nii.gz wm.seg.nii.gz # epi_reg で DWI→T1 の変換行列を計算し、逆行列 (T1→DWI) も計算 bet orig.nii.gz orig_brain.nii.gz -f 0.1 -B -m fslroi dwi.nii.gz b0.nii.gz 0 1 epi_reg --epi=b0.nii.gz --t1=orig.nii.gz --t1brain=orig_brain.nii.gz --out=DWI_to_T1 convert_xfm -omat T1_to_DWI.mat -inverse DWI_to_T1.mat # White matter ラベルを DWI 空間に移動 flirt -in wm.seg.nii.gz -ref b0.nii.gz -out wm.nii.gz -init T1_to_DWI.mat -applyxfm -interp nearestneighbour # 確認 freeview dwi.nii.gz wm.nii.gz:colormap=jet
5. 標準空間にあるROIを各被験者脳に位置合わせ
# required files ## T1_brain.nii.gz : BET T1WI ## T1.nii.gz : T1WI ## nodif_brain.nii.gz : b0 image ## MNI152_T1_1mm_brain.nii.gz : template image ## SN_labels_LR.nii.gz : subsegmented mask # Register SN-labels to Subject space ## MNI to T1WI flirt -in T1_brain -ref ../MNI152_T1_1mm_brain -omat SubT1_to_MNI.mat # fnirt --ref=../MNI152_T1_1mm_brain --in=T1_brain --aff=SubT1_to_MNI.mat --config=T1_2_MNI152_2mm --cout=warp_SubT1_to_MNI fnirt --ref=../MNI152_T1_1mm_brain --in=T1_brain --aff=SubT1_to_MNI.mat --cout=warp_SubT1_to_MNI invwarp -w warp_SubT1_to_MNI -o warp_MNI_to_SubT1 -r T1_brain ## T1WI to DWI epi_reg --epi=nodif_brain --t1=T1 --t1brain=T1_brain --out=DWI_to_T1 convert_xfm -omat T1_to_DWI.mat -inverse DWI_to_T1.mat # warp MNI to Subject T1WI space # applywarp --in=../SN_labels_L --ref=T1_brain --warp=warp_MNI_to_SubT1 --interp=nn --out=SN_labels_L_to_SubT1 # applywarp --in=../SN_labels_R --ref=T1_brain --warp=warp_MNI_to_SubT1 --interp=nn --out=SN_labels_R_to_SubT1 applywarp --in=../SN_labels_LR --ref=T1_brain --warp=warp_MNI_to_SubT1 --interp=nn --out=SN_labels_LR_to_SubT1 # warp Subject T1WI space to Subject DWI space # flirt -in SN_labels_L_to_SubT1 -ref nodif_brain -out SN_labels_L_to_SubDWI -init T1_to_DWI.mat -applyxfm -interp nearestneighbour # flirt -in SN_labels_R_to_SubT1 -ref nodif_brain -out SN_labels_R_to_SubDWI -init T1_to_DWI.mat -applyxfm -interp nearestneighbour flirt -in SN_labels_LR_to_SubT1 -ref nodif_brain -out SN_labels_LR_to_SubDWI -init T1_to_DWI.mat -applyxfm -interp nearestneighbour # calc map values [[ -d results ]] && \rm -rf results mkdir -p results MASK='SN_labels_LR_to_SubDWI' for MAP in $(\ls -1 map/*.nii.gz | xargs -i basename -s ".nii.gz" {}); do fslstats -K ${MASK} map/${MAP} -M >> results/SN-labels_${MAP}_mean.txt & # fslstats -K ${MASK} map/${MAP} -S >> results/SN-labels_${MAP}_sd.txt & wait done
6. bertのwmparcをMNI空間に移動後、個人脳(Perfusion image)にレジストレーション
# Required files # - brain.mgz: bert's T1WI # - wmparc.mgz: bert's wmparc # - <perfusion>.nii.gz: a subjects's perfusion images # Definition PERFUSION='E_01_TR05_sms_perfusion_Junten_176_20190212142306_121' LABEL='std_subj_wmparc' # 1. Preparation echo '1. Preparation' ## compress data find . -name "*nii" |xargs -i gzip {} ## copy files mkdir preprocessing cp brain.mgz wmparc.mgz ${PERFUSION}.nii.gz preprocessing # cp brain.mgz wmparc.mgz ${PERFUSION}.nii.gz std_bert_wmparc_MNI std_bert_brain_MNI preprocessing cd preprocessing ## convert bert's mgz to nii.gz mrconvert brain.mgz bert_brain.nii.gz mrconvert wmparc.mgz bert_wmparc.nii.gz ## abstract first volume from perfusion images fslroi $PERFUSION perfusion 0 1 ## reorient to FMRIB'S standard fslreorient2std bert_brain std_bert_brain fslreorient2std bert_wmparc std_bert_wmparc fslreorient2std perfusion std_perfusion ## BET perfusion image bet std_perfusion std_perfusion_brain # 2. bert2MNI echo '2. bert2MNI' ## flirt flirt -in std_bert_brain \ -ref ${FSLDIR}/data/standard/MNI152_T1_1mm_brain \ -omat bert_to_MNI.mat ## fnirt fnirt --ref=${FSLDIR}/data/standard/MNI152_T1_1mm_brain \ --in=std_bert_brain --aff=bert_to_MNI.mat \ --cout=warp_bert_to_MNI --iout=std_bert_brain_MNI applywarp --in=std_bert_wmparc \ --ref=${FSLDIR}/data/standard/MNI152_T1_1mm_brain \ --warp=warp_bert_to_MNI --interp=nn \ --out=std_bert_wmparc_MNI ## 3. regster ROIs to subject space (bert2subj) echo '3. regster ROIs to subject space (bert2subj)' flirt -in std_perfusion_brain \ -ref std_bert_brain_MNI \ -omat subj_to_bert.mat \ -out std_perfusion_brain_flirt convert_xfm -omat bert_to_subj.mat -inverse subj_to_bert.mat flirt -in std_bert_wmparc_MNI \ -ref std_perfusion_brain \ -out std_subj_wmparc \ -init bert_to_subj.mat \ -applyxfm \ -interp nearestneighbour ## 4. abstract Tissues echo '4. abstract Tissues' mkdir ROI ## GM fslmaths $LABEL -thr 800 -uthr 1200 -bin ROI/l_gm fslmaths $LABEL -thr 1800 -uthr 2200 -bin ROI/r_gm ## WM fslmaths $LABEL -thr 2800 -uthr 3200 -bin ROI/l_wm # fslmaths $LABEL -thr 5001 -uthr 5001 -bin l_wm_tmp2 # fsladd l_wm l_wm_tmp* fslmaths $LABEL -thr 3800 -uthr 4200 -bin ROI/r_wm # fslmaths $LABEL -thr 5002 -uthr 5002 -bin r_wm_tmp2 # fsladd r_wm r_wm_tmp* # rm *_wm_tmp* ## Cerebellum fslmaths $LABEL -thr 7 -uthr 8 -bin ROI/l_cblm fslmaths $LABEL -thr 46 -uthr 47 -bin ROI/r_cblm mv ROI ../ cd .. ## 5. check results fsleyes $PERFUSION \ ROI/l_gm ROI/r_gm \ ROI/l_wm ROI/r_wm \ ROI/l_cblm ROI/r_cblm &
bert脳とwmparcをMNIに移動した画像が用意できていれば、次のコードを実行するとよい。
# Required files # - brain.mgz: bert's T1WI # - wmparc.mgz: bert's wmparc # - <perfusion>.nii.gz: a subjects's perfusion images # - std_bert_brain_MNI.nii.gz: bert's brain T1WI in MNI # - std_bert_wmparc_MNI.nii.gz: bert's wmparc in MNI # Definition PERFUSION='org_perfusion' LABEL='std_subj_wmparc' TEMPLATE='std_bert_brain_MNI' TEMPLAET_LABEL='std_bert_wmparc_MNI' # 1. Preparation echo '1. Preparation' ## compress data find . -name "*nii" |xargs -i gzip {} ## copy files mkdir preprocessing cp ${PERFUSION}.nii.gz ${TEMPLAET_LABEL}.nii.gz ${TEMPLATE}.nii.gz preprocessing cd preprocessing ## abstract first volume from perfusion images mcflirt -in $PERFUSION -out ${PERFUSION}_realign fslmaths ${PERFUSION}_realign -Tmean perfusion ## reorient to FMRIB'S standard fslreorient2std perfusion std_perfusion ## BET perfusion image bet std_perfusion std_perfusion_brain ## 2. regster ROIs to subject space (bert2subj) echo '2. regster ROIs to subject space (bert2subj)' ## subj2bert # flirt -in std_perfusion_brain \ # -ref std_bert_brain_MNI \ # -omat subj_to_bert.mat \ # -out std_perfusion_brain_flirt # convert_xfm -omat bert_to_subj.mat -inverse subj_to_bert.mat ## check std_perfusion_brain_flirt.nii.gz ## if fail subj2bert, use the follwing code: ## bert2subj flirt -in std_bert_brain_MNI \ -ref std_perfusion_brain \ -omat bert_to_subj.mat \ -out std_bert_brain_subj ## apply warp to register bert's to subj's wmparc flirt -in std_bert_wmparc_MNI \ -ref std_perfusion_brain \ -out std_subj_wmparc \ -init bert_to_subj.mat \ -applyxfm \ -interp nearestneighbour # fsleyes std_perfusion_brain.nii.gz std_bert_brain_subj.nii.gz ## 3. abstract Tissues echo '3. abstract Tissues' mkdir ROI ## GM fslmaths $LABEL -thr 800 -uthr 1200 -bin -mul 1 ROI/l_gm fslmaths $LABEL -thr 1800 -uthr 2200 -bin -mul 2 ROI/r_gm ## WM fslmaths $LABEL -thr 2800 -uthr 3200 -bin -mul 3 ROI/l_wm # fslmaths $LABEL -thr 5001 -uthr 5001 -bin l_wm_tmp2 # fsladd l_wm l_wm_tmp* fslmaths $LABEL -thr 3800 -uthr 4200 -bin -mul 4 ROI/r_wm # fslmaths $LABEL -thr 5002 -uthr 5002 -bin r_wm_tmp2 # fsladd r_wm r_wm_tmp* # rm *_wm_tmp* ## Cerebellum fslmaths $LABEL -thr 7 -uthr 8 -bin -mul 5 ROI/l_cblm fslmaths $LABEL -thr 46 -uthr 47 -bin -mul 6 ROI/r_cblm fsladd ROI/subj_WM_GM_CBLM_labels ROI/l_gm ROI/r_gm ROI/l_wm ROI/r_wm ROI/l_cblm ROI/r_cblm mv ROI ../ cd .. ## 5. check results # fsleyes $PERFUSION \ # ROI/l_gm ROI/r_gm \ # ROI/l_wm ROI/r_wm \ # ROI/l_cblm ROI/r_cblm & # for k in *;do # fsleyes $k/preprocessing/std_perfusion_brain \ # $k/ROI/l_gm $k/ROI/r_gm \ # $k/ROI/l_wm $k/ROI/r_wm \ # $k/ROI/l_cblm $k/ROI/r_cblm # done
大変お世話になっております。
「JHU White-matter labels & tractography atlasでROI解析する方法」のスクリプトを使わせていただきました。結果を出す所でちょっとつまずきましたが、一つ上のディレクトリに移動して実行したらうまく行きました。根本先生の解説もよく分かりました。ありがとうございました。
素人質問で恐縮なのですが、「fslmaths」、「fslstats」などのコマンドや、アトラスの使い方などはどこかにまとめて載っていたりするのでしょうか。探しても見つけられなかったのでもしありましたらご教示いただけると幸いです。
金子先生
fslmaths, fslstats はオフィシャルの解説は “fslmaths -h” と “fslstats -h” なんです。
いつも困るとターミナルでこのコマンドを叩いて確認しています。
根本清貴
根本先生、お返事ありがとうございます。
やはりそうなのですね。複雑でなかなか覚えられないのでお聞きしてしまいました。
どこかに保存してじっくり読んでみます。