Skip to content

Commit 24bebd8

Browse files
committed
ENH: --random-seed cmdline option
1 parent 81e4a38 commit 24bebd8

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

heudiconv/cli/run.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -88,9 +88,14 @@ def process_extra_commands(outdir, args):
8888
def main(argv=None):
8989
parser = get_parser()
9090
args = parser.parse_args(argv)
91+
# To be done asap so anything random is deterministic
92+
if args.random_seed is not None:
93+
import random
94+
random.seed(args.random_seed)
95+
import numpy
96+
numpy.random.seed(args.random_seed)
9197
if args.debug:
9298
lgr.setLevel(logging.DEBUG)
93-
9499
if args.files and args.subjs:
95100
raise ValueError("Unable to processes `--subjects` with files")
96101

@@ -173,7 +178,8 @@ def get_parser():
173178
parser.add_argument('--minmeta', action='store_true',
174179
help='Exclude dcmstack meta information in sidecar '
175180
'jsons')
176-
181+
parser.add_argument('--random-seed', type=int, default=None,
182+
help='Random seed to initialize RNG')
177183
submission = parser.add_argument_group('Conversion submission options')
178184
submission.add_argument('-q', '--queue', default=None,
179185
help='select batch system to submit jobs to instead'

0 commit comments

Comments
 (0)