Macro recording to open an KLB file with SCIFO failed


#1

Dear All,

Upon macro-recording the opening of an KLB file (KLB…) i get this result:

IJ.run(imp, "KLB...", "datasetservice=[io.scif.services.SCIFIODatasetService [priority = 1.0]] uiservice=[org.scijava.ui.DefaultUIService [priority = 0.0]] logservice=[org.scijava.log.StderrLogService [priority = -100.0]]");

I would like to pass on a string, which file to open:

e.g.

IJ.run(imp, "KLB...", "datasetservice=[io.scif.services.SCIFIODatasetService openme="C:/Tobias/nice_pic.klb" ");

Then the file just needs to be opened (but not displayed).
No GUI to enter filenames ect. is needed.

Is there a direct SCIFO command that might work in this instance?

Thanks a lot in advance for your help &

Kind regards

Tobias


#2

Dear @Tobias,

the Command that implements opening KLB files does currently not support providing a file via a macro (hence it is not recorded).

This could be remedied by refactoring KlbImageJLoader#L38-40 to a field in the class with an @Parameter annotation:

@Parameter
private File file;

This is more a note to Burkard Höckendorf (maintainer of the plugin?) whom I have invited to this thread as well.

Best,
Stefan


#3

Dear Tobias and Stefan,

Thanks for trying KLB and letting me know about the issue. This seems as if it would be a quick fix, but please note that I have been experiencing issues with distributing updates via the updater. Also, I’m about to begin travelling, so I will not be able to look into this right away.

That being said, I’d like to note that there are two ways to read KLB files in ImageJ. The first one is via SCIFIO, and would simply be invoked via File > Open, drag-and-drop, or the open("/path/to/file.ext") command of the macro language. For this to work, please enable SCIFIO via Edit > Options > ImageJ2. I think this should work for you out of the box without requiring any code modifications on my part. Please let me know if this does not work for you.

I added KlbImageJLoader to bypass some of SCIFIO’s limitations that conflict with block-based formats like KLB. Unless you have 4D or 5D images, SCIFIO should be able to handle your files though. I will certainly still add the required annotation to the file path parameter in this class.

Hope this helps, and best wishes,
Burkhard


#4

Dear Burkhard and Stefan,

thanks a lot for your help!

I just tried this suggestion:

The first one is via SCIFIO, and would simply be invoked via File > Open, drag-and-drop, or the open("/path/to/file.ext") command of the macro language. For this to work, please enable SCIFIO via Edit > Options > ImageJ2. I think this should work for you out of the box without requiring any code modifications on my part. Please let me know if this does not work for you.

The drag and drop works nicely:

However, when i try to record what i did
Plugin>Marcos>Record> (in Java Script)

nothing is recorded (with drag and drop).

If i open the Klb file with Image>open

I record:
imp = IJ.openImage(“org.scijava.Context@6ebc9573”)

(I want to make a script in Fiji Jython that opens and processes "a lot of files"
and i miss the line of code that opens me the klb file).

like:
imp = IJ.openImage(file=“C:/nice_pic.tif” , format=“KLB”)

If that is not possible with the current KLB script / SCIFO i can still convert the files upfront with Matlab, but i thought to raise the issue as this might be a common application.

Kind regards & Thanks again.

Tobias


#5

Hi,

I can not try this myself currently, but I think you can literally use open("/path/to/file.ext");.

Cheers,
Burkhard


#6

Dear Burkhard,

Yes, indeed that works!
This is much simpler than I thought.

I just summarize the “how-to” again in case someone else encounters the same problem:

  1. Fiji > Update > Manage Update Sites > SiMView

  2. Restart Fiji

  3. Fiji > Edit > Options > ImageJ2 > Use SCIFIO when opening files (BETA!)

Then you can open (and resave) KLB files very generic…

e.g. in Jython:

from ij import IJ, ImagePlus

file_name="C:/....test.klb"
imp = IJ.openImage(file_name)
file_name=file_name.replace(".klb",".tif")
print ("Saving", file_name)
IJ.saveAs(imp, "Tiff", file_name)

Thank you very much for your help!

Kind regards

Tobias