wsi_enhance_operator is a custom mapper operator package for DataMate.
It includes:
- operator registration entry
- operator metadata and UI settings
- main pipeline implementation
- a bundled OpenSlide runtime library for WSI reading
- slide segmentation helpers
- patch extraction helpers
- stain normalization helpers
- augmentation helpers
wsi_enhance_operator/
|-- __init__.py
|-- metadata.yml
|-- openslide/
| `-- libopenslide.so.1
|-- process.py
|-- README.md
|-- requirements.txt
|-- tests/
| |-- pytest.ini
| `-- pytest/
| |-- test_augmentations.py
| |-- test_helpers.py
| |-- test_stain_normalization.py
| |-- test_stain_template_manager.py
| |-- test_wsi_processor.py
| `-- test_wsi_reader.py
|-- augmentations/
| |-- __init__.py
| `-- augmentations.py
|-- slidesegmenter/
| |-- __init__.py
| |-- _model_utils.py
| |-- slidesegmenter.py
| `-- model_files/
| `-- __init__.py
|-- stain_normalization/
| |-- __init__.py
| `-- stain_normalization.py
|-- wsi_processor/
| |-- __init__.py
| `-- wsi_processor.py
`-- wsi_reader/
|-- __init__.py
|-- wsi_reader.py
`-- wsi_types.py
__init__.py: registersWSIEnhanceMapperinto DataMate operator registrymetadata.yml: defines operator identity, category, runtime resources, and frontend settingsprocess.py: main mapper entry, parameter parsing, segmentation, patch extraction, and artifact exportopenslide/: bundled OpenSlide shared library loaded directly from the mapper packageaugmentations/: patch augmentation utilitiesslidesegmenter/: segmentation model loading and inference helpersstain_normalization/: stain normalization logicwsi_processor/: contour and detection post-processing helperswsi_reader/: WSI file reading abstractionrequirements.txt: Python dependencies required by this operator packagetests/: pytest-based unit tests for the mapper package
The runtime environment is expected to provide model files under:
/models/WSIEnhance/<model_folder>
Default model_folder:
2025-10-18
The operator accepts a sample dictionary. Common supported input fields are:
filePath: source WSI pathimage_path: source WSI path aliassource_path: optional source path aliasexport_path,exportPath, oroutput_dir: output root directory
Common configurable settings in metadata.yml include:
model_folderthumbnail_sizepatch_sizepatch_bg_threshpatch_max_bg_ratiosave_patchesenable_stain_normalizesave_normalized_patchesstain_methodstain_targetenable_augmentationsave_augmented_patchesaug_factoraug_rotateaug_flipaug_color_jitter
For each input slide, the operator can generate:
segmentation/thumbnail.pngsegmentation/thumbnail_overlay.pngsegmentation/coords_thumbnail.jsonpatch_extract/patch_positions.jsonpatch_extract/pipeline_manifest.jsonpatch_extract/patches/when raw patch saving is enabledpatch_extract/patches_normalized/when stain normalization output saving is enabledpatch_extract/patches_augmented/when augmentation output saving is enabled
The operator writes result paths and summary fields back into sample. Common output fields include:
thumbnail_paththumbnail_overlay_pathcoords_thumbnail_jsonpatch_positions_jsonpipeline_manifest_jsonpatch_countnormalized_patch_countaugmented_countpatches_dirnormalized_patches_diraugmented_patches_dir
- Place the operator directory under
runtime/ops/mapper/wsi_enhance_operator. - Ensure
metadata.yml,process.py, and__init__.pyare present. - Ensure
openslide/libopenslide.so.1is packaged with the mapper directory. - Ensure model files are mounted under
/models/WSIEnhance/<model_folder>. - Import the operator package from
runtime/ops/mapper/__init__.py. - Configure parameters from the DataMate frontend or task definition.
Run unit tests from the mapper directory with PYTHONPATH pointed to the operator package root:
cd runtime/ops/mapper/wsi_enhance_operator
PYTHONPATH=. python -m pytest tests/pytest -q