#!/bin/sh
# this is MERGED script for (i)transformation, (ii) roi making, and (iii) exclusion masking.
# THIS IS VERSION 2: FOR APARC+ASEGS2009S.
# THIS SCRIPT IS TO BE FOLLOWED BY TRAC_02_MAKEROILIST
cmd=$hr/batchcode/commands_roimerge
echo command file is $cmd
export FSLDIR=$WORK/fsl/fsl
for s in `cat $hr/fs/goodsubject.txt`
do
cat <<EOM > $cmd
#!/bin/bash
#$ -l mem=3G,time=6::
#$ -cwd
#$ -V
#$ -N roi
#$ -j y
#$ -o batchcode/roi
echo "Starting on : $(date)"
echo "Running on node : $(hostname)"
echo "Current directory : $(pwd)"
echo "Current job ID : $JOB_ID"
echo "Current job name : $JOB_NAME"
cd $hr/fs/$s/mri
echo -------------NOW MNI152REG WITH 1MM
export SUBJECTS_DIR=$hr/fs
mni152reg --s $s --1
echo -------------NOW CONVERTING MNI152.ORIG TO NII.GZ
mri_convert mni152.orig.mgz mni152.orig.nii.gz
fslreorient2std mni152.orig.nii.gz mni152.orig.orient.nii.gz
mri_convert orig.mgz orig.nii.gz
fslreorient2std orig.nii.gz orig.orient.nii.gz
echo -------------NOW TRANSFORMATION_REGISTRATION TO MNI152 TO CREATE FREESURFER2MAT.MAT
flirt -in orig.orient.nii.gz -ref mni152.orig.orient.nii.gz -omat ./transforms/freesurfer2mni152.mat -out ~/tmp
echo -------------NOW TRANSFORMATION_REGISTRATION TO APARC+ASEG to MNI152 space USING FREESURFER2MAT.MAT
for im in aparc+aseg aparc.a2009s+aseg wmparc
do
echo MRI_converting
mri_convert \${im}.mgz \${im}.nii.gz && fslreorient2std \${im}.nii.gz \${im}_orient.nii.gz
echo FLIRTING1
flirt -in \${im}_orient.nii.gz -ref mni152.orig.orient.nii.gz -applyxfm -init ./transforms/freesurfer2mni152.mat -interp nearestneighbour -omat ~/tmp -out \${im}_orient_mni152
echo FLIRTING2
flirt -in \${im}_orient_mni152 -ref mni152.orig.orient.nii.gz -applyisoxfm 1 -out \${im}_orient_mni152_1mm
done
mv roi roi3 && mkdir roi
echo ------------NOW MAKING ALL ROI MASKS
#export roilist=$hr/fs/$s/mri/roi/roilist_wb.txt && rm \${roilist}
for roi in \`cat $WORK/code/roi_2009\` ;
do
echo MAKING ROI FOR \${roi}
fslmaths aparc.a2009s+aseg_orient_mni152_1mm -thr \${roi} -uthr \${roi} -bin ./roi/\${roi} && fslmaths ./roi/\${roi} -dilM ./roi/\${roi}_dil
#
echo $hr/fs/$s/mri/roi/\${roi}_dil.nii.gz >> \${roilist}
done
#echo ------------NOW MAKING HIPPO-SUBDIVISION ROI MASKS (NIFTI CONVERSION, REORIENTATION, AND REGRSTATION)
#for lr in left right ;
#do
# for roi in CA1 CA2_3 CA4_DG fimbria hippocampal_fissure presubiculum subiculum ;
# do
# im=posterior_\${lr}_\${roi}
# echo MAKING HIPPO-SUBDIVISION ROI FOR \$im
# mri_convert \${im}.mgz \${im}.nii.gz && fslreorient2std \${im}.nii.gz \${im}_orient.nii.gz
# echo FLIRTING-1
# flirt -in \${im}_orient.nii.gz -ref mni152.orig.orient.nii.gz -applyxfm -init ./transforms/freesurfer2mni152.mat -interp nearestneighbour -out \${im}_orient_mni152
# echo flirting-2
# flirt -in \${im}_orient_mni152 -ref mni152.orig.orient.nii.gz -applyisoxfm 1 -out \${im}_orient_mni152_1mm
#
#
done
#done
echo -----------NOW EXCLUSION MASK
for roi in 4 43 14 15 72 24
do
echo MAKING EXCLUSION MASK \${roi}
fslmaths aparc+aseg_orient_mni152_1mm -thr \${roi} -uthr \${roi} -bin ./roi/\${roi} && fslmaths ./roi/\${roi} -dilM -bin ./roi/\${roi}_dil
done
echo -----------NOW EXCLUSION MASK from APARC_ASEG MASK
fslmaths aparc+aseg_orient_mni152_1mm -bin -mul -1 -add 1 ./roi/exclusionmask_additional
fslmaths ./roi/4 -add ./roi/43 -add ./roi/14 -add ./roi/15 -add ./roi/72 -add ./roi/24 -bin ./roi/exclusionmask
fslmaths ./roi/exclusionmask -add ./roi/exclusionmask_additional -bin ./roi/exclusionmask2
echo ALL THE PREPRCESSING STEPS SUCCESSFULLY COMPLETED!!
EOM
#chmod +x $cmd
#cat $cmd
#ls $cmd
qsub $cmd
done
'Brain imaging & Unix command > command' 카테고리의 다른 글
Smoothing (0) | 2016.10.13 |
---|---|
registration script (0) | 2016.10.10 |
소아 templete 최종 결과 (0) | 2016.10.07 |
brain thalamus ROI file (0) | 2016.09.28 |
randomized and fslmath, fslreorient2st (0) | 2016.09.28 |