loci.formats.in

## Class KLBReader

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

- All Implemented Interfaces:
    java.io.Closeable, java.lang.AutoCloseable, ICompressedTileReader, IFormatHandler, IFormatReader, IMetadataConfigurable, IPyramidHandler

      public class KLBReader
      extends FormatReader

  Reader for Keller Lab Block (KLB) files.

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `private long[]` | `blockOffsets`
    `private int` | `blocksPerPlane`
    `static java.lang.String` | `CHANNEL_PREFIX` Prefixes indicating dimensions and projections
    `private java.util.ArrayList<java.lang.Integer>` | `channels`
    `private static int` | `COMPRESSION_BZIP2`
    `private static int` | `COMPRESSION_NONE`
    `private static int` | `COMPRESSION_ZLIB`
    `private int` | `compressionType`
    `private static java.lang.String` | `DEFAULT_SERIES`
    `private int[]` | `dims_blockSize`
    `private int[]` | `dims_xyzct`
    `private java.util.LinkedHashMap<java.lang.String,java.lang.String[][]>` | `filelist`
    `private static int` | `FLOAT32_TYPE`
    `private static int` | `FLOAT64_TYPE`
    `private long` | `headerSize`
    `private int` | `headerVersion`
    `private static int` | `INT16_TYPE`
    `private static int` | `INT32_TYPE`
    `private static int` | `INT64_TYPE`
    `private static int` | `INT8_TYPE`
    `private static int` | `KLB_DATA_DIMS`
    `private static int` | `KLB_DEFAULT_HEADER_VERSION`
    `private static int` | `KLB_METADATA_SIZE`
    `private double` | `numBlocks`
    `private long` | `offsetFilePointer`
    `static java.lang.String` | `PROJECTION_PREFIX`
    `static java.lang.String` | `PROJECTION_SUFFIX`
    `static java.util.Set<java.lang.String>` | `SERIES_PREFIXES`
    `private MetadataStore` | `store`
    `static java.lang.String` | `TIME_PREFIX`
    `static java.lang.String` | `TIME_SUFFIX`
    `private static int` | `UINT16_TYPE`
    `private static int` | `UINT32_TYPE`
    `private static int` | `UINT64_TYPE`
    `private static int` | `UINT8_TYPE`

    - ### 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
    `KLBReader()` Constructs a new BDV 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 void` | `convertPixelType(CoreMetadata ms0, int pixelType)`
    `int` | `fileGroupOption(java.lang.String id)` Returns an indication of whether the files in a multi-file dataset can be handled individually.
    `java.lang.String[]` | `getUsedFiles(boolean noPixels)` Returns an array of filenames needed to open this dataset.
    `protected void` | `initFile(java.lang.String id)` Initializes the given file (parsing header information, etc.).
    `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 ome.xml.model.primitives.PositiveFloat` | `readFloat32()`
    `private void` | `readHeader(CoreMetadata coreMeta)`
    `private int` | `readUInt32()`
    `private long` | `readUInt64()`
    `private void` | `reCalculateBlockOffsets(int no)`

    - ### 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, flattenHashtables, get16BitLookupTable, get8BitLookupTable, getAcquisitionMode, getAdvancedSeriesUsedFiles, getAdvancedUsedFiles, getArcType, getAvailableOptions, 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, getZCTCoords, getZCTModuloCoords, hasCompanionFiles, hasFlattenedResolutions, isFalseColor, isGroupFiles, isIndexed, isInterleaved, isInterleaved, isLittleEndian, isMetadataComplete, isMetadataFiltered, isNormalized, isOrderCertain, isOriginalMetadataPopulated, isRGB, isSingleFile, isThisType, 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

    - #### KLB_DATA_DIMS

          private static final int KLB_DATA_DIMS

      See Also:
        Constant Field Values

    - #### KLB_METADATA_SIZE

          private static final int KLB_METADATA_SIZE

      See Also:
        Constant Field Values

    - #### KLB_DEFAULT_HEADER_VERSION

          private static final int KLB_DEFAULT_HEADER_VERSION

      See Also:
        Constant Field Values

    - #### UINT8_TYPE

          private static final int UINT8_TYPE

      See Also:
        Constant Field Values

    - #### UINT16_TYPE

          private static final int UINT16_TYPE

      See Also:
        Constant Field Values

    - #### UINT32_TYPE

          private static final int UINT32_TYPE

      See Also:
        Constant Field Values

    - #### UINT64_TYPE

          private static final int UINT64_TYPE

      See Also:
        Constant Field Values

    - #### INT8_TYPE

          private static final int INT8_TYPE

      See Also:
        Constant Field Values

    - #### INT16_TYPE

          private static final int INT16_TYPE

      See Also:
        Constant Field Values

    - #### INT32_TYPE

          private static final int INT32_TYPE

      See Also:
        Constant Field Values

    - #### INT64_TYPE

          private static final int INT64_TYPE

      See Also:
        Constant Field Values

    - #### FLOAT32_TYPE

          private static final int FLOAT32_TYPE

      See Also:
        Constant Field Values

    - #### FLOAT64_TYPE

          private static final int FLOAT64_TYPE

      See Also:
        Constant Field Values

    - #### COMPRESSION_NONE

          private static final int COMPRESSION_NONE

      See Also:
        Constant Field Values

    - #### COMPRESSION_BZIP2

          private static final int COMPRESSION_BZIP2

      See Also:
        Constant Field Values

    - #### COMPRESSION_ZLIB

          private static final int COMPRESSION_ZLIB

      See Also:
        Constant Field Values

    - #### store

          private MetadataStore store

    - #### compressionType

          private int compressionType

    - #### numBlocks

          private double numBlocks

    - #### dims_blockSize

          private int[] dims_blockSize

    - #### dims_xyzct

          private int[] dims_xyzct

    - #### blockOffsets

          private long[] blockOffsets

    - #### headerSize

          private long headerSize

    - #### blocksPerPlane

          private int blocksPerPlane

    - #### offsetFilePointer

          private long offsetFilePointer

    - #### headerVersion

          private int headerVersion

    - #### filelist

          private java.util.LinkedHashMap<java.lang.String,java.lang.String[][]> filelist

    - #### channels

          private java.util.ArrayList<java.lang.Integer> channels

    - #### DEFAULT_SERIES

          private static final java.lang.String DEFAULT_SERIES

      See Also:
        Constant Field Values

    - #### CHANNEL_PREFIX

          public static final java.lang.String CHANNEL_PREFIX

      Prefixes indicating dimensions and projections
      See Also:
        Constant Field Values

    - #### TIME_PREFIX

          public static final java.lang.String TIME_PREFIX

      See Also:
        Constant Field Values

    - #### TIME_SUFFIX

          public static final java.lang.String TIME_SUFFIX

      See Also:
        Constant Field Values

    - #### PROJECTION_PREFIX

          public static final java.lang.String PROJECTION_PREFIX

      See Also:
        Constant Field Values

    - #### PROJECTION_SUFFIX

          public static final java.lang.String PROJECTION_SUFFIX

      See Also:
        Constant Field Values

    - #### SERIES_PREFIXES

          public static final java.util.Set<java.lang.String> SERIES_PREFIXES

  - ### Constructor Detail

    - #### KLBReader

          public KLBReader()

      Constructs a new BDV reader.

  - ### Method Detail

    - #### 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)`

    - #### 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

    - #### readHeader

          private void readHeader(CoreMetadata coreMeta)
                           throws java.io.IOException,
                                  FormatException

      Throws:
        `java.io.IOException`
        `FormatException`

    - #### getUsedFiles

          public java.lang.String[] getUsedFiles(boolean noPixels)

      Description copied from interface: `IFormatReader`
      Returns an array of filenames needed to open this dataset. If the 'noPixels' flag is set, then only files that do not contain pixel data will be returned. The first element in the array is expected to be the path passed to `IFormatHandler.setId(String)`, if appropriate based upon 'noPixels'. The remaining elements are expected to be in a consistent order; if a directory listing is necessary to build the list then it should be sorted first.
      Specified by:
        `getUsedFiles` in interface `IFormatReader`
      Overrides:
        `getUsedFiles` in class `FormatReader`

    - #### reCalculateBlockOffsets

          private void reCalculateBlockOffsets(int no)
                                        throws java.io.IOException,
                                               FormatException

      Throws:
        `java.io.IOException`
        `FormatException`

    - #### convertPixelType

          private void convertPixelType(CoreMetadata ms0,
                                        int pixelType)
                                 throws FormatException

      Throws:
        `FormatException`

    - #### readUInt32

          private int readUInt32()
                          throws java.io.IOException

      Throws:
        `java.io.IOException`

    - #### readUInt64

          private long readUInt64()
                           throws java.io.IOException

      Throws:
        `java.io.IOException`

    - #### readFloat32

          private ome.xml.model.primitives.PositiveFloat readFloat32()
                                                              throws java.io.IOException

      Throws:
        `java.io.IOException`

    - #### fileGroupOption

          public int fileGroupOption(java.lang.String id)
                              throws FormatException,
                                     java.io.IOException

      Description copied from interface: `IFormatReader`
      Returns an indication of whether the files in a multi-file dataset can be handled individually. This method is only useful for formats and datasets which contain multiple files.
      Specified by:
        `fileGroupOption` in interface `IFormatReader`
      Overrides:
        `fileGroupOption` in class `FormatReader`
      Parameters:
        `id` - a file in the multi-file dataset
      Returns:
        an int indicating that we cannot, must, or might group the files. A return value of `FormatTools.MUST_GROUP` indicates that the files cannot be handled separately; the reader will always detect and read all files in the dataset. `FormatTools.CAN_GROUP` indicates that the files may be handled separately, but file grouping must then be disabled via `IFormatReader.setGroupFiles(boolean)`. `FormatTools.CANNOT_GROUP` indicates that the files must be handled separately; the reader will not attempt to read all files in the dataset (this is rare).
      Throws:
        `FormatException`
        `java.io.IOException`
      See Also:
        `FormatTools.MUST_GROUP`, `FormatTools.CAN_GROUP`, `FormatTools.CANNOT_GROUP`

    - #### 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`

Copyright © 2026 Open Microscopy Environment