Class IM3Reader

All Implemented Interfaces:
Closeable, AutoCloseable, ICompressedTileReader, IFormatHandler, IFormatReader, IMetadataConfigurable, IPyramidHandler

public class IM3Reader extends FormatReader
Author:
Lee Kamentsky This is a FormatReader for the Perkin-Elmer Nuance line of multispectral imaging microscopes' .im3 file format. The .im3 format stores 63 planes representing intensity measurements taken on separate spectral bands. The pixel intensity at a single band might be used as a proxy for fluorophore presence, but the best results are obtained if the whole spectrum is used to synthesize an intensity. The most efficient strategy is to use IM3Reader.openRaw() to fetch the entire image which may then be scanned sequentially to create one planar image per desired signal. IM3Reader may be run as a Java application to dump a per-record description of the file to standard output
  • Field Details

  • Constructor Details

    • IM3Reader

      public IM3Reader()
      Construct an uninitialized reader of .im3 files.
  • Method Details

    • openBytes

      public byte[] openBytes(int no, byte[] buf, int x, int y, int w, int h) throws FormatException, IOException
      Description copied from interface: IFormatReader
      Obtains a sub-image of the specified image plane into a pre-allocated byte array.
      Specified by:
      openBytes in interface IFormatReader
      Specified by:
      openBytes in class FormatReader
      Parameters:
      no - the plane index within the current series.
      buf - a pre-allocated buffer.
      x - X coordinate of the upper-left corner of the sub-image
      y - Y coordinate of the upper-left corner of the sub-image
      w - width of the sub-image
      h - height of the sub-image
      Returns:
      the pre-allocated buffer buf for convenience.
      Throws:
      FormatException - if there was a problem parsing the metadata of the file.
      IOException - if there was a problem reading the file.
    • openRaw

      public byte[] openRaw() throws IOException
      Open the current series in raw-mode, returning the interleaved image bytes. The data format for a pixel is a run of 63 unsigned short little endian values.
      Returns:
      a byte array containing the data organized by spectral channel, then x, then y. Returns null if, for some incomprehensible reason, the DATA block was missing.
      Throws:
      IOException
    • getSpectra

      public List<IM3Reader.Spectrum> getSpectra()
      If a Nuance file is a spectral library set (.csl) file, there is a spectral library inside that contains a profile of spectral bin magnitudes for each of several measured fluorophores (or auto fluorescence). This method finds the spectral library and returns the spectra inside.
      Returns:
      a list of the Spectrum records contained in the library
    • initFile

      protected void initFile(String id) throws FormatException, IOException
      Description copied from class: FormatReader
      Initializes the given file (parsing header information, etc.). Most subclasses should override this method to perform initialization operations such as parsing metadata.
      Overrides:
      initFile in class FormatReader
      Throws:
      FormatException - if a parsing error occurs processing the file.
      IOException - if an I/O error occurs processing the file
    • parseString

      protected static String parseString(loci.common.IRandomAccess is) throws IOException
      Parse a string from the IM3 file at the current file pointer loc
      Parameters:
      is - stream to read from
      Returns:
      parsed string or null for string of zero length
      Throws:
      IOException
    • parseRecord

      private static IM3Reader.IM3Record parseRecord(loci.common.IRandomAccess is) throws IOException
      Parse an IM3 record at the current file pointer location
      Parameters:
      is - random access stream, pointing at the record's start (the length-quadword of the record's tag name)
      Returns:
      an IM3Record or subclass depending on the record's type
      Throws:
      IOException - on file misparsing leading to overrun and other
    • isThisType

      public boolean isThisType(loci.common.RandomAccessInputStream stream) throws IOException
      Description copied from interface: IFormatReader
      Checks if the given stream is a valid stream for this file format. The number of bytes read is format-dependent.
      Specified by:
      isThisType in interface IFormatReader
      Overrides:
      isThisType in class FormatReader
      Parameters:
      stream - A RandomAccessInputStream representing the file to check. The first byte in the stream is assumed to be the first byte in the file.
      Returns:
      true if the file represented by the stream can be read by this reader; false otherwise.
      Throws:
      IOException
    • setSeries

      public void setSeries(int no)
      Description copied from interface: IFormatReader
      Activates the specified series. This also resets the resolution to 0.
      Specified by:
      setSeries in interface IFormatReader
      Overrides:
      setSeries in class FormatReader
    • close

      public void close(boolean fileOnly) throws IOException
      Description copied from interface: IFormatReader
      Closes the currently open file. If the flag is set, this is all that happens; if unset, it is equivalent to calling Closeable.close().
      Specified by:
      close in interface IFormatReader
      Overrides:
      close in class FormatReader
      Throws:
      IOException
    • writeSummary

      public void writeSummary() throws IOException
      Write a summary of each field in the IM3 file to the writer
      Throws:
      IOException
    • main

      public static void main(String[] args) throws IOException
      Write a summary of each record to STDOUT
      Parameters:
      args -
      Throws:
      IOException