Using ilastik Fiji plugin within a macro

Hi,
I’m writing a macro for Fiji that is supposed to use ilastik pixel classifier to process a bunch of images. I’m using the ilastik plugin to first convert the data to hdf5 (using “export” within ilastik plugin) and than import the data (using “import” option). However I did not manage to get it working within a macro that is supposed to process all the images in a certain folder because user interaction is required to click on various prompts the popup during the macro execution. For example when I try to import the data using the following code:

dir1 = getDirectory("Where is the data?");
list = getFileList(dir1);
setBatchMode(true);
	for (i=0; i<list.length; i++) 
		{
 		filename = dir1 + list[i]; 			
run("Import HDF5", "hdf5filename=["+filename+"]");
}

I’m getting prompts after each image where I need to click “load raw” or “load and apply LUT”. How can I automate this?
Similar is true when I want to export as hdf5 using the “export” function in ilastik plugin

dir1 = getDirectory("Where is the data?");
dir2 = getDirectory("Choose an output directory");
list = getFileList(dir1);
setBatchMode(true);
	for (i=0; i<list.length; i++) 
		{
 		filename = dir1 + list[i];
 		name = list[i];
 			if (endsWith(filename, "czi")) {
 				open(filename);
 				t = getTitle();
 				t = replace(t, ".czi", ".h5");
 				run("Export HDF5", "hdf5filename=["+dir2 + t +"] input=&name compressionlevel=0");
 					}
 			}

A “warning” (something about being careful when saving the hdf5 since it can mess up the axes…) pops up after every image where I need to click “OK” to get the macro going. Is there a way to suppress these popups or give them some default state?
thanks!

1 Like

Hi @metavibor,

thanks for reporting the issue. Improving the ilastik Fiji plugin to support headless processing has been long overdue and we have finally managed to push it out together with the latest release of the plugin (v1.3.0). Please update the plugin to the latest version and enjoy batch processing with ilastik plugin commands.
Just as an example here’s a Java macro which should accomplish exactly what you’re looking for:

import ij.*;
import ij.process.*;
import ij.gui.*;
import java.awt.*;
import ij.plugin.*;
import java.io.File;

public class My_Plugin implements PlugIn {
	public void run(String arg) {
		File dir = new File("<DATASET_DIR>");
		String inputDataset="data";
		String outputDataset="exported_data";
		String ilastikProject = "<ILASTIK_PROJECT_PATH>";
		int i = 0;
		for(File file : dir.listFiles((d, name) -> name.endsWith(".h5"))) {
			IJ.run("Import HDF5", String.format("select=%s datasetname=%s axisorder=tzyxc", file.getAbsolutePath(), inputDataset));
			IJ.run(IJ.getImage(), "Run Pixel Classification Prediction", String.format("saveonly=false projectfilename=%s chosenoutputtype=Probabilities", ilastikProject));
			IJ.run(IJ.getImage(), "Export HDF5", String.format("select=%s/output%d.h5 datasetname=%s compressionlevel=0", file.getParent(), ++i, outputDataset));
		}
	}
}

Cheers!
Adrian

2 Likes

works like a charm now
thank you!

1 Like

Thanks for this plugin!

However, it doesn’t work in may case, I got some this error:

[INFO] Dumping input image to temporary file C:\Users\chiarutt\AppData\Local\Temp\ilastik4j2252073625513654854_raw.h5
[INFO] Exporting image of shape (1, 1, 1040, 1388, 1). Axis order: 'TZYXC'
[INFO] Saving as 'uint16'. Compression level: 0
[INFO] Running ilastik headless command:
[INFO] [C:\Program Files\ilastik-1.3.2\ilastik.exe, --headless, --project=Z:\public\SandrineIsaac\WorkFlow_v1\MyProject-PixelClassification.ilp, --output_filename_format=C:\Users\chiarutt\AppData\Local\Temp\ilastik4j1434989950357268814_outProbabilities.h5, --output_format=hdf5, --output_axis_order=tzyxc, C:\Users\chiarutt\AppData\Local\Temp\ilastik4j2252073625513654854_raw.h5]
[INFO] INFO lazyflow.operators.filterOperators: Using fast filters.
[ERROR] WARNING __init__.py(11): UserWarning: init: Could not import tiktorch classifier
[INFO] INFO ilastik_main: Starting ilastik from "C:\Program Files\ilastik-1.3.2".
[INFO] Starting ilastik from "C:\Program Files\ilastik-1.3.2".
[INFO] INFO ilastik_main: Configuring lazyflow RAM limit to 4.0GiB
[INFO] INFO lazyflow.utility.memory: Available memory set to 4.0GiB
[ERROR] WARNING 2019-03-01 16:42:07,255 opConservationTracking 7276 8100 Could not find any ILP solver
[ERROR] WARNING 2019-03-01 16:42:07,279 opStructuredTracking 7276 8100 Could not find any ILP solver
[ERROR] WARNING 2019-03-01 16:42:07,283 structuredTrackingWorkflow 7276 8100 Could not find any learning solver. Tracking will use flow-based solver (DPCT). Learning for tracking will be disabled!
[INFO] INFO ilastik.shell.projectManager: Opening Project: Z:/public/SandrineIsaac/WorkFlow_v1/MyProject-PixelClassification.ilp
[ERROR] WARNING stype.py(181): UserWarning: ArrayLike.isCompatible: FIXME here
[INFO] INFO ilastik.workflows.pixelClassification.pixelClassificationWorkflow: Beginning Batch Processing
[ERROR] ERROR 2019-03-01 16:42:11,841 log_exception 7276 8100 Traceback (most recent call last):
[ERROR]   File "C:\Program Files\ilastik-1.3.2\ilastik-meta\ilastik\ilastik\shell\projectManager.py", line 441, in _loadProject
[ERROR]     self.workflow.onProjectLoaded( self )
[ERROR]   File "C:\Program Files\ilastik-1.3.2\ilastik-meta\ilastik\ilastik\workflows\pixelClassification\pixelClassificationWorkflow.py", line 337, in onProjectLoaded
[ERROR]     self.batchProcessingApplet.run_export_from_parsed_args(self._batch_input_args)
[ERROR]   File "C:\Program Files\ilastik-1.3.2\ilastik-meta\ilastik\ilastik\applets\batchProcessing\batchProcessingApplet.py", line 66, in run_export_from_parsed_args
[ERROR]     return self.run_export(role_path_dict, parsed_args.input_axes, sequence_axis=parsed_args.stack_along)
[ERROR]   File "C:\Program Files\ilastik-1.3.2\ilastik-meta\ilastik\ilastik\applets\batchProcessing\batchProcessingApplet.py", line 131, in run_export
[ERROR]     export_to_array=export_to_array)
[ERROR]   File "C:\Program Files\ilastik-1.3.2\ilastik-meta\ilastik\ilastik\applets\batchProcessing\batchProcessingApplet.py", line 239, in _run_export_with_empty_batch_lane
[ERROR]     opDataSelectionBatchLaneView.DatasetGroup[role_index].setValue(info)
[ERROR]   File "C:\Program Files\ilastik-1.3.2\ilastik-meta\lazyflow\lazyflow\slot.py", line 118, in call_in_setup_context
[ERROR]     return func(self, *args, **kwargs)
[ERROR]   File "C:\Program Files\ilastik-1.3.2\ilastik-meta\lazyflow\lazyflow\slot.py", line 1232, in setValue
[ERROR]     self._changed()
[ERROR]   File "C:\Program Files\ilastik-1.3.2\ilastik-meta\lazyflow\lazyflow\slot.py", line 1433, in _changed
[ERROR]     c._changed()
[ERROR]   File "C:\Program Files\ilastik-1.3.2\ilastik-meta\lazyflow\lazyflow\slot.py", line 1433, in _changed
[ERROR]     c._changed()
[ERROR]   File "C:\Program Files\ilastik-1.3.2\ilastik-meta\lazyflow\lazyflow\slot.py", line 1433, in _changed
[ERROR]     c._changed()
[ERROR]   File "C:\Program Files\ilastik-1.3.2\ilastik-meta\lazyflow\lazyflow\slot.py", line 1439, in _changed
[ERROR]     self._configureOperator(self)
[ERROR]   File "C:\Program Files\ilastik-1.3.2\ilastik-meta\lazyflow\lazyflow\slot.py", line 1453, in _configureOperator
[ERROR]     self.operator._setupOutputs()
[ERROR]   File "C:\Program Files\ilastik-1.3.2\ilastik-meta\lazyflow\lazyflow\operator.py", line 455, in _setupOutputs
[ERROR]     self.setupOutputs()
[ERROR]   File "C:\Program Files\ilastik-1.3.2\ilastik-meta\ilastik\ilastik\applets\dataSelection\opDataSelection.py", line 410, in setupOutputs
[ERROR]     len(providerSlot.meta.shape)))
[ERROR] Exception: Your dataset's provided axistags (yx) do not have the correct dimensionality for your dataset, which has 5 dimensions.
[ERROR] 
[ERROR] ERROR 2019-03-01 16:42:11,841 log_exception 7276 8100 Project could not be loaded due to the exception shown above.
[ERROR] Aborting Project Open Action
[ERROR] ERROR 2019-03-01 16:42:12,749 excepthooks 7276 8100 Unhandled exception in thread: 'MainThread'
[ERROR] ERROR 2019-03-01 16:42:12,754 excepthooks 7276 8100 Traceback (most recent call last):
[ERROR]   File "C:\Program Files\ilastik-1.3.2\ilastik-meta\ilastik\ilastik.py", line 123, in <module>
[ERROR]     main()
[ERROR]   File "C:\Program Files\ilastik-1.3.2\ilastik-meta\ilastik\ilastik.py", line 108, in main
[ERROR]     hShell = ilastik_main.main(parsed_args, workflow_cmdline_args)
[ERROR]   File "C:\Program Files\ilastik-1.3.2\ilastik-meta\ilastik\ilastik_main.py", line 138, in main
[ERROR]     f(shell)
[ERROR]   File "C:\Program Files\ilastik-1.3.2\ilastik-meta\ilastik\ilastik_main.py", line 373, in loadProject
[ERROR]     shell.openProjectFile(path, parsed_args.readonly)
[ERROR]   File "C:\Program Files\ilastik-1.3.2\ilastik-meta\ilastik\ilastik\shell\headless\headlessShell.py", line 117, in openProjectFile
[ERROR]     self.projectManager._loadProject(hdf5File, projectFilePath, readOnly)
[ERROR]   File "C:\Program Files\ilastik-1.3.2\ilastik-meta\lazyflow\lazyflow\utility\timer.py", line 146, in wrapper
[ERROR]     return func(*args, **kwargs)
[ERROR]   File "C:\Program Files\ilastik-1.3.2\ilastik-meta\ilastik\ilastik\shell\projectManager.py", line 441, in _loadProject
[ERROR]     self.workflow.onProjectLoaded( self )
[ERROR]   File "C:\Program Files\ilastik-1.3.2\ilastik-meta\ilastik\ilastik\workflows\pixelClassification\pixelClassificationWorkflow.py", line 337, in onProjectLoaded
[ERROR]     self.batchProcessingApplet.run_export_from_parsed_args(self._batch_input_args)
[ERROR]   File "C:\Program Files\ilastik-1.3.2\ilastik-meta\ilastik\ilastik\applets\batchProcessing\batchProcessingApplet.py", line 66, in run_export_from_parsed_args
[ERROR]     return self.run_export(role_path_dict, parsed_args.input_axes, sequence_axis=parsed_args.stack_along)
[ERROR]   File "C:\Program Files\ilastik-1.3.2\ilastik-meta\ilastik\ilastik\applets\batchProcessing\batchProcessingApplet.py", line 131, in run_export
[ERROR]     export_to_array=export_to_array)
[ERROR]   File "C:\Program Files\ilastik-1.3.2\ilastik-meta\ilastik\ilastik\applets\batchProcessing\batchProcessingApplet.py", line 239, in _run_export_with_empty_batch_lane
[ERROR]     opDataSelectionBatchLaneView.DatasetGroup[role_index].setValue(info)
[ERROR]   File "C:\Program Files\ilastik-1.3.2\ilastik-meta\lazyflow\lazyflow\slot.py", line 118, in call_in_setup_context
[ERROR]     return func(self, *args, **kwargs)
[ERROR]   File "C:\Program Files\ilastik-1.3.2\ilastik-meta\lazyflow\lazyflow\slot.py", line 1232, in setValue
[ERROR]     self._changed()
[ERROR]   File "C:\Program Files\ilastik-1.3.2\ilastik-meta\lazyflow\lazyflow\slot.py", line 1433, in _changed
[ERROR]     c._changed()
[ERROR]   File "C:\Program Files\ilastik-1.3.2\ilastik-meta\lazyflow\lazyflow\slot.py", line 1433, in _changed
[ERROR]     c._changed()
[ERROR]   File "C:\Program Files\ilastik-1.3.2\ilastik-meta\lazyflow\lazyflow\slot.py", line 1433, in _changed
[ERROR]     c._changed()
[ERROR]   File "C:\Program Files\ilastik-1.3.2\ilastik-meta\lazyflow\lazyflow\slot.py", line 1439, in _changed
[ERROR]     self._configureOperator(self)
[ERROR]   File "C:\Program Files\ilastik-1.3.2\ilastik-meta\lazyflow\lazyflow\slot.py", line 1453, in _configureOperator
[ERROR]     self.operator._setupOutputs()
[ERROR]   File "C:\Program Files\ilastik-1.3.2\ilastik-meta\lazyflow\lazyflow\operator.py", line 455, in _setupOutputs
[ERROR]     self.setupOutputs()
[ERROR]   File "C:\Program Files\ilastik-1.3.2\ilastik-meta\ilastik\ilastik\applets\dataSelection\opDataSelection.py", line 410, in setupOutputs
[ERROR]     len(providerSlot.meta.shape)))
[ERROR] Exception: Your dataset's provided axistags (yx) do not have the correct dimensionality for your dataset, which has 5 dimensions.
[ERROR] 
[ERROR] ilastik error: 
[ERROR] The operation completed successfully.
[ERROR] 
[ERROR] 
[INFO] ilastik finished successfully!
[INFO] Reading resulting Probabilities from C:\Users\chiarutt\AppData\Local\Temp\ilastik4j1434989950357268814_outProbabilities.h5
[WARNING] something went wrong during processing ilastik pixel classification
[INFO] Cleaning up

Do you have any idea how to solve this ? I can give you the test image and ilastik project file if you wish.

2 Likes
[ERROR] 
[ERROR] ilastik error: 
[ERROR] The operation completed successfully.
[ERROR] 
[ERROR] 
[INFO] ilastik finished successfully!

:roll_eyes: what an error message…

Hey @NicoKiaru,

this is a very counter-intuitive one.
is it safe to assume that you did not train your project on a file exported from Fiji via the export plugin? The problem is, that the plugin always exports 5D data (time z y x channel) and the check whether datasets can be processed with a trained project isn’t smart enough to ignore singleton axes.
So right now, I would say that the only way to achieve what you want to do is to export the training data with the fiji ilastik plugin, and then train your tracking project.

I opened an issue about it on our github repo: https://github.com/ilastik/ilastik/issues/1970

3 Likes

Hi @ilastik_team,

I have a folder full of nice 3D segmentation masks in HDF5 format from the batch processing mode in the Ilastik standalone. Now I want to further process and analyse those files in FIJI, so it would be fantastic to be able to batch-import them within a FIJI-macro. But when executing my macro I’m still having the same issue the original poster has had, after each file it’s prompting user interaction and I need to select each .h5 file manually, and that’s the opposite of what I want the script to do.

I’m essentially using the same code as @metavibor:

dir1 = getDirectory("Where is the data?");
list = getFileList(dir1);
setBatchMode(true);
	for (i=0; i<list.length; i++) 
		{
 		filename = dir1 + list[i]; 			
run("Import HDF5", "hdf5filename=["+filename+"]");
}

Any idea what could be wrong? Thanks a lot!

Hi @TobiasKletter,

looks like the macro you’re using is incorrect. Please have a look at the README of ilastik-Fiji plugin, in particular this section: https://github.com/ilastik/ilastik4ij#batch-processing.

For you the relevant section of the script should be only:

dataDir = "<DATASET_DIR>";
fileList = getFileList(dataDir);
for (i = 0; i < fileList.length; i++) {
	// import image from the H5
	fileName = dataDir + fileList[i];	
	importArgs = "select=" + fileName + " datasetname=" + inputDataset + " axisorder=" + axisOrder; 			
	run("Import HDF5", importArgs);

This should do the trick. If it doesn’t please let us know.

Best,
Adrian

2 Likes

Hi @wolny,

thanks a lot, that indeed did the trick!

Cheers,
Tobias

1 Like

Hi,
I have been trying to use this code to create a macro to batch process my segmentations in Fiji. However I keep getting the error that there is an undefine variable in the following line:

importArgs = “select=” + fileName + " datasetname=" + inputDataset + " axisorder=" + axisOrder;

The full code I have been using is the following:

#@ File (label = "Input directory", style = "directory") input
#@ File (label = "Output directory", style = "directory") output
#@ String (label = "File suffix", value = ".h5") suffix

processFolder(input);

// function to scan folders/subfolders/files to find files with correct suffix
function processFolder(input) {
	list = getFileList(input);
	list = Array.sort(list);
	for (i = 0; i < list.length; i++) {
		if(File.isDirectory(input + File.separator + list[i]))
			processFolder(input + File.separator + list[i]);
		if(endsWith(list[i], suffix))
			processFile(input, output, list[i]);
	}
}

axisOrder = "yxc";

function processFile(input, output, file) {
	fileList = getFileList(input);
	for (i = 0; i < fileList.length; i++) {
		// import image from the H5
		fileName = input + fileList[i];	
		importArgs = "select=" + fileName + " datasetname=" + inputDataset + " axisorder=" + axisOrder;		
		run("Import HDF5", importArgs);
		setAutoThreshold("Default dark no-reset");
		//run("Threshold...");
		setThreshold(2, 255);
		//setThreshold(2, 255);
		setOption("BlackBackground", true);
		run("Convert to Mask");
		run("Create Selection");
		run("Measure");
}

Not sure what I am missing, so any help is appreciated. I have never made macros before, so please be easy on me :wink:

Does it work with .tiff files, instead of h5?
Thank you

Hi @FlorianH,

I don’t see inputDataset variable to be defined in your macro. Please set it accordingly to your h5 content and try again.

Hey @mmvpgs,

ilastik Fiji plugin import/export functionality works only with h5 files. You could convert the tiff files to h5 using our plugin though, see https://github.com/ilastik/ilastik4ij#export.

Best,
Adrian

I had defined the inputDataset variable as input, but I somehow didn’t copy that here?

Still not sure what was wrong, but I found a workaround exporting as .tiff from ilastik using a slightly different script than what I posted here. Thanks for the reply anyway!

Hi everyone,

My first post in the image.sc forum ! (even if I read you many times with all my macro problems).

So after many days alone and two days at two people try to read every post many times, we can’t solve our batch macro Ilsatik h5 import. And also It works with no problem with the plug in interface.

We tried to find the error that could explain the “no image open” bug windows (see below) :
change the file name
change the trailing slash \ with /
modify the string InputDataset (we don’t understand the “data” string)

Could someone help us to understand what goes wrong in it ?

Thanks for your help :wink:

\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\

here it s the macro written in Fiji with imageJ macro language :

// select input and output directories

dir = getDirectory("Select the folder you want to treat..");
dataDir = dir;
fileList = getFileList(dataDir);
pathSave =  getDirectory("Select the folder you want to save the TIFF");

// Ilastik Args
inputDataset = "data";
axisOrder = "tzyxc";

// let s start 
for (i = 0; i < fileList.length; i++) 
{
	// import image from the H5
	fileName = dataDir + fileList[i];	
	importArgs = "select=" + fileName + " datasetname=" + inputDataset + " axisorder=" + axisOrder;		
	run("Import HDF5", importArgs);

// save as tiff
	name = File.getName(fileName);
	saveAs("Tiff", pathSave+name);
	close();
}

\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\

the macro stop with a window with that message :
no image open

\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\

then, the Console message :

[ERROR] Module threw exception
ncsa.hdf.hdf5lib.exceptions.HDF5FileNotFoundException: Path does not exit. (C:\Users\PIC-SFR_Necker\Desktop\Ilastik)
	at ch.systemsx.cisd.hdf5.HDF5BaseReader.openFile(HDF5BaseReader.java:194)
	at ch.systemsx.cisd.hdf5.HDF5BaseReader.<init>(HDF5BaseReader.java:147)
	at ch.systemsx.cisd.hdf5.HDF5BaseReader.<init>(HDF5BaseReader.java:126)
	at ch.systemsx.cisd.hdf5.HDF5ReaderConfigurator.reader(HDF5ReaderConfigurator.java:86)
	at ch.systemsx.cisd.hdf5.HDF5FactoryProvider$HDF5Factory.openForReading(HDF5FactoryProvider.java:54)
	at ch.systemsx.cisd.hdf5.HDF5Factory.openForReading(HDF5Factory.java:64)
	at org.ilastik.ilastik4ij.IlastikImport.run(IlastikImport.java:46)
	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(Unknown Source)
	at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
	at java.lang.Thread.run(Unknown Source)
cloooose

\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\

then the Exception windows message :

(Fiji Is Just) ImageJ 2.0.0-rc-69/1.52p; Java 1.8.0_201 [64-bit]; Windows 7 6.1; 400MB of 115000MB (<1%)
 
java.lang.RuntimeException: java.util.concurrent.ExecutionException: ncsa.hdf.hdf5lib.exceptions.HDF5FileNotFoundException: Path does not exit. (C:\Users\PIC-SFR_Necker\Desktop\Ilastik)
	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.IJ.runMacro(IJ.java:148)
	at ij.IJ.runMacro(IJ.java:137)
	at net.imagej.legacy.IJ1Helper$3.call(IJ1Helper.java:1108)
	at net.imagej.legacy.IJ1Helper$3.call(IJ1Helper.java:1104)
	at net.imagej.legacy.IJ1Helper.runMacroFriendly(IJ1Helper.java:1055)
	at net.imagej.legacy.IJ1Helper.runMacro(IJ1Helper.java:1104)
	at net.imagej.legacy.plugin.IJ1MacroEngine.eval(IJ1MacroEngine.java:147)
	at org.scijava.script.ScriptModule.run(ScriptModule.java:160)
	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(Unknown Source)
	at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
	at java.lang.Thread.run(Unknown Source)
Caused by: java.util.concurrent.ExecutionException: ncsa.hdf.hdf5lib.exceptions.HDF5FileNotFoundException: Path does not exit. (C:\Users\PIC-SFR_Necker\Desktop\Ilastik)
	at java.util.concurrent.FutureTask.report(Unknown Source)
	at java.util.concurrent.FutureTask.get(Unknown Source)
	at net.imagej.legacy.LegacyService.runLegacyCompatibleCommand(LegacyService.java:305)
	... 34 more
Caused by: ncsa.hdf.hdf5lib.exceptions.HDF5FileNotFoundException: Path does not exit. (C:\Users\PIC-SFR_Necker\Desktop\Ilastik)
	at ch.systemsx.cisd.hdf5.HDF5BaseReader.openFile(HDF5BaseReader.java:194)
	at ch.systemsx.cisd.hdf5.HDF5BaseReader.<init>(HDF5BaseReader.java:147)
	at ch.systemsx.cisd.hdf5.HDF5BaseReader.<init>(HDF5BaseReader.java:126)
	at ch.systemsx.cisd.hdf5.HDF5ReaderConfigurator.reader(HDF5ReaderConfigurator.java:86)
	at ch.systemsx.cisd.hdf5.HDF5FactoryProvider$HDF5Factory.openForReading(HDF5FactoryProvider.java:54)
	at ch.systemsx.cisd.hdf5.HDF5Factory.openForReading(HDF5Factory.java:64)
	at org.ilastik.ilastik4ij.IlastikImport.run(IlastikImport.java:46)
	at org.scijava.command.CommandModule.run(CommandModule.java:199)
	... 8 more

Hi @NicoPIC,

I hope there is nothing wrong with the ilastik imagej plugin, so lets see :slight_smile:

A few pointers:

  • the error seems to imply that the file you are trying to open (C:\Users\PIC-SFR_Necker\Desktop\Ilastik) does not exit. This looks more like a folder. Can you verify, that the fileName variable has the correct value? I would probably print it out to be sure. And then go from there. It might also be useful to print the importArgs.
  • the inputDataset refers to the name (or internal path) of the data in the file. When you don’t modify it in ilastik, (and the file was produced by ilastik) it will be “exported_data”. You can set it in ilastik in the export settings.

Thanks @k-dominik for your reply,

Yes we try to print many of the variable to see if they are correct and control it with the recorder if Fiji.
We thought that it was a problem of / and \ we tried to change it before add it in the ImprotArgs but it change nothing.
The only thing we don’t try is to print the ImportArgs.

I’ll try it this morning.and send you the result of it and the other variable.

Edit :

When I print the variables (see below) I remember that I tried to print importArg and when I saw no [ and ] (the only difference with the recorder) I thought it was the problem.

I tried to concatenate my Args with the [ and ] it didn’t work but maybe I did a mystake in my concatenation…

the printed variable : order = dataDir / pathSave / fileName / importArgs / name
//////////////////////////////////////

C:\Users\PIC-SFR_Necker\Desktop\Ilastik macro import H5 and save TIFF\H5\

C:\Users\PIC-SFR_Necker\Desktop\Ilastik macro import H5 and save TIFF\tiff\

C:\Users\PIC-SFR_Necker\Desktop\Ilastik macro import H5 and save TIFF\H5\C2_myo siebert p62 488 lc3 594 ebss-02_Simple Segmentation.h5

select=C:\Users\PIC-SFR_Necker\Desktop\Ilastik macro import H5 and save TIFF\H5\C2_myo siebert p62 488 lc3 594 ebss-02_Simple Segmentation.h5 datasetname=data axisorder=tzyxc

C2_myo siebert p62 488 lc3 594 ebss-02_Simple Segmentation.h5

/////////////////////////////////////////

Only a guess, but could you try not using paths with spaces in them?

Just try it by replacing all " " and “-” with “_” or just put simple name with img_01 etc. same problem

I just add two more information that I forget before :

  • manualy with the Ilastik plugin it work with no problem
  • if I remove the close in my macro and open an H5 in fiji the macro work but save 13 time the open image in tiff (13=filelis.tlength) that’s why I had the close option at the end of the macro.

Maybe @k-dominik is very busy, thanks for all the suggestion you gave us, a little up for @ilastik_team could you give us a little help ?

Thanks

Maybe @wolny has an idea? :slight_smile:

Update: I just talked to @wolny and the conclusion is still the same.

When you construct the variable importArgs you end up with something like this (taken from your post):

select=C:\Users\PIC-SFR_Necker\Desktop\Ilastik macro import H5 and save TIFF\H5\C2_myo siebert p62 488 lc3 594 ebss-02_Simple Segmentation.h5 datasetname=data axisorder=tzyxc

did you remove/replace spaces only in the filename, or also in the folder (could you print out the current value of this variable)?
Sorry for the inconvenience with that.