StainFit

StainFit#

class squidpy.experimental.im.StainFit(method, stain_matrix=None, mu=None, sigma=None, white_point=None, max_concentrations=None)[source]#

A fitted stain reference.

Returned by fit_stain_reference(). Use transform() to normalize an image to it, or decompose() to project one onto its stain matrix.

Parameters:
method Literal['macenko', 'vahadane', 'reinhard']

Fitting method: "macenko", "vahadane", or "reinhard".

stain_matrix ndarray | None (default: None)

Shape (3, 3) unit-norm matrix in canonical order (H, E, complement). Required for decomposition methods.

mu ndarray | None (default: None)

Shape (3,) Ruderman Lab channel means. Reinhard only.

sigma ndarray | None (default: None)

Shape (3,) Ruderman Lab channel standard deviations. Reinhard only.

white_point ndarray | None (default: None)

Shape (3,) per-channel white-point estimate. Required for decomposition methods (apply consumes it). Forbidden for Reinhard because Reinhard’s color transfer operates in Ruderman Lab and does not model absorbance. There is no universal default; pass an estimate from your data (see estimate_white_point).

max_concentrations ndarray | None (default: None)

Shape (2,) reference per-stain (H, E) 99th-percentile concentrations - a fitted characterization of the reference’s staining strength. Decomposition only, and diagnostic: the colour-basis apply transfers stain colour, not amount, so it does not consume this. Optional; forbidden for Reinhard.

Methods

decompose(sdata, *, image_key[, scale, ...])

Decompose an image in sdata into separate per-stain concentration maps.

transform(sdata, *, image_key[, scale, ...])

Normalize an image in sdata to this reference.

method: Literal['macenko', 'vahadane', 'reinhard']#
stain_matrix: ndarray | None = None#
mu: ndarray | None = None#
sigma: ndarray | None = None#
white_point: ndarray | None = None#
max_concentrations: ndarray | None = None#