<html><head><meta http-equiv="Content-Type" content="text/html charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class="">Dear ome-devel list.<div class=""><br class=""></div><div class="">I am trying to use the bioformats_package.jar in my Java app to save a single image file comprising multiple channels (each channel acquired with a different fluorescence filter set). I am using the setChannelName() and this appears to work insofar as I can see the entry being created in the resulting OME-XML data contained within the the .ome.tif file. However, if I use ImageJ with the BioFormats importer plugin, the multi channel image is loaded and displayed, but the channel names are set not to the names I specify, but “c1/4”, “c:2/4”, “c3/4”, “c:4/4”.</div><div class=""><br class=""></div><div class="">My SSCCE is as follows:</div><div class=""><br class=""></div><div class=""><div class="">public class BioFormatsTest2 {</div><div class=""><br class=""></div><div class=""> private IMetadata createMetadata(int width, int height, int pixelType, String[] channelNames, Color[] channelColors) {</div><div class=""> IMetadata meta;</div><div class=""> try {</div><div class=""> // create the OME-XML metadata storage object</div><div class=""> ServiceFactory factory = new ServiceFactory();</div><div class=""> OMEXMLService service = factory.getInstance(OMEXMLService.class);</div><div class=""> meta = service.createOMEXMLMetadata();</div><div class=""> meta.createRoot();</div><div class=""><br class=""></div><div class=""> // define each stack of images - this defines a single stack of images</div><div class=""> meta.setImageID("Image:0", 0);</div><div class=""> meta.setPixelsID("Pixels:0", 0);</div><div class=""><br class=""></div><div class=""> // specify that the pixel data is stored in big-endian format</div><div class=""> // change 'TRUE' to 'FALSE' to specify little-endian format</div><div class=""> meta.setPixelsBinDataBigEndian(Boolean.TRUE, 0, 0);</div><div class=""><br class=""></div><div class=""> // specify that the images are stored in ZCT order</div><div class=""> meta.setPixelsDimensionOrder(DimensionOrder.XYCZT, 0);</div><div class=""><br class=""></div><div class=""> // specify that the pixel type of the images</div><div class=""> meta.setPixelsType(</div><div class=""> PixelType.fromString(FormatTools.getPixelTypeString(pixelType)), 0);</div><div class=""><br class=""></div><div class=""> // specify the dimensions of the images</div><div class=""> meta.setPixelsSizeX(new PositiveInteger(width), 0);</div><div class=""> meta.setPixelsSizeY(new PositiveInteger(height), 0);</div><div class=""> meta.setPixelsSizeZ(new PositiveInteger(1), 0);</div><div class=""> meta.setPixelsSizeC(new PositiveInteger(channelNames.length), 0);</div><div class=""> meta.setPixelsSizeT(new PositiveInteger(1), 0);</div><div class=""><br class=""></div><div class=""> for (int channel = 0; channel < channelNames.length; channel++) {</div><div class=""> meta.setChannelID("Channel:0:" + channel, 0, channel);</div><div class=""> meta.setChannelSamplesPerPixel(new PositiveInteger(1), 0, channel);</div><div class=""> meta.setChannelName(channelNames[channel], 0, channel);</div><div class=""> ome.xml.model.primitives.Color c = new ome.xml.model.primitives.Color(channelColors[channel].getRGB());</div><div class=""> meta.setChannelColor(c, 0, channel);</div><div class=""> }</div><div class=""> } catch (DependencyException | ServiceException | EnumerationException e) {</div><div class=""> System.err.println("Failed to populate OME-XML metadata object.");</div><div class=""> e.printStackTrace();</div><div class=""> meta = null;</div><div class=""> }</div><div class=""><br class=""></div><div class=""> return meta;</div><div class=""> }</div><div class=""><br class=""></div><div class=""> public static void main(String[] args) throws Exception {</div><div class=""> BioFormatsTest2 exporter = new BioFormatsTest2();</div><div class=""> exporter.run();</div><div class=""> }</div><div class=""><br class=""></div><div class=""> public void run() throws IOException, FormatException {</div><div class=""> int width = 256, height = 256;</div><div class=""> int pixelType = FormatTools.UINT8;</div><div class=""> String[] channelNames = {"Dapi", "Fitc", "TxRed", "Aqua"};</div><div class=""> Color[] channelColors = {Color.BLUE, Color.GREEN, Color.RED, Color.CYAN};</div><div class=""> String filePath = "/Users/michaelellis/Documents/Development/SmartCapture4/BioFormat2.ome.tif";</div><div class=""><br class=""></div><div class=""> // Create image data buffer;</div><div class=""> byte[] img = new byte[width * height * FormatTools.getBytesPerPixel(pixelType)];</div><div class=""><br class=""></div><div class=""> try (ImageWriter writer = new ImageWriter()) {</div><div class=""> IMetadata omexml = createMetadata(width, height, pixelType, channelNames, channelColors);</div><div class=""> writer.setMetadataRetrieve(omexml);</div><div class=""> writer.setId(filePath);</div><div class=""><br class=""></div><div class=""> // only save a plane if the file writer was initialized successfully</div><div class=""> for (int planeIndex = 0; planeIndex < channelNames.length; ++planeIndex) {</div><div class=""> // savePlane(planeIndex, width, height, pixelType);</div><div class=""> // byte[] plane = createImage(width, height, pixelType);</div><div class=""><br class=""></div><div class=""> // fill it with random data</div><div class=""> for (int i = 0; i < img.length; i++) {</div><div class=""> img[i] = (byte) (256 * Math.random());</div><div class=""> }</div><div class=""><br class=""></div><div class=""> writer.saveBytes(planeIndex, img);</div><div class=""> }</div><div class=""><br class=""></div><div class=""> } // Autoclose writer</div><div class=""><br class=""></div><div class=""> }</div><div class="">}</div></div><div class=""><br class=""></div><div class="">===</div><div class=""><br class=""></div><div class="">The OME-XML in the .ome.tif file is as follows. Note that channel names appear to be Dapi, Fitc, TxRed and Aqua</div><div class=""><br class=""></div><div class=""><br class=""></div><div class=""><div class=""> <OME UUID="urn:uuid:42b524fd-b842-4052-bf6c-5977c9d06a97" xmlns="<a href="http://www.openmicroscopy.org/Schemas/OME/2015-01" class="">http://www.openmicroscopy.org/Schemas/OME/2015-01</a>" xmlns:xsi="<a href="http://www.w3.org/2001/XMLSchema-instance" class="">http://www.w3.org/2001/XMLSchema-instance</a>" xsi:schemaLocation="<a href="http://www.openmicroscopy.org/Schemas/OME/2015-01" class="">http://www.openmicroscopy.org/Schemas/OME/2015-01</a> <a href="http://www.openmicroscopy.org/Schemas/OME/2015-01/ome.xsd" class="">http://www.openmicroscopy.org/Schemas/OME/2015-01/ome.xsd</a>"></div><div class=""> <Image ID="Image:0"></div><div class=""> <Pixels BigEndian="true" DimensionOrder="XYCZT" ID="Pixels:0" Interleaved="false" SignificantBits="8" SizeC="4" SizeT="1" SizeX="256" SizeY="256" SizeZ="1" Type="uint8"></div><div class=""> <Channel Color="-16776961" ID="Channel:0:0" Name="Dapi" SamplesPerPixel="1"></div><div class=""> <LightPath/></div><div class=""> <Channel Color="-16711936" ID="Channel:0:1" Name="Fitc" SamplesPerPixel="1"></div><div class=""> <LightPath/></div><div class=""> <Channel Color="-65536" ID="Channel:0:2" Name="TxRed" SamplesPerPixel="1"></div><div class=""> <LightPath/></div><div class=""> <Channel Color="-16711681" ID="Channel:0:3" Name="Aqua" SamplesPerPixel="1"></div><div class=""> <LightPath/></div><div class=""> <TiffData FirstC="0" FirstT="0" FirstZ="0" IFD="0" PlaneCount="1"></div><div class=""> <UUID FileName="BioFormat2.ome.tif">urn:uuid:42b524fd-b842-4052-bf6c-5977c9d06a97</UUID></div><div class=""> <TiffData FirstC="1" FirstT="0" FirstZ="0" IFD="1" PlaneCount="1"></div><div class=""> <UUID FileName="BioFormat2.ome.tif">urn:uuid:42b524fd-b842-4052-bf6c-5977c9d06a97</UUID></div><div class=""> <TiffData FirstC="2" FirstT="0" FirstZ="0" IFD="2" PlaneCount="1"></div><div class=""> <UUID FileName="BioFormat2.ome.tif">urn:uuid:42b524fd-b842-4052-bf6c-5977c9d06a97</UUID></div><div class=""> <TiffData FirstC="3" FirstT="0" FirstZ="0" IFD="3" PlaneCount="1"></div><div class=""> <UUID FileName="BioFormat2.ome.tif">urn:uuid:42b524fd-b842-4052-bf6c-5977c9d06a97</UUID></div><div class=""> </div></div><div class=""><br class=""></div><div class="">After loading the created image with the BioFormats Import plugin into Fiji and running the following script:</div><div class=""><br class=""></div><div class=""><div class=""> IJ.log("nSlices=" + nSlices);</div><div class=""><br class=""></div><div class=""> for(i = 1; i <= nSlices; i=i+1) {</div><div class=""> setSlice(i);</div><div class=""> name = getInfo("slice.label");</div><div class=""> IJ.log("Slice " + i + ": " + name);</div><div class=""> }</div></div><div class=""><br class=""></div><div class="">The log output is: </div><div class=""><br class=""></div><div class=""><div class=""> nSlices=4</div><div class=""> Slice 1: c:1/4</div><div class=""> Slice 2: c:2/4</div><div class=""> Slice 3: c:3/4</div><div class=""> Slice 4: c:4/4</div></div><div class=""><br class=""></div><div class="">Also, consistent with the script output, the names displayed in the Fiji image window title show the plane names as “c1/4”, “c:2/4”, “c3/4”, “c:4/4”.</div><div class=""><br class=""></div><div class="">What am I doing wrong?</div><div class="">Am I doing something wrong?</div><div class=""><br class=""></div><div class="">Also, I have read the developer documentation at <a href="http://www.openmicroscopy.org/site/support/bio-formats5.2/developers/index.html" class="">http://www.openmicroscopy.org/site/support/bio-formats5.2/developers/index.html</a> but either I am missing something or there is insufficient explanation for some of the items. For instance in the example <a href="http://www.openmicroscopy.org/site/support/bio-formats5.2/_downloads/FileExport.java" class="">http://www.openmicroscopy.org/site/support/bio-formats5.2/_downloads/FileExport.java</a>, where can I find an explanation for the string identifiers used in the following calls:</div><div class=""><br class=""></div><div class=""><span class="Apple-tab-span" style="white-space:pre"> </span>meta.setImageID("Image:0", 0);<br class=""><span class="Apple-tab-span" style="white-space:pre"> </span>meta.setPixelsID(“Pixels:0", 0);<br class=""><span class="Apple-tab-span" style="white-space:pre"> </span>meta.setChannelID(“Channel:0:0", 0, 0);</div><div class=""><br class=""></div><div class="">Any help gratefully appreciated!</div><div class=""><br class=""></div><div class="">— Michael Ellis</div><div class=""><br class=""></div><div class=""><br class=""></div><div class=""><pre style="word-wrap: break-word;" class=""><br class=""></pre></div><div class=""><br class=""></div><div class=""><br class=""><div class="">
<div style="text-align: right;" class="">Michael Ellis (Managing Director)</div><div style="text-align: right;" class="">Digital Scientific UK Ltd.</div><div style="text-align: right;" class=""><a href="http://www.dsuk.biz" class="">http://www.dsuk.biz</a></div><div style="text-align: right;" class=""><a href="mailto:michael.ellis@dsuk.biz" class="">michael.ellis@dsuk.biz</a></div><div style="text-align: right;" class="">tel: +44(0)1223 911215</div><div style="text-align: right;" class=""><br class=""></div><div style="text-align: right;" class="">The Commercial Centre</div><div style="text-align: right;" class="">6 Green End</div><div style="text-align: right;" class="">Cambridge</div><div style="text-align: right;" class="">CB23 7DY</div>
</div>
<br class=""></div></body></html>