/** * @return true if min-max is set * @throws FormatException * @throws IOException */ @SuppressWarnings("unchecked") public boolean isMinMaxSet() throws FormatException, IOException { if (minMaxSet == null) { MetadataStore store = reader.getMetadataStore(); int series = reader.getSeries(); List<Pixels> pixels = (List<Pixels>) store.getRoot(); if (pixels == null) { return minMaxSet = true; } Pixels p = pixels.get(series); Channel c = p.getChannel(p.getSizeC().getValue() - 1); if (c.getStatsInfo() == null) { minMaxSet = false; } else { minMaxSet = true; } } return minMaxSet; }
private void parseROIs(MetadataStore store) throws FormatException, IOException { if (MetadataTools.isOMEXMLMetadata(store) || MetadataTools.isOMEXMLRoot(store.getRoot())) { return; } String roiID = MetadataTools.createLSID("ROI", 0, 0); String maskID = MetadataTools.createLSID("Shape", 0, 0); store.setROIID(roiID, 0); store.setMaskID(maskID, 0, 0); String positionData = DataTools.readFile(roiDrawFile); String[] coordinates = positionData.split("[ ,]"); double x1 = Double.parseDouble(coordinates[1]); double y1 = Double.parseDouble(coordinates[2]); double x2 = Double.parseDouble(coordinates[3]); double y2 = Double.parseDouble(coordinates[5]); store.setMaskX(x1, 0, 0); store.setMaskY(y1, 0, 0); store.setMaskWidth(x2 - x1, 0, 0); store.setMaskHeight(y2 - y1, 0, 0); store.setImageROIRef(roiID, 0, 0); ImageReader roiReader = new ImageReader(); roiReader.setId(roiFile); byte[] roiPixels = roiReader.openBytes(0); roiReader.close(); BitWriter bits = new BitWriter(roiPixels.length / 8); for (int i = 0; i < roiPixels.length; i++) { bits.write(roiPixels[i] == 0 ? 0 : 1, 1); } store.setMaskBinData(bits.toByteArray(), 0, 0); }