<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=us-ascii">
</head>
<body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class="">
Hi Jean,
<div class=""><br class="">
</div>
<div class="">At the writing level, the ImageWriter.getWriter() method [1] will select the writer</div>
<div class="">to use to save the file using the value of the id. If you pass imageTest.tif, it will </div>
<div class="">return a TiffWriter instance [2] but if you pass imageTest.ome.tif, it will return an</div>
<div class="">OMETiffWriter instance [3].</div>
<div class=""><br class="">
</div>
<div class="">If you want to keep imageTest.tif as the filename but want to write the OME-XML,</div>
<div class="">you could try imposing the writer instance using something like:</div>
<div class=""><br class="">
</div>
<div class="">
<div class="gmail_extra">
<div class="gmail_quote">
<div dir="ltr" class="">
<div class="">
<div class=""><span class="Apple-tab-span" style="white-space:pre"></span>IFormatWriter writer = new loci.formats.out.OMETiffWriter();</div>
</div>
</div>
</div>
</div>
</div>
<div class=""><br class="">
</div>
<div class="">instead of:</div>
<div class=""><br class="">
</div>
<div class="">
<div class="">
<div class="gmail_extra">
<div class="gmail_quote">
<div dir="ltr" class="">
<div class="">
<div class=""><span class="Apple-tab-span" style="white-space: pre;"></span>IFormatWriter writer = new loci.formats.ImageWriter();</div>
<div class=""><br class="">
</div>
<div class="">Best,</div>
<div class="">Sebastien</div>
<div class=""><br class="">
</div>
<div class="">[1] <a href="http://downloads.openmicroscopy.org/bio-formats/5.1.2/api/loci/formats/ImageWriter.html#getWriter()" class="">http://downloads.openmicroscopy.org/bio-formats/5.1.2/api/loci/formats/ImageWriter.html#getWriter()</a></div>
<div class="">[2] <a href="http://downloads.openmicroscopy.org/bio-formats/5.1.2/api/loci/formats/out/TiffWriter.html" class="">http://downloads.openmicroscopy.org/bio-formats/5.1.2/api/loci/formats/out/TiffWriter.html</a></div>
<div class="">[3] <a href="http://downloads.openmicroscopy.org/bio-formats/5.1.2/api/loci/formats/out/OMETiffWriter.html" class="">http://downloads.openmicroscopy.org/bio-formats/5.1.2/api/loci/formats/out/OMETiffWriter.html</a></div>
<div class=""><br class="">
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<div class="">
<div>
<blockquote type="cite" class="">
<div class="">On 30 Jun 2015, at 10:20, Jean Ollion <<a href="mailto:smogollion@yahoo.fr" class="">smogollion@yahoo.fr</a>> wrote:</div>
<br class="Apple-interchange-newline">
<div class="">
<div dir="ltr" class="">
<div class="">
<div class="">
<div class="">
<div class="">
<div class="">
<div class="">Hello Sebastien, <br class="">
</div>
When I change the format to ome.tif, it works well. <br class="">
</div>
Also for the other problem I mentioned (inversion of number of time points and number of slices)
<br class="">
<br class="">
</div>
I also tried to change the format to APNG (.png), and I get the same errors as in .tif (ie the calibration is not readable and the inversion of number of time points and number of slices  )<br class="">
</div>
Does the bug comes from my code or from the bioformats? <br class="">
</div>
Thanks you, <br class="">
</div>
<div class="">Best,<br class="">
</div>
Jean Ollion<br class="">
</div>
<div class="gmail_extra"><br class="">
<div class="gmail_quote">2015-06-29 18:38 GMT+02:00 Jean Ollion <span dir="ltr" class="">
<<a href="mailto:smogollion@yahoo.fr" target="_blank" class="">smogollion@yahoo.fr</a>></span>:<br class="">
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div dir="ltr" class="">
<div class="">Hello, <br class="">
</div>
I have trouble reading and writing calibration in metadata. Here is a minimal example, written as a JUnit test.<br class="">
<div class="">
<div class=""><br class="">
@Rule<br class="">
    public TemporaryFolder testFolder = new TemporaryFolder();<br class="">
@org.junit.Test<br class="">
    public void testIOImageCalibration() {<br class="">
        String id = testFolder.newFolder("imageTest").getAbsolutePath() + File.separator + "imageTest.tif";<br class="">
        int w = 512, h = 512, c = 1, z = 1;<br class="">
        int pixelType = FormatTools.UINT16;<br class="">
        byte[] img = new byte[w * h * c * FormatTools.getBytesPerPixel(pixelType)];<br class="">
        for (int i = 0; i < img.length; i++) {<br class="">
            img[i] = (byte) (256 * Math.random());<br class="">
        }<br class="">
        double calX = 0.1d;<br class="">
        double calZ = 0.23d;<br class="">
        try {<br class="">
            ServiceFactory factory = new ServiceFactory();<br class="">
            OMEXMLService service = factory.getInstance(OMEXMLService.class);<br class="">
            IMetadata meta = service.createOMEXMLMetadata();<br class="">
            MetadataTools.populateMetadata(meta, 0, null, false, "XYZCT", FormatTools.getPixelTypeString(pixelType), w, h, z, c, 1, c);<br class="">
            meta.setPixelsPhysicalSizeX(new Length(calX, UNITS.MICROM), 0);<br class="">
            meta.setPixelsPhysicalSizeY(new Length(calX, UNITS.MICROM), 0);<br class="">
            meta.setPixelsPhysicalSizeZ(new Length(calZ, UNITS.MICROM), 0);<br class="">
<br class="">
            IFormatWriter writer = new loci.formats.ImageWriter();<br class="">
            writer.setMetadataRetrieve(meta);<br class="">
            writer.setId(id);<br class="">
            writer.saveBytes(0, img);<br class="">
            writer.close();<br class="">
        } catch (Exception e) {<br class="">
            fail("problem writing image to disk");<br class="">
        }<br class="">
<br class="">
        ImageProcessorReader r = new ImageProcessorReader(new ChannelSeparator(LociPrefs.makeImageReader()));<br class="">
        IMetadata meta = null;<br class="">
        try {<br class="">
            ServiceFactory factory = new ServiceFactory();<br class="">
            OMEXMLService service = factory.getInstance(OMEXMLService.class);<br class="">
            try {<br class="">
                meta = service.createOMEXMLMetadata();<br class="">
                r.setMetadataStore(meta);<br class="">
            } catch (ServiceException ex) {<br class="">
                fail("problem setting metadata");<br class="">
            }<br class="">
        } catch (DependencyException ex) {<br class="">
            fail("problem setting metadata");<br class="">
        }<br class="">
        try {<br class="">
            r.setId(id);<br class="">
            r.setSeries(0);<br class="">
            Length lx = meta.getPixelsPhysicalSizeX(0);<br class="">
            Length lz = meta.getPixelsPhysicalSizeZ(0);<br class="">
            Assert.assertTrue("testing calibration X is not null?", lx!=null);<br class="">
            Assert.assertTrue("testing calibration Z is not null?", lz!=null);<br class="">
            Assert.assertEquals("testing calibration X retrieve", calX, lx.value());<br class="">
            Assert.assertEquals("testing calibration Z retrieve", calZ, lz.value());<br class="">
            r.close();<br class="">
        } catch (FormatException exc) {<br class="">
            fail("error reading image");<br class="">
        } catch (IOException exc) {<br class="">
            fail("error reading image");<br class="">
        }<br class="">
    }<br class="">
<br class="">
</div>
<div class="">It appears the objects "lx" and "lz" are null. <br class="">
</div>
<div class="">Could you point me the error? <br class="">
<br class="">
</div>
<div class="">I also have a slide question: here I use the ImageProcessorReader for simplicity, is there a reader that outputs directly one primitive array per plane, in order not to use imageJ's library?<br class="">
</div>
<div class="">Thank you,<br class="">
</div>
<div class="">Best, <br class="">
Jean<br class="">
</div>
</div>
</div>
</blockquote>
</div>
<br class="">
</div>
_______________________________________________<br class="">
ome-devel mailing list<br class="">
<a href="mailto:ome-devel@lists.openmicroscopy.org.uk" class="">ome-devel@lists.openmicroscopy.org.uk</a><br class="">
http://lists.openmicroscopy.org.uk/mailman/listinfo/ome-devel<br class="">
</div>
</blockquote>
</div>
<br class="">
</div>
<br>
<span style="font-size:10pt;">The University of Dundee is a registered Scottish Charity, No: SC015096</span>
</body>
</html>