From 880da66f37692d28b05e9291483a298ec4543b95 Mon Sep 17 00:00:00 2001 From: dgault Date: Mon, 7 Sep 2015 11:51:08 +0100 Subject: [PATCH] VoxelSize reading in MetaMorph To fix the physical Z size, the difference between the absolute Z positions will need to be used. MetaMorph handler already parses the z positions. The physical z size is then calculated by subtracting the top and bottom values and dividing by the number of steps. Ticket details below: https://trac.openmicroscopy.org/ome/ticket/12977 --- .../src/loci/formats/in/MetamorphReader.java | 26 +++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/components/formats-gpl/src/loci/formats/in/MetamorphReader.java b/components/formats-gpl/src/loci/formats/in/MetamorphReader.java index 61fd5b6070d..c2ac718944e 100644 --- a/components/formats-gpl/src/loci/formats/in/MetamorphReader.java +++ b/components/formats-gpl/src/loci/formats/in/MetamorphReader.java @@ -778,6 +778,32 @@ else if (differentZs) { if (zDistances != null) { stepSize = zDistances[0]; } + else { + Vector zPositions = new Vector(); + Vector uniqueZ = new Vector(); + + for (IFD ifd : ifds) { + String xml = XMLTools.sanitizeXML(ifd.getComment()); + XMLTools.parseXML(xml, handler); + + zPositions = handler.getZPositions(); + for (Double z : zPositions) { + if (!uniqueZ.contains(z)) uniqueZ.add(z); + } + } + + if (uniqueZ.size() > 0) { + CoreMetadata ms0 = core.get(0); + if (getSizeZ() == 0) ms0.sizeZ = 1; + + Double zRange = zPositions.get(zPositions.size() - 1) - zPositions.get(0); + stepSize = Math.abs(zRange); + if (ms0.sizeZ > 1) { + stepSize /= (ms0.sizeZ - 1); + } + } + } + Length physicalSizeZ = FormatTools.getPhysicalSizeZ(stepSize); if (physicalSizeZ != null) { store.setPixelsPhysicalSizeZ(physicalSizeZ, i);