/** * Helper method to properly log any exceptions raised by Bio-Formats. * @param filePath Non-null. * @param series series to use * @return the initialized {@link BfPixelBuffer} */ protected BfPixelBuffer createBfPixelBuffer(final String filePath, final int series) { try { IFormatReader reader = createBfReader(); BfPixelBuffer pixelBuffer = new BfPixelBuffer(filePath, reader); pixelBuffer.setSeries(series); log.info(String.format("Creating BfPixelBuffer: %s Series: %d", filePath, series)); return pixelBuffer; } catch (Exception e) { String msg = "Error instantiating pixel buffer: " + filePath; log.error(msg, e); throw new ResourceError(msg); } }
/** * Helper method to properly log any exceptions raised by Bio-Formats and * add a min/max calculator wrapper to the reader stack. * @param filePath Non-null. * @param series series to use * @param store Min/max store to use with the min/max calculator. */ protected BfPixelBuffer createMinMaxBfPixelBuffer(final String filePath, final int series, final IMinMaxStore store) { try { IFormatReader reader = createBfReader(); MinMaxCalculator calculator = new MinMaxCalculator(reader); calculator.setMinMaxStore(store); BfPixelBuffer pixelBuffer = new BfPixelBuffer(filePath, calculator); pixelBuffer.setSeries(series); log.info(String.format("Creating BfPixelBuffer: %s Series: %d", filePath, series)); return pixelBuffer; } catch (Exception e) { String msg = "Error instantiating pixel buffer: " + filePath; log.error(msg, e); throw new ResourceError(msg); } }
/** * Short-cut in the FS case where we know that we are dealing with a FS-lite * file, and want to retrieve the actual file as opposed to a pyramid or anything * else. This may be used to access the original metadata. * @throws FormatException * @throws IOException */ public IFormatReader getBfReader(Pixels pixels) throws FormatException, IOException { // from getPixelBuffer final String originalFilePath = getOriginalFilePath(pixels); final int series = getSeries(pixels); final IFormatReader reader = createBfReader(); reader.setId(originalFilePath); // Called by BfPixelsBuffer elsewhere. reader.setSeries(series); return reader; }