Exception when trying to run Elastix

Dear all,

I am running into the following error when I try to run Elastix:

(Fiji Is Just) ImageJ 2.0.0-rc-71/1.52p; Java 1.8.0_172 [64-bit]; Linux 4.8.0-58-generic; 336MB of 60000MB (<1%)
java.lang.RuntimeException: java.util.concurrent.ExecutionException: java.lang.NullPointerException
	at net.imagej.legacy.LegacyService.runLegacyCompatibleCommand(LegacyService.java:309)
	at net.imagej.legacy.DefaultLegacyHooks.interceptRunPlugIn(DefaultLegacyHooks.java:163)
	at ij.IJ.runPlugIn(IJ.java)
	at ij.Executer.runCommand(Executer.java:137)
	at ij.Executer.run(Executer.java:66)
	at java.lang.Thread.run(Thread.java:748)
Caused by: java.util.concurrent.ExecutionException: java.lang.NullPointerException
	at java.util.concurrent.FutureTask.report(FutureTask.java:122)
	at java.util.concurrent.FutureTask.get(FutureTask.java:192)
	at net.imagej.legacy.LegacyService.runLegacyCompatibleCommand(LegacyService.java:305)
	... 5 more
Caused by: java.lang.NullPointerException
	at de.embl.cba.elastixwrapper.commands.ElastixCommand.getSettings(ElastixCommand.java:174)
	at de.embl.cba.elastixwrapper.commands.ElastixCommand.runElastix(ElastixCommand.java:113)
	at de.embl.cba.elastixwrapper.commands.ElastixCommand.run(ElastixCommand.java:108)
	at org.scijava.command.CommandModule.run(CommandModule.java:199)
	at org.scijava.module.ModuleRunner.run(ModuleRunner.java:168)
	at org.scijava.module.ModuleRunner.call(ModuleRunner.java:127)
	at org.scijava.module.ModuleRunner.call(ModuleRunner.java:66)
	at org.scijava.thread.DefaultThreadService$3.call(DefaultThreadService.java:238)
	at java.util.concurrent.FutureTask.run(FutureTask.java:266)
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
	... 1 more

If I got to the terminal and type:

elastix -h

I do get help.

Does anyone have an idea of what I could be missing?

Hi @Buono,

Thanks for including the error, that’s helpful. Could you also how you ran it (i.e. the values of the parameters?)

Some thing’s I’d double check are:

  1. is elastix is really installed where you expect (where you told the plugin it should be.
  2. Does the output directory exist?

also pinging @Christian_Tischer who’s a good source of help here.


Hi @bogovicj,

Thank you for the fast answer.

The parameters:

1.Yes, it is written “ilastix” for the directory folder. Old typo.
2.All folders in the menu exist. Including the “Working directory”


1 Like



Just a guess, but could you try specifying a Transformation output file?

The fact that you’re getting a NullPointer from line 174 makes this seem like it could be the cause.


1 Like

And it works!
Specifying a Transformation output file did the trick!

Now for a follow up:

  1. Can it work with time series?
  2. Can I provide it with an ROI to use only an area of the image for the registration? Is that what “fixed image mask” is for? How do I use it?

Thank you again!

1 Like


Do you mean to register time points to each other?

Yes, and you’re exactly right, though you may need to explicitly convert your ROI to a binary mask and write it to file.


Yes. At this point I am converting my time frames into channels.

Took me a while to figure out. What I am now doing is creating a z-stack of the exact same dimensions as my fixed image but with a white cube in the region I want used as a reference and everything else black.

The results are not perfect, specially in translation (I’m using Euler), but it is certainly doing something.

1 Like

Exactly! That’s the way to do it.
I have to work on throwing more informative error messages!
To improve the registration you can try increasing the Number of iterations or specify a less rigid transformation, e.g. Affine. Some screenshots of your images before registration would help to provide you more guidance.

1 Like

Thanks! I will try it further. But I now believe that the problem is that the data is just two different between time points so there is little to be matched between the stacks to properly align them.

If you provide example data for download I am happy to have a look for you as well.