loci.formats.in

## Class GatanReader

- java.lang.Object
- - loci.formats.FormatHandler
  - - loci.formats.FormatReader
    - - loci.formats.in.GatanReader

- All Implemented Interfaces:
    java.io.Closeable, java.lang.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

- - ### Nested Class Summary

    Nested Classes
    Modifier and Type | Class and Description
    --- | ---
    `(package private) class` | `GatanReader.ROIShape`

  - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `private boolean` | `adjustEndianness`
    `private static int` | `ARRAY` Data types.
    `private static int` | `BYTE`
    `private static int` | `CHAR`
    `static int` | `DM3_MAGIC_BYTES`
    `static int` | `DM4_MAGIC_BYTES`
    `private static int` | `DOUBLE`
    `private static int` | `ELLIPSE`
    `private static int` | `FLOAT`
    `private boolean` | `foundMontage`
    `private double` | `gamma`
    `private static int` | `GROUP` Tag types.
    `private java.lang.String` | `info`
    `private static int` | `INT`
    `private static int` | `LINE` Shape types
    `private double` | `mag`
    `private long` | `numPixelBytes`
    `private long` | `pixelOffset` Offset to pixel data.
    `private java.util.List<java.lang.Double>` | `pixelSizes` List of pixel sizes.
    `private ome.units.quantity.Length` | `posX`
    `private ome.units.quantity.Length` | `posY`
    `private ome.units.quantity.Length` | `posZ`
    `private static int` | `RECTANGLE`
    `private double` | `sampleTime`
    `private java.util.List<GatanReader.ROIShape>` | `shapes`
    `private static int` | `SHORT`
    `private boolean` | `signed`
    `static java.lang.String` | `SPLIT_MONTAGE`
    `static boolean` | `SPLIT_MONTAGE_DEFAULT`
    `private java.util.List<ome.units.quantity.Length>` | `stageX`
    `private java.util.List<ome.units.quantity.Length>` | `stageY`
    `private java.util.List<ome.units.quantity.Length>` | `stageZ`
    `private static int` | `TEXT`
    `private long` | `timestamp`
    `private static int` | `UBYTE`
    `private static int` | `UINT`
    `private java.util.List<java.lang.String>` | `units`
    `private static int` | `UNKNOWN`
    `private static int` | `UNKNOWN2`
    `private static int` | `USHORT`
    `private static int` | `VALUE`
    `private int` | `version`
    `private double` | `voltage`

    - ### Fields inherited from class loci.formats.FormatReader

      `core, coreIndex, datasetDescription, domains, fillColor, filterMetadata, flattenedResolutions, group, hasCompanionFiles, in, indexedAsRGB, metadata, metadataStore, normalizeData, resolution, saveOriginalMetadata, series, suffixNecessary, suffixSufficient, THUMBNAIL_DIMENSION`

    - ### Fields inherited from class loci.formats.FormatHandler

      `COMPRESSION_SUFFIXES, currentId, format, LOGGER, metadataOptions, suffixes`

    - ### Fields inherited from interface loci.formats.IFormatReader

      `CAN_GROUP, CANNOT_GROUP, MUST_GROUP`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `GatanReader()` Constructs a new Gatan reader.

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `close(boolean fileOnly)` Closes the currently open file.
    `private ome.units.unit.Unit<ome.units.quantity.Length>` | `convertUnits(java.lang.String units)`
    `private java.lang.String` | `createROI(MetadataStore store, int index)` Create an empty ROI and link it to the Image.
    `protected java.util.ArrayList<java.lang.String>` | `getAvailableOptions()` Returns the list of available metadata options.
    `private int` | `getNumBytes(int type)`
    `protected void` | `initFile(java.lang.String id)` Initializes the given file (parsing header information, etc.).
    `boolean` | `isThisType(loci.common.RandomAccessInputStream stream)` Checks if the given stream is a valid stream for this file format.
    `byte[]` | `openBytes(int no, byte[] buf, int x, int y, int w, int h)` Obtains a sub-image of the specified image plane into a pre-allocated byte array.
    `private void` | `parseTags(int numTags, java.lang.String parent, java.lang.String indent)` Parses Gatan DM3 tags.
    `private double` | `readValue(int type)`
    `private void` | `skipPadding()`
    `boolean` | `splitMontage()`

    - ### Methods inherited from class loci.formats.FormatReader

      `addGlobalMeta, addGlobalMeta, addGlobalMeta, addGlobalMeta, addGlobalMeta, addGlobalMeta, addGlobalMeta, addGlobalMeta, addGlobalMeta, addGlobalMetaList, addMeta, addMetaList, addSeriesMeta, addSeriesMeta, addSeriesMeta, addSeriesMeta, addSeriesMeta, addSeriesMeta, addSeriesMeta, addSeriesMeta, addSeriesMeta, addSeriesMetaList, close, coreIndexToSeries, fileGroupOption, flattenHashtables, get16BitLookupTable, get8BitLookupTable, getAcquisitionMode, getAdvancedSeriesUsedFiles, getAdvancedUsedFiles, getArcType, getBinning, getBitsPerPixel, getCompression, getContrastMethod, getCoreIndex, getCoreMetadataList, getCorrection, getCurrentCore, getCurrentFile, getDatasetStructureDescription, getDetectorType, getDimensionOrder, getDimensionOrder, getDomains, getEffectiveSizeC, getExperimentType, getFilamentType, getFillColor, getFillRule, getFilterType, getFontFamily, getFontStyle, getGlobalMeta, getGlobalMetadata, getIlluminationType, getImageCount, getImmersion, getIndex, getIndex, getLaserMedium, getLaserType, getMarker, getMedium, getMetadataStore, getMetadataStoreRoot, getMetadataValue, getMicrobeamManipulationType, getMicroscopeType, getModuloC, getModuloT, getModuloZ, getNamingConvention, getOptimalTileHeight, getOptimalTileWidth, getPixelType, getPixelType, getPossibleDomains, getPulse, getRequiredDirectories, getResolution, getResolutionCount, getRGBChannelCount, getRotationTransform, getSeries, getSeriesCount, getSeriesMeta, getSeriesMetadata, getSeriesMetadataValue, getSeriesUsedFiles, getSeriesUsedFiles, getSizeC, getSizeT, getSizeX, getSizeY, getSizeZ, getThumbSizeX, getThumbSizeY, getTileColumns, getTileRows, getUnderlyingReaders, getUsedFiles, getUsedFiles, getZCTCoords, getZCTModuloCoords, hasCompanionFiles, hasFlattenedResolutions, isFalseColor, isGroupFiles, isIndexed, isInterleaved, isInterleaved, isLittleEndian, isMetadataComplete, isMetadataFiltered, isNormalized, isOrderCertain, isOriginalMetadataPopulated, isRGB, isSingleFile, isThisType, isThisType, isThisType, isThumbnailSeries, isUsedFile, makeFilterMetadata, openBytes, openBytes, openBytes, openPlane, openThumbBytes, readPlane, readPlane, readPlane, reopenFile, seriesToCoreIndex, setCoreIndex, setFillColor, setFlattenedResolutions, setGroupFiles, setId, setMetadataFiltered, setMetadataStore, setNormalized, setOriginalMetadataPopulated, setResolution, setSeries, updateMetadataLists`

    - ### Methods inherited from class loci.formats.FormatHandler

      `checkSuffix, checkSuffix, getFormat, getMetadataOptions, getNativeDataType, getSuffixes, getSupportedMetadataLevels, setMetadataOptions`

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

    - ### Methods inherited from interface loci.formats.IFormatHandler

      `getFormat, getNativeDataType, getSuffixes`

    - ### Methods inherited from interface loci.formats.IMetadataConfigurable

      `getMetadataOptions, getSupportedMetadataLevels, setMetadataOptions`

    - ### Methods inherited from interface loci.formats.ICompressedTileReader

      `getTileCodec, getTileCodecOptions, openCompressedBytes, openCompressedBytes`

- - ### Field Detail

    - #### DM3_MAGIC_BYTES

          public static final int DM3_MAGIC_BYTES

      See Also:
        Constant Field Values

    - #### DM4_MAGIC_BYTES

          public static final int DM4_MAGIC_BYTES

      See Also:
        Constant Field Values

    - #### GROUP

          private static final int GROUP

      Tag types.
      See Also:
        Constant Field Values

    - #### VALUE

          private static final int VALUE

      See Also:
        Constant Field Values

    - #### ARRAY

          private static final int ARRAY

      Data types.
      See Also:
        Constant Field Values

    - #### SHORT

          private static final int SHORT

      See Also:
        Constant Field Values

    - #### USHORT

          private static final int USHORT

      See Also:
        Constant Field Values

    - #### INT

          private static final int INT

      See Also:
        Constant Field Values

    - #### UINT

          private static final int UINT

      See Also:
        Constant Field Values

    - #### FLOAT

          private static final int FLOAT

      See Also:
        Constant Field Values

    - #### DOUBLE

          private static final int DOUBLE

      See Also:
        Constant Field Values

    - #### BYTE

          private static final int BYTE

      See Also:
        Constant Field Values

    - #### UBYTE

          private static final int UBYTE

      See Also:
        Constant Field Values

    - #### CHAR

          private static final int CHAR

      See Also:
        Constant Field Values

    - #### UNKNOWN

          private static final int UNKNOWN

      See Also:
        Constant Field Values

    - #### UNKNOWN2

          private static final int UNKNOWN2

      See Also:
        Constant Field Values

    - #### LINE

          private static final int LINE

      Shape types
      See Also:
        Constant Field Values

    - #### RECTANGLE

          private static final int RECTANGLE

      See Also:
        Constant Field Values

    - #### ELLIPSE

          private static final int ELLIPSE

      See Also:
        Constant Field Values

    - #### TEXT

          private static final int TEXT

      See Also:
        Constant Field Values

    - #### SPLIT_MONTAGE

          public static final java.lang.String SPLIT_MONTAGE

      See Also:
        Constant Field Values

    - #### SPLIT_MONTAGE_DEFAULT

          public static final boolean SPLIT_MONTAGE_DEFAULT

      See Also:
        Constant Field Values

    - #### pixelOffset

          private long pixelOffset

      Offset to pixel data.

    - #### pixelSizes

          private java.util.List<java.lang.Double> pixelSizes

      List of pixel sizes.

    - #### units

          private java.util.List<java.lang.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 java.lang.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 java.util.List<GatanReader.ROIShape> shapes

    - #### foundMontage

          private transient boolean foundMontage

    - #### stageX

          private transient java.util.List<ome.units.quantity.Length> stageX

    - #### stageY

          private transient java.util.List<ome.units.quantity.Length> stageY

    - #### stageZ

          private transient java.util.List<ome.units.quantity.Length> stageZ

  - ### Constructor Detail

    - #### GatanReader

          public GatanReader()

      Constructs a new Gatan reader.

  - ### Method Detail

    - #### isThisType

          public boolean isThisType(loci.common.RandomAccessInputStream stream)
                             throws java.io.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:
        `java.io.IOException`

    - #### openBytes

          public byte[] openBytes(int no,
                                  byte[] buf,
                                  int x,
                                  int y,
                                  int w,
                                  int h)
                           throws FormatException,
                                  java.io.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.
        `java.io.IOException` - if there was a problem reading the file.
      See Also:
        `IFormatReader.openBytes(int, byte[], int, int, int, int)`

    - #### close

          public void close(boolean fileOnly)
                     throws java.io.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:
        `java.io.IOException`

    - #### getAvailableOptions

          protected java.util.ArrayList<java.lang.String> getAvailableOptions()

      Description copied from class: `FormatReader`
      Returns the list of available metadata options.
      Overrides:
        `getAvailableOptions` in class `FormatReader`

    - #### initFile

          protected void initFile(java.lang.String id)
                           throws FormatException,
                                  java.io.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.
        `java.io.IOException` - if an I/O error occurs processing the file

    - #### splitMontage

          public boolean splitMontage()

    - #### parseTags

          private void parseTags(int numTags,
                                 java.lang.String parent,
                                 java.lang.String indent)
                          throws FormatException,
                                 java.io.IOException,
                                 java.text.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`
        `java.io.IOException`
        `java.text.ParseException`

    - #### readValue

          private double readValue(int type)
                            throws java.io.IOException

      Throws:
        `java.io.IOException`

    - #### getNumBytes

          private int getNumBytes(int type)

    - #### skipPadding

          private void skipPadding()
                            throws java.io.IOException

      Throws:
        `java.io.IOException`

    - #### convertUnits

          private ome.units.unit.Unit<ome.units.quantity.Length> convertUnits(java.lang.String units)

    - #### createROI

          private java.lang.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

Copyright © 2026 Open Microscopy Environment