
1. 目的
2. フォルダ構造
3. ソースコード
3.1. segcalc_basalganglia.sh
4. 実行
5. 結果
5.1. nresult_vol.csv
1. 目的
- FSLを用いて大脳基底核(Basal Ganglia)のセグメントと体積(Volume)計測
2. フォルダ構造
dataフォルダを作成し、その中に各被験者のフォルダ用意。大脳基底核のセグメントに必要な3D-T1WIは各被験者フォルダに<フォルダ名>_vol.nii(.gzも可)というファイル名で入れておく。
segcalc_basalganglia.sh # ソースコード
data
├── Sub001
│ └── Sub001_vol.nii
├── Sub002
│ └── Sub002_vol.nii
└── Sub003
└── Sub003_vol.nii
3. ソースコード
以下のコードをsegcalc_basalganglia.shとして、dataフォルダと同じ階層に保存。
3.1. segcalc_basalganglia.sh
# folder name
foldername="data"
# make ROI name file
for roiname in \
"Region" \
"Left-Thalamus-Proper" \
"Left-Caudate" \
"Left-Putamen" \
"Left-Pallidum" \
"Brain-Stem/4th/Ventricle" \
"Left-Hippocampus" \
"Left-Amygdala" \
"Left-Accumbens-area" \
"Right-Thalamus-Proper" \
"Right-Caudate" \
"Right-Putamen" \
"Right-Pallidum" \
"Right-Hippocampus" \
"Right-Amygdala" \
"Right-Accumbens-area"
do
echo $roiname >> tmp1
done
# segment basal ganglia and calc volume
cd $foldername
for k in *;do
echo "processing $k"
cd $k # move each subject folder
echo $k > ../../tmp2 # make ID name file
fslreorient2std ${k}_vol std # reorient data to standard
run_first_all -i std -o output # segment basal ganglia
fslstats -K output_all_fast_firstseg.nii.gz output_all_fast_firstseg.nii.gz -V \
|grep -v missing |cut -d " " -f2 >> ../../tmp2 # calc volume in each basal ganglia
## save ID and volume ,and accumulate them in result_vol.csv
cat ../../tmp2 > ../../tmp3
paste ../../tmp1 ../../tmp3 > ../../result_vol.csv
cat ../../result_vol.csv > ../../tmp1
cd ..
done
cd ..
# remove temporaly files
rm tmp*
4. 実行
$ bash segcalc_basalganglia.sh processing Sub001 processing Sub002 processing Sub003 ...
5. 結果
スクリプトを実行後にresult_vol.csvが生成される。
5.1. nresult_vol.csv
| Region | Sub001 | Sub002 | Sub003 |
|---|---|---|---|
| Left-Thalamus-Proper | 8149.043 | 8709.082 | 7327.969 |
| Left-Caudate | 3083.379 | 3821.397 | 3065.977 |
| Left-Putamen | 4282.559 | 6002.227 | 4072.94 |
| Left-Pallidum | 1759.219 | 2430.791 | 1729.16 |
| Brain-Stem/4th/Ventricle | 24451.88 | 28020.15 | 23077.09 |
| Left-Hippocampus | 3444.873 | 4572.07 | 3547.705 |
| Left-Amygdala | 1850.977 | 1954.6 | 1489.482 |
| Left-Accumbens-area | 322.7344 | 637.5586 | 382.8516 |
| Right-Thalamus-Proper | 7768.565 | 9053.965 | 7305.821 |
| Right-Caudate | 3101.572 | 4038.926 | 3061.231 |
| Right-Putamen | 4237.471 | 5684.239 | 4460.537 |
| Right-Pallidum | 1803.516 | 2244.902 | 1754.473 |
| Right-Hippocampus | 4017.569 | 4812.539 | 3796.875 |
| Right-Amygdala | 1585.986 | 1762.383 | 1651.641 |
| Right-Accumbens-area | 357.5391 | 509.4141 | 237.3047 |
