/** * If the pyramid file exists (which the constructor guarantees) then we * assume that even if a lock file is present, that it's no longer valid. */ protected synchronized void initializeReader() throws IOException, FormatException { File lockFile = lockFile(); if (readerFile.exists() && lockFile.exists()) { // note: we double checked readerFile exists just in case. lockFile.delete(); } reader = new OmeroPixelsPyramidReader(); delegate = new BfPixelBuffer(readerFile.getAbsolutePath(), reader); byteOrder = delegate.isLittleEndian()? ByteOrder.LITTLE_ENDIAN : ByteOrder.BIG_ENDIAN; }
/** * 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); } }