We're Hiring!

OME metadata in ImageJ

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.

OME metadata in ImageJ

Postby lando.wark » Sat May 21, 2016 2:52 pm

I've made a FIJI batch script to deconvolve multiple images using the FIJI cookbook plugin. In short I import an image with Bio-formats importer, split into channels and perform operations on each and then merge the channels afterward, saving as an ome.tif.
When I re-import the tif image I get green where the blue channel should be. According to https://www.openmicroscopy.org/community/viewtopic.php?f=6&t=536 this should be because the correct metadata is not present.
The trouble I am having is that altering the metadata using setMetadata("Info", List.getList) doesn't seem to change anything. Are there specific parameter I need to set in List? Was this just not meant to happen? I feel like I've tried everything.

prop = getMetadata("Info");
List.setList(prop);
<< Do stuff here >>
setMetadata("Info", List.getList);
lando.wark
 
Posts: 11
Joined: Fri May 20, 2016 3:23 am

Re: OME metadata in ImageJ

Postby dgault » Wed May 25, 2016 3:42 pm

Hi,

Apologies for the delayed response, I have spent some time investigating and trying out a few macro combinations that may be suitable.

It doesn't appear to be possible to manipulate the channels from the basic ImageJ property list post import, instead I would suggest attempting to reorder the channels prior to merging.

If you know which channels are being misplaced then it could perhaps be achieved by setting the channels in the merge macro:
options="open=["+path+"] view=[Standard ImageJ] split_channels ";
run("Bio-Formats Importer",options);
title=getTitle();
s=lastIndexOf(title, " - C=2");
subtitle=substring(title, 0, s);
run("Merge Channels...", "c0=["+ subtitle + " - C=1] c1=[" + subtitle + " - C=0] c2=[" + subtitle + " - C=2] create");

Alternatively you could perhaps use the setBackgroundColor function similar to below:
Stack.setChannel(1)
c1 = getValue("color.foreground")
c2 = getValue("color.background")
Stack.setChannel(2)
c3 = getValue("color.foreground")
c4 = getValue("color.background")
run("Split Channels");
count = nImages()
n = nImages;
list = newArray(n);
setBatchMode(true);
for (i=1; i<=n; i++) {
selectImage(i);
if (i==1)
setBackgroundColor(c2,0,0);
if (i==2)
setBackgroundColor(c4,0,0);
}
setBatchMode(false);

If you have a sample image file which we could use then we might be able to help further with some macro examples. You can upload sample files to https://www.openmicroscopy.org/qa2/qa/upload/

With Thanks,
David Gault
User avatar
dgault
Team Member
 
Posts: 208
Joined: Fri Aug 14, 2015 2:56 pm

Re: OME metadata in ImageJ

Postby lando.wark » Thu May 26, 2016 5:38 pm

Thanks for your reply.

I've tried the first option you mention a couple of different ways before. Since getting the reply I've tried it a few other ways. Even if I manually reopen the created image and reset the channels to what I want, after reimporting the image I still have Channel 1 = red (expected result), Channel 2 = green (instead of blue).

I think the conclusion is that because the deconvolution creates a new image I have to pass in the old metadata using "setMetadata("Info", string);. I get the correct result if I later call print(getMetadata("Info");, but that the OME-TIF format does not save this particular data and that is what is causing the problem when I reimport. I need a way to directly pass in this information OME-XML.
I notice "Bio-Formats has a high-level scripting interface, accessible by Java and all scripting languages supported by Fiji (but not the ImageJ macro language)." So I guess I will have to move to another scripting language.

Below is the outcome of my troubleshooting:

1. Import .zvi with importer
* Channels as expected. Standard metadata intact. Ome-xml metadata intact.

2. Export as ome.tif and reimport
* Channels as expected. Standard metadata destroyed. Ome-xml metadata intact.

3. Split channels, export Channel 2 (originally blue) as ome.tif and reimport.
* Channel 2 appears red. Standard metadata destroyed. Ome-xml metadata (somewhat?) destroyed.

4. Split channels, merge (Channel 1 as C1 (red) and Channel 2 as C3 (blue)). Export as ome.tif and reimport.
* Channels as expected. Standard metadata destroyed. Ome-xml metadata (somewhat?) destroyed.
* Weird.

5. Run batch with "keep" during merging of channels to keep source images and disabling "setMetadata".
* Channel 2 appears green. Standard metadata destroyed. Ome-xml metadata (somewhat?) destroyed.

6. Run batch with .ome.tif taken off exported filename.
* If this turns out to be the problem I'm going to feel like an ass.
* File did not save, so I don't feel like an ass.

7. Run batch using save as ome.tif (FIJI) instead of Bio-format exporter.
* Channel 2 appears green. Standard metadata destroyed. Ome-xml metadata (somewhat?) destroyed.

8. Run batch. Tried my old method of passing in metadata using info = getImageInfo(); and passing to new image created by deconvolution using setImageInfo("Info", info);
* Channel 2 appears green. Standard metadata destroyed. Ome-xml metadata (somewhat?) destroyed.
lando.wark
 
Posts: 11
Joined: Fri May 20, 2016 3:23 am

Re: OME metadata in ImageJ

Postby sbesson » Mon May 30, 2016 1:22 pm

Hi,

we are currently preparing our annual Users meeting so please bear with us as we might be less responsive to our community issues this week.

We will be working on reproducing the workflow described in your last answer. In the meantime, it would be handy to have access to 1- the sample file you are using for your testing (which can be be uploaded via the link posted by David above http://qa.openmicroscopy.org.uk/qa/upload/) and 2- the source code of the batch script you are applying to your images.

Best,
Sebastien
User avatar
sbesson
Team Member
 
Posts: 421
Joined: Tue Feb 28, 2012 7:20 pm


Return to User Discussion [Legacy]

Who is online

Users browsing this forum: No registered users and 1 guest