Using SlicerElastix binaries in the terminal

Operating system: Ubuntu
Slicer version: 4.10
Expected behavior: work
Actual behavior: does not work

Based on this and this discussions, I tried to use:

  .config/NA-MIC/Extensions-27501/SlicerElastix/lib/Slicer-4.10/elastix  

but I got this error:

  .config/NA-MIC/Extensions-27501/SlicerElastix/lib/Slicer-4.10/elastix: error while loading shared libraries: libi2d.so.13: cannot open shared object file: No such file or directory

I know I can just call some function but I will have to modify many things in my code. Is there another way to call it from the terminal?

Can you start Elastix bundled with the latest nightly version? Does Elastix work with the latest nightly build when launched useing “General registration (Elastix)” module? Next steps depend on the answer to these questions.

I got same error above using nightly build (just downloaded it) . Elastix works in Slicer but does not work from the terminal. It would be nice if it runs from the terminal even using Slicer --launch option.

I did more testing, here is the result

Using nightly build:

  • I can run elastix in the python interactor, I guess it should work also in the plugin.
  • I can not run elastix in Ubuntu terminal but I think this should not be a problem as the above work.

Using 4.10:

  • I can not run elastix in Ubuntu terminal
  • In Slicer, the plugin itself is not stable, sometimes the testing works and sometimes not.

I did more testing. SlicerElastix does not work after I run SliacerCochlea. If I restart Slicer and run SlicerElastix, it works.

What could be the problem in SlicerCochlea code???

Problem solved! I disabled these lines

#os.environ['LD_LIBRARY_PATH'] = self.vissimPath + "/sw/elastix-4.9.0/lib"
#os.environ['LD_LIBRARY_PATH'] = self.vissimPath + "/sw/elastix-4.9.0/lib"

Everything works now in Slicer. Only the terminal problem to be solved.

1 Like

Since some plugins affect other plugins negatively, something should be done to avoid this as this makes it difficult to find the source of the problem if it is from another extension.

I don’t think there are any issues or limitations here, you just need to clearly distinguish between binaries built by Slicer factory machines (and included in extensions); and third-party binaries present on the system. Third-party binaries can be included in extensions, but this should be avoided.

Running executables bundled in a Slicer extension:

There is no interference between extensions if you let Slicer factory build all libraries (you must not bundle binaries created elsewhere). If there are libraries or executable used by multiple extensions (for example Elastix is used by several extensions) then you need to make sure that one extension builds the shared library and all other extensions depend on that. See how SequenceRegistration extension uses SlicerElastix for an example.

In the very rare case that different extensions use must incompatible versions of the same libraries, you can statically link the old version of the library to the extension that requires the old library version. We have 100+ extensions and I think this happened only once.

Running third-party executables or scripts installed on the system (not bundled with Slicer):

If you want to start third-party programs (executables, Python scripts, etc.) from Slicer, then you usually need to use startup environment as described here.

Thanks for the detailed info. I don’t understand the last part. Could you please provide an example of how to run the elastix binary in the terminal (not in python).

Binaries to run elastix in the terminal can be downloaded from the elastix GitHub release page.

1 Like

Would you run it manually by typing commands on the terminal? Or using a bash script? Don’t you want to use it from your Python scripted module?

Anyway, you can use third-party libraries on your system as @thewtex suggested above (completely independently from Slicer), or run any Slicer executables using the launcher, for example:

"c:\Program Files\Slicer 4.10.0\Slicer.exe" --launch c:\Users\andra\AppData\Roaming\NA-MIC\Extensions-27501\SlicerElastix\lib\Slicer-4.10\elastix.exe --help >>output.txt

Binaries to run elastix in the terminal can be

I needed the one from Slicer to debug my module.

or run any Slicer executables using the launcher
Slicer --launch executable

That is exactly what I needed, thanks a lot.

1 Like