Class MRCReader

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

public class MRCReader extends FormatReader
MRCReader is the file format reader for MRC files. Specifications available at http://bio3d.colorado.edu/imod/doc/mrc_format.txt
  • Field Details

    • TYPES

      private static final String[] TYPES
    • MRC_SUFFIXES

      private static final String[] MRC_SUFFIXES
    • HEADER_SIZE

      private static final int HEADER_SIZE
      See Also:
    • GRIDSIZE_OFFSET

      private static final int GRIDSIZE_OFFSET
      See Also:
    • ENDIANNESS_OFFSET

      private static final int ENDIANNESS_OFFSET
      See Also:
    • IMODSTAMP_OFFSET

      private static final int IMODSTAMP_OFFSET
      See Also:
    • extHeaderSize

      private int extHeaderSize
      Size of extended header
  • Constructor Details

    • MRCReader

      public MRCReader()
      Constructs a new MRC reader.
  • Method Details

    • 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
      See Also:
    • 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.
      See Also:
    • 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
    • initFile

      public 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
    • setLittleEndian

      private void setLittleEndian(loci.common.RandomAccessInputStream s) throws IOException
      Detect the correct endianness and set the stream accordingly. New-style headers have a value that can be checked, but older headers do not (and are assumed to be little endian). See the definition of offsets 196-216 in: https://bio3d.colorado.edu/imod/doc/mrc_format.txt
      Throws:
      IOException