From d13ce5c7127f7bc7c49ea396f55b08bdd168ff42 Mon Sep 17 00:00:00 2001 From: Blanca Pablos Date: Fri, 20 Nov 2026 16:05:54 +0100 Subject: [PATCH 1/3] feat(wsi): accept Ventana BIF and Hamamatsu NDPI slides Add .bif and .ndpi to WSI_SUPPORTED_FILE_EXTENSIONS so HETA run preparation reads their metadata with OpenSlide and uploads them as application/octet-stream, like .svs. CZI stays out: the bundled OpenSlide cannot decode JPEG XR compressed CZI files. Co-Authored-By: Claude Opus 5.5 --- CLAUDE.md | 2 +- README.md | 2 +- docs/partials/README_platform.md | 2 +- specifications/SPEC-APPLICATION-SERVICE.md | 2 +- specifications/SPEC-QUPATH-SERVICE.md | 20 ++++++++++---------- specifications/SPEC_WSI_SERVICE.md | 21 +++++++++++---------- src/aignostics/CLAUDE.md | 2 +- src/aignostics/constants.py | 2 +- src/aignostics/qupath/scripts/add.groovy | 2 +- src/aignostics/wsi/CLAUDE.md | 2 +- tests/aignostics/application/utils_test.py | 3 +-- tests/aignostics/wsi/service_test.py | 22 ++++++++++++++++++++++ 12 files changed, 52 insertions(+), 30 deletions(-) diff --git a/CLAUDE.md b/CLAUDE.md index 5df847cc7..4a18d45b3 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -414,7 +414,7 @@ This is a computational pathology SDK working with: **WSI Processing:** -* OpenSlide for standard formats (.svs, .tiff, .ndpi) +* OpenSlide for standard formats (.svs, .tiff, .bif, .ndpi) * PyDICOM for DICOM files * Support for multi-resolution pyramidal images * Tile-based processing for memory efficiency diff --git a/README.md b/README.md index b33bbd700..66e96a6b9 100644 --- a/README.md +++ b/README.md @@ -126,7 +126,7 @@ Aignostics Platform offers key features designed to maximize value for its users 2. **Multiple Access Points:** Interact with the platform via various pathways, from **Aignostics Launchpad** (desktop application for MacOS, Windows and Linux), **Aignostics CLI** (command-line interface for your terminal or shell scripts), **Example Notebooks** (we support Jupyter and Marimo), **Aignostics Client Library** (for integration with your Python codebase), or directly through the **API of the Aignostics Platform** (for integration with any programming language). Contact your business partner at Aignostics if you are interested to discuss a direct integration with your Imaging Management Systems (IMS) and Laboratory Information Management Systems (LIMS). 3. **Secure Data Handling:** Maintain control of your slide data through secure self-signed URLs. Results are automatically deleted after 30 days, and can be deleted earlier by the user. 4. **High-throughput processing with incremental results delivery:** Submit up to 500 whole slide images (WSI) in one batch request. Access results for individual slides as they completed processing, without having to wait for the entire batch to finish. -5. **Standard formats:** Support for commonly used image formats in digital pathology such as pyramidal DICOM, TIFF, and SVS. Results provided in standard formats like QuPath GeoJSON (polygons), TIFF (heatmaps) and CSV (measurements and statistics). +5. **Standard formats:** Support for commonly used image formats in digital pathology such as pyramidal DICOM, TIFF, SVS, NDPI, and BIF. Results provided in standard formats like QuPath GeoJSON (polygons), TIFF (heatmaps) and CSV (measurements and statistics). ### Registration and User Access diff --git a/docs/partials/README_platform.md b/docs/partials/README_platform.md index 3dfe4fc06..8327f4ca1 100644 --- a/docs/partials/README_platform.md +++ b/docs/partials/README_platform.md @@ -13,7 +13,7 @@ Aignostics Platform offers key features designed to maximize value for its users 2. **Multiple Access Points:** Interact with the platform via various pathways, from **Aignostics Launchpad** (desktop application for MacOS, Windows and Linux), **Aignostics CLI** (command-line interface for your terminal or shell scripts), **Example Notebooks** (we support Jupyter and Marimo), **Aignostics Client Library** (for integration with your Python codebase), or directly through the **API of the Aignostics Platform** (for integration with any programming language). Contact your business partner at Aignostics if you are interested to discuss a direct integration with your Imaging Management Systems (IMS) and Laboratory Information Management Systems (LIMS). 3. **Secure Data Handling:** Maintain control of your slide data through secure self-signed URLs. Results are automatically deleted after 30 days, and can be deleted earlier by the user. 4. **High-throughput processing with incremental results delivery:** Submit up to 500 whole slide images (WSI) in one batch request. Access results for individual slides as they completed processing, without having to wait for the entire batch to finish. -5. **Standard formats:** Support for commonly used image formats in digital pathology such as pyramidal DICOM, TIFF, and SVS. Results provided in standard formats like QuPath GeoJSON (polygons), TIFF (heatmaps) and CSV (measurements and statistics). +5. **Standard formats:** Support for commonly used image formats in digital pathology such as pyramidal DICOM, TIFF, SVS, NDPI, and BIF. Results provided in standard formats like QuPath GeoJSON (polygons), TIFF (heatmaps) and CSV (measurements and statistics). ### Registration and User Access diff --git a/specifications/SPEC-APPLICATION-SERVICE.md b/specifications/SPEC-APPLICATION-SERVICE.md index b056cee50..2b0ccaf61 100644 --- a/specifications/SPEC-APPLICATION-SERVICE.md +++ b/specifications/SPEC-APPLICATION-SERVICE.md @@ -41,7 +41,7 @@ The Application Module shall: ### 1.4 Constraints and Limitations - Platform API compatibility requirements with auto-generated client integration -- File format support limited to major medical imaging formats (DICOM, TIFF, SVS) +- File format support limited to major medical imaging formats (DICOM, TIFF, SVS, BIF, NDPI) - Memory management constraints for large file processing with configurable chunk sizes - Optional QuPath integration requiring ijson dependency for full functionality diff --git a/specifications/SPEC-QUPATH-SERVICE.md b/specifications/SPEC-QUPATH-SERVICE.md index b3b0e10b6..256f4bae7 100644 --- a/specifications/SPEC-QUPATH-SERVICE.md +++ b/specifications/SPEC-QUPATH-SERVICE.md @@ -25,7 +25,7 @@ The QuPath Module shall: - **[FR-01]** Automatically download, verify, and install QuPath from GitHub releases with cross-platform support (Linux x64, macOS x64/ARM64, Windows x64) - **[FR-02]** Maintain version-specific QuPath installations with health monitoring and compatibility validation -- **[FR-03]** Create QuPath projects automatically when adding images, with support for WSI files from various formats (DICOM, SVS, TIFF) and metadata synchronization +- **[FR-03]** Create QuPath projects automatically when adding images, with support for WSI files from various formats (DICOM, SVS, TIFF, BIF, NDPI) and metadata synchronization - **[FR-04]** Import and process large-scale annotation datasets with batch processing, progress tracking, and error recovery - **[FR-05]** Convert between Aignostics Platform annotation formats and QuPath-compatible GeoJSON with coordinate system validation - **[FR-06]** Provide CLI, GUI, and notebook interfaces for scripted workflows, management service, and exploratory analysis @@ -97,14 +97,14 @@ qupath/ ### 3.1 Inputs -| Input Type | Source | Format/Type | Validation Rules | -| ----------------- | ----------- | --------------- | ----------------------------------------------------------------- | -| QuPath Version | CLI/GUI/API | String (semver) | Must match available GitHub releases, defaults to 0.6.0-rc5 | -| Installation Path | CLI/GUI | Path | Must be writable directory, defaults to user data directory | -| Platform Override | CLI | String | Must be valid platform identifier (Windows/Linux/Darwin) | -| WSI File Paths | CLI/API | List[Path] | Files must exist and be readable, supports DICOM/SVS/TIFF formats | -| Annotation Data | CLI/API | GeoJSON/JSON | Must contain valid coordinate data and classification schemas | -| Project Metadata | API | Dict | Key-value pairs for QuPath project properties | +| Input Type | Source | Format/Type | Validation Rules | +| ----------------- | ----------- | --------------- | -------------------------------------------------------------------------- | +| QuPath Version | CLI/GUI/API | String (semver) | Must match available GitHub releases, defaults to 0.6.0-rc5 | +| Installation Path | CLI/GUI | Path | Must be writable directory, defaults to user data directory | +| Platform Override | CLI | String | Must be valid platform identifier (Windows/Linux/Darwin) | +| WSI File Paths | CLI/API | List[Path] | Files must exist and be readable, supports DICOM/SVS/TIFF/BIF/NDPI formats | +| Annotation Data | CLI/API | GeoJSON/JSON | Must contain valid coordinate data and classification schemas | +| Project Metadata | API | Dict | Key-value pairs for QuPath project properties | ### 3.2 Outputs @@ -362,7 +362,7 @@ uvx aignostics qupath terminate - **QuPath Version**: Must match semver pattern and be available in GitHub releases - **Installation Path**: Must be writable directory with sufficient disk space -- **WSI File Paths**: Files must exist, be readable, and match supported formats (DICOM, SVS, TIFF) +- **WSI File Paths**: Files must exist, be readable, and match supported formats (DICOM, SVS, TIFF, BIF, NDPI) - **Annotation Data**: Must contain valid GeoJSON structure with coordinate data and classification schemas ### 7.3 Graceful Degradation diff --git a/specifications/SPEC_WSI_SERVICE.md b/specifications/SPEC_WSI_SERVICE.md index 88db40c20..5a71ef86b 100644 --- a/specifications/SPEC_WSI_SERVICE.md +++ b/specifications/SPEC_WSI_SERVICE.md @@ -19,7 +19,7 @@ The WSI (Whole Slide Image) Module provides comprehensive support for digital pa The WSI Module shall: -- **[FR-01]** Support multi-format WSI processing including DICOM (.dcm), TIFF/BigTIFF (.tiff, .tif), and Aperio SVS (.svs) formats +- **[FR-01]** Support multi-format WSI processing including DICOM (.dcm), TIFF/BigTIFF (.tiff, .tif), Aperio SVS (.svs), Ventana BIF (.bif), and Hamamatsu NDPI (.ndpi) formats - **[FR-02]** Generate standardized PNG thumbnails (256x256 pixels) from any supported WSI format - **[FR-03]** Extract comprehensive metadata from WSI files including resolution, dimensions, and format-specific properties - **[FR-04]** Provide DICOM-specific hierarchical organization by study → container (slide) → series @@ -38,10 +38,11 @@ The WSI Module shall: ### 1.4 Constraints and Limitations -- **File Format Support**: Limited to extensions defined in `WSI_SUPPORTED_FILE_EXTENSIONS = {".dcm", ".tiff", ".tif", ".svs"}` with format-specific capabilities: +- **File Format Support**: Limited to extensions defined in `WSI_SUPPORTED_FILE_EXTENSIONS = {".dcm", ".tiff", ".tif", ".svs", ".bif", ".ndpi"}` with format-specific capabilities: - DICOM (.dcm): Complete metadata, pyramidal support, annotation support via PydicomHandler - TIFF/BigTIFF (.tiff, .tif): Standard metadata, pyramidal support, limited annotations via OpenSlideHandler - Aperio SVS (.svs): Vendor-specific metadata, pyramidal support, no annotation support via OpenSlideHandler + - Ventana BIF (.bif) and Hamamatsu NDPI (.ndpi): Vendor-specific metadata, pyramidal support, no annotation support via OpenSlideHandler - **OpenSlide Dependency**: Non-DICOM formats require OpenSlide library installation for processing - **Memory Constraints**: Large WSI files require careful memory management and streaming operations - **Platform Dependencies**: Requires platform-specific compilation of OpenSlide and image processing libraries @@ -60,7 +61,7 @@ wsi/ ├── _service.py # Core business logic and WSI processing service ├── _cli.py # Command-line interface for WSI inspection ├── _gui.py # Web-based GUI components and HTTP endpoints -├── _openslide_handler.py # Handler for TIFF/SVS formats using OpenSlide +├── _openslide_handler.py # Handler for TIFF/SVS/BIF/NDPI formats using OpenSlide ├── _pydicom_handler.py # Handler for DICOM formats using PyDICOM/HighDICOM ├── _utils.py # Helper functions for output formatting ├── __init__.py # Module exports and public API @@ -73,7 +74,7 @@ wsi/ | Component | Type | Purpose | Public Interface | Dependencies | | ------------------ | ----- | ------------------------------------- | ------------------------------------------------------------ | -------------------------------- | | `Service` | Class | Core WSI processing service | Thumbnail generation, metadata extraction, format conversion | OpenSlideHandler, PydicomHandler | -| `OpenSlideHandler` | Class | Handles TIFF/SVS formats | Format detection, thumbnail creation, metadata parsing | OpenSlide, PIL | +| `OpenSlideHandler` | Class | Handles TIFF/SVS/BIF/NDPI formats | Format detection, thumbnail creation, metadata parsing | OpenSlide, PIL | | `PydicomHandler` | Class | Handles DICOM formats and annotations | DICOM parsing, hierarchy organization, annotation import | PyDICOM, HighDICOM | | `PageBuilder` | Class | Web interface registration | HTTP endpoint registration | NiceGUI (optional) | | `cli` | Typer | Command-line interface | WSI inspection, DICOM analysis | Typer, Rich | @@ -389,7 +390,7 @@ uvx aignostics wsi [subcommand] [options] | Dependency | Min Version | Purpose | Optional/Required | Fallback Behavior | | ------------------ | ----------- | -------------------------------------- | ---------------------- | ----------------------------------- | -| `openslide-python` | Latest | Reading TIFF/SVS formats | Required for non-DICOM | Clear error with installation guide | +| `openslide-python` | Latest | Reading TIFF/SVS/BIF/NDPI formats | Required for non-DICOM | Clear error with installation guide | | `pydicom` | Latest | DICOM file parsing | Required for DICOM | Error message for DICOM operations | | `highdicom` | Latest | DICOM annotation handling | Required for DICOM | Annotation features unavailable | | `Pillow (PIL)` | Latest | Image processing and format conversion | Required | Core functionality fails | @@ -413,11 +414,11 @@ _Note: For exact version requirements, refer to `pyproject.toml` and dependency ### 6.1 Configuration Parameters -| Parameter | Type | Default | Description | Required | -| ------------------------------- | ----------------- | ----------------------------------- | ------------------------------- | -------- | -| `WSI_SUPPORTED_FILE_EXTENSIONS` | `set[str]` | `{".dcm", ".tiff", ".tif", ".svs"}` | Supported WSI file extensions | Yes | -| `TIMEOUT` | `int` | `60` | HTTP request timeout in seconds | No | -| Thumbnail size | `tuple[int, int]` | `(256, 256)` | Standard thumbnail dimensions | No | +| Parameter | Type | Default | Description | Required | +| ------------------------------- | ----------------- | ---------------------------------------------------- | ------------------------------- | -------- | +| `WSI_SUPPORTED_FILE_EXTENSIONS` | `set[str]` | `{".dcm", ".tiff", ".tif", ".svs", ".bif", ".ndpi"}` | Supported WSI file extensions | Yes | +| `TIMEOUT` | `int` | `60` | HTTP request timeout in seconds | No | +| Thumbnail size | `tuple[int, int]` | `(256, 256)` | Standard thumbnail dimensions | No | ### 6.2 Environment Variables diff --git a/src/aignostics/CLAUDE.md b/src/aignostics/CLAUDE.md index 739c43204..b14d781db 100644 --- a/src/aignostics/CLAUDE.md +++ b/src/aignostics/CLAUDE.md @@ -57,7 +57,7 @@ handling, IDC access, Marimo notebook assets, thumbnailing, TIFF I/O). - **Core Features**: Format detection, thumbnail generation, metadata extraction - **CLI**: `inspect`; `dicom inspect`, `dicom geojson_import` (see `wsi/_cli.py`) - **GUI**: Image viewer and metadata display -- **Handlers**: OpenSlide (.svs, .tiff), PyDICOM (DICOM files) +- **Handlers**: OpenSlide (.svs, .tiff, .bif, .ndpi), PyDICOM (DICOM files) - **Dependencies**: `utils` (logging) ### 📦 dataset diff --git a/src/aignostics/constants.py b/src/aignostics/constants.py index 5dec6e89b..9910544d5 100644 --- a/src/aignostics/constants.py +++ b/src/aignostics/constants.py @@ -35,7 +35,7 @@ HETA_APPLICATION_ID = "he-tme" TEST_APP_APPLICATION_ID = "test-app" -WSI_SUPPORTED_FILE_EXTENSIONS = {".dcm", ".tiff", ".tif", ".svs"} +WSI_SUPPORTED_FILE_EXTENSIONS = {".dcm", ".tiff", ".tif", ".svs", ".bif", ".ndpi"} WSI_SUPPORTED_FILE_EXTENSIONS_TEST_APP = {".tiff"} WINDOW_TITLE = "Aignostics Launchpad" diff --git a/src/aignostics/qupath/scripts/add.groovy b/src/aignostics/qupath/scripts/add.groovy index 4f353ee8f..6964d37b3 100644 --- a/src/aignostics/qupath/scripts/add.groovy +++ b/src/aignostics/qupath/scripts/add.groovy @@ -91,7 +91,7 @@ try { // Define supported file extensions (matching WSI_SUPPORTED_FILE_EXTENSIONS from Python) def supportedExtensions = [ - ".dcm", ".svs", ".tif", ".tiff" + ".dcm", ".svs", ".tif", ".tiff", ".bif", ".ndpi" ] as Set // Helper function to check if file is supported diff --git a/src/aignostics/wsi/CLAUDE.md b/src/aignostics/wsi/CLAUDE.md index 6c1a9a95a..49e8bf004 100644 --- a/src/aignostics/wsi/CLAUDE.md +++ b/src/aignostics/wsi/CLAUDE.md @@ -7,7 +7,7 @@ and `aignostics.utils`. See `../CLAUDE.md` for where this sits in the SDK. ## Supported formats -`WSI_SUPPORTED_FILE_EXTENSIONS = {".dcm", ".tiff", ".tif", ".svs"}` — defined in +`WSI_SUPPORTED_FILE_EXTENSIONS = {".dcm", ".tiff", ".tif", ".svs", ".bif", ".ndpi"}` — defined in `aignostics/constants.py`, re-exported from `aignostics/__init__.py`. That set is the single source of truth; `Service` rejects anything else. Note `.dicom` is NOT accepted (only `.dcm`). diff --git a/tests/aignostics/application/utils_test.py b/tests/aignostics/application/utils_test.py index 40a418e7e..45565e441 100644 --- a/tests/aignostics/application/utils_test.py +++ b/tests/aignostics/application/utils_test.py @@ -163,8 +163,7 @@ def test_get_supported_extensions_for_heta_application() -> None: extensions = get_supported_extensions_for_application(HETA_APPLICATION_ID) assert extensions == WSI_SUPPORTED_FILE_EXTENSIONS - assert isinstance(extensions, set) - assert len(extensions) > 0 + assert extensions == {".dcm", ".tiff", ".tif", ".svs", ".bif", ".ndpi"} @pytest.mark.unit diff --git a/tests/aignostics/wsi/service_test.py b/tests/aignostics/wsi/service_test.py index 64074ae4f..32d988158 100644 --- a/tests/aignostics/wsi/service_test.py +++ b/tests/aignostics/wsi/service_test.py @@ -480,3 +480,25 @@ def test_get_wsi_files_to_process_non_dicom_passthrough(tmp_path: Path) -> None: assert len(files) == 2 assert tiff1 in files assert tiff2 in files + + +@pytest.mark.unit +@pytest.mark.parametrize("suffix", [".bif", ".ndpi", ".BIF", ".NDPI"]) +def test_get_metadata_accepts_bif_and_ndpi_extensions(tmp_path: Path, suffix: str) -> None: + """Test BIF and NDPI files pass the extension check and reach OpenSlide.""" + slide = tmp_path / f"slide{suffix}" + slide.write_bytes(b"not a slide") + + # RuntimeError means OpenSlide rejected the content, so the extension was accepted. + with pytest.raises(RuntimeError, match="Error processing file"): + WSIService.get_metadata(slide) + + +@pytest.mark.unit +def test_get_metadata_rejects_czi_extension(tmp_path: Path) -> None: + """Test CZI files are rejected before OpenSlide is called.""" + slide = tmp_path / "slide.czi" + slide.write_bytes(b"not a slide") + + with pytest.raises(ValueError, match=r"Unsupported file type: \.czi"): + WSIService.get_metadata(slide) From 5ce10a770538d0a621461bf43010f2d53c650cb5 Mon Sep 17 00:00:00 2001 From: Blanca Pablos Date: Fri, 20 Nov 2026 17:24:01 +0100 Subject: [PATCH 2/3] feat(application): offer BIF and NDPI only for HETA 2.2.0 and later Older HETA versions do not reject BIF or NDPI at submission; the run fails while processing, and 2.1.1 would even try to process a BIF. Metadata generation now uses the resolved application version, so HETA before 2.2.0 keeps the .dcm/.tiff/.tif/.svs set. The submit page lists the formats of the selected version. Local WSI tooling keeps the full set. Co-Authored-By: Claude Opus 5.5 --- specifications/SPEC-APPLICATION-SERVICE.md | 16 +++---- .../_gui/_page_application_describe.py | 27 +++++++++-- src/aignostics/application/_service.py | 5 +- src/aignostics/application/_utils.py | 13 +++-- src/aignostics/constants.py | 3 ++ tests/aignostics/application/gui_test.py | 5 +- .../page_application_describe_test.py | 18 +++++++ tests/aignostics/application/service_test.py | 41 ++++++++++++++++ tests/aignostics/application/utils_test.py | 48 +++++++++++++------ 9 files changed, 143 insertions(+), 33 deletions(-) diff --git a/specifications/SPEC-APPLICATION-SERVICE.md b/specifications/SPEC-APPLICATION-SERVICE.md index 2b0ccaf61..123ff2de9 100644 --- a/specifications/SPEC-APPLICATION-SERVICE.md +++ b/specifications/SPEC-APPLICATION-SERVICE.md @@ -41,7 +41,7 @@ The Application Module shall: ### 1.4 Constraints and Limitations - Platform API compatibility requirements with auto-generated client integration -- File format support limited to major medical imaging formats (DICOM, TIFF, SVS, BIF, NDPI) +- File format support limited to major medical imaging formats (DICOM, TIFF, SVS, BIF, NDPI); HETA accepts BIF and NDPI only from version 2.2.0 on - Memory management constraints for large file processing with configurable chunk sizes - Optional QuPath integration requiring ijson dependency for full functionality @@ -89,13 +89,13 @@ application/ ### 3.1 Inputs -| Input Type | Source | Data Type/Format | Validation Rules | Business Rules | -| -------------------------- | ------------- | ---------------- | ------------------------------------------------------ | ----------------------------------------------- | -| **Supported WSI Files** | CLI/GUI | Path object | Must exist, extension in WSI_SUPPORTED_FILE_EXTENSIONS | File must be readable, format must be supported | -| **Application Version ID** | API | String | Must be valid UUID format | Must correspond to existing application version | -| **Input Items** | API | List[InputItem] | Each item must have valid metadata | Items must match application input schema | -| **Run ID** | API | String | Must be valid UUID format | Must correspond to existing application run | -| **Upload Chunks** | Configuration | Integer | Must be positive value | Configurable based on platform limits | +| Input Type | Source | Data Type/Format | Validation Rules | Business Rules | +| -------------------------- | ------------- | ---------------- | ------------------------------------------------------------------- | ----------------------------------------------- | +| **Supported WSI Files** | CLI/GUI | Path object | Must exist, extension supported by the resolved application version | File must be readable, format must be supported | +| **Application Version ID** | API | String | Must be valid UUID format | Must correspond to existing application version | +| **Input Items** | API | List[InputItem] | Each item must have valid metadata | Items must match application input schema | +| **Run ID** | API | String | Must be valid UUID format | Must correspond to existing application run | +| **Upload Chunks** | Configuration | Integer | Must be positive value | Configurable based on platform limits | ### 3.2 Outputs diff --git a/src/aignostics/application/_gui/_page_application_describe.py b/src/aignostics/application/_gui/_page_application_describe.py index 55dbc2d62..69262644c 100644 --- a/src/aignostics/application/_gui/_page_application_describe.py +++ b/src/aignostics/application/_gui/_page_application_describe.py @@ -12,7 +12,7 @@ from nicegui import run as nicegui_run from nicegui.events import ValueChangeEventArguments -from aignostics.constants import WSI_SUPPORTED_FILE_EXTENSIONS +from aignostics.constants import HETA_APPLICATION_ID, TEST_APP_APPLICATION_ID, WSI_SUPPORTED_FILE_EXTENSIONS from aignostics.platform import ( DEFAULT_CPU_PROVISIONING_MODE, DEFAULT_FLEX_START_MAX_RUN_DURATION_MINUTES, @@ -28,7 +28,7 @@ from aignostics.platform import UserInfo from .._service import Service # noqa: TID252 -from .._utils import get_mime_type_for_artifact # noqa: TID252 +from .._utils import get_mime_type_for_artifact, get_supported_extensions_for_application # noqa: TID252 from ._frame import _frame from ._utils import ( application_id_to_icon, @@ -175,6 +175,23 @@ class SubmitForm: submit_form = SubmitForm() + +def _supported_formats_text(application_id: str | None, application_version: str | None) -> str: + """Label text listing the file formats the selected application version accepts. + + Args: + application_id: The application ID. + application_version: The selected application version. + + Returns: + str: The label text. + """ + extensions = WSI_SUPPORTED_FILE_EXTENSIONS + if application_version and application_id in {HETA_APPLICATION_ID, TEST_APP_APPLICATION_ID}: + extensions = get_supported_extensions_for_application(application_id, application_version) + return f"Supported formats: {', '.join(sorted(extensions))}" + + upload_message_queue = Manager().Queue() service = Service() @@ -487,7 +504,11 @@ def _info_dialog_content() -> None: submit_form.wsi_step_label = ui.label( "Select the folder with the whole slide images you want to analyze then click Next." ) - ui.label(f"Supported formats: {', '.join(sorted(WSI_SUPPORTED_FILE_EXTENSIONS))}").classes("text-caption") + ui.label().classes("text-caption").bind_text_from( + submit_form, + "application_version", + backward=lambda version: _supported_formats_text(submit_form.application_id, version), + ) with ui.stepper_navigation(): if "pytest" in sys.modules: ui.button("Home", on_click=_pytest_home, icon="folder").mark("BUTTON_PYTEST_HOME") diff --git a/src/aignostics/application/_service.py b/src/aignostics/application/_service.py index 5693be25c..8fc17df11 100644 --- a/src/aignostics/application/_service.py +++ b/src/aignostics/application/_service.py @@ -364,14 +364,13 @@ def generate_metadata_from_source_directory( # noqa: PLR0913, PLR0917 """ logger.trace("Generating metadata from source directory: {}", source_directory) - # TODO(Helmut): Use it - _ = Service().application_version(application_id, application_version) + resolved_version = Service().application_version(application_id, application_version) metadata: list[dict[str, Any]] = [] wsi_service = WSIService() try: - extensions = get_supported_extensions_for_application(application_id) + extensions = get_supported_extensions_for_application(application_id, resolved_version.version_number) for extension in extensions: files_to_process = wsi_service.get_wsi_files_to_process(source_directory, extension) diff --git a/src/aignostics/application/_utils.py b/src/aignostics/application/_utils.py index 5a78be36b..83c8d6f54 100644 --- a/src/aignostics/application/_utils.py +++ b/src/aignostics/application/_utils.py @@ -16,12 +16,15 @@ from typing import Any, Protocol import humanize +import semver from loguru import logger from aignostics.constants import ( HETA_APPLICATION_ID, + HETA_MIN_VERSION_FOR_BIF_AND_NDPI, TEST_APP_APPLICATION_ID, WSI_SUPPORTED_FILE_EXTENSIONS, + WSI_SUPPORTED_FILE_EXTENSIONS_HETA_BEFORE_BIF_AND_NDPI, WSI_SUPPORTED_FILE_EXTENSIONS_TEST_APP, ) from aignostics.platform import ( @@ -579,20 +582,24 @@ def get_file_extension_for_artifact(artifact: OutputArtifactData) -> str: return file_extension -def get_supported_extensions_for_application(application_id: str) -> set[str]: - """Get the list of supported file extensions for a given application. +def get_supported_extensions_for_application(application_id: str, application_version: str) -> set[str]: + """Get the list of supported file extensions for a given application version. Args: application_id (str): The application ID + application_version (str): The resolved semantic version of the application Returns: set[str]: List of supported file extensions Raises: RuntimeError: If the application ID is not supported + ValueError: If the application version is not a valid semantic version """ if application_id == HETA_APPLICATION_ID: - return WSI_SUPPORTED_FILE_EXTENSIONS + if semver.Version.parse(application_version) >= HETA_MIN_VERSION_FOR_BIF_AND_NDPI: + return WSI_SUPPORTED_FILE_EXTENSIONS + return WSI_SUPPORTED_FILE_EXTENSIONS_HETA_BEFORE_BIF_AND_NDPI if application_id == TEST_APP_APPLICATION_ID: return WSI_SUPPORTED_FILE_EXTENSIONS_TEST_APP diff --git a/src/aignostics/constants.py b/src/aignostics/constants.py index 9910544d5..e1385c11f 100644 --- a/src/aignostics/constants.py +++ b/src/aignostics/constants.py @@ -36,6 +36,9 @@ HETA_APPLICATION_ID = "he-tme" TEST_APP_APPLICATION_ID = "test-app" WSI_SUPPORTED_FILE_EXTENSIONS = {".dcm", ".tiff", ".tif", ".svs", ".bif", ".ndpi"} +# HETA versions before this one reject BIF and NDPI while the run is processing. +HETA_MIN_VERSION_FOR_BIF_AND_NDPI = "2.2.0" +WSI_SUPPORTED_FILE_EXTENSIONS_HETA_BEFORE_BIF_AND_NDPI = {".dcm", ".tiff", ".tif", ".svs"} WSI_SUPPORTED_FILE_EXTENSIONS_TEST_APP = {".tiff"} WINDOW_TITLE = "Aignostics Launchpad" diff --git a/tests/aignostics/application/gui_test.py b/tests/aignostics/application/gui_test.py index bdb041e35..0235e616d 100644 --- a/tests/aignostics/application/gui_test.py +++ b/tests/aignostics/application/gui_test.py @@ -13,13 +13,13 @@ from nicegui.testing import User from typer.testing import CliRunner -from aignostics import WSI_SUPPORTED_FILE_EXTENSIONS from aignostics.application import Service from aignostics.application._gui._page_application_run_describe import ( RESULTS_PAGE_SIZE, _resolve_artifact_url_and_invoke, _resolve_artifact_url_or_notify, ) +from aignostics.application._utils import get_supported_extensions_for_application from aignostics.cli import cli from tests.conftest import assert_notified, assert_parquet_geojson_parity, normalize_output, print_directory_structure from tests.constants_test import ( @@ -211,7 +211,8 @@ async def test_gui_download_dataset_via_application_to_run_cancel_to_find_back( # Check the file picker opens and closes await user.should_see("Select the folder with the whole slide images you want to analyze then click Next") - await user.should_see(f"Supported formats: {', '.join(sorted(WSI_SUPPORTED_FILE_EXTENSIONS))}") + supported_extensions = get_supported_extensions_for_application("he-tme", latest_application_version.number) + await user.should_see(f"Supported formats: {', '.join(sorted(supported_extensions))}") user.find(marker="BUTTON_WSI_SELECT_DATA").click() await user.should_see("Ok") await user.should_see("Cancel") diff --git a/tests/aignostics/application/page_application_describe_test.py b/tests/aignostics/application/page_application_describe_test.py index 1b2224b35..ca3fdbf65 100644 --- a/tests/aignostics/application/page_application_describe_test.py +++ b/tests/aignostics/application/page_application_describe_test.py @@ -13,6 +13,7 @@ _js_set_membership, _metadata_row_is_valid, _specimen_metadata_column_defs, + _supported_formats_text, ) @@ -122,3 +123,20 @@ def test_metadata_row_is_valid_accepts_supported_combinations(tissue: str, disea def test_metadata_row_is_valid_rejects_unsupported_or_missing(row: dict) -> None: """Rows with an unsupported or missing tissue/disease fail validation.""" assert _metadata_row_is_valid(row) is False + + +@pytest.mark.unit +@pytest.mark.parametrize( + ("application_id", "application_version", "expected"), + [ + ("he-tme", "2.1.1", "Supported formats: .dcm, .svs, .tif, .tiff"), + ("he-tme", "2.2.0", "Supported formats: .bif, .dcm, .ndpi, .svs, .tif, .tiff"), + ("test-app", "0.1.0", "Supported formats: .tiff"), + ("he-tme", None, "Supported formats: .bif, .dcm, .ndpi, .svs, .tif, .tiff"), + ], +) +def test_supported_formats_text_follows_selected_version( + application_id: str, application_version: str | None, expected: str +) -> None: + """The formats caption lists only the extensions the selected application version accepts.""" + assert _supported_formats_text(application_id, application_version) == expected diff --git a/tests/aignostics/application/service_test.py b/tests/aignostics/application/service_test.py index 07c2ff6f0..8e9cad6a9 100644 --- a/tests/aignostics/application/service_test.py +++ b/tests/aignostics/application/service_test.py @@ -2,6 +2,7 @@ from datetime import UTC, datetime, timedelta from http import HTTPStatus +from pathlib import Path from unittest.mock import MagicMock, patch import pytest @@ -1118,3 +1119,43 @@ def test_application_run_with_share_token_uses_share_token_path( mock_for_run_id.assert_called_once_with("run-id", share_token="s3cr3t") # noqa: S106 mock_get_client.return_value.run.assert_not_called() + + +@pytest.mark.unit +@pytest.mark.parametrize( + ("requested_version", "resolved_version", "expected_suffixes"), + [ + (None, "2.1.1", {".svs"}), + ("2.1.1", "2.1.1", {".svs"}), + (None, "2.2.0", {".svs", ".bif", ".ndpi"}), + ("2.3.0", "2.3.0", {".svs", ".bif", ".ndpi"}), + ], +) +@patch("aignostics.application._service.WSIService.get_metadata") +@patch("aignostics.application._service.Service._get_platform_client") +def test_generate_metadata_offers_bif_and_ndpi_only_from_heta_2_2_0( # noqa: PLR0913, PLR0917 + mock_get_client: MagicMock, + mock_get_metadata: MagicMock, + tmp_path: Path, + requested_version: str | None, + resolved_version: str, + expected_suffixes: set[str], +) -> None: + """Test metadata generation picks the file extensions of the resolved HETA version.""" + for suffix in (".svs", ".bif", ".ndpi"): + (tmp_path / f"slide{suffix}").write_bytes(b"slide") + mock_get_client.return_value.application_version.return_value = MagicMock(version_number=resolved_version) + mock_get_metadata.return_value = { + "dimensions": {"width": 100, "height": 200}, + "resolution": {"mpp_x": 0.25}, + "file": {"size_human": "5 B"}, + } + + metadata = ApplicationService.generate_metadata_from_source_directory( + source_directory=tmp_path, + application_id="he-tme", + application_version=requested_version, + ) + + mock_get_client.return_value.application_version.assert_called_once_with("he-tme", requested_version) + assert {Path(entry["external_id"]).suffix for entry in metadata} == expected_suffixes diff --git a/tests/aignostics/application/utils_test.py b/tests/aignostics/application/utils_test.py index 45565e441..53543ba29 100644 --- a/tests/aignostics/application/utils_test.py +++ b/tests/aignostics/application/utils_test.py @@ -44,6 +44,9 @@ TEST_MAPPING_TIFF_HE = ".*\\.tiff:staining_method=H&E" SUBMITTED_BY = "user@example.com" +HETA_EXTENSIONS_BEFORE_BIF_AND_NDPI = {".dcm", ".tiff", ".tif", ".svs"} +HETA_EXTENSIONS_WITH_BIF_AND_NDPI = {".dcm", ".tiff", ".tif", ".svs", ".bif", ".ndpi"} +APPLICATION_VERSION = "1.0.0" _ISO_8601_FORMAT = "%Y-%m-%dT%H:%M:%S" @@ -158,22 +161,39 @@ def _make_item_result( # noqa: PLR0913 @pytest.mark.unit -def test_get_supported_extensions_for_heta_application() -> None: - """Test that HETA application returns the correct set of supported extensions.""" - extensions = get_supported_extensions_for_application(HETA_APPLICATION_ID) +@pytest.mark.parametrize( + ("application_version", "expected"), + [ + ("1.0.0", HETA_EXTENSIONS_BEFORE_BIF_AND_NDPI), + ("2.1.1", HETA_EXTENSIONS_BEFORE_BIF_AND_NDPI), + ("2.2.0-rc.1", HETA_EXTENSIONS_BEFORE_BIF_AND_NDPI), + ("2.2.0", HETA_EXTENSIONS_WITH_BIF_AND_NDPI), + ("2.3.0", HETA_EXTENSIONS_WITH_BIF_AND_NDPI), + ("3.0.0", HETA_EXTENSIONS_WITH_BIF_AND_NDPI), + ], +) +def test_get_supported_extensions_for_heta_application(application_version: str, expected: set[str]) -> None: + """Test that HETA accepts BIF and NDPI only from version 2.2.0 on.""" + extensions = get_supported_extensions_for_application(HETA_APPLICATION_ID, application_version) + + assert extensions == expected - assert extensions == WSI_SUPPORTED_FILE_EXTENSIONS - assert extensions == {".dcm", ".tiff", ".tif", ".svs", ".bif", ".ndpi"} + +@pytest.mark.unit +def test_get_supported_extensions_for_heta_rejects_invalid_version() -> None: + """Test that a version that is not semver raises ValueError.""" + with pytest.raises(ValueError, match="not valid SemVer"): + get_supported_extensions_for_application(HETA_APPLICATION_ID, "latest") @pytest.mark.unit -def test_get_supported_extensions_for_test_app() -> None: - """Test that test application returns the correct set of supported extensions.""" - extensions = get_supported_extensions_for_application(TEST_APP_APPLICATION_ID) +@pytest.mark.parametrize("application_version", ["0.1.0", "2.1.1", "2.2.0"]) +def test_get_supported_extensions_for_test_app(application_version: str) -> None: + """Test that test application returns the same extensions for every version.""" + extensions = get_supported_extensions_for_application(TEST_APP_APPLICATION_ID, application_version) assert extensions == WSI_SUPPORTED_FILE_EXTENSIONS_TEST_APP - assert isinstance(extensions, set) - assert len(extensions) > 0 + assert extensions == {".tiff"} @pytest.mark.unit @@ -182,7 +202,7 @@ def test_get_supported_extensions_for_unsupported_application() -> None: unsupported_app_id = "unsupported-application-id" with pytest.raises(RuntimeError) as exc_info: - get_supported_extensions_for_application(unsupported_app_id) + get_supported_extensions_for_application(unsupported_app_id, APPLICATION_VERSION) assert f"Unsupported application {unsupported_app_id}" in str(exc_info.value) @@ -191,7 +211,7 @@ def test_get_supported_extensions_for_unsupported_application() -> None: def test_get_supported_extensions_for_empty_string() -> None: """Test that an empty string application ID raises RuntimeError.""" with pytest.raises(RuntimeError) as exc_info: - get_supported_extensions_for_application("") + get_supported_extensions_for_application("", APPLICATION_VERSION) assert "Unsupported application" in str(exc_info.value) @@ -199,8 +219,8 @@ def test_get_supported_extensions_for_empty_string() -> None: @pytest.mark.unit def test_get_supported_extensions_returns_different_sets() -> None: """Test that different applications return different extension sets.""" - heta_extensions = get_supported_extensions_for_application(HETA_APPLICATION_ID) - test_extensions = get_supported_extensions_for_application(TEST_APP_APPLICATION_ID) + heta_extensions = get_supported_extensions_for_application(HETA_APPLICATION_ID, "2.2.0") + test_extensions = get_supported_extensions_for_application(TEST_APP_APPLICATION_ID, APPLICATION_VERSION) # Verify they are separate sets (even if they might have the same contents) assert heta_extensions is WSI_SUPPORTED_FILE_EXTENSIONS From cf2c13129cce0ebe33ab664b24d058402f27128f Mon Sep 17 00:00:00 2001 From: Blanca Pablos Date: Fri, 20 Nov 2026 17:29:51 +0100 Subject: [PATCH 3/3] feat(application): offer BIF and NDPI to HETA 2.2.0 release candidates too Co-Authored-By: Claude Opus 5.5 --- src/aignostics/application/_utils.py | 3 ++- tests/aignostics/application/utils_test.py | 6 ++++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/src/aignostics/application/_utils.py b/src/aignostics/application/_utils.py index 83c8d6f54..49f83137c 100644 --- a/src/aignostics/application/_utils.py +++ b/src/aignostics/application/_utils.py @@ -597,7 +597,8 @@ def get_supported_extensions_for_application(application_id: str, application_ve ValueError: If the application version is not a valid semantic version """ if application_id == HETA_APPLICATION_ID: - if semver.Version.parse(application_version) >= HETA_MIN_VERSION_FOR_BIF_AND_NDPI: + # Release candidates of 2.2.0 already read BIF and NDPI. + if semver.Version.parse(application_version).finalize_version() >= HETA_MIN_VERSION_FOR_BIF_AND_NDPI: return WSI_SUPPORTED_FILE_EXTENSIONS return WSI_SUPPORTED_FILE_EXTENSIONS_HETA_BEFORE_BIF_AND_NDPI if application_id == TEST_APP_APPLICATION_ID: diff --git a/tests/aignostics/application/utils_test.py b/tests/aignostics/application/utils_test.py index 53543ba29..b7e314f2c 100644 --- a/tests/aignostics/application/utils_test.py +++ b/tests/aignostics/application/utils_test.py @@ -166,14 +166,16 @@ def _make_item_result( # noqa: PLR0913 [ ("1.0.0", HETA_EXTENSIONS_BEFORE_BIF_AND_NDPI), ("2.1.1", HETA_EXTENSIONS_BEFORE_BIF_AND_NDPI), - ("2.2.0-rc.1", HETA_EXTENSIONS_BEFORE_BIF_AND_NDPI), + ("2.1.1-rc.1", HETA_EXTENSIONS_BEFORE_BIF_AND_NDPI), + ("2.2.0-rc.1", HETA_EXTENSIONS_WITH_BIF_AND_NDPI), + ("2.2.0+build.5", HETA_EXTENSIONS_WITH_BIF_AND_NDPI), ("2.2.0", HETA_EXTENSIONS_WITH_BIF_AND_NDPI), ("2.3.0", HETA_EXTENSIONS_WITH_BIF_AND_NDPI), ("3.0.0", HETA_EXTENSIONS_WITH_BIF_AND_NDPI), ], ) def test_get_supported_extensions_for_heta_application(application_version: str, expected: set[str]) -> None: - """Test that HETA accepts BIF and NDPI only from version 2.2.0 on.""" + """Test that HETA accepts BIF and NDPI from version 2.2.0 on, its release candidates included.""" extensions = get_supported_extensions_for_application(HETA_APPLICATION_ID, application_version) assert extensions == expected