glencoesoftware/bioformats2raw

'?m' not a supported value of 'class ome.xml.model.enums.UnitsLength'

Closed this issue · 6 comments

I have converted MRXS to n5 using https://github.com/glencoesoftware/bioformats2raw, now trying to convert to ome-tiff but I am facing issue with the following:

2019-12-05 11:47:37,277 [main] INFO  c.g.p.PyramidFromDirectoryWriter - Creating tiled pyramid file /nfs/MRXS/HB_BRC2083.ome.tif
WARNING: An illegal reflective access operation has occurred
WARNING: Illegal reflective access by org.janelia.saalfeldlab.n5.CompressionAdapter (file:/opt/raw2ometiff-0.1.0/lib/n5-2.1.3.jar) to field java.lang.reflect.Field.modifiers
WARNING: Please consider reporting this to the maintainers of org.janelia.saalfeldlab.n5.CompressionAdapter
WARNING: Use --illegal-access=warn to enable warnings of further illegal reflective access operations
WARNING: All illegal access operations will be denied in a future release
2019-12-05 11:47:37,472 [main] INFO  org.perf4j.TimingLogger - start[1575546457002] time[469] tag[initialize]
Exception in thread "main" picocli.CommandLine$ExecutionException: Error while calling command (com.glencoesoftware.pyramid.PyramidFromDirectoryWriter@47dbb1e2): java.lang.RuntimeException: loci.formats.FormatException: Could not parse OME-XML
	at picocli.CommandLine.execute(CommandLine.java:1180)
	at picocli.CommandLine.access$800(CommandLine.java:141)
	at picocli.CommandLine$RunLast.handle(CommandLine.java:1367)
	at picocli.CommandLine$RunLast.handle(CommandLine.java:1335)
	at picocli.CommandLine$AbstractParseResultHandler.handleParseResult(CommandLine.java:1243)
	at picocli.CommandLine.parseWithHandlers(CommandLine.java:1526)
	at picocli.CommandLine.call(CommandLine.java:1786)
	at picocli.CommandLine.call(CommandLine.java:1710)
	at com.glencoesoftware.pyramid.PyramidFromDirectoryWriter.main(PyramidFromDirectoryWriter.java:260)
Caused by: java.lang.RuntimeException: loci.formats.FormatException: Could not parse OME-XML
	at com.glencoesoftware.pyramid.PyramidFromDirectoryWriter.call(PyramidFromDirectoryWriter.java:291)
	at com.glencoesoftware.pyramid.PyramidFromDirectoryWriter.call(PyramidFromDirectoryWriter.java:97)
	at picocli.CommandLine.execute(CommandLine.java:1173)
	... 8 more
Caused by: loci.formats.FormatException: Could not parse OME-XML
	at com.glencoesoftware.pyramid.PyramidFromDirectoryWriter.initialize(PyramidFromDirectoryWriter.java:530)
	at com.glencoesoftware.pyramid.PyramidFromDirectoryWriter.call(PyramidFromDirectoryWriter.java:277)
	... 10 more
Caused by: loci.common.services.ServiceException: ome.xml.model.enums.EnumerationException: '?m' not a supported value of 'class ome.xml.model.enums.UnitsLength'
	at loci.formats.services.OMEXMLServiceImpl.createRoot(OMEXMLServiceImpl.java:417)
	at loci.formats.services.OMEXMLServiceImpl.createOMEXMLMetadata(OMEXMLServiceImpl.java:373)
	at loci.formats.services.OMEXMLServiceImpl.createOMEXMLMetadata(OMEXMLServiceImpl.java:360)
	at com.glencoesoftware.pyramid.PyramidFromDirectoryWriter.initialize(PyramidFromDirectoryWriter.java:517)
	... 11 more
Caused by: ome.xml.model.enums.EnumerationException: '?m' not a supported value of 'class ome.xml.model.enums.UnitsLength'
	at ome.xml.model.enums.UnitsLength.fromString(UnitsLength.java:280)
	at ome.xml.model.Pixels.update(Pixels.java:255)
	at ome.xml.model.Pixels.<init>(Pixels.java:167)
	at ome.xml.model.Image.update(Image.java:357)
	at ome.xml.model.Image.<init>(Image.java:161)
	at ome.xml.model.OME.update(OME.java:314)
	at ome.xml.model.OME.<init>(OME.java:155)
	at ome.xml.meta.OMEXMLMetadataRoot.<init>(OMEXMLMetadataRoot.java:68)
	at loci.formats.services.OMEXMLServiceImpl.createRoot(OMEXMLServiceImpl.java:412)
	... 14 more

Looks like in METADATA.ome.xml all the units were prefixed with ? e.g.

PhysicalSizeXUnit="?m" ... PhysicalSizeYUnit="?m" ... ExposureTimeUnit="?s"

I am not sure where they come from but removing them manually allows me to run converter

Looks like you are having an issue with encoding @olatarkowska. For files that we have been converting the corresponding XML looks like:

...
<Pixels BigEndian="true" DimensionOrder="XYCZT" ID="Pixels:0" Interleaved="false" 
    PhysicalSizeX="0.325" PhysicalSizeXUnit="µm" PhysicalSizeY="0.325" PhysicalSizeYUnit="µm" 
    SignificantBits="16" SizeC="3" SizeT="1" SizeX="17576" SizeY="80048" SizeZ="1" Type="uint16">
...
      <Plane ExposureTime="20000.0" ExposureTimeUnit="µs" TheC="0" TheT="0" TheZ="0"/>
      <Plane ExposureTime="20000.0" ExposureTimeUnit="µs" TheC="1" TheT="0" TheZ="0"/>
      <Plane ExposureTime="20000.0" ExposureTimeUnit="µs" TheC="2" TheT="0" TheZ="0"/>
...

You will note the µ where you have ? indicating that the UTF-8 got stripped.

I don't think we're forcing any encoding and we'll look at that. In the mean time you might want to look at your LANG environment variable and how Java is installed where the default encoding might be forced to C or ASCII. This can be especially problematic if you are doing your conversion in a Docker container and don't have ENV LANG C.UTF-8 in your Dockerfile. The ubuntu:18.04 Docker container for instance defaults to LANG=C which can create all sorts of problems like this.

@melissalinkert: Probably worthwhile forcing UTF-8 everywhere. I can't see a reason not to.

Thanks @chris-allan for explanation. Yes thats the case.

This is a problem in bioformats2raw. I could reproduce by doing the following:

$ export LANG=en_US.ASCII
$ bin/bioformats2raw CMU-1.svs CMU-1.n5
$ grep PhysicalSizeX CMU-1.n5/METADATA.ome.xml

@olatarkowska : thanks for reporting this. #12 should hopefully fix it, but if you still see problems with that change just let us know.