From c69ffc4d52011d50dfbfb9335ae5d0aabab6814e Mon Sep 17 00:00:00 2001 From: Philip Cook Date: Mon, 22 May 2023 09:34:06 -0400 Subject: [PATCH 1/2] ENH: Set ANTS_RANDOM SEED if antsCorticalThickness.sh run with -u 0 Previously, this only set the random seed for antsAtroposN4.sh --- Scripts/antsCorticalThickness.sh | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/Scripts/antsCorticalThickness.sh b/Scripts/antsCorticalThickness.sh index ee4f7a489..a772d08fe 100755 --- a/Scripts/antsCorticalThickness.sh +++ b/Scripts/antsCorticalThickness.sh @@ -76,7 +76,7 @@ We use *label* to denote a label image with values in range 0 to N. * Registration metric mask (-f) * Thickness prior image (-r). - -m: Brain extraction probability mask Brain *probability* mask in the segmentation template space. A binary mask + -m: Brain extraction probability mask Brain *probability* mask in the segmentation template space. A binary mask is an acceptable probability image. -p: Brain segmentation priors Tissue *probability* priors corresponding to the image specified @@ -127,7 +127,7 @@ Optional arguments: https://github.com/ANTsX/ANTs/wiki. -f: extraction registration mask Binary metric mask defined in the segmentation template space (-e). During the - registration for brain extraction, the similarity metric is only computed within + registration for brain extraction, the similarity metric is only computed within this mask. -k: keep temporary files Keep brain extraction/segmentation warps, etc (default = 0). @@ -147,7 +147,10 @@ Optional arguments: -j: use floating-point precision Use single float precision in registrations (default = 0). - -u: use random seeding Use random number generated from system clock in Atropos (default = 1). + -u: use random seeding Use random number generated from system clock (default = 1). If 0, a fixed + random seed is used. To set your own seed, set this option to 0 and export the + environment variable ANTS_RANDOM_SEED. To achieve exactly identical results, you must + also set ITK_GLOBAL_DEFAULT_NUMBER_OF_THREADS to 1. -v: use b-spline smoothing Use B-spline SyN for registrations and B-spline exponential mapping in DiReCT (default = 0). @@ -173,7 +176,7 @@ Optional arguments: Another example would be computing cortical thickness in the presence of white matter lesions. We can accommodate this by specifying a lesion mask posterior as an additional posterior (suppose label '7'), combining this with - normal white matter in the thickness estimation by specifying '-c "WM[ 7 ]"' + normal white matter in the thickness estimation by specifying '-c "WM[ 7 ]"' or '-c "3[ 7 ]"'. -q: Use quick registration parameters If = 1, use antsRegistrationSyNQuick.sh as the basis for registration @@ -540,6 +543,13 @@ if [[ $DEBUG_MODE -gt 0 ]]; fi +if [[ ${USE_RANDOM_SEEDING} -eq 0 ]]; then + # Use fixed random seed unless one is already defined + if [[ -z $ANTS_RANDOM_SEED ]] ; then + export ANTS_RANDOM_SEED=19650218 + fi +fi + ################################################################################ # # Preliminaries: From da61ae5abecec5258ad8f7129aef835d747cd9c8 Mon Sep 17 00:00:00 2001 From: Philip Cook Date: Mon, 22 May 2023 09:48:13 -0400 Subject: [PATCH 2/2] DOC: Clarify random seeding option --- Scripts/antsBrainExtraction.sh | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/Scripts/antsBrainExtraction.sh b/Scripts/antsBrainExtraction.sh index 3f44c6edf..588b1a564 100755 --- a/Scripts/antsBrainExtraction.sh +++ b/Scripts/antsBrainExtraction.sh @@ -131,9 +131,8 @@ Optional arguments: Without this option, this script calls antsAI to search for a good initial moving transform. -s: Image file suffix Any of the standard ITK IO formats e.g. nrrd, nii.gz, mhd (default = $OUTPUT_SUFFIX) - -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 + -u: Use random seeding Use random number generated from system clock (1) or a fixed seed (0). 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. -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).