Skip to content
Snippets Groups Projects
Commit 2236c0f3 authored by Taylor Hanayik's avatar Taylor Hanayik
Browse files

move else statement to fix linear reg + bet

parent 6767f0bf
No related branches found
No related tags found
1 merge request!3fix fsl_anat nonlinreg failure
Pipeline #20603 skipped
......@@ -471,40 +471,44 @@ fi
#### REGISTRATION AND BRAIN EXTRACTION
# required input: ${T1}_biascorr
# output: ${T1}_biascorr_brain ${T1}_biascorr_brain_mask ${T1}_to_MNI_lin ${T1}_to_MNI [plus transforms, inverse transforms, jacobians, etc.]
if [ $do_reg = yes ] ; then
if [ $do_bet != yes ] ; then
echo "Skipping registration, as it requires a non-brain-extracted input image"
else
date; echo "Registering to standard space (linear)"
flirtargs="$flirtargs $nosearch"
if [ $use_lesionmask = yes ] ; then flirtargs="$flirtargs -inweight lesionmaskinv" ; fi
run $FSLDIR/bin/flirt -interp spline -dof 12 -in ${T1}_biascorr -ref $FSLDIR/data/standard/MNI152_${T1}_2mm -dof 12 -omat ${T1}_to_MNI_lin.mat -out ${T1}_to_MNI_lin $flirtargs
if [ $do_nonlinreg = yes ] ; then
date; echo "Registering to standard space (non-linear)"
#refmask=$FSLDIR/data/standard/MNI152_${T1}_2mm_brain_mask_dil1
refmask=MNI152_${T1}_2mm_brain_mask_dil1
fnirtargs=""
if [ $use_lesionmask = yes ] ; then fnirtargs="$fnirtargs --inmask=lesionmaskinv" ; fi
run $FSLDIR/bin/fslmaths $FSLDIR/data/standard/MNI152_${T1}_2mm_brain_mask -fillh -dilF $refmask
run $FSLDIR/bin/fnirt --in=${T1}_biascorr --ref=$FSLDIR/data/standard/MNI152_${T1}_2mm --fout=${T1}_to_MNI_nonlin_field --jout=${T1}_to_MNI_nonlin_jac --iout=${T1}_to_MNI_nonlin --logout=${T1}_to_MNI_nonlin.txt --cout=${T1}_to_MNI_nonlin_coeff --config=$FSLDIR/etc/flirtsch/${T1}_2_MNI152_2mm.cnf --aff=${T1}_to_MNI_lin.mat --refmask=$refmask $fnirtargs
date; echo "Performing brain extraction (using FNIRT)"
run $FSLDIR/bin/invwarp --ref=${T1}_biascorr -w ${T1}_to_MNI_nonlin_coeff -o MNI_to_${T1}_nonlin_field
run $FSLDIR/bin/applywarp --interp=nn --in=$FSLDIR/data/standard/MNI152_${T1}_2mm_brain_mask --ref=${T1}_biascorr -w MNI_to_${T1}_nonlin_field -o ${T1}_biascorr_brain_mask
run $FSLDIR/bin/fslmaths ${T1}_biascorr_brain_mask -fillh ${T1}_biascorr_brain_mask
run $FSLDIR/bin/fslmaths ${T1}_biascorr -mas ${T1}_biascorr_brain_mask ${T1}_biascorr_brain
if [ $do_reg = yes ]; then
if [ $do_bet != yes ]; then
echo "Skipping registration, as it requires a non-brain-extracted input image"
else
date
echo "Registering to standard space (linear)"
flirtargs="$flirtargs $nosearch"
if [ $use_lesionmask = yes ]; then flirtargs="$flirtargs -inweight lesionmaskinv"; fi
run $FSLDIR/bin/flirt -interp spline -dof 12 -in ${T1}_biascorr -ref $FSLDIR/data/standard/MNI152_${T1}_2mm -dof 12 -omat ${T1}_to_MNI_lin.mat -out ${T1}_to_MNI_lin $flirtargs
if [ $do_nonlinreg = yes ]; then
date
echo "Registering to standard space (non-linear)"
#refmask=$FSLDIR/data/standard/MNI152_${T1}_2mm_brain_mask_dil1
refmask=MNI152_${T1}_2mm_brain_mask_dil1
fnirtargs=""
if [ $use_lesionmask = yes ]; then fnirtargs="$fnirtargs --inmask=lesionmaskinv"; fi
run $FSLDIR/bin/fslmaths $FSLDIR/data/standard/MNI152_${T1}_2mm_brain_mask -fillh -dilF $refmask
run $FSLDIR/bin/fnirt --in=${T1}_biascorr --ref=$FSLDIR/data/standard/MNI152_${T1}_2mm --fout=${T1}_to_MNI_nonlin_field --jout=${T1}_to_MNI_nonlin_jac --iout=${T1}_to_MNI_nonlin --logout=${T1}_to_MNI_nonlin.txt --cout=${T1}_to_MNI_nonlin_coeff --config=$FSLDIR/etc/flirtsch/${T1}_2_MNI152_2mm.cnf --aff=${T1}_to_MNI_lin.mat --refmask=$refmask $fnirtargs
date
echo "Performing brain extraction (using FNIRT)"
run $FSLDIR/bin/invwarp --ref=${T1}_biascorr -w ${T1}_to_MNI_nonlin_coeff -o MNI_to_${T1}_nonlin_field
run $FSLDIR/bin/applywarp --interp=nn --in=$FSLDIR/data/standard/MNI152_${T1}_2mm_brain_mask --ref=${T1}_biascorr -w MNI_to_${T1}_nonlin_field -o ${T1}_biascorr_brain_mask
run $FSLDIR/bin/fslmaths ${T1}_biascorr_brain_mask -fillh ${T1}_biascorr_brain_mask
run $FSLDIR/bin/fslmaths ${T1}_biascorr -mas ${T1}_biascorr_brain_mask ${T1}_biascorr_brain
else
if [ $do_bet = yes ]; then
date
echo "Performing brain extraction (using BET)"
run $FSLDIR/bin/bet ${T1}_biascorr ${T1}_biascorr_brain -m $betopts ## results sensitive to the f parameter
else
run $FSLDIR/bin/fslmaths ${T1}_biascorr ${T1}_biascorr_brain
run $FSLDIR/bin/fslmaths ${T1}_biascorr_brain -bin ${T1}_biascorr_brain_mask
fi
fi
## In the future, could check the initial ROI extraction here
fi
## In the future, could check the initial ROI extraction here
fi
else
if [ $do_bet = yes ] ; then
date; echo "Performing brain extraction (using BET)"
run $FSLDIR/bin/bet ${T1}_biascorr ${T1}_biascorr_brain -m $betopts ## results sensitive to the f parameter
else
run $FSLDIR/bin/fslmaths ${T1}_biascorr ${T1}_biascorr_brain
run $FSLDIR/bin/fslmaths ${T1}_biascorr_brain -bin ${T1}_biascorr_brain_mask
fi
fi
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment