Created
May 18, 2017 02:23
-
-
Save kcho/aac0a972ac9e24acef8c648a2e903544 to your computer and use it in GitHub Desktop.
MNI tractography
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
for i in $@ | |
do | |
echo ${i} | |
MNIdir=${i}/DTI_MNI | |
if [ ! -d ${MNIdir} ] | |
then | |
mkdir ${MNIdir} | |
fi | |
# MNI registration | |
for img in ${i}/DTI/data_eddy.nii.gz ${i}/DTI/nodif_brain_mask.nii.gz | |
do | |
echo registering ${img} | |
imgBase=`basename ${img}` | |
imgName=${imgBase%.nii.gz*} | |
if [ ! -e ${MNIdir}/${imgBase} ] | |
then | |
flirt -in ${img} \ | |
-ref ${FSLDIR}/data/standard/MNI152_T1_2mm.nii.gz \ | |
-applyxfm -init ${i}/registration/nodifToMNI.mat \ | |
-out ${MNIdir}/${imgBase} | |
fi | |
done | |
# DTIfit | |
if [ ! -e ${MNIdir}/DTI_FA.nii.gz ] | |
then | |
dtifit -k ${MNIdir}/data_eddy.nii.gz \ | |
-o ${MNIdir}/DTI \ | |
-m ${MNIdir}/nodif_brain_mask.nii.gz \ | |
-r ${i}/DTI/bvecs \ | |
-b ${i}/DTI/bvals | |
fi | |
cp ${MNIdir}/data_eddy.nii.gz ${MNIdir}/data.nii.gz | |
# Bedpostx | |
${bedpostDir}=${MNIdir}.bedpostX | |
if [ -d ${bedpostDir} ] | |
then | |
bedpostx ${MNIdir} | |
fi | |
# Tractography | |
${mniThalROI}=/Volume/CCNC_W1_2T/2017_CHR_thalamus_microstructure_kcho/allData/scripts/lh_thalamus_HOSC_60.nii.gz | |
${tractDir}=${i}/tractography | |
if [ ! -e ${tractDir}/fdt_paths.nii.gz ] | |
then | |
rm -rf ${tractDir} | |
mkdir -p ${tractDir} | |
probtrackx2 \ | |
-x ${mniThalROI} \ | |
-l \ | |
--onewaycondition \ | |
--omatrix2 \ | |
--target2=${bedpostDir}/nodif_brain_mask.nii.gz \ | |
-c 0.2 \ | |
-S 2000 \ | |
--steplength=0.5 \ | |
-P 5000 \ | |
--fibthresh=0.01 \ | |
--distthresh=0.0 \ | |
--sampvox=0.0 \ | |
--forcedir \ | |
--opd \ | |
-s ${bedpostDir}/merged \ | |
-m ${bedpostDir}/nodif_brain_mask \ | |
--dir=${tractDir} | |
fi | |
if [ -e ${tractDir}/fdt_matrix2_reconstructed.nii.gz ] | |
then | |
postProcessing=/Volume/CCNC_W1_2T/2017_CHR_thalamus_microstructure_kcho/allData/scripts/tracktography/postprocessing/probtrackx_postprocessing.py | |
python ${postProcessing} \ | |
${tractDir} \ | |
${bedpostDir}/nodif_brain_mask.nii.gz | |
fi | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment