Skip to content

Commit

Permalink
Merge pull request #1406 from ANTsX/antsRegistrationSyNMask
Browse files Browse the repository at this point in the history
ENH: Allow fixed,moving masks in scripts
  • Loading branch information
cookpa committed Jul 29, 2022
2 parents 04a018d + b71d646 commit 0effc09
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 23 deletions.
36 changes: 24 additions & 12 deletions Scripts/antsRegistrationSyN.sh
Original file line number Diff line number Diff line change
Expand Up @@ -82,10 +82,10 @@ Optional arguments:
-g: gradient step size for SyN and B-spline SyN (default = 0.1)
-x: mask(s) for the fixed image space. Should specify either a single image to be used for
all stages or one should specify a mask image for each "stage" (cf -t option). If
no mask is to be used for a particular stage, the keyword 'NULL' should be used
in place of a file name.
-x: mask(s) for the fixed image space, or for the fixed and moving image space in the format
"fixedMask,MovingMask". Use -x once to specify mask(s) to be used for all stages or use
-x for each "stage" (cf -t option). If no mask is to be used for a particular stage,
the keyword 'NULL' should be used in place of file names.
-p: precision type (default = 'd')
f: float
Expand Down Expand Up @@ -114,6 +114,14 @@ Example:
`basename $0` -d 3 -f fixedImage.nii.gz -m movingImage.nii.gz -o output
Example with masks:
`basename $0` -d 3 -f fixedImage.nii.gz -m movingImage.nii.gz -x fixedMask.nii.gz -o output
`basename $0` -d 3 -f fixedImage.nii.gz -m movingImage.nii.gz -x fixedMask.nii.gz,movingMask.nii.gz -o output
`basename $0` -d 3 -f fixedImage.nii.gz -m movingImage.nii.gz -t sr -x NULL -x fixedMask.nii.gz -t -o output
--------------------------------------------------------------------------------------
ANTs was created by:
--------------------------------------------------------------------------------------
Expand Down Expand Up @@ -171,10 +179,10 @@ Optional arguments:
-g: gradient step size for SyN and B-spline SyN (default = 0.1)
-x: mask(s) for the fixed image space. Should specify either a single image to be used for
all stages or one should specify a mask image for each "stage" (cf -t option). If
no mask is to be used for a particular stage, the keyword 'NULL' should be used
in place of a file name.
-x: mask(s) for the fixed image space, or for the fixed and moving image space in the format
"fixedMask,MovingMask". Use -x once to specify mask(s) to be used for all stages or use
-x for each "stage" (cf -t option). If no mask is to be used for a particular stage,
the keyword 'NULL' should be used in place of file names.
-p: precision type (default = 'd')
f: float
Expand Down Expand Up @@ -322,7 +330,7 @@ while getopts "d:e:f:g:h:i:m:j:n:o:p:r:s:t:x:y:z:" OPT
e) # seed
RANDOMSEED=$OPTARG
;;
x) # inclusive mask
x) # inclusive masks
MASKIMAGES[${#MASKIMAGES[@]}]=$OPTARG
;;
f) # fixed image
Expand Down Expand Up @@ -402,14 +410,18 @@ for(( i=0; i<${#FIXEDIMAGES[@]}; i++ ))
#
##############################

NUMBEROFMASKIMAGES=${#MASKIMAGES[@]}
NUMBEROFMASKSTAGES=${#MASKIMAGES[@]}

MASKCALL=""
if [[ ${#MASKIMAGES[@]} -gt 0 ]];
then
for (( i = 0; i < ${#MASKIMAGES[@]}; i++ ))
do
MASKCALL="${MASKCALL} -x [ ${MASKIMAGES[$i]}, NULL ]"
if [[ ${MASKIMAGES[$i]} =~ "," ]]; then
MASKCALL="${MASKCALL} -x [ ${MASKIMAGES[$i]} ]"
else
MASKCALL="${MASKCALL} -x [ ${MASKIMAGES[$i]}, NULL ]"
fi
done
fi

Expand Down Expand Up @@ -614,7 +626,7 @@ case "$TRANSFORMTYPE" in
;;
esac

if [[ $NUMBEROFMASKIMAGES -ne 0 && $NUMBEROFMASKIMAGES -ne 1 && $NUMBEROFMASKIMAGES -ne $NUMBEROFREGISTRATIONSTAGES ]];
if [[ $NUMBEROFMASKSTAGES -ne 0 && $NUMBEROFMASKSTAGES -ne 1 && $NUMBEROFMASKSTAGES -ne $NUMBEROFREGISTRATIONSTAGES ]];
then
echo "The specified number of mask images is not correct. Please see help menu."
exit
Expand Down
36 changes: 25 additions & 11 deletions Scripts/antsRegistrationSyNQuick.sh
Original file line number Diff line number Diff line change
Expand Up @@ -82,10 +82,10 @@ Optional arguments:
-g: gradient step size for SyN and B-spline SyN (default = 0.1)
-x: mask(s) for the fixed image space. Should specify either a single image to be used for
all stages or one should specify a mask image for each "stage" (cf -t option). If
no mask is to be used for a particular stage, the keyword 'NULL' should be used
in place of a file name.
-x: mask(s) for the fixed image space, or for the fixed and moving image space in the format
"fixedMask,MovingMask". Use -x once to specify mask(s) to be used for all stages or use
-x for each "stage" (cf -t option). If no mask is to be used for a particular stage,
the keyword 'NULL' should be used in place of file names.
-p: precision type (default = 'd')
f: float
Expand Down Expand Up @@ -116,6 +116,15 @@ Example:
`basename $0` -d 3 -f fixedImage.nii.gz -m movingImage.nii.gz -o output
Example with masks:
`basename $0` -d 3 -f fixedImage.nii.gz -m movingImage.nii.gz -x fixedMask.nii.gz -o output
`basename $0` -d 3 -f fixedImage.nii.gz -m movingImage.nii.gz -x fixedMask.nii.gz,movingMask.nii.gz -o output
`basename $0` -d 3 -f fixedImage.nii.gz -m movingImage.nii.gz -t sr -x NULL -x fixedMask.nii.gz -t -o output
--------------------------------------------------------------------------------------
ANTs was created by:
--------------------------------------------------------------------------------------
Expand Down Expand Up @@ -173,10 +182,10 @@ Optional arguments:
-g: gradient step size for SyN and B-spline SyN (default = 0.1)
-x: mask(s) for the fixed image space. Should specify either a single image to be used for
all stages or one should specify a mask image for each "stage" (cf -t option). If
no mask is to be used for a particular stage, the keyword 'NULL' should be used
in place of a file name.
-x: mask(s) for the fixed image space, or for the fixed and moving image space in the format
"fixedMask,MovingMask". Use -x once to specify mask(s) to be used for all stages or use
-x for each "stage" (cf -t option). If no mask is to be used for a particular stage,
the keyword 'NULL' should be used in place of file names.
-p: precision type (default = 'd')
f: float
Expand Down Expand Up @@ -404,17 +413,22 @@ for(( i=0; i<${#FIXEDIMAGES[@]}; i++ ))
#
##############################

NUMBEROFMASKIMAGES=${#MASKIMAGES[@]}
NUMBEROFMASKSTAGES=${#MASKIMAGES[@]}

MASKCALL=""
if [[ ${#MASKIMAGES[@]} -gt 0 ]];
then
for (( i = 0; i < ${#MASKIMAGES[@]}; i++ ))
do
MASKCALL="${MASKCALL} -x [ ${MASKIMAGES[$i]}, NULL ]"
if [[ ${MASKIMAGES[$i]} =~ "," ]]; then
MASKCALL="${MASKCALL} -x [ ${MASKIMAGES[$i]} ]"
else
MASKCALL="${MASKCALL} -x [ ${MASKIMAGES[$i]}, NULL ]"
fi
done
fi


###############################
#
# Set number of threads
Expand Down Expand Up @@ -621,7 +635,7 @@ case "$TRANSFORMTYPE" in
;;
esac

if [[ $NUMBEROFMASKIMAGES -ne 0 && $NUMBEROFMASKIMAGES -ne 1 && $NUMBEROFMASKIMAGES -ne $NUMBEROFREGISTRATIONSTAGES ]];
if [[ $NUMBEROFMASKSTAGES -ne 0 && $NUMBEROFMASKSTAGES -ne 1 && $NUMBEROFMASKSTAGES -ne $NUMBEROFREGISTRATIONSTAGES ]];
then
echo "The specified number of mask images is not correct. Please see help menu."
exit
Expand Down

0 comments on commit 0effc09

Please sign in to comment.