mantispy.pp.image_qc

Contents

mantispy.pp.image_qc#

mantispy.pp.image_qc(adata, metrics=('FocusScore', 'PowerLogLogSlope', 'PercentMaximal', 'PercentMinimal', 'Saturation'), channel=None, method='mad', threshold='auto', by='Metadata_Plate', k=15, copy=False)#

Flag low-quality images and broadcast the verdict onto their cells.

Parameters:
  • adata (AnnData) – Object carrying uns["mantispy"]["image_table"] and obs["Metadata_ImageNumber"].

  • metrics (Sequence[str] (default: ('FocusScore', 'PowerLogLogSlope', 'PercentMaximal', 'PercentMinimal', 'Saturation'))) – Which MeasureImageQuality metrics to use.

  • channel (str | None (default: None)) – Restrict to one channel’s metrics. None uses every channel present.

  • method (str (default: 'mad')) – "mad" flags an image when any metric is an outlier within its by group. "knn" flags images that sit far from their neighbors in the standardized metric space, which catches unusual combinations of metrics that a per-metric rule misses.

  • threshold (float | str (default: 'auto')) – "auto" flags a score above the method’s default robust-z cutoff (DEFAULT_CUTOFF). A float thresholds the raw score instead.

  • by (str | None (default: 'Metadata_Plate')) – Compute thresholds within each group of this column, normally the plate. None pools every image, which flags every image on a dim plate and misses a blurred image on a bright one.

  • k (int (default: 15)) – Neighbors for method="knn".

  • copy (bool (default: False)) – Return a modified copy instead of mutating in place.

Return type:

AnnData | None

Returns:

None, or the modified copy. Writes uns["mantispy"]["image_qc"] (the image table plus qc_image_score and qc_image_pass) and broadcasts obs["qc_image_pass"].

Raises:
  • KeyError – If the image table is missing, holds none of the requested metrics, or lacks the by column, or obs has no Metadata_ImageNumber to broadcast onto.

  • ValueError – If method is unknown, or some images have no value in by.