Class GatanReader

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

public class GatanReader extends FormatReader
GatanReader is the file format reader for Gatan files.
Author:
Melissa Linkert melissa at glencoesoftware.com
  • Field Details

    • DM3_MAGIC_BYTES

      public static final int DM3_MAGIC_BYTES
      See Also:
    • DM4_MAGIC_BYTES

      public static final int DM4_MAGIC_BYTES
      See Also:
    • GROUP

      private static final int GROUP
      Tag types.
      See Also:
    • VALUE

      private static final int VALUE
      See Also:
    • ARRAY

      private static final int ARRAY
      Data types.
      See Also:
    • SHORT

      private static final int SHORT
      See Also:
    • USHORT

      private static final int USHORT
      See Also:
    • INT

      private static final int INT
      See Also:
    • UINT

      private static final int UINT
      See Also:
    • FLOAT

      private static final int FLOAT
      See Also:
    • DOUBLE

      private static final int DOUBLE
      See Also:
    • BYTE

      private static final int BYTE
      See Also:
    • UBYTE

      private static final int UBYTE
      See Also:
    • CHAR

      private static final int CHAR
      See Also:
    • UNKNOWN

      private static final int UNKNOWN
      See Also:
    • UNKNOWN2

      private static final int UNKNOWN2
      See Also:
    • LINE

      private static final int LINE
      Shape types
      See Also:
    • RECTANGLE

      private static final int RECTANGLE
      See Also:
    • ELLIPSE

      private static final int ELLIPSE
      See Also:
    • TEXT

      private static final int TEXT
      See Also:
    • SPLIT_MONTAGE

      public static final String SPLIT_MONTAGE
      See Also:
    • SPLIT_MONTAGE_DEFAULT

      public static final boolean SPLIT_MONTAGE_DEFAULT
      See Also:
    • pixelOffset

      private long pixelOffset
      Offset to pixel data.
    • pixelSizes

      private List<Double> pixelSizes
      List of pixel sizes.
    • units

      private List<String> units
    • numPixelBytes

      private long numPixelBytes
    • signed

      private boolean signed
    • timestamp

      private long timestamp
    • gamma

      private double gamma
    • mag

      private double mag
    • voltage

      private double voltage
    • info

      private String info
    • posX

      private ome.units.quantity.Length posX
    • posY

      private ome.units.quantity.Length posY
    • posZ

      private ome.units.quantity.Length posZ
    • sampleTime

      private double sampleTime
    • adjustEndianness

      private boolean adjustEndianness
    • version

      private int version
    • shapes

      private transient List<GatanReader.ROIShape> shapes
    • foundMontage

      private transient boolean foundMontage
    • stageX

      private transient List<ome.units.quantity.Length> stageX
    • stageY

      private transient List<ome.units.quantity.Length> stageY
    • stageZ

      private transient List<ome.units.quantity.Length> stageZ
  • Constructor Details

    • GatanReader

      public GatanReader()
      Constructs a new Gatan 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
    • 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
    • getAvailableOptions

      protected ArrayList<String> getAvailableOptions()
      Description copied from class: FormatReader
      Returns the list of available metadata options.
      Overrides:
      getAvailableOptions in class FormatReader
    • 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
    • splitMontage

      public boolean splitMontage()
    • parseTags

      private void parseTags(int numTags, String parent, String indent) throws FormatException, IOException, ParseException
      Parses Gatan DM3 tags. Information on the DM3 structure found at: http://rsb.info.nih.gov/ij/plugins/DM3Format.gj.html and http://www-hrem.msm.cam.ac.uk/~cbb/info/dmformat/ The basic structure is this: the file is comprised of a list of tags. Each tag is either a data tag or a group tag. Group tags are simply containers for more group and data tags, where data tags contain actual metadata. Each data tag is comprised of a type (byte, short, etc.), a label, and a value.
      Throws:
      FormatException
      IOException
      ParseException
    • readValue

      private double readValue(int type) throws IOException
      Throws:
      IOException
    • getNumBytes

      private int getNumBytes(int type)
    • skipPadding

      private void skipPadding() throws IOException
      Throws:
      IOException
    • convertUnits

      private ome.units.unit.Unit<ome.units.quantity.Length> convertUnits(String units)
    • createROI

      private String createROI(MetadataStore store, int index)
      Create an empty ROI and link it to the Image.
      Parameters:
      store - MetadataStore in which to create the ROI
      index - ROI index
      Returns:
      corresponding Shape ID to be used with the new ROI