SlicerANTs antsRegistration in Slicer

Hi,

Just made a PR to ExtensionsIndex to add SlicerANTs extension, which implements antsRegistration.

Probably needs some fixes, but it’s currently functional.

This effort is based on the following:

I tried to keep it understandable despite the vast amount of parameters it has. Any feedback is welcome!

I used a json string as a parameter in the parameter node to keep up with this amount of settings. Also, I stored presets as json files so loading them is straightforward. Is this a good practice?

It was mostly based on the SlicerElastix implementation, from which I copied parts of code.

Best

2 Likes

This is great. Do you have it for windows platform too?

yes, it builds, but there’s still work needed to integrate with Slicer ITK

Hi, just tested with latest nightly in win, mac and ubuntu and is working! Thanks @lassoan for the contributions during the PR!

Further work includes:

  • Merging compilation modifications back to ants repo so as to checkout from there.
  • Making the Advanced section more robust (currently could run to some errors with some settings if not familiarised).
  • Adding more presets.

Hope this is helpful

1 Like

Failed! A problem with my software.

win 64

antsCommand standard error:

Traceback (most recent call last):
File “E:/Slicer/Slicer41120210226/OpenExtentions/SlicerANTs-master/antsCommand/antsCommand.py”, line 131, in
process = runAntsCommand(antsExecutable, antsCommand, outputLogPath)
File “E:/Slicer/Slicer41120210226/OpenExtentions/SlicerANTs-master/antsCommand/antsCommand.py”, line 12, in runAntsCommand
executableFilePath = os.path.join(getAntsBinDir(), executableFileName)
File “E:/Slicer/Slicer41120210226/OpenExtentions/SlicerANTs-master/antsCommand/antsCommand.py”, line 55, in getAntsBinDir
raise ValueError(‘ANTs not found’)
ValueError: ANTs not found

hi, doesn’t seem you installed via Extension Manager in latest nightly

Best

I downloaded it from Github,then installed it via developer Tools.

You need to install via Extension Manager from a nightly build (starting today)

1 Like

@simonoxen I tried with the latest build and it seems to work fine, thank you this nice work. It is great to be able to explore the parameters and visualize the outcome in the same place.

Can you consider saving/outputting the actual antsRegistration call somewhere, so that we can use that parameter set directly on with ANTs or ANTsR when we are running a large number of samples programmatically?

@simonoxen The module is intuitive and fast and works very robustly. Thanks a lot for your contribution! It would be great if you could create a short YouTube video that shows a few basic and maybe some more advanced use cases in 1-2 minutes.

@muratmaga you can find the command line argument list that is passed to ants in the application log.

2 Likes

I know but it is always better to write them explicitly to disk (in json or whatever) for posterity. If I close the application, I may loose the parameters (I know the logs exists for a while, but still…)

If you created one or a few files at each execution of ANTS, when those file would be deleted? (you don’t want to end up with potentially hundreds of temporary files if you perform registration many times)

Saving the parameters into the log is nice because the last 10-15 log files are preserved but older ones are cleaned up automatically. You would normally get the parameters right after the successful registration anyway, so it should not be even necessary to dig into the archived log files.

Thanks!

I’ll add this to my to-do.

@muratmaga I didn’t think about it, but the log files seem to be a good solution.

Hi, I made some changes in the implementation of this extension.

  • I made a small contribution to the ANTs project and now I checkout from there.
  • ANTs is built with shared libraries and linked to a new antsRegistrationCLI module.
  • ANTs is patched to communicate CLI progress with Slicer.
  • The CLI modules manages all the I/O making the implementation much cleaner.
  • I also migrated the repo to the netstim organization and made a PR to update this is in the Extension Index.

One question I had is wether shared or static libraries is preferred to build an external project (ANTs in this case). Any comments on this?

Thanks

Often the maintainers of a library has a preference (they mainly test with statically-linked or shared libraries) and if that’s the case then we follow that. If there is no preference then the decision factors include expected binary compatibility issues (if the library is widely used as a shared library in different projects and no name mangling is supported then it is safer to link statically) and binary size (if the library size is big and the project provides many executables then shared libraries can cut down the size very significantly).

Since we only use a single executable and binary compatibility might come up as an issue when Slicer is used in a workflow that already uses ANTs, it might make sense to link statically.

This would be really nice if you could do this. If you wrote a short post about the module (in “Support” category, with “feature” tag added) and included a short video demo/tutorial then we could advertise this further on twitter etc. and the impact of your work would be increased a lot. Thanks again for your contribution!

1 Like