ANTsPy icon indicating copy to clipboard operation
ANTsPy copied to clipboard

Registration is not deterministic

Open rueberger opened this issue 2 years ago • 3 comments

antspy 0.3.3, the latest as of time writing installed via PyPI

Screen Shot 2022-06-09 at 12 09 16 PM

cc #86

rueberger avatar Jun 09 '22 19:06 rueberger

https://github.com/ANTsX/ANTs/wiki/antsRegistration-reproducibility-issues

gdevenyi avatar Jun 09 '22 19:06 gdevenyi

there are other issues here - affine gradient step and other things impact this. anyway, the Mattes metric ( by definition probabilistic ) is the culprit. if you use mean squares or GC ( correlation ) then this goes away. also see the help(ants.registration) which shows *repro option which are the simplified reproducible interfaces that still maintain speed from multi-threading.

stnava avatar Jun 09 '22 19:06 stnava

I see. I was able to achieve reproducibility by setting ITK_GLOBAL_DEFAULT_NUMBER_OF_THREADS=1.

I think that registration should throw a warning if random_seed is not None but ITK_GLOBAL_DEFAULT_NUMBER_OF_THREADS is not set to 1.

The only reason someone would ever set the random seed is because they want reproducible behavior

rueberger avatar Jun 09 '22 20:06 rueberger