From 66b393fe2faa2767dd06dfff3d0a0663ba54addd Mon Sep 17 00:00:00 2001 From: Philip Cook Date: Thu, 30 Mar 2023 11:13:31 -0400 Subject: [PATCH 1/2] STYLE: rearrange brain extraction script to better document defaults --- Scripts/antsBrainExtraction.sh | 138 +++++++++++++++++---------------- 1 file changed, 71 insertions(+), 67 deletions(-) diff --git a/Scripts/antsBrainExtraction.sh b/Scripts/antsBrainExtraction.sh index 5b937f0a3..f329a50a5 100755 --- a/Scripts/antsBrainExtraction.sh +++ b/Scripts/antsBrainExtraction.sh @@ -19,6 +19,67 @@ if [[ ! -s ${ANTSPATH}/antsApplyTransforms ]]; then exit fi +################################################################################ +# +# General parameters +# +################################################################################ + +HOSTNAME=`hostname` +DATE=`date` + +CURRENT_DIR=`pwd`/ +OUTPUT_DIR=${CURRENT_DIR}/tmp$RANDOM/ +OUTPUT_PREFIX=${OUTPUT_DIR}/tmp +OUTPUT_SUFFIX="nii.gz" + +KEEP_TMP_IMAGES=0 + +USE_RANDOM_SEEDING=1 + +DIMENSION=3 + +ANATOMICAL_IMAGES=() + +USE_FLOAT_PRECISION=0 + +# Intial affine supplied on command line +USER_INITIAL_AFFINE="" + +################################################################################ +# +# Programs and their parameters +# +################################################################################ + + +ATROPOS=${ANTSPATH}/Atropos +ATROPOS_NUM_CLASSES=3 +ATROPOS_CSF_CLASS_LABEL=1 +ATROPOS_GM_CLASS_LABEL=2 +ATROPOS_WM_CLASS_LABEL=3 +ATROPOS_BRAIN_EXTRACTION_INITIALIZATION="kmeans[ ${ATROPOS_NUM_CLASSES} ]" +ATROPOS_BRAIN_EXTRACTION_LIKELIHOOD="Gaussian" +ATROPOS_BRAIN_EXTRACTION_CONVERGENCE="[ 3,0.0 ]" + +ANTS=${ANTSPATH}/antsRegistration +ANTS_MAX_ITERATIONS="100x100x70x20" +ANTS_TRANSFORMATION="SyN[ 0.1,3,0 ]" +ANTS_LINEAR_METRIC_PARAMS="1,32,Regular,0.25" +ANTS_LINEAR_CONVERGENCE="[ 1000x500x250x100,1e-8,10 ]" +ANTS_METRIC="CC" +ANTS_METRIC_PARAMS="1,4" + +WARP=${ANTSPATH}/antsApplyTransforms + +N4=${ANTSPATH}/N4BiasFieldCorrection +N4_CONVERGENCE_1="[ 50x50x50x50,0.0000001 ]" +N4_CONVERGENCE_2="[ 50x50x50x50,0.0000001 ]" +N4_SHRINK_FACTOR_1=4 +N4_SHRINK_FACTOR_2=2 +N4_BSPLINE_PARAMS="[ 200 ]" + + function Usage { cat < 0, runs a faster version of the script. Only for debugging, results will not be good. @@ -154,61 +213,6 @@ function logCmd() { # ################################################################################ -HOSTNAME=`hostname` -DATE=`date` - -CURRENT_DIR=`pwd`/ -OUTPUT_DIR=${CURRENT_DIR}/tmp$RANDOM/ -OUTPUT_PREFIX=${OUTPUT_DIR}/tmp -OUTPUT_SUFFIX="nii.gz" - -KEEP_TMP_IMAGES=0 - -USE_RANDOM_SEEDING=1 - -DIMENSION=3 - -ANATOMICAL_IMAGES=() - -################################################################################ -# -# Programs and their parameters -# -################################################################################ - -ATROPOS=${ANTSPATH}/Atropos - -ATROPOS_NUM_CLASSES=3 - -ATROPOS_CSF_CLASS_LABEL=1 -ATROPOS_GM_CLASS_LABEL=2 -ATROPOS_WM_CLASS_LABEL=3 - -ATROPOS_BRAIN_EXTRACTION_INITIALIZATION="kmeans[ ${ATROPOS_NUM_CLASSES} ]" -ATROPOS_BRAIN_EXTRACTION_LIKELIHOOD="Gaussian" -ATROPOS_BRAIN_EXTRACTION_CONVERGENCE="[ 3,0.0 ]" - -ANTS=${ANTSPATH}/antsRegistration -ANTS_MAX_ITERATIONS="100x100x70x20" -ANTS_TRANSFORMATION="SyN[ 0.1,3,0 ]" -ANTS_LINEAR_METRIC_PARAMS="1,32,Regular,0.25" -ANTS_LINEAR_CONVERGENCE="[ 1000x500x250x100,1e-8,10 ]" -ANTS_METRIC="CC" -ANTS_METRIC_PARAMS="1,4" - -WARP=${ANTSPATH}/antsApplyTransforms - -N4=${ANTSPATH}/N4BiasFieldCorrection -N4_CONVERGENCE_1="[ 50x50x50x50,0.0000001 ]" -N4_CONVERGENCE_2="[ 50x50x50x50,0.0000001 ]" -N4_SHRINK_FACTOR_1=4 -N4_SHRINK_FACTOR_2=2 -N4_BSPLINE_PARAMS="[ 200 ]" - -USE_FLOAT_PRECISION=0 - -# Intial affine supplied on command line -USER_INITIAL_AFFINE="" if [[ $# -lt 3 ]] ; then Usage >&2 From 5bbcebd3ac59e0f68e9575e6b8b69544708b36be Mon Sep 17 00:00:00 2001 From: Philip Cook Date: Thu, 30 Mar 2023 11:16:13 -0400 Subject: [PATCH 2/2] DOC: Punctuation --- Scripts/antsBrainExtraction.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Scripts/antsBrainExtraction.sh b/Scripts/antsBrainExtraction.sh index f329a50a5..3f44c6edf 100755 --- a/Scripts/antsBrainExtraction.sh +++ b/Scripts/antsBrainExtraction.sh @@ -106,10 +106,10 @@ Required arguments: images are used during the segmentation process. However, only the first image is used in the registration of priors. Our suggestion would be to specify the T1 as the first image. - -e: Brain extraction template Anatomical template + -e: Brain extraction template Anatomical template. -m: Brain extraction probability mask Brain probability mask, with intensity range 1 (definitely brain) to 0 (definitely background). - -o: Output prefix Output directory + file prefix + -o: Output prefix Output directory + file prefix. Optional arguments: @@ -134,7 +134,7 @@ Optional arguments: -u: Use random seeding Use random number generated from system clock (1) or a fixed seed (0). Using "-u 0" overrides a system setting of ANTS_RANDOM_SEED. To produce identical results, multi-threading must also be disabled by setting the environment variable - ITK_GLOBAL_DEFAULT_NUMBER_OF_THREADS=1. Default = $USE_RANDOM_SEEDING + ITK_GLOBAL_DEFAULT_NUMBER_OF_THREADS=1. Default = $USE_RANDOM_SEEDING. -k: Keep temporary files Keep brain extraction/segmentation warps, etc (default = $KEEP_TMP_IMAGES). -q: Use single floating point precision Use antsRegistration with single (1) or double (0) floating point precision (default = $USE_FLOAT_PRECISION).