You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
fix(wsi): Add multi-file pyramid + WSI selection for DICOM files (#270)
* Add `select_dicom_files` which filters out non-WSI files using `SOPClassUID` and selects onlu the highest resolution image from multi-file pyramids to be processed
* Integrate into `wsi` service to handle files with `.dcm` extension
* Refactor `_scan_files` in `PydicomHandler` to reduce complexity, and add WSI /pyramid filtering as an option
* Update docs accordingly, including mention of highdicom now being optional
The WSI module automatically handles multi-file DICOM pyramids (whole slide images stored across multiple DICOM instances) by selecting only the highest resolution file from each pyramid. This prevents redundant processing since OpenSlide can automatically find related pyramid files in the same directory.
219
+
220
+
**Implementation Location:**
221
+
222
+
The DICOM file selection logic is implemented in `_utils.py` as `select_dicom_files()`. This function **only depends on pydicom** (not highdicom), making it compatible with Python 3.14+ where highdicom is not available.
The DICOM file selection functionality is organized as follows:
336
+
-**`_utils.py`**: Contains `select_dicom_files()` and `_find_highest_resolution_files()` helper
337
+
- Only depends on `pydicom`, `pathlib`, `collections.defaultdict`, and `loguru`
338
+
- Compatible with Python 3.14+ (no highdicom dependency)
339
+
-**`_service.py`**: Uses `select_dicom_files()` in `get_wsi_files_to_process()`
340
+
-**`_pydicom_handler.py`**: Uses `select_dicom_files()` for metadata extraction with `wsi_only=True`
341
+
- This module still requires highdicom for annotation/measurement features
342
+
- Only the CLI commands that need highdicom (geojson import, detailed inspection) use PydicomHandler
343
+
344
+
213
345
## Usage Patterns
214
346
215
347
### Basic WSI Operations
@@ -264,13 +396,10 @@ for wsi in wsi_files:
264
396
aignostics wsi inspect slide.svs
265
397
266
398
# Inspect DICOM metadata
267
-
aignostics wsi dicom-inspect scan.dcm
399
+
aignostics wsi dicominspect scan.dcm
268
400
269
401
# Import GeoJSON annotations
270
-
aignostics wsi dicom-geojson-import \
271
-
--dicom-file scan.dcm \
272
-
--geojson-file annotations.json \
273
-
--output annotated.dcm
402
+
aignostics wsi dicom geojson_import scan.dcm annotations.json
274
403
```
275
404
276
405
## Dependencies & Integration
@@ -285,8 +414,17 @@ aignostics wsi dicom-geojson-import \
285
414
286
415
-`openslide-python` - Core WSI reading functionality
287
416
-`Pillow` - Image processing and thumbnail generation
288
-
-`pydicom` - DICOM file handling
417
+
-`pydicom` - DICOM file handling (required for basic DICOM WSI operations)
289
418
-`numpy` - Array manipulation for pixel data
419
+
-`highdicom` - DICOM annotation/measurement features (optional, not available on Python 3.14+)
420
+
421
+
**Python 3.14+ Compatibility:**
422
+
423
+
The core WSI functionality (thumbnail generation, metadata extraction, DICOM file selection) works on Python 3.14+ without highdicom. Only the following CLI commands require highdicom and are unavailable on Python 3.14+:
424
+
-`aignostics wsi dicom geojson_import` - Import GeoJSON to DICOM annotations
425
+
- Detailed annotation/measurement inspection features
426
+
427
+
The DICOM file selection logic (`select_dicom_files()`) works on all Python versions since it only depends on `pydicom`.
0 commit comments