Skip to content

Commit

Permalink
fix a reversed registration in misc/pipeline.sh
Browse files Browse the repository at this point in the history
It looks as if a copy-paste error back in 2017 was causing the template
to subject DOF to be reversed.

Also revise formatting in this section to be clearer.

See #14
  • Loading branch information
jcupitt committed Nov 15, 2020
1 parent 84f9322 commit aa214f2
Showing 1 changed file with 66 additions and 21 deletions.
87 changes: 66 additions & 21 deletions scripts/misc/pipeline.sh
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ if [ -f T1/$subj.nii.gz -a ! -f $T1masked ];then
fi

# transform the serag mask to native and add on the brain mask
if [ ! -f masks/${subj}_mask_defaced.nii.gz ];then
if [ ! -f masks/${subj}_mask_defaced.nii.gz ]; then
run mirtk transform-image \
$parameters_dir/deface/template-$age-facemask.nii.gz \
masks/${subj}_serag_mask.nii.gz \
Expand All @@ -130,38 +130,83 @@ if [ ! -f masks/${subj}_mask_defaced.nii.gz ];then
fi

# deface images
for m in T1 T2;do
if [ -f $m/$subj.nii.gz -a ! -f restore/$m/${subj}_restore_defaced.nii.gz ];then
for m in T1 T2; do
if [ -f $m/$subj.nii.gz -a ! -f restore/$m/${subj}_restore_defaced.nii.gz ]; then
deface_image $m
fi
done


if [ ! -f dofs/template-$age-$subj-n.dof.gz ];then
run mirtk register $T2masked $template_T2/template-$age.nii.gz -dofout dofs/template-$age-$subj-n.dof.gz -parin $registration_config_template -threads $threads -v 0
if [ ! -f dofs/$subj-template-$age-r.dof.gz ]; then
run mirtk convert-dof \
dofs/$subj-template-$age-n.dof.gz \
dofs/$subj-template-$age-r.dof.gz \
-input-format mirtk \
-output-format rigid
fi

if [ ! -f dofs/$subj-template-$age-r.dof.gz ];then
run mirtk convert-dof dofs/$subj-template-$age-n.dof.gz dofs/$subj-template-$age-r.dof.gz -input-format mirtk -output-format rigid
fi
if [ ! -f dofs/template-$age-$subj-n.dof.gz ]; then
run mirtk invert-dof \
dofs/$subj-template-$age-n.dof.gz \
dofs/template-$age-$subj-i.dof.gz

run mirtk register \
$template_T2/template-$age.nii.gz \
$T2masked \
-dofin dofs/template-$age-$subj-i.dof.gz \
-dofout dofs/template-$age-$subj-n.dof.gz \
-parin $registration_config_template \
-threads $threads \
-v 0

if [ ! -f dofs/template-$age-$subj-n.dof.gz ];then
run mirtk invert-dof dofs/$subj-template-$age-n.dof.gz dofs/template-$age-$subj-i.dof.gz
run mirtk register $template_T2/template-$age.nii.gz $T2masked -dofin dofs/template-$age-$subj-i.dof.gz -dofout dofs/template-$age-$subj-n.dof.gz -parin $registration_config_template -threads $threads -v 0
run rm dofs/template-$age-$subj-i.dof.gz
fi

if [ $age != 40 ];then
if [ ! -f dofs/$subj-template-40-n.dof.gz ];then
run mirtk convert-dof dofs/$subj-template-$age-n.dof.gz dofs/$subj-template-$age-a.dof.gz -output-format affine
run mirtk compose-dofs dofs/$subj-template-$age-a.dof.gz $template_dofs/$age-40-a.dof.gz dofs/$subj-template-40-i.dof.gz -target $T2masked
run mirtk register $T2masked $template_T2/template-40.nii.gz -dofin dofs/$subj-template-40-i.dof.gz -dofout dofs/$subj-template-40-n.dof.gz -parin $registration_config_template -threads $threads -v 0
if [ $age != 40 ]; then
if [ ! -f dofs/$subj-template-40-n.dof.gz ]; then
run mirtk convert-dof \
dofs/$subj-template-$age-n.dof.gz \
dofs/$subj-template-$age-a.dof.gz \
-output-format affine

run mirtk compose-dofs \
dofs/$subj-template-$age-a.dof.gz \
$template_dofs/$age-40-a.dof.gz \
dofs/$subj-template-40-i.dof.gz \
-target $T2masked

run mirtk register \
$T2masked \
$template_T2/template-40.nii.gz \
-dofin dofs/$subj-template-40-i.dof.gz \
-dofout dofs/$subj-template-40-n.dof.gz \
-parin $registration_config_template \
-threads $threads \
-v 0

run rm dofs/$subj-template-$age-a.dof.gz dofs/$subj-template-40-i.dof.gz
fi
if [ ! -f dofs/template-40-$subj-n.dof.gz ];then
run mirtk convert-dof dofs/template-$age-$subj-n.dof.gz dofs/template-$age-$subj-a.dof.gz -output-format affine
run mirtk compose-dofs $template_dofs/40-$age-a.dof.gz dofs/template-$age-$subj-a.dof.gz dofs/template-40-$subj-i.dof.gz -target $template_T2/template-40.nii.gz
run mirtk register $template_T2/template-40.nii.gz $T2masked -dofin dofs/template-40-$subj-i.dof.gz -dofout dofs/template-40-$subj-n.dof.gz -parin $registration_config_template -threads $threads -v 0

if [ ! -f dofs/template-40-$subj-n.dof.gz ]; then
run mirtk convert-dof \
dofs/template-$age-$subj-n.dof.gz \
dofs/template-$age-$subj-a.dof.gz \
-output-format affine

run mirtk compose-dofs \
$template_dofs/40-$age-a.dof.gz \
dofs/template-$age-$subj-a.dof.gz \
dofs/template-40-$subj-i.dof.gz \
-target $template_T2/template-40.nii.gz

run mirtk register \
$template_T2/template-40.nii.gz \
$T2masked \
-dofin dofs/template-40-$subj-i.dof.gz \
-dofout dofs/template-40-$subj-n.dof.gz \
-parin $registration_config_template \
-threads $threads \
-v 0

run rm dofs/template-$age-$subj-a.dof.gz dofs/template-40-$subj-i.dof.gz
fi
fi

0 comments on commit aa214f2

Please sign in to comment.