Giter Site home page Giter Site logo

Comments (7)

dzenanz avatar dzenanz commented on June 23, 2024 1

You should be able too look up all the Elastix parameters here, but the page is not working for me right now. @N-Dekker @ViktorvdValk Is that just me, or is the page really down?

from itkelastix.

N-Dekker avatar N-Dekker commented on June 23, 2024 1

You should be able too look up all the Elastix parameters here, but the page is not working for me right now. @N-Dekker @ViktorvdValk Is that just me, or is the page really down?

Thanks for reporting this problem @dzenanz It's hopefully back online soon. For the time being, you may use the Internet Archive: https://web.archive.org/web/20230204115458/https://elastix.lumc.nl/doxygen/parameter.html

from itkelastix.

Pedro-Filipe avatar Pedro-Filipe commented on June 23, 2024 1

Thank you both for your comments. Really appreciate the support.

How about parameter_map['RandomSeed'] = ['30101983']? In the parameter file that might be (RandomSeed 30101983).

@dzenanz The parameter RandomSeed sounds like an obvious answer to the problem but in practice it doesn't seem to do anything. I found a couple of posts on the SimpleElastix GitHub reporting similar behaviour.

Make SimpleElastix more deterministic by setting RandomSeed #460

multiple SimpleElastix instances/runs ignore RandomSeed in ParameterFile #122


@Pedro-Filipe Thanks for asking! It may be helpful to reset the global ITK random number generator before each registration.

Which version of itk-elastix do you have installed? ITK v5.4rc02 introduces a new function, MersenneTwisterRandomVariateGenerator.ResetNextSeed(), which should be of help. I think it should be available with the latest itk-elastix release.

The idea is to call MersenneTwisterRandomVariateGenerator.ResetNextSeed() before each registration. Please let us know if that does indeed solve the problem!

@N-Dekker I have these versions currently installed:

itk                          5.4rc2
itk-core                     5.4rc2
itk-elastix                  0.19.1
itk-filtering                5.4rc2
itk-io                       5.4rc2
itk-numerics                 5.4rc2
itk-registration             5.4rc2
itk-segmentation             5.4rc2

I have added this line of code before calling each registration:

itk.MersenneTwisterRandomVariateGenerator.ResetNextSeed()

It does reduce significantly the variation, although unfortunately not 100%. The values of the registered images differ after a few decimal places.

from itkelastix.

dzenanz avatar dzenanz commented on June 23, 2024

How about parameter_map['RandomSeed'] = ['30101983']? In the parameter file that might be (RandomSeed 30101983).

from itkelastix.

N-Dekker avatar N-Dekker commented on June 23, 2024

@Pedro-Filipe Thanks for asking! It may be helpful to reset the global ITK random number generator before each registration.

Which version of itk-elastix do you have installed? ITK v5.4rc02 introduces a new function, MersenneTwisterRandomVariateGenerator.ResetNextSeed(), which should be of help. I think it should be available with the latest itk-elastix release.

The idea is to call MersenneTwisterRandomVariateGenerator.ResetNextSeed() before each registration. Please let us know if that does indeed solve the problem!

from itkelastix.

N-Dekker avatar N-Dekker commented on June 23, 2024

@Pedro-Filipe I'm glad to hear that ResetNextSeed() reduces the variation significantly. You might consider to also do a SetSeed (while calling ResetNextSeed() as well), using a fixed constant seed, something like:

itk.MersenneTwisterRandomVariateGenerator.GetInstance().SetSeed(1)

(Not 100% sure about the syntax.) Does that further reduce the variation?

Another cause of variation could be multi-threading. You see, internally, elastix may do some floating point operations in a different order, depending on the order in which the threads process the work units. Mathematically, it should not matter, but the order of those floating point operations might affect the floating point rounding errors. You may eliminate those effects by setting the number of threads to one, globally:

itk.MultiThreaderBase.SetGlobalMaximumNumberOfThreads(1)

Obviously this may slow down the registration process. But it might still be interesting to know if that will totally eliminate all variations... I'm interested to hear what you will find!

from itkelastix.

Pedro-Filipe avatar Pedro-Filipe commented on June 23, 2024

Thanks for the additional suggestions @N-Dekker .

Results

Also using itk.MersenneTwisterRandomVariateGenerator.GetInstance().SetSeed(1)

Syntax seems OK, but didn't seem to have a significant effect.

Reducing threads with itk.MultiThreaderBase.SetGlobalMaximumNumberOfThreads(1)

Slows down registration as expected, but no effect on the randomness. I was sort of expecting this, as I use multithreading with the parameter (ImageSampler "Full") and I get reproducible results.


So at the moment, if I want deterministic results I can use:

  • (ImageSampler "Full") although you get a slower registration even with multithreading.
  • (ImageSampler "Grid") registration faster than full as expected.

from itkelastix.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.