nucleus_detector¶
Nucleus Detection Engine for Digital Pathology (WSIs and patches).
This module implements the NucleusDetector class which extends SemanticSegmentor to perform instance-level nucleus detection on histology images. It supports patch-mode and whole slide image (WSI) workflows using TIAToolbox or custom PyTorch models, and provides utilities for parallel post-processing (centroid extraction, thresholding), merging detections across patches, and exporting results in multiple formats (in-memory dict, Zarr, AnnotationStore).
Classes¶
- NucleusDetectorRunParams
TypedDict specifying runtime configuration keys for detection.
- NucleusDetector
Core engine for nucleus detection on image patches or WSIs.
Examples:¶
>>> from tiatoolbox.models.engine.nucleus_detector import NucleusDetector
>>> detector = NucleusDetector(model="mapde-conic")
>>> # WSI workflow: save to AnnotationStore (.db)
>>> out = detector.run(
... images=[pathlib.Path("example_wsi.tiff")],
... patch_mode=False,
... device="cuda",
... save_dir=pathlib.Path("output_directory/"),
... overwrite=True,
... output_type="annotationstore",
... class_dict={0: "nucleus"},
... auto_get_mask=True,
... memory_threshold=80,
... )
>>> # Patch workflow: return in-memory detections
>>> patches = [np.ndarray, np.ndarray] # NHWC
>>> out = detector.run(patches, patch_mode=True, output_type="dict")
Notes:¶
Outputs can be returned as Python dictionaries, saved as Zarr groups, or converted to AnnotationStore (.db).
Post-processing uses tile rechunking and halo padding to facilitate centroid extraction near chunk boundaries.
Functions
Write nucleus detection arrays to QuPath JSON. |
|
Write nucleus detection arrays to an SQLite-backed AnnotationStore. |
Classes
Nucleus detection engine for digital histology images. |
|
Runtime parameters for configuring the NucleusDetector.run() method. |