@Override public int getSeries() { return reader.getSeries(); }
/** * Determines whether the given reader represents any floating point data. * @param reader the reader to check * @return true if any of the reader's series have a floating point pixel type * @see #isFloatingPoint(int) */ public static boolean isFloatingPoint(IFormatReader reader) { int originalSeries = reader.getSeries(); for (int s=0; s<reader.getSeriesCount(); s++) { reader.setSeries(s); if (isFloatingPoint(reader.getPixelType())) { reader.setSeries(originalSeries); return true; } } reader.setSeries(originalSeries); return false; }
/** * Determines whether the given reader represents any floating point data. * @param reader the reader to check * @return true if any of the reader's series have a floating point pixel type * @see #isFloatingPoint(int) */ public static boolean isFloatingPoint(IFormatReader reader) { int originalSeries = reader.getSeries(); for (int s=0; s<reader.getSeriesCount(); s++) { reader.setSeries(s); if (isFloatingPoint(reader.getPixelType())) { reader.setSeries(originalSeries); return true; } } reader.setSeries(originalSeries); return false; }
@Override public int getSeries() { return reader.getSeries(); }
public static void populatePixelsOnly(MetadataStore store, IFormatReader r) { int oldSeries = r.getSeries(); for (int i=0; i<r.getSeriesCount(); i++) { r.setSeries(i); String pixelType = FormatTools.getPixelTypeString(r.getPixelType()); populatePixelsOnly(store, i, r.isLittleEndian(), r.getDimensionOrder(), pixelType, r.getSizeX(), r.getSizeY(), r.getSizeZ(), r.getSizeC(), r.getSizeT(), r.getRGBChannelCount()); if (store instanceof IPyramidStore) { for (int res=1; res<r.getResolutionCount(); res++) { r.setResolution(res); ((IPyramidStore) store).setResolutionSizeX( new PositiveInteger(r.getSizeX()), i, res); ((IPyramidStore) store).setResolutionSizeY( new PositiveInteger(r.getSizeY()), i, res); } r.setResolution(0); } } r.setSeries(oldSeries); }
/** * Retrieves the current series of the underlying Bio-Formats reader. * @return The series. */ public int getSeries() { // Ensure the reader has been initialized reader(); return bfReader.getSeries(); }
public static void populatePixelsOnly(MetadataStore store, IFormatReader r) { int oldSeries = r.getSeries(); for (int i=0; i<r.getSeriesCount(); i++) { r.setSeries(i); String pixelType = FormatTools.getPixelTypeString(r.getPixelType()); populatePixelsOnly(store, i, r.isLittleEndian(), r.getDimensionOrder(), pixelType, r.getSizeX(), r.getSizeY(), r.getSizeZ(), r.getSizeC(), r.getSizeT(), r.getRGBChannelCount()); if (store instanceof IPyramidStore) { for (int res=1; res<r.getResolutionCount(); res++) { r.setResolution(res); ((IPyramidStore) store).setResolutionSizeX( new PositiveInteger(r.getSizeX()), i, res); ((IPyramidStore) store).setResolutionSizeY( new PositiveInteger(r.getSizeY()), i, res); } r.setResolution(0); } } r.setSeries(oldSeries); }
@Override public int getSeries() { return getReader().getSeries(); }
@Override public int getSeries() { return getReader().getSeries(); }
public List<List<Integer>> getResolutionDescriptions() { final List<List<Integer>> rv = new ArrayList<List<Integer>>(); final int no = bfReader.getResolutionCount(); final List<CoreMetadata> cms = bfReader.getCoreMetadataList(); for (int i = 0; i < no; i++) { int coreIndex = bfReader.seriesToCoreIndex(bfReader.getSeries()) + i; CoreMetadata cm = cms.get(coreIndex); List<Integer> sizes = Arrays.asList(cm.sizeX, cm.sizeY); rv.add(sizes); } return rv; }
/** Checks that the given plane number is valid for the given reader. */ public static void checkPlaneNumber(IFormatReader r, int no) throws FormatException { int imageCount = r.getImageCount(); if (no < 0 || no >= imageCount) { throw new FormatException("Invalid image number: " + no + " (series=" + r.getSeries() + ", imageCount=" + imageCount + ")"); } }
/** check if the given reader is set to the given file and series * * @param reader the reader * @param file the file * @param series the series * @return true or false */ public static boolean checkReaderFileAndSeries(final IFormatReader reader, final File file, final int series) { // if we have a fileStitcher, do not check the actual file name final boolean isFileStitcher = FileStitcher.class.isInstance( ( (Memoizer) reader).getReader() ); if (isFileStitcher) if (reader.getCurrentFile() == null) return false; else return reader.getSeries() == series; if (reader.getCurrentFile() == null || !reader.getCurrentFile().equals( file.getAbsolutePath() )) return false; else return reader.getSeries() == series; }
/** Checks that the given plane number is valid for the given reader. */ public static void checkPlaneNumber(IFormatReader r, int no) throws FormatException { int imageCount = r.getImageCount(); if (no < 0 || no >= imageCount) { throw new FormatException("Invalid image number: " + no + " (series=" + r.getSeries() + ", imageCount=" + imageCount + ")"); } }
private void assertBlock(int blockSize, int posX, int posY, int width, int height) throws Exception { byte[] plane = new byte[planeSize]; byte[] buf = new byte[blockSize]; String planeDigest, bufDigest; for (int i = 0; i < imageCount; i++) { // Read the data as a full plane reader.openBytes(i, plane); // Read the data as a block try { reader.openBytes(i, buf, posX, posY, width, height); } catch (Exception e) { throw new RuntimeException( String.format( "openBytes(series:%d i:%d, buf.length:%d, x:%d, y:%d, w:%d, h:%d) " + "[sizeX: %d sizeY:%d bpp:%d] threw exception!", reader.getSeries(), i, buf.length, posX, posY, width, height, sizeX, sizeY, bpp), e); } // Compare hash digests planeDigest = TestTools.md5(plane, sizeX, sizeY, posX, posY, width, height, bpp); bufDigest = TestTools.md5(buf, 0, width * height * bpp); if (!planeDigest.equals(bufDigest)) { fail(String.format("MD5:%d;%d len:%d %s != %s", reader.getSeries(), i, blockSize, planeDigest, bufDigest)); } } }
/** Finds the Plane index corresponding to the given image plane number. */ private static int getPlaneIndex(IFormatReader r, int no) { MetadataRetrieve retrieve = (MetadataRetrieve) r.getMetadataStore(); int imageIndex = r.getSeries(); int planeCount = retrieve.getPlaneCount(imageIndex); int[] zct = r.getZCTCoords(no); for (int i=0; i<planeCount; i++) { Integer theC = retrieve.getPlaneTheC(imageIndex, i).getValue(); Integer theT = retrieve.getPlaneTheT(imageIndex, i).getValue(); Integer theZ = retrieve.getPlaneTheZ(imageIndex, i).getValue(); if (zct[0] == theZ.intValue() && zct[1] == theC.intValue() && zct[2] == theT.intValue()) { return i; } } return -1; }
/** Finds the Plane index corresponding to the given image plane number. */ private static int getPlaneIndex(IFormatReader r, int no) { MetadataRetrieve retrieve = (MetadataRetrieve) r.getMetadataStore(); int imageIndex = r.getSeries(); int planeCount = retrieve.getPlaneCount(imageIndex); int[] zct = r.getZCTCoords(no); for (int i=0; i<planeCount; i++) { Integer theC = retrieve.getPlaneTheC(imageIndex, i).getValue(); Integer theT = retrieve.getPlaneTheT(imageIndex, i).getValue(); Integer theZ = retrieve.getPlaneTheZ(imageIndex, i).getValue(); if (zct[0] == theZ.intValue() && zct[1] == theC.intValue() && zct[2] == theT.intValue()) { return i; } } return -1; }
/** * @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); minMaxSet = c.getStatsInfo() != null; } return minMaxSet; }