diff --git a/CHANGELOG.md b/CHANGELOG.md index c7737fe2e..bd715e4f9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,7 +1,8 @@ **Note**: Numbers like (\#123) point to closed Pull Requests on the fractal-tasks-core repository. -# Unreleased +# 0.12.1 +* Make `Channel.window` attribute optional in `lib_ngff.py` (\#548). * Automate procedure for publishing package to PyPI (\#545). # 0.12.0 diff --git a/fractal_tasks_core/lib_ngff.py b/fractal_tasks_core/lib_ngff.py index 0f09e929d..4830b445d 100644 --- a/fractal_tasks_core/lib_ngff.py +++ b/fractal_tasks_core/lib_ngff.py @@ -33,7 +33,7 @@ class Channel(BaseModel): See https://ngff.openmicroscopy.org/0.4/#omero-md. """ - window: Window + window: Optional[Window] = None label: Optional[str] = None family: Optional[str] = None color: str diff --git a/tests/data/ngff_examples/image_no_omero_channel_window.json b/tests/data/ngff_examples/image_no_omero_channel_window.json new file mode 100644 index 000000000..8bfebb209 --- /dev/null +++ b/tests/data/ngff_examples/image_no_omero_channel_window.json @@ -0,0 +1,53 @@ +{ + "multiscales": [ + { + "axes": [ + { + "name": "y", + "type": "space", + "unit": "micrometer" + }, + { + "name": "x", + "type": "space", + "unit": "micrometer" + } + ], + "datasets": [ + { + "path": 0, + "coordinateTransformations": [ + { + "type": "scale", + "scale": [ + 0.1625, + 0.1625 + ] + } + ] + } + ], + "version": "0.4" + } + ], + "omero": { + "channels": [ + { + "wavelength_id": "A01_C01", + "label": "some-label-1", + "color": "00FFFF" + }, + { + "wavelength_id": "A01_C02", + "label": "some-label-2", + "color": "00FFFF", + "window":{ + "start": 0, + "end": 1, + "min": 0, + "max": 1 + } + } + ] + } +} diff --git a/tests/test_unit_ngff.py b/tests/test_unit_ngff.py index 669841f20..75a7a4e03 100644 --- a/tests/test_unit_ngff.py +++ b/tests/test_unit_ngff.py @@ -118,6 +118,14 @@ def test_NgffImageMeta(ngffdata_path): debug(e.value) assert "are too small" in str(e.value) + # Load an image where not all omero channels have a window attribute + ngff_image_meta = _load_and_validate( + ngffdata_path / "image_no_omero_channel_window.json", NgffImageMeta + ) + debug(ngff_image_meta.omero) + assert ngff_image_meta.omero.channels[0].window is None + assert ngff_image_meta.omero.channels[1].window is not None + def test_ImageNgffMeta_missing_Z(ngffdata_path, caplog): ngff_image_meta = _load_and_validate(