loci.formats

## Class AxisGuesser

- java.lang.Object
- - loci.formats.AxisGuesser

-     public class AxisGuesser
      extends java.lang.Object

  AxisGuesser guesses which blocks in a file pattern correspond to which dimensional axes (Z, T, C or S), potentially recommending an adjustment in dimension order within the files, depending on the confidence of each guess.
  Author:
    Curtis Rueden ctrueden at wisc.edu

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `protected int[]` | `axisTypes` Guessed axis types.
    `static int` | `C_AXIS` Axis type for channels.
    `static java.util.Set<java.lang.String>` | `C_PREFIXES` Prefixes indicating channel dimension.
    `protected boolean` | `certain` Whether the guesser is confident that all axis types are correct.
    `protected java.lang.String` | `dimOrder` Original ordering of internal dimensional axes.
    `protected FilePattern` | `fp` File pattern identifying dimensional axis blocks.
    `protected java.lang.String` | `newOrder` Adjusted ordering of internal dimensional axes.
    `protected static java.lang.String` | `ONE`
    `static int` | `S_AXIS` Axis type for series.
    `static java.util.Set<java.lang.String>` | `S_PREFIXES` Prefixes indicating series dimension.
    `static int` | `T_AXIS` Axis type for time points.
    `static java.util.Set<java.lang.String>` | `T_PREFIXES` Prefixes indicating time dimension.
    `protected static java.lang.String` | `THREE`
    `protected static java.lang.String` | `TWO`
    `static int` | `UNKNOWN_AXIS` Axis type for unclassified axes.
    `static int` | `Z_AXIS` Axis type for focal planes.
    `static java.util.Set<java.lang.String>` | `Z_PREFIXES` Prefixes indicating space dimension.

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `AxisGuesser(FilePattern fp, java.lang.String dimOrder, int sizeZ, int sizeT, int sizeC, boolean isCertain)` Guesses dimensional axis assignments corresponding to the given file pattern, using the specified dimensional information from within each file as a guide.

  - ### Method Summary

    All Methods Static Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `java.lang.String` | `getAdjustedOrder()` Gets the adjusted dimension order.
    `int` | `getAxisCount(int axisType)` Gets the number of axes in the pattern of the given type.
    `int` | `getAxisCountC()` Gets the number of C axes in the pattern.
    `int` | `getAxisCountS()` Gets the number of S axes in the pattern.
    `int` | `getAxisCountT()` Gets the number of T axes in the pattern.
    `int` | `getAxisCountZ()` Gets the number of Z axes in the pattern.
    `static int` | `getAxisType(java.lang.String label)` Convert the given label to an axis type.
    `int[]` | `getAxisTypes()` Gets the guessed axis type for each dimensional block.
    `FilePattern` | `getFilePattern()` Gets the file pattern.
    `java.lang.String` | `getOriginalOrder()` Gets the original dimension order.
    `boolean` | `isCertain()` Gets whether the guesser is confident that all axes are correct.
    `void` | `setAxisTypes(int[] axes)` Sets the axis type for each dimensional block.

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

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

- - ### Field Detail

    - #### UNKNOWN_AXIS

          public static final int UNKNOWN_AXIS

      Axis type for unclassified axes.
      See Also:
        Constant Field Values

    - #### Z_AXIS

          public static final int Z_AXIS

      Axis type for focal planes.
      See Also:
        Constant Field Values

    - #### T_AXIS

          public static final int T_AXIS

      Axis type for time points.
      See Also:
        Constant Field Values

    - #### C_AXIS

          public static final int C_AXIS

      Axis type for channels.
      See Also:
        Constant Field Values

    - #### S_AXIS

          public static final int S_AXIS

      Axis type for series.
      See Also:
        Constant Field Values

    - #### Z_PREFIXES

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

      Prefixes indicating space dimension.

    - #### T_PREFIXES

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

      Prefixes indicating time dimension.

    - #### C_PREFIXES

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

      Prefixes indicating channel dimension.

    - #### S_PREFIXES

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

      Prefixes indicating series dimension.

    - #### ONE

          protected static final java.lang.String ONE

      See Also:
        Constant Field Values

    - #### TWO

          protected static final java.lang.String TWO

      See Also:
        Constant Field Values

    - #### THREE

          protected static final java.lang.String THREE

      See Also:
        Constant Field Values

    - #### fp

          protected FilePattern fp

      File pattern identifying dimensional axis blocks.

    - #### dimOrder

          protected java.lang.String dimOrder

      Original ordering of internal dimensional axes.

    - #### newOrder

          protected java.lang.String newOrder

      Adjusted ordering of internal dimensional axes.

    - #### axisTypes

          protected int[] axisTypes

      Guessed axis types.

    - #### certain

          protected boolean certain

      Whether the guesser is confident that all axis types are correct.

  - ### Constructor Detail

    - #### AxisGuesser

          public AxisGuesser(FilePattern fp,
                             java.lang.String dimOrder,
                             int sizeZ,
                             int sizeT,
                             int sizeC,
                             boolean isCertain)

      Guesses dimensional axis assignments corresponding to the given file pattern, using the specified dimensional information from within each file as a guide.

      The algorithm first assigns pattern blocks based on known prefixes. For instance, a block preceded by "time" is assigned to the time points (T) axis. Blocks that don't have a known prefix are checked for special cases (Bio-Rad .pic, RGB). Remaining blocks are assigned according to the given dimensional sizes: dimensions with size greater than 1 are assumed to be already contained within each file, while those with size equal to 1 can be scattered across multiple files and thus are assigned to pattern blocks.

      If `isCertain` is `false`, the algorithm checks for cases where the reader might have mixed up the Z and T dimensions. For instance, if the pattern string is `z<*>_<*>` and `size{Z,T,C} = 2,1,1`, then the reader is assumed to be wrong about the relative positions of Z and T in the given `dimOrder`. The new suggested order (see `getAdjustedOrder()`) will have Z and T swapped and the second block will be assigned to C (the actual dimensional sizes are assumed to be `1,2,1`).

      If after trying all of the above there are still unassigned blocks, they will be assigned to the last dimension in the (possibly adjusted) order.

      Parameters:
        `fp` - The file pattern of the files
        `dimOrder` - The dimension order (e.g., XYZTC) within each file
        `sizeZ` - The number of Z positions within each file
        `sizeT` - The number of T positions within each file
        `sizeC` - The number of C positions within each file
        `isCertain` - Whether the dimension order given is known to be good, or merely a guess
      See Also:
        `FilePattern`

  - ### Method Detail

    - #### getFilePattern

          public FilePattern getFilePattern()

      Gets the file pattern.

    - #### getOriginalOrder

          public java.lang.String getOriginalOrder()

      Gets the original dimension order.

    - #### getAdjustedOrder

          public java.lang.String getAdjustedOrder()

      Gets the adjusted dimension order.

    - #### isCertain

          public boolean isCertain()

      Gets whether the guesser is confident that all axes are correct.

    - #### getAxisTypes

          public int[] getAxisTypes()

      Gets the guessed axis type for each dimensional block.
      Returns:
        An array containing values from the enumeration:
        - Z_AXIS: focal planes
        - T_AXIS: time points
        - C_AXIS: channels
        - S_AXIS: series

    - #### setAxisTypes

          public void setAxisTypes(int[] axes)

      Sets the axis type for each dimensional block.
      Parameters:
        `axes` - An array containing values from the enumeration:
        - Z_AXIS: focal planes
        - T_AXIS: time points
        - C_AXIS: channels
        - S_AXIS: series

    - #### getAxisCountZ

          public int getAxisCountZ()

      Gets the number of Z axes in the pattern.

    - #### getAxisCountT

          public int getAxisCountT()

      Gets the number of T axes in the pattern.

    - #### getAxisCountC

          public int getAxisCountC()

      Gets the number of C axes in the pattern.

    - #### getAxisCountS

          public int getAxisCountS()

      Gets the number of S axes in the pattern.

    - #### getAxisCount

          public int getAxisCount(int axisType)

      Gets the number of axes in the pattern of the given type.
      Parameters:
        `axisType` - One of:
        - Z_AXIS: focal planes
        - T_AXIS: time points
        - C_AXIS: channels
        - S_AXIS: series

    - #### getAxisType

          public static int getAxisType(java.lang.String label)

      Convert the given label to an axis type. If the label ends with one of the known prefixes for the Z, C, T or S axis (as defined in `Z_PREFIXES, C_PREFIXES, T_PREFIXES, S_PREFIXES`), return the corresponding axis type; otherwise, return `UNKNOWN_AXIS`. Note that the match is case-insensitive.

Copyright © 2026 Open Microscopy Environment