Skip to content

Commit

Permalink
Merge pull request #1196 from ANTsX/repro
Browse files Browse the repository at this point in the history
ENH: Allow user to set random seed in repro mode
  • Loading branch information
ntustison authored May 17, 2021
2 parents caefeee + f580d19 commit 51a52c9
Show file tree
Hide file tree
Showing 2 changed files with 61 additions and 9 deletions.
35 changes: 30 additions & 5 deletions Scripts/antsRegistrationSyN.sh
Original file line number Diff line number Diff line change
Expand Up @@ -95,14 +95,19 @@ Optional arguments:
0: false
1: true
-y: use 'repro' mode. GC for linear stages and fixed seed
-y: use 'repro' mode for exact reproducibility of output. Uses GC metric for linear
stages and a fixed random seed (default = 0).
0: false
1: true
-z: collapse output transforms (default = 1)
-e: Fix random seed to an int value
NB: Multiple image pairs can be specified for registration during the SyN stage.
Specify additional images using the '-m' and '-f' options. Note that image
pair correspondence is given by the order specified on the command line.
Only the first fixed and moving image pair is used for the linear resgitration
Only the first fixed and moving image pair is used for the linear registration
stages.
Example:
Expand Down Expand Up @@ -179,11 +184,16 @@ Optional arguments:
0: false
1: true
-y: use 'repro' mode. GC for linear stages and fixed seed
-y: use 'repro' mode for exact reproducibility of output. Uses GC metric for linear
stages and a fixed random seed (default = 0).
0: false
1: true
-z: collapse output transforms (default = 1)
0: false
1: true
-e: Fix random seed to an int value (default = system time)
-e: Fix random seed to an int value
NB: Multiple image pairs can be specified for registration during the SyN stage.
Specify additional images using the '-m' and '-f' options. Note that image
Expand Down Expand Up @@ -491,11 +501,26 @@ if [[ $ISLARGEIMAGE -eq 1 ]];

LINEARMETRIC="MI"
LINEARMETRICPARAMETER=32

# Precedence for random seeding
# 1. Command line option -e
# 2. Environment variable ANTS_RANDOM_SEED
# 3. Fixed seed = 1 if run in repro mode
# 4. ITK default (system time)

if [[ -n ${ANTS_RANDOM_SEED} ]] && [[ ${RANDOMSEED} -eq 0 ]];
then
RANDOMSEED=${ANTS_RANDOM_SEED}
fi

if [[ $REPRO -eq 1 ]];
then
LINEARMETRIC="GC"
LINEARMETRICPARAMETER=1
RANDOMSEED=1
if [[ ${RANDOMSEED} -eq 0 ]];
then
RANDOMSEED=1
fi
fi

INITIALSTAGE="--initial-moving-transform [ ${FIXEDIMAGES[0]},${MOVINGIMAGES[0]},1 ]"
Expand Down
35 changes: 31 additions & 4 deletions Scripts/antsRegistrationSyNQuick.sh
Original file line number Diff line number Diff line change
Expand Up @@ -95,9 +95,16 @@ Optional arguments:
0: false
1: true
-y: use 'repro' mode. GC for linear stages and fixed seed
-y: use 'repro' mode for exact reproducibility of output. Uses GC metric for linear
stages, CC metric for deformable stages, and a fixed random seed (default = 0).
0: false
1: true
-z: collapse output transforms (default = 1)
0: false
1: true
-e: Fix random seed to an int value
NB: Multiple image pairs can be specified for registration during the SyN stage.
Specify additional images using the '-m' and '-f' options. Note that image
Expand Down Expand Up @@ -179,11 +186,16 @@ Optional arguments:
0: false
1: true
-y: use 'repro' mode. GC for linear stages and fixed seed
-y: use 'repro' mode for exact reproducibility of output. Uses GC metric for linear
stages, CC metric for deformable stages, and a fixed random seed (default = 0).
0: false
1: true
-z: collapse output transforms (default = 1)
0: false
1: true
-e: Fix random seed to an int value (default = system time)
-e: Fix random seed to an int value
NB: Multiple image pairs can be specified for registration during the SyN stage.
Specify additional images using the '-m' and '-f' options. Note that image
Expand Down Expand Up @@ -491,11 +503,26 @@ if [[ $ISLARGEIMAGE -eq 1 ]];

LINEARMETRIC="MI"
LINEARMETRICPARAMETER=32

# Precedence for random seeding
# 1. Command line option -e
# 2. Environment variable ANTS_RANDOM_SEED
# 3. Fixed seed = 1 if run in repro mode
# 4. ITK default (system time)

if [[ -n ${ANTS_RANDOM_SEED} ]] && [[ ${RANDOMSEED} -eq 0 ]];
then
RANDOMSEED=${ANTS_RANDOM_SEED}
fi

if [[ $REPRO -eq 1 ]];
then
LINEARMETRIC="GC"
LINEARMETRICPARAMETER=1
RANDOMSEED=1
if [[ ${RANDOMSEED} -eq 0 ]];
then
RANDOMSEED=1
fi
fi

INITIALSTAGE="--initial-moving-transform [ ${FIXEDIMAGES[0]},${MOVINGIMAGES[0]},1 ]"
Expand Down

0 comments on commit 51a52c9

Please sign in to comment.