<div dir="ltr"><div><div><div><div><div><div>Hello Sebastien, <br></div>When I change the format to ome.tif, it works well. <br></div>Also for the other problem I mentioned (inversion of number of time points and number of slices) <br><br></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></div>Does the bug comes from my code or from the bioformats? <br></div>Thanks you, <br></div><div>Best,<br></div>Jean Ollion<br></div><div class="gmail_extra"><br><div class="gmail_quote">2015-06-29 18:38 GMT+02:00 Jean Ollion <span dir="ltr"><<a href="mailto:smogollion@yahoo.fr" target="_blank">smogollion@yahoo.fr</a>></span>:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div>Hello, <br></div>I have trouble reading and writing calibration in metadata. Here is a minimal example, written as a JUnit test.<br><div><div><br>@Rule<br> public TemporaryFolder testFolder = new TemporaryFolder();<br>@org.junit.Test<br> public void testIOImageCalibration() {<br> String id = testFolder.newFolder("imageTest").getAbsolutePath() + File.separator + "imageTest.tif";<br> int w = 512, h = 512, c = 1, z = 1;<br> int pixelType = FormatTools.UINT16;<br> byte[] img = new byte[w * h * c * FormatTools.getBytesPerPixel(pixelType)];<br> for (int i = 0; i < img.length; i++) {<br> img[i] = (byte) (256 * Math.random());<br> }<br> double calX = 0.1d;<br> double calZ = 0.23d;<br> try {<br> ServiceFactory factory = new ServiceFactory();<br> OMEXMLService service = factory.getInstance(OMEXMLService.class);<br> IMetadata meta = service.createOMEXMLMetadata();<br> MetadataTools.populateMetadata(meta, 0, null, false, "XYZCT", FormatTools.getPixelTypeString(pixelType), w, h, z, c, 1, c);<br> meta.setPixelsPhysicalSizeX(new Length(calX, UNITS.MICROM), 0);<br> meta.setPixelsPhysicalSizeY(new Length(calX, UNITS.MICROM), 0);<br> meta.setPixelsPhysicalSizeZ(new Length(calZ, UNITS.MICROM), 0);<br><br> IFormatWriter writer = new loci.formats.ImageWriter();<br> writer.setMetadataRetrieve(meta);<br> writer.setId(id);<br> writer.saveBytes(0, img);<br> writer.close();<br> } catch (Exception e) {<br> fail("problem writing image to disk");<br> }<br><br> ImageProcessorReader r = new ImageProcessorReader(new ChannelSeparator(LociPrefs.makeImageReader()));<br> IMetadata meta = null;<br> try {<br> ServiceFactory factory = new ServiceFactory();<br> OMEXMLService service = factory.getInstance(OMEXMLService.class);<br> try {<br> meta = service.createOMEXMLMetadata();<br> r.setMetadataStore(meta);<br> } catch (ServiceException ex) {<br> fail("problem setting metadata");<br> }<br> } catch (DependencyException ex) {<br> fail("problem setting metadata");<br> }<br> try {<br> r.setId(id);<br> r.setSeries(0);<br> Length lx = meta.getPixelsPhysicalSizeX(0);<br> Length lz = meta.getPixelsPhysicalSizeZ(0);<br> Assert.assertTrue("testing calibration X is not null?", lx!=null);<br> Assert.assertTrue("testing calibration Z is not null?", lz!=null);<br> Assert.assertEquals("testing calibration X retrieve", calX, lx.value());<br> Assert.assertEquals("testing calibration Z retrieve", calZ, lz.value());<br> r.close();<br> } catch (FormatException exc) {<br> fail("error reading image");<br> } catch (IOException exc) {<br> fail("error reading image");<br> }<br> }<br><br></div><div>It appears the objects "lx" and "lz" are null. <br></div><div>Could you point me the error? <br><br></div><div>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></div><div>Thank you,<br></div><div>Best, <br>Jean<br></div></div></div>
</blockquote></div><br></div>