Ilastik FIJI Macro Issues

Hi all,

I currently have several hundred oib files which I need to convert to hdf5 files for analysis in Ilastik. I used bioformats command line tools to convert the images into tiff (because the bio-formats plugin for imagej cannot run in headless mode).

I am trying to run the following macro from the command line:

//**Define directories where data will be located and where results will be stored
dataDir = “E:/Omar/BIM4009-Honors-Project/Raw-Data-tiff/”;
exportDir = “E:/Omar/BIM4009-Honors-Project/Raw-Data-h5”;

//**Retrieve files in data directory
dataList = getFileList(dataDir);

//**Read file name and path for each file in data directory
for (i = 0; i < dataList.length; i++) {
//**dataName: Path to data file as in E:/.tiff
dataName = dataDir + dataList[i];
//**oibName: Path to data file as in "
.tiff"
oibName = dataList[i];
//print(dataName);
//print(oibName);
//**exportName: Path to new file (to be created by conversion) as in E:/*.h5
exportName = replace(dataName,“tiff”,“h5”);
// print(exportName);
//**ImageJ runs its built-in funcitons with a long string being interpreted as the arguments. Each argument MUST be seperated by a space
open(dataName);
importArgs = “select=”+exportName+" exportpath="+exportName+" datasetname=data compressionlevel=0 input=["+dataName+"]";
run(“Export HDF5”, importArgs);
wait(10000);
close(dataName);

}

However whenever I run the command "ImageJ-win64.exe --headless --console -macro “path\to\macro.ijm”: I get the following error:

[ERROR] Module threw exception
java.lang.RuntimeException: Macro canceled
at ij.macro.Interpreter.error(Interpreter.java:1291)
at ij.macro.Interpreter.abort(Interpreter.java:1948)
at ij.IJ.error(IJ.java:677)
at ij.IJ.error(IJ.java:665)
at org.ilastik.ilastik4ij.ui.IlastikExportCommand.run(IlastikExportCommand.java:52)
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.lambda$wrap$2(DefaultThreadService.java:228)
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)
at java.lang.Thread.run(Thread.java:748)
java.lang.RuntimeException: java.util.concurrent.ExecutionException: java.lang.RuntimeException: Macro canceled
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 ij.IJ.run(IJ.java:312)
at ij.IJ.run(IJ.java:323)
at ij.macro.Functions.doRun(Functions.java:624)
at ij.macro.Functions.doFunction(Functions.java:97)
at ij.macro.Interpreter.doStatement(Interpreter.java:275)
at ij.macro.Interpreter.doBlock(Interpreter.java:671)
at ij.macro.Interpreter.doStatement(Interpreter.java:320)
at ij.macro.Interpreter.doFor(Interpreter.java:593)
at ij.macro.Interpreter.doStatement(Interpreter.java:302)
at ij.macro.Interpreter.doStatements(Interpreter.java:261)
at ij.macro.Interpreter.run(Interpreter.java:157)
at ij.macro.Interpreter.run(Interpreter.java:91)
at ij.macro.Interpreter.run(Interpreter.java:102)
at ij.plugin.Macro_Runner.runMacro(Macro_Runner.java:161)
at ij.plugin.Macro_Runner.runMacroFile(Macro_Runner.java:145)
at ij.IJ.runMacroFile(IJ.java:160)
at net.imagej.legacy.IJ1Helper$4.call(IJ1Helper.java:1125)
at net.imagej.legacy.IJ1Helper$4.call(IJ1Helper.java:1121)
at net.imagej.legacy.IJ1Helper.runMacroFriendly(IJ1Helper.java:1055)
at net.imagej.legacy.IJ1Helper.runMacroFile(IJ1Helper.java:1121)
at net.imagej.legacy.LegacyCommandline$Macro.handle(LegacyCommandline.java:187)
at org.scijava.console.DefaultConsoleService.processArgs(DefaultConsoleService.java:102)
at org.scijava.AbstractGateway.launch(AbstractGateway.java:97)
at net.imagej.Main.main(Main.java:55)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at net.imagej.launcher.ClassLauncher.launch(ClassLauncher.java:279)
at net.imagej.launcher.ClassLauncher.run(ClassLauncher.java:186)
at net.imagej.launcher.ClassLauncher.main(ClassLauncher.java:77)
Caused by: java.util.concurrent.ExecutionException: java.lang.RuntimeException: Macro canceled
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)
… 35 more
Caused by: java.lang.RuntimeException: Macro canceled
at ij.macro.Interpreter.error(Interpreter.java:1291)
at ij.macro.Interpreter.abort(Interpreter.java:1948)
at ij.IJ.error(IJ.java:677)
at ij.IJ.error(IJ.java:665)
at org.ilastik.ilastik4ij.ui.IlastikExportCommand.run(IlastikExportCommand.java:52)
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.lambda$wrap$2(DefaultThreadService.java:228)
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)
at java.lang.Thread.run(Thread.java:748)

[INFO] M9-Section-12-LVH-MN-2.tiff = net.imagej.display.DefaultDatasetView@3054bfca
[INFO] P25-LC-slide2-s7-n2-4.tif = net.imagej.display.DefaultDatasetView@12bec2bd

The weirdest thing is that the first conversion works perfectly! I thought based on the wording of the error that adding a line causing the macro to wait between conversions would help but it hasn’t.

The same error appears if I try to run the macro from the ImageJ script editor. I am currently using the latest stable version of FIJI with the ilastik plugin website followed.

Any help would be appreciated!

Hi @Omar,

I’m really not a imagej macro export, but one possible issue might be, that the output path is not completely specified. By that I mean that you never use exportDir. But other than that, i find it really puzzling. can you try printing the importArgs?

Hello Everyone,

I m hesitating between opening a new thread or keep going on this one but since it’s relative to using Ilastik with Macro ImageJ Langage. I will shout out my issue here…

After reading and realising that running a pixel segmentation with a pretrained Ilastik project needs the use of hdf5 file. Using the export seems to be the first step.

First of all, simply running the plug-in Export HDF5 leads to that list of errors at the 1st try…

(Fiji Is Just) ImageJ 2.0.0-rc-69/1.52p; Java 1.8.0_172 [64-bit]; Windows 10 10.0; 130MB of 24405MB (<1%)
java.lang.RuntimeException: java.util.concurrent.ExecutionException: java.lang.AbstractMethodError: Method net/imglib2/img/VirtualStackAdapter$ImagePlusLoader$$Lambda$100.extract(Ljava/lang/Object;)Ljava/lang/Object; is abstract
at net.imagej.legacy.LegacyService.runLegacyCompatibleCommand(LegacyService.java:307)
at net.imagej.legacy.DefaultLegacyHooks.interceptRunPlugIn(DefaultLegacyHooks.java:166)
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)
Cused by: java.util.concurrent.ExecutionException: java.lang.AbstractMethodError: Method net/imglib2/img/VirtualStackAdapter$ImagePlusLoader$$Lambda$100.extract(Ljava/lang/Object;)Ljava/lang/Object; is abstract

The 2nd try seems to work better, I got
image
then
image

And well, something is happening as the vent of the computer are buzzing but… nothing is happening…

Thank you for your assistance…

by the way, I updated Fiji to the last version and the ilastik plug-in as well.

Hi @Bertrand_BIA,

welcome to the Forum! :slight_smile: and to this nice long thread.

This is not necessary anymore. If you can load your data in into ilastik and the axes are interpreted correctly, you can go on.
However, if you want to be 100% sure, use the hdf5 exported from the ilastik pluging. I don’t think the error you are showing here was produced by it. It should be Plugins -> ilastik -> export HDF5.

Thanks for your reply !

Finally… I manage to make it work !

For the story and I am aware it’s kind of fantastic one…

I finally installed a new version of Fiji with only Ilastik plugins thinking (maybe there is something corrupted in my regular Fiji )
I ran a pxl Classification using the plugin : it works :smiley:
I ran a pxl Classification using the macro commande line : it works :smiley:

I close Fiji

I ran again my first Fiji instance
I ran the pxl Classification using the plugin and… it works…

Mystic… Something got finally right in place…

My problem is solved…Hurray !

Hi @Bertrand_BIA,

thank you very much for your persistence on that. Just recently I heard reports by another user who also found that some plugins are clashing with the ilastik one. It was a pretty large list, so I didn’t have the chance to investigate this properly.
But very cool that you have it working for you :slight_smile: