We're Hiring!

ImageJ: open several image windowless with a macro

Historical discussions about the Bio-Formats library. Please look for and ask new questions at https://forum.image.sc/tags/bio-formats
Please note:
Historical discussions about the Bio-Formats library. Please look for and ask new questions at https://forum.image.sc/tags/bio-formats

If you are having trouble with image files, there is information about reporting bugs in the Bio-Formats documentation. Please send us the data and let us know what version of Bio-Formats you are using. For issues with your code, please provide a link to a public repository, ideally GitHub.

ImageJ: open several image windowless with a macro

Postby Mojo Dodo » Mon Feb 20, 2017 8:01 am

I'm trying to edit all .ids-files from a directory using a ImageJ macro (with the loci_tools.jar installed):

Code: Select all
input = "/home/user/inputfolder/";
output = "/home/user/outputfolder/";

function action(input, output, filename) {

print(input + filename);

run("Bio-Formats Importer", "open= ["+ (input + filename) +"] autoscale color_mode=Custom view=Hyperstack stack_order=XYCZT series_0_channel_0_red=0 series_0_channel_0_green=255 series_0_channel_0_blue=0 series_0_channel_1_red=255 series_0_channel_1_green=0 series_0_channel_1_blue=0 series_0_channel_2_red=0 series_0_channel_2_green=0 series_0_channel_2_blue=255");

close();
}

setBatchMode(true);
list = getFileList(input);Bio-Formats Windowless Importer
for (i = 0; i < list.length; i++)
action(input, output, list[i]);
setBatchMode(false);


The problem is that when loading the files with the macro, the open dialog in the graphical user interface shows up and the macro will not continue until I manually choose a file.

I was suggested to use the Bio-Formats Windowless Importer, but it seems that I can't specify all the options, like I did in the macro above. Since I need the macro to work properly irrespective of previously used import settings this doesn't seem to be an option.

Any suggestions are greatly appreciated!
Mojo Dodo
 
Posts: 3
Joined: Fri Feb 17, 2017 7:51 am

Re: ImageJ: open several image windowless with a macro

Postby bramalingam » Mon Feb 20, 2017 3:09 pm

Hi,

Thank you for submitting your issue, adding a " windowless=true " flag to the options in the Bio-Formats Importer command, should suppress the pop up windows. But that seems to be failing, I have filed a ticket on this regard,
https://trac.openmicroscopy.org/ome/ticket/13323#ticket

As a work around, please try the following:

The documentation for the windowless importer can be found in the following link,
[url]
https://www.openmicroscopy.org/site/sup ... ndowlessly[/url]

and please check the following line in the documentation,
"Bio-Formats will import the file using the same settings you used the last time you imported a file with the same format."

Please do your import manually once on an image from the folder using the Bio-Formats Importer... and choose the options in the "Bio-Formats Import Options" dialog manually, and this will become the default import configuration when you use the Bio-Formats windowless importer (when you call it from the macro for the "same image format").

And please notice the small edit in the macro as well,

Code: Select all
input = "/home/user/inputfolder/";
output = "/home/user/outputfolder/";

function action(input, output, filename) {

filename1 = input + filename;
print(input + filename);
Ext.openImagePlus(filename1);

close();
}

run("Bio-Formats Macro Extensions")
setBatchMode(true);
list = getFileList(input);//Bio-Formats Windowless Importer
for (i = 0; i < list.length; i++)
action(input, output, list[i]);
setBatchMode(false);


This uses the Bio-Formats macro extensions, which are designed to suppress all windows when setBatchMode is set to "true".

Hope that helps.
Please let us know if this does not work for you.

Best,
Balaji
User avatar
bramalingam
 
Posts: 70
Joined: Tue Jan 14, 2014 12:01 pm

Re: ImageJ: open several image windowless with a macro

Postby Mojo Dodo » Fri Feb 24, 2017 4:18 pm

Thank you for your reply!
The documentation for the windowless importer can be found in the following link,
[url]
https://www.openmicroscopy.org/site/sup ... ndowlessly[/url]

and please check the following line in the documentation,
"Bio-Formats will import the file using the same settings you used the last time you imported a file with the same format."


Well, I think the problem with the windowless importer is that my macro should be used on different computers. Thus the setting used for the last import will vary. I need to specify those setting somehow, like I tried to in my macro above by using:
Code: Select all
run("Bio-Formats Importer", "open= ["+ (input + filename) +"] autoscale color_mode=Custom view=Hyperstack stack_order=XYCZT series_0_channel_0_red=0 series_0_channel_0_green=255 series_0_channel_0_blue=0 series_0_channel_1_red=255 series_0_channel_1_green=0 series_0_channel_1_blue=0 series_0_channel_2_red=0 series_0_channel_2_green=0 series_0_channel_2_blue=255");
Mojo Dodo
 
Posts: 3
Joined: Fri Feb 17, 2017 7:51 am

Re: ImageJ: open several image windowless with a macro

Postby bramalingam » Mon Feb 27, 2017 10:38 am

Hi,

Please follow the instructions given here in the ImageJ forum post,
http://forum.imagej.net/t/macro-opening ... ols/4146/3

I somehow missed the space in your Importer command,
Removing the extra space as suggested in the forum post should solve your issue.

Please let us know if that doesn't solve your issue.

Best,
Balaji
User avatar
bramalingam
 
Posts: 70
Joined: Tue Jan 14, 2014 12:01 pm

Re: ImageJ: open several image windowless with a macro

Postby Mojo Dodo » Wed Mar 01, 2017 9:53 am

Thank you for all the help!
The erroneously inserted space before the square bracket was one problem. In addition the parentheses enclosing the variables input and filename, caused my macro to fail. For further details one can refer to the post (from the above mentioned thread): http://forum.imagej.net/t/macro-opening-ids-files-with-bioformats-plugin-loci-tools/4146/6?u=mojododo

Code: Select all
input = "/home/user/inputfolder/";
output = "/home/user/outputfolder/";

function action(input, output, filename) {

run("Bio-Formats Importer", "open=["+ input + filename +"] autoscale color_mode=Custom view=Hyperstack stack_order=XYCZT series_0_channel_0_red=0 series_0_channel_0_green=255 series_0_channel_0_blue=0 series_0_channel_1_red=255 series_0_channel_1_green=0 series_0_channel_1_blue=0 series_0_channel_2_red=0 series_0_channel_2_green=0 series_0_channel_2_blue=255");

close();
}

setBatchMode(true);
list = getFileList(input);
for (i = 0; i < list.length; i++)
action(input, output, list[i]);
setBatchMode(false);
Mojo Dodo
 
Posts: 3
Joined: Fri Feb 17, 2017 7:51 am


Return to User Discussion [Legacy]

Who is online

Users browsing this forum: No registered users and 0 guests