Package loci.formats

Class AxisGuesser

java.lang.Object
loci.formats.AxisGuesser

public class AxisGuesser extends 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
    Description
    protected int[]
    Guessed axis types.
    static final int
    Axis type for channels.
    static final Set<String>
    Prefixes indicating channel dimension.
    protected boolean
    Whether the guesser is confident that all axis types are correct.
    protected String
    Original ordering of internal dimensional axes.
    protected FilePattern
    File pattern identifying dimensional axis blocks.
    protected String
    Adjusted ordering of internal dimensional axes.
    protected static final String
     
    static final int
    Axis type for series.
    static final Set<String>
    Prefixes indicating series dimension.
    static final int
    Axis type for time points.
    static final Set<String>
    Prefixes indicating time dimension.
    protected static final String
     
    protected static final String
     
    static final int
    Axis type for unclassified axes.
    static final int
    Axis type for focal planes.
    static final Set<String>
    Prefixes indicating space dimension.
  • Constructor Summary

    Constructors
    Constructor
    Description
    AxisGuesser(FilePattern fp, 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

    Modifier and Type
    Method
    Description
    Gets the adjusted dimension order.
    int
    getAxisCount(int axisType)
    Gets the number of axes in the pattern of the given type.
    int
    Gets the number of C axes in the pattern.
    int
    Gets the number of S axes in the pattern.
    int
    Gets the number of T axes in the pattern.
    int
    Gets the number of Z axes in the pattern.
    static int
    Convert the given label to an axis type.
    int[]
    Gets the guessed axis type for each dimensional block.
    Gets the file pattern.
    Gets the original dimension order.
    boolean
    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 Details

    • UNKNOWN_AXIS

      public static final int UNKNOWN_AXIS
      Axis type for unclassified axes.
      See Also:
    • Z_AXIS

      public static final int Z_AXIS
      Axis type for focal planes.
      See Also:
    • T_AXIS

      public static final int T_AXIS
      Axis type for time points.
      See Also:
    • C_AXIS

      public static final int C_AXIS
      Axis type for channels.
      See Also:
    • S_AXIS

      public static final int S_AXIS
      Axis type for series.
      See Also:
    • Z_PREFIXES

      public static final Set<String> Z_PREFIXES
      Prefixes indicating space dimension.
    • T_PREFIXES

      public static final Set<String> T_PREFIXES
      Prefixes indicating time dimension.
    • C_PREFIXES

      public static final Set<String> C_PREFIXES
      Prefixes indicating channel dimension.
    • S_PREFIXES

      public static final Set<String> S_PREFIXES
      Prefixes indicating series dimension.
    • ONE

      protected static final String ONE
      See Also:
    • TWO

      protected static final String TWO
      See Also:
    • THREE

      protected static final String THREE
      See Also:
    • fp

      protected FilePattern fp
      File pattern identifying dimensional axis blocks.
    • dimOrder

      protected String dimOrder
      Original ordering of internal dimensional axes.
    • newOrder

      protected 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 Details

    • AxisGuesser

      public AxisGuesser(FilePattern fp, 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:
  • Method Details

    • getFilePattern

      public FilePattern getFilePattern()
      Gets the file pattern.
    • getOriginalOrder

      public String getOriginalOrder()
      Gets the original dimension order.
    • getAdjustedOrder

      public 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(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.