Login  Register

Re: BioFormats Export/Import of Composite Images

Posted by David Gault (Staff) on Oct 21, 2016; 11:04am
URL: http://imagej.273.s1.nabble.com/BioFormats-Export-Import-of-Composite-Images-tp5017403p5017443.html

Hi Michael,

Im afraid the addGlobalMetaList function is not available through the ImageJ macros, instead the metadata will need to have been written to the file before it is imported.
In this case as the metadata values are already stored on the image perhaps another alternative to get the data into ImageJ would be through a custom plugin using Bio-Formats.
A good example of this to read images including populating slices and LUTs would be https://github.com/openmicroscopy/bioformats/blob/v5.2.4/components/bio-formats-plugins/utils/Read_Image.java

This could be modified to read the channelNames as such:
IMetadata retrieve = (IMetadata) reader.getMetadataStore();
String channelName = retrieve.getChannelName(imageIndex, channelIndex);

Then to add them as labels for the slices:
stack.addSlice(channelName, ip);

The full Bio-Formats documentation has can be found from http://www.openmicroscopy.org/site/support/bio-formats5.2/
Examples of using Bio-Formats in an ImageJ plugin can be found here: http://www.openmicroscopy.org/site/support/bio-formats5.2/developers/java-library.html

With Thanks,
David Gault
________________
Software Developer
OME Team
School of Life Sciences
University of Dundee

On 20 Oct 2016, at 20:01, Michael Ellis <[hidden email]<mailto:[hidden email]>> wrote:

Dear David Gault and Balaji Ramalingam

Thank you for your suggestions about using global metadata list as suggest here:

http://lists.openmicroscopy.org.uk/pipermail/ome-devel/2016-October/003769.html <http://lists.openmicroscopy.org.uk/pipermail/ome-devel/2016-October/003769.html>

However I am unsure of the context on where addGlobalMetaList() is being called. Is this ImageJ macro code? There does not seem to be any methods in Metadata called  addGlobalMetaList(). A google search reveals there is a method by this name in the FormatReader class, but I am not making use of the class when calling BioFormats library when writing my file.

This leads me to ask if there is any other sources for BIoFormats documentation. There seems to be so much that is not explained. The Java docs often offer little more than a long winded version of the function name:

addGlobalMeta <http://downloads.openmicroscopy.org/bio-formats/5.2.3/api/loci/formats/FormatReader.html#addGlobalMeta(java.lang.String,%20java.lang.Object)>(String <http://docs.oracle.com/javase/7/docs/api/java/lang/String.html?is-external=true> key, Object <http://docs.oracle.com/javase/7/docs/api/java/lang/Object.html?is-external=true> value)
Adds an entry to the global metadata table.

There seems to be very little overview and few example/

Any help would be greatly appreciated.

— Michael Ellis



On 17 Oct 2016, at 14:39, David Gault (Staff) <[hidden email]<mailto:[hidden email]>> wrote:

Hi Michael,

Following up on this from the response on the Bio-Formats developer mailing list below:
http://lists.openmicroscopy.org.uk/pipermail/ome-devel/2016-October/003769.html

The information which is being exported and stored in the OME header is indeed correct, the issue is that when importing the file the channel names are not being populated back onto the Image Window and instead you are seeing names such as “c1/4”, “c:2/4”, “c3/4”, “c:4/4”. The ticket which has been opened (https://trac.openmicroscopy.org/ome/ticket/13306) looks to address this labeling of ImagePlus windows within the Bio-Formats plugin.

The suggested solution from the mailing list link above (using global metadata list) is not perfect but would allow you to retain this information when importing the image into ImageJ. Hopefully this can be useful as a workaround until the issue of importing slice labels is resolved.


With Thanks,
David Gault
________________
Software Developer
OME Team
School of Life Sciences
University of Dundee


On 14 Oct 2016, at 10:57, Michael Ellis (DSUK) <[hidden email]<mailto:[hidden email]><mailto:[hidden email]>> wrote:

Is it possible to use the BioFormat Exporter to save a multi-slice composite images, and then have the BioFormats Importer import that image restoring the ImageJ slice names and slice LUTS?

This ImageJ script creates a 4 channel composite image, with channel names and luts specified.

newImage("MyStack", "8-bit random", 256, 256, 4);
run("Make Composite", "display=Composite");
setSlice(1);
run("Set Label...", "label=Dapi");
run("Blue");
setSlice(2);
run("Set Label...", "label=Fitc");
run("Green");
setSlice(3);
run("Set Label...", "label=TxRed");
run("Red");
setSlice(4);
run("Set Label...", "label=Aqua");
run("Cyan");

If I use BioFormats Exporter/Importer on this image, the slice labels and slice LUTS are not restored.

The created file certainly has the slice name information as can be seen from the .ome.tif header

<OME UUID="urn:uuid:9ac10dd4-2ed8-4a6e-a5ec-8a7a8309f327" xmlns="http://www.openmicroscopy.org/Schemas/OME/2015-01" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.openmicroscopy.org/Schemas/OME/2015-01 http://www.openmicroscopy.org/Schemas/OME/2015-01/ome.xsd">
<Image ID="Image:0">
<Pixels BigEndian="false" DimensionOrder="XYCZT" ID="Pixels:0" Interleaved="false" PhysicalSizeX="1.0" PhysicalSizeXUnit="µm" PhysicalSizeY="1.0" PhysicalSizeYUnit="µm" PhysicalSizeZ="1.0" PhysicalSizeZUnit="µm" SignificantBits="8" SizeC="4" SizeT="1" SizeX="256" SizeY="256" SizeZ="1" TimeIncrement="0.0" TimeIncrementUnit="s" Type="uint8">
<Channel Color="-16776961" ID="Channel:0:0" Name="Dapi" SamplesPerPixel="1">
<LightPath/>
<Channel Color="-16711936" ID="Channel:0:1" Name="Fitc" SamplesPerPixel="1">
<LightPath/>
<Channel Color="-65536" ID="Channel:0:2" Name="TxRed" SamplesPerPixel="1">
<LightPath/>
<Channel Color="-16711681" ID="Channel:0:3" Name="Aqua" SamplesPerPixel="1">
<LightPath/>
<TiffData FirstC="0" FirstT="0" FirstZ="0" IFD="0" PlaneCount="1">
<UUID FileName="FromImageJ.ome.tif">urn:uuid:9ac10dd4-2ed8-4a6e-a5ec-8a7a8309f327</UUID>
<TiffData FirstC="1" FirstT="0" FirstZ="0" IFD="1" PlaneCount="1">
<UUID FileName="FromImageJ.ome.tif">urn:uuid:9ac10dd4-2ed8-4a6e-a5ec-8a7a8309f327</UUID>
<TiffData FirstC="2" FirstT="0" FirstZ="0" IFD="2" PlaneCount="1">
<UUID FileName="FromImageJ.ome.tif">urn:uuid:9ac10dd4-2ed8-4a6e-a5ec-8a7a8309f327</UUID>
<TiffData FirstC="3" FirstT="0" FirstZ="0" IFD="3" PlaneCount="1">
<UUID FileName=“FromImageJ.ome.tif">urn:uuid:9ac10dd4-2ed8-4a6e-a5ec-8a7a8309f327</UUID>

— Michael Ellis

--
ImageJ mailing list: http://imagej.nih.gov/ij/list.html


The University of Dundee is a registered Scottish Charity, No: SC015096

--
ImageJ mailing list: http://imagej.nih.gov/ij/list.html

Michael Ellis (Managing Director)
Digital Scientific UK Ltd.
http://www.dsuk.biz<http://www.dsuk.biz/> <http://www.dsuk.biz/>
[hidden email]<mailto:[hidden email]>
tel: +44(0)1223 911215

The Commercial Centre
6 Green End
Cambridge
CB23 7DY


--
ImageJ mailing list: http://imagej.nih.gov/ij/list.html


The University of Dundee is a registered Scottish Charity, No: SC015096

--
ImageJ mailing list: http://imagej.nih.gov/ij/list.html