qc_image#
- squidpy.experimental.im.qc_image(sdata, *, image_key, scale='scale0', metrics=None, tile_size='auto', is_hne=True, detect_outliers=True, detect_tissue=True, outlier_threshold=0.1, progress=True, tissue_mask_key=None, preview=True)[source]#
Perform quality control analysis on an image.
Computes tile-based QC metrics including sharpness, intensity, staining (H&E only), artifact detection, and tissue coverage.
- Parameters:
- sdata
SpatialData SpatialData object containing the image.
- image_key
str Key of the image in
sdata.imagesto analyze.- scale
str(default:'scale0') Scale level to use for processing.
- metrics QCMetric |
list[QCMetric] |None(default:None) QC metric name, or a list of them.
Noneuses sensible defaults based onis_hne. Accepted values, by what they measure:sharpness:
"tenengrad","var_of_laplacian","variance","fft_high_freq_energy","haar_wavelet_energy"intensity:
"brightness_mean","brightness_std","entropy"staining, H&E only:
"hematoxylin_mean","hematoxylin_std","eosin_mean","eosin_std","he_ratio"artifacts, H&E only:
"fold_fraction"tissue coverage:
"tissue_fraction"
- tile_size
Literal['auto'] |tuple[int,int] (default:'auto') Size of tiles for analysis. If
"auto", automatically determines size.- is_hne
bool(default:True) Whether the image is H&E stained. Controls which metrics are available and which defaults are used. If
Falseand H&E-specific metrics are explicitly requested, raisesValueError.- detect_outliers
bool(default:True) Whether to detect outlier tiles based on QC scores.
- detect_tissue
bool(default:True) Whether to detect tissue regions for context-aware outlier detection.
- outlier_threshold
float(default:0.1) Percentile threshold (0-1) for outlier detection. A tile is flagged as an outlier if its within-tissue percentile rank falls below this value. For example,
0.1flags the bottom 10% of tissue tiles (by their worst sharpness metric) as outliers.- progress
bool(default:True) Whether to show progress bar during computation.
- tissue_mask_key
str|None(default:None) Key of the tissue mask in
sdata.labelsto use. IfNone, the function will check if"{image_key}_tissue"already exists insdata.labelsand reuse it. If it doesn’t exist, tissue detection will be performed and the mask will be added tosdata.labelswith key"{image_key}_tissue". If provided, the existing mask at this key will be used.- preview
bool(default:True) If
True, render a preview showing the image overlaid with outlier tiles highlighted in red. Only shown whendetect_outliers=True.
- sdata
- Returns:
None– None Results are stored in the following locations:sdata.tables[f"qc_img_{image_key}"]: AnnData object with QC scoressdata.shapes[f"qc_img_{image_key}_grid"]: GeoDataFrame with tile geometriessdata.tables[...].uns["qc_image"]: Metadata about the analysis