Skip to content

Commit

Permalink
ENH: Fix output dir logic in scripts, check dim in template construction
Browse files Browse the repository at this point in the history
  • Loading branch information
cookpa committed Jul 26, 2023
1 parent ddf5d47 commit d4f84bc
Show file tree
Hide file tree
Showing 9 changed files with 83 additions and 13 deletions.
4 changes: 2 additions & 2 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ Once your code compiles without error and runs satisfactorily, you can open a pu

### 3. Open a pull request

All contributions must be made via pull request on a fork of the ANTs repository. The developers will review and give feedback.
All contributions must be made via pull request on a fork of the ANTs repository. The developers will review and give feedback.

Write your commit messages using the standard prefixes for ITK commit messages:

Expand All @@ -31,4 +31,4 @@ A Github continuous integration test will be run on the PR, confirming that it c

### Licensing of contributions

All accepted contributions will be incorporated into the ANTs source code and distributed according to the terms of the ANTs license.
All accepted contributions will be incorporated into the ANTs source code and distributed according to the terms of the ANTs license.
8 changes: 7 additions & 1 deletion Scripts/antsBrainExtraction.sh
Original file line number Diff line number Diff line change
Expand Up @@ -339,7 +339,13 @@ for (( i = 0; i < ${#ANATOMICAL_IMAGES[@]}; i++ ))
fi
done

OUTPUT_DIR=${OUTPUT_PREFIX%\/*}
if [[ ${OUTPUT_PREFIX} == */ ]];
then
OUTPUT_DIR=${OUTPUT_PREFIX%/}
else
OUTPUT_DIR=$(dirname $OUTPUT_PREFIX)
fi

if [[ ! -d $OUTPUT_DIR ]];
then
echo "The output directory \"$OUTPUT_DIR\" does not exist. Making it."
Expand Down
12 changes: 9 additions & 3 deletions Scripts/antsCorticalThickness.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ SCRIPTS_DEPENDENCIES=( 'antsBrainExtraction.sh' 'antsAtroposN4.sh' )

for D in ${PROGRAM_DEPENDENCIES[@]};
do
if ! command -v ${D} &> /dev/null
if ! command -v ${D} &> /dev/null
then
echo "Error: we can't find the $D program."
echo "Perhaps you need to \(re\)define \$PATH in your environment."
Expand All @@ -19,7 +19,7 @@ for D in ${PROGRAM_DEPENDENCIES[@]};

for D in ${SCRIPT_DEPENDENCIES[@]};
do
if ! command -v ${D} &> /dev/null
if ! command -v ${D} &> /dev/null
then
echo "We can't find the $D script."
echo "Perhaps you need to \(re\)define \$PATH in your environment."
Expand Down Expand Up @@ -703,7 +703,13 @@ if [[ $DO_REGISTRATION_TO_TEMPLATE -eq 1 ]];
fi
fi

OUTPUT_DIR=${OUTPUT_PREFIX%\/*}
if [[ ${OUTPUT_PREFIX} == */ ]];
then
OUTPUT_DIR=${OUTPUT_PREFIX%/}
else
OUTPUT_DIR=$(dirname $OUTPUT_PREFIX)
fi

if [[ ! -d $OUTPUT_DIR ]];
then
echo "The output directory \"$OUTPUT_DIR\" does not exist. Making it."
Expand Down
8 changes: 7 additions & 1 deletion Scripts/antsIntermodalityIntrasubject.sh
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,13 @@ if [[ ${#ANATOMICAL_SPACE} -lt 1 ]];
ANATOMICAL_SPACE=$ANATOMICAL_BRAIN
fi

OUTPUT_DIR=${OUTPUT_PREFIX%\/*}
if [[ ${OUTPUT_PREFIX} == */ ]];
then
OUTPUT_DIR=${OUTPUT_PREFIX%/}
else
OUTPUT_DIR=$(dirname $OUTPUT_PREFIX)
fi

if [[ ! -d $OUTPUT_DIR ]];
then
echo "The output directory \"$OUTPUT_DIR\" does not exist. Making it."
Expand Down
16 changes: 14 additions & 2 deletions Scripts/antsJointLabelFusion.sh
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ Compulsory arguments (minimal command line requires SGE cluster, otherwise use -
-l: Labels: Labels corresponding to atlas (cf -g).
Optional arguments:
-m: Majority vote: Use majority vote instead of joint label fusion (default = ${MAJORITYVOTE}).
-k: Keep files: Keep warped atlas and label files (default = ${KEEP_ALL_IMAGES}).
Expand Down Expand Up @@ -492,7 +492,19 @@ if [[ ${PRECISION} -eq 0 ]];
PRECISIONFLAG='d'
fi

mkdir ${OUTPUT_DIR}
if [[ ${OUTPUT_PREFIX} == */ ]];
then
OUTPUT_DIR=${OUTPUT_PREFIX%/}
else
OUTPUT_DIR=$(dirname $OUTPUT_PREFIX)
fi

if [[ ! -d $OUTPUT_DIR ]];
then
echo "The output directory \"$OUTPUT_DIR\" does not exist. Making it."
mkdir -p $OUTPUT_DIR
fi


##########################################################################
#
Expand Down
8 changes: 7 additions & 1 deletion Scripts/antsLongitudinalCorticalThickness.sh
Original file line number Diff line number Diff line change
Expand Up @@ -614,7 +614,13 @@ if [[ $DO_REGISTRATION_TO_TEMPLATE -eq 1 ]];
fi
fi

OUTPUT_DIR=${OUTPUT_PREFIX%\/*}
if [[ ${OUTPUT_PREFIX} == */ ]];
then
OUTPUT_DIR=${OUTPUT_PREFIX%/}
else
OUTPUT_DIR=$(dirname $OUTPUT_PREFIX)
fi

if [[ ! -d $OUTPUT_DIR ]];
then
echo "The output directory \"$OUTPUT_DIR\" does not exist. Making it."
Expand Down
13 changes: 12 additions & 1 deletion Scripts/antsLongitudinalJointLabelFusion.sh
Original file line number Diff line number Diff line change
Expand Up @@ -484,7 +484,18 @@ if [[ ${PRECISION} -eq 0 ]];
PRECISIONFLAG='d'
fi

mkdir ${OUTPUT_DIR}
if [[ ${OUTPUT_PREFIX} == */ ]];
then
OUTPUT_DIR=${OUTPUT_PREFIX%/}
else
OUTPUT_DIR=$(dirname $OUTPUT_PREFIX)
fi

if [[ ! -d $OUTPUT_DIR ]];
then
echo "The output directory \"$OUTPUT_DIR\" does not exist. Making it."
mkdir -p $OUTPUT_DIR
fi

##########################################################################
#
Expand Down
14 changes: 13 additions & 1 deletion Scripts/antsMultivariateTemplateConstruction.sh
Original file line number Diff line number Diff line change
Expand Up @@ -600,7 +600,19 @@ elif [[ $nargs -lt 6 ]]
Usage >&2
fi

OUTPUT_DIR=`dirname ${OUTPUTNAME}`
if [[ -z ${DIM} ]]
then
echo "Image dimension (-d) is required"
exit 1
fi

if [[ ${OUTPUTNAME} == */ ]];
then
OUTPUT_DIR=${OUTPUTNAME%/}
else
OUTPUT_DIR=$(dirname $OUTPUTNAME)
fi

if [[ ! -d $OUTPUT_DIR ]];
then
echo "The output directory \"$OUTPUT_DIR\" does not exist. Making it."
Expand Down
13 changes: 12 additions & 1 deletion Scripts/antsMultivariateTemplateConstruction2.sh
Original file line number Diff line number Diff line change
Expand Up @@ -699,7 +699,18 @@ elif [[ $nargs -lt 6 ]]
Usage >&2
fi

OUTPUT_DIR=`dirname ${OUTPUTNAME}`
if [[ -z ${DIM} ]]
then
echo "Image dimension (-d) is required"
exit 1
fi

if [[ ${OUTPUTNAME} == */ ]];
then
OUTPUT_DIR=${OUTPUTNAME%/}
else
OUTPUT_DIR=$(dirname $OUTPUTNAME)
fi

if [[ ! -d $OUTPUT_DIR ]];
then
Expand Down

0 comments on commit d4f84bc

Please sign in to comment.