Coordinate systems

See Coordinate systems for a conceptual overview of the transform graph design.

Coordinate system

SpatialOmics.CoordinateSystemType
CoordinateSystem(name; axes=(:x, :y), units=("µm", "µm"))

Named 2-D coordinate system — a node in the dataset's transform graph.

Every spatial element belongs to one coordinate system by name. The graph of CoordinateSystem nodes connected by AbstractTransformation edges is stored in the parent SpatialDataset. Use resolve to find a composed path between any two named systems.

See also

SpatialDataset, resolve, AbstractTransformation

Transformation types

SpatialOmics.IdentityType
Identity(src, dst)

Trivial transformation that returns its input unchanged.

Produced by resolve when src == dst, and used as the default pixel_to_cs when no explicit transform is provided to SpatialImage.

SpatialOmics.AffineType
Affine(matrix, src, dst)

2-D affine transformation stored as a 3×3 augmented matrix in homogeneous coordinates.

The matrix encodes rotation, scaling, shear, and translation in a single [R t; 0 0 1] form, allowing sequential transforms to be fused by matrix multiplication. Construct via translation, scaling, rotation, or flip_y.

See also

compose, apply

SpatialOmics.SequenceType
Sequence(steps, src, dst)

Ordered composition of transformations applied left-to-right.

Produced by resolve when the path through the transform graph passes through multiple intermediate coordinate systems, or when the steps cannot be fused into a single Affine (e.g., if the path includes non-Affine steps).

See also

compose, resolve

Transformation constructors

SpatialOmics.translationFunction
translation(tx, ty, src, dst) → Affine

Affine transformation that shifts coordinates by (tx, ty).

SpatialOmics.scalingFunction
scaling(sx, sy, src, dst) → Affine

Affine transformation that scales the x-axis by sx and y-axis by sy.

SpatialOmics.rotationFunction
rotation(θ, src, dst) → Affine

Affine transformation for counter-clockwise rotation by angle θ (radians).

SpatialOmics.flip_yFunction
flip_y(src, dst) → Affine

Affine transformation that negates the y-axis (reflects about the x-axis).

Used to convert between image pixel space (y increases downward) and physical space (y increases upward).

Operations

SpatialOmics.composeFunction
compose(a, b, ...) → Affine or Sequence

Compose two or more transformations into a single transformation applied left-to-right.

When all arguments are Affine, the result is a fused Affine (matrix product). Mixed types produce a Sequence. Raises an error if adjacent src/dst names do not chain (a.dst ≠ b.src).

t = compose(scaling(0.325, 0.325, "pixel", "fov"), translation(1000.0, 500.0, "fov", "global"))

See also

resolve, apply

SpatialOmics.applyFunction
apply(t, data) → same type as data

Apply transformation t to data, returning a transformed copy.

Accepts a single Point / SVector{2}, a Vector of points, an N×2 Matrix, SpatialPoints, or SpatialShapes. The coordinate system name is updated to t.dst.

See also

apply!, compose, resolve

SpatialOmics.apply!Function
apply!(t, el) → el

Apply transformation t to el in-place, mutating coordinates and updating the element's coord_system to t.dst. Returns el.

Defined for SpatialPoints and SpatialShapes. Prefer apply (non-mutating) when the element is attached to a dataset.

See also

apply

SpatialOmics.resolveFunction
resolve(transforms, src, dst) → AbstractTransformation

Find a transformation path from coordinate system src to dst through the transform graph, and return the composed result.

Performs BFS over the directed graph of (t.src → t.dst) edges, treating Affine edges as bidirectional (the inverse is computed automatically). When all steps are Affine, they are fused into a single Affine; otherwise a Sequence is returned. Raises an error if no path exists.

The two-argument convenience form transform(ds, src, dst) calls this function using the dataset's transform list.

See also

transform, compose, Sequence