/** Parses metadata from the given {@code Sequence} element. */ public void parse(final Element sequenceElement) { checkElement(sequenceElement, "Sequence"); // parse <PVStateShard> key/value block parsePVStateShard(sequenceElement, sequenceValues); type = attr(sequenceElement, "type"); cycle = i(attr(sequenceElement, "cycle")); if (cycle == null) { throw new IllegalArgumentException("Sequence missing cycle attribute"); } spectralMode = b(attr(sequenceElement, "SpectralMode")); // iterate over all Frame elements final NodeList frameNodes = sequenceElement.getElementsByTagName("Frame"); for (int f = 0; f < frameNodes.getLength(); f++) { final Element frameElement = el(frameNodes, f); if (frameElement == null) continue; final Frame frame = new Frame(this, frameElement); if (firstFrame == null) firstFrame = frame; final int index = frame.getIndex(); if (index < indexMin) indexMin = index; if (index > indexMax) indexMax = index; frames.put(index, frame); } }
final PFile file = frame.getFile(channel); if (file == null) { warnFile(sequence, index, channel);
final Sequence sequence = sequence(0, s, seriesCount); final Frame frame = sequence.getFirstFrame(); final PFile file = frame == null ? null : frame.getFirstFile(); if (frame == null || file == null) { throw new FormatException("No metadata for series #" + s); final Integer linesPerFrame = frame.getLinesPerFrame(); final Integer pixelsPerLine = frame.getPixelsPerLine(); final int indexCount = sequence.getIndexCount();
pf(firstFrame.getMicronsPerPixelX(), "PhysicalSizeX"); if (physicalSizeX != null) { store.setPixelsPhysicalSizeX(FormatTools.createLength(physicalSizeX, UNITS.MICROMETER), s); pf(firstFrame.getMicronsPerPixelY(), "PhysicalSizeY"); if (physicalSizeY != null) { store.setPixelsPhysicalSizeY(FormatTools.createLength(physicalSizeY, UNITS.MICROMETER), s); final PFile file = firstFrame.getFile(channel); final Double zoom = firstFrame.getOpticalZoom(); if (zoom != null) store.setDetectorZoom(zoom, 0, c); final Double offset = firstFrame.getOffset(c); if (offset != null) store.setDetectorSettingsOffset(offset, s, c); final Double gain = firstFrame.getGain(c); if (gain != null) store.setDetectorSettingsGain(gain, s, c); final Double magnification = firstFrame.getMagnification(); if (magnification != null) { store.setObjectiveNominalMagnification(magnification, 0, 0); firstFrame.getObjectiveManufacturer(); store.setObjectiveManufacturer(objectiveManufacturer, 0, 0); final String immersion = firstFrame.getImmersion(); store.setObjectiveImmersion(MetadataTools.getImmersion(immersion), 0, 0);
pf(firstFrame.getMicronsPerPixelX(), "PhysicalSizeX"); if (physicalSizeX != null) { store.setPixelsPhysicalSizeX(FormatTools.createLength(physicalSizeX, UNITS.MICROMETER), s); pf(firstFrame.getMicronsPerPixelY(), "PhysicalSizeY"); if (physicalSizeY != null) { store.setPixelsPhysicalSizeY(FormatTools.createLength(physicalSizeY, UNITS.MICROMETER), s); final PFile file = firstFrame.getFile(channel); final Double zoom = firstFrame.getOpticalZoom(); if (zoom != null) store.setDetectorZoom(zoom, 0, c); final Double offset = firstFrame.getOffset(c); if (offset != null) store.setDetectorSettingsOffset(offset, s, c); final Double gain = firstFrame.getGain(c); if (gain != null) store.setDetectorSettingsGain(gain, s, c); final Double magnification = firstFrame.getMagnification(); if (magnification != null) { store.setObjectiveNominalMagnification(magnification, 0, 0); firstFrame.getObjectiveManufacturer(); store.setObjectiveManufacturer(objectiveManufacturer, 0, 0); final String immersion = firstFrame.getImmersion(); store.setObjectiveImmersion(MetadataTools.getImmersion(immersion), 0, 0);
final Sequence sequence = sequence(0, s, seriesCount); final Frame frame = sequence.getFirstFrame(); final PFile file = frame == null ? null : frame.getFirstFile(); if (frame == null || file == null) { throw new FormatException("No metadata for series #" + s); final Integer linesPerFrame = frame.getLinesPerFrame(); final Integer pixelsPerLine = frame.getPixelsPerLine(); final int indexCount = sequence.getIndexCount();
final PFile file = frame.getFile(channel); if (file == null) { warnFile(sequence, index, channel);
@Override public byte[] openBytes(int no, byte[] buf, int x, int y, int w, int h) throws FormatException, IOException { FormatTools.checkPlaneParameters(this, no, buf.length, x, y, w, h); if (singleTiffMode) return tiff.openBytes(no, buf, x, y, w, h); // convert 1D index to (sequence, index, channel) coordinates. final int[] zct = getZCTCoords(no); final int z = zct[0], c = zct[1], t = zct[2]; final Sequence sequence = sequence(t, getSeries()); final int index = frameIndex(sequence, z, t, getSeries()); final Frame frame = sequence.getFrame(index); if (frame == null) { warnFrame(sequence, index); return blank(buf); } final int channel = channels[c]; final PFile file = frame.getFile(channel); if (file == null) { warnFile(sequence, index, channel); return blank(buf); } tiff.setId(getPath(file)); return tiff.openBytes(0, buf, x, y, w, h); }
/** Parses metadata from the given {@code Sequence} element. */ public void parse(final Element sequenceElement) { checkElement(sequenceElement, "Sequence"); // parse <PVStateShard> key/value block parsePVStateShard(sequenceElement, sequenceValues); type = attr(sequenceElement, "type"); cycle = i(attr(sequenceElement, "cycle")); if (cycle == null) { throw new IllegalArgumentException("Sequence missing cycle attribute"); } spectralMode = b(attr(sequenceElement, "SpectralMode")); // iterate over all Frame elements final NodeList frameNodes = sequenceElement.getElementsByTagName("Frame"); for (int f = 0; f < frameNodes.getLength(); f++) { final Element frameElement = el(frameNodes, f); if (frameElement == null) continue; final Frame frame = new Frame(this, frameElement); if (firstFrame == null) firstFrame = frame; final int index = frame.getIndex(); if (index < indexMin) indexMin = index; if (index > indexMax) indexMax = index; frames.put(index, frame); } }
@Override public byte[] openBytes(int no, byte[] buf, int x, int y, int w, int h) throws FormatException, IOException { FormatTools.checkPlaneParameters(this, no, buf.length, x, y, w, h); if (singleTiffMode) return tiff.openBytes(no, buf, x, y, w, h); // convert 1D index to (sequence, index, channel) coordinates. final int[] zct = getZCTCoords(no); final int z = zct[0], c = zct[1], t = zct[2]; final Sequence sequence = sequence(t, getSeries()); final int index = frameIndex(sequence, z, t, getSeries()); final Frame frame = sequence.getFrame(index); if (frame == null) { warnFrame(sequence, index); return blank(buf); } final int channel = channels[c]; final PFile file = frame.getFile(channel); if (file == null) { warnFile(sequence, index, channel); return blank(buf); } tiff.setId(getPath(file)); return tiff.openBytes(0, buf, x, y, w, h); }
@Test public void testParseNewXML() throws ParserConfigurationException, SAXException, IOException { final Document xml = XMLTools.parseDOM(NEW_XML); final PrairieMetadata meta = new PrairieMetadata(xml, null, null); final ValueTable positionCurrent = (ValueTable) meta.getSequence(1).getFrame(1).getValue("positionCurrent"); final ValueTable xAxis = (ValueTable) positionCurrent.get("XAxis"); assertEquals("-621.412879412341", xAxis.value()); final ValueTable yAxis = (ValueTable) positionCurrent.get("YAxis"); assertEquals("255.652372573538", yAxis.value()); final ValueTable zAxis = (ValueTable) positionCurrent.get("ZAxis"); assertEquals("28.15", zAxis.get(0).value()); assertEquals("111.23", zAxis.get(1).value()); } }
@Test public void testParseOldXML() throws ParserConfigurationException, SAXException, IOException { final Document xml = XMLTools.parseDOM(OLD_XML); final PrairieMetadata meta = new PrairieMetadata(xml, null, null); final Value positionCurrent = meta.getSequence(1).getFrame(1).getValue("positionCurrent"); final Value xAxis = positionCurrent.get("XAxis"); assertEquals("0.95", xAxis.value()); final Value yAxis = positionCurrent.get("YAxis"); assertEquals("-4.45", yAxis.value()); final ValueTable zAxis = (ValueTable) positionCurrent.get("ZAxis"); assertEquals("-9", zAxis.get(0).value()); assertEquals("62.45", zAxis.get(1).value()); }
/** Gets the optical zoom associated with this {@code Frame}. */ public Double getOpticalZoom() { return d(value(getValue("opticalZoom"))); }
/** Gets the microns per pixel along X for this {@code Frame}. */ public Double getMicronsPerPixelX() { return d(value(getValue("micronsPerPixel"), "XAxis")); }
/** Gets the numerical aperture of the lens for this {@code Frame}. */ public Double getObjectiveLensNA() { return d(value(getValue("objectiveLensNA"))); }
/** Gets the imaging device associated with this {@code Frame}. */ public String getImagingDevice() { return value(getValue("imagingDevice")); }
/** Gets the microns per pixel along X for this {@code Frame}. */ public Double getMicronsPerPixelX() { return d(value(getValue("micronsPerPixel"), "XAxis")); }
/** Gets the lines per frame for this {@code Frame}. */ public Integer getLinesPerFrame() { return i(value(getValue("linesPerFrame"))); }
/** Gets the microns per pixel along Y for this {@code Frame}. */ public Double getMicronsPerPixelY() { return d(value(getValue("micronsPerPixel"), "YAxis")); }
/** Gets the lines per frame for this {@code Frame}. */ public Integer getLinesPerFrame() { return i(value(getValue("linesPerFrame"))); }