itasc.cellpose.shape

Layout-free input canonicalisation for the standalone tool.

The standalone Cellpose tool supports neither stitching-as-a-mode nor true 3D segmentation, so it never needs the 4-way 2D/2D+t/3D/3D+t layout: it segments every plane individually. The only place axis identity matters is tracking, which links the z axis by spatial overlap (stitch) and the t axis by motion (laptrack). By convention the shorter of the two leading axes is z (few z-slices, many timepoints is the common case) and the longer is t.

to_canonical_tzyx() applies that convention so the rest of the pipeline can keep working in canonical (T, Z, Y, X) without the user declaring a layout.

Functions

describe_axes(shape)

Human-readable summary of how an input shape is interpreted.

to_canonical_tzyx(arr, *[, z_axis, warn])

Coerce any 2-D..4-D input to canonical (T, Z, Y, X) without a layout.

itasc.cellpose.shape.to_canonical_tzyx(arr, *, z_axis=None, warn=True)[source]

Coerce any 2-D..4-D input to canonical (T, Z, Y, X) without a layout.

  • 2-D (Y, X) → (1, 1, Y, X).

  • 3-D → one leading axis, read as time (the common 2D+t case); Z is a singleton: (T, 1, Y, X).

  • 4-D → two leading axes; the shorter is Z and the longer is T, so the result is reordered to (T, Z, Y, X) (a no-op when already so).

Parameters:
  • z_axis (int | None) – For 4-D input, explicitly declare which leading axis is Z (0 or 1), bypassing the shorter-axis-is-Z heuristic. Use this when the acquisition has fewer timepoints than z-slices, where the heuristic would otherwise transpose T and Z and corrupt tracking.

  • warn (bool) – When True (default), log a warning if a 4-D input’s T/Z identity is guessed from axis lengths (both leading axes non-singleton and no z_axis given), since the guess can be wrong and is otherwise silent. Descriptive callers (e.g. describe_axes()) pass False.

  • arr (ndarray)

Return type:

ndarray

itasc.cellpose.shape.describe_axes(shape)[source]

Human-readable summary of how an input shape is interpreted.

Used for widget status so the user can see the inferred T/Z without a picker, e.g. "6×512×512 → T=6, Z=1" or "40×5×512×512 → T=40, Z=5".

Return type:

str

Parameters:

shape (tuple[int, ...])