napari-zenapi-streaming 0.0.3__tar.gz → 0.0.4__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {napari_zenapi_streaming-0.0.3 → napari_zenapi_streaming-0.0.4}/CHANGELOG.md +11 -0
- {napari_zenapi_streaming-0.0.3/src/napari_zenapi_streaming.egg-info → napari_zenapi_streaming-0.0.4}/PKG-INFO +29 -15
- {napari_zenapi_streaming-0.0.3 → napari_zenapi_streaming-0.0.4}/README.md +28 -14
- {napari_zenapi_streaming-0.0.3 → napari_zenapi_streaming-0.0.4}/pyproject.toml +1 -1
- {napari_zenapi_streaming-0.0.3 → napari_zenapi_streaming-0.0.4}/src/napari_zen_streaming/ZEN_omezarr.py +101 -11
- {napari_zenapi_streaming-0.0.3 → napari_zenapi_streaming-0.0.4}/src/napari_zen_streaming/ZEN_stream2omezarr.py +21 -0
- {napari_zenapi_streaming-0.0.3 → napari_zenapi_streaming-0.0.4}/src/napari_zen_streaming/ZEN_ui.py +1 -0
- {napari_zenapi_streaming-0.0.3 → napari_zenapi_streaming-0.0.4}/src/napari_zen_streaming/__init__.py +1 -1
- {napari_zenapi_streaming-0.0.3 → napari_zenapi_streaming-0.0.4}/src/napari_zen_streaming/_tests/test_experiment_xml.py +73 -0
- {napari_zenapi_streaming-0.0.3 → napari_zenapi_streaming-0.0.4}/src/napari_zen_streaming/_tests/test_initial_experiment_selection.py +12 -1
- {napari_zenapi_streaming-0.0.3 → napari_zenapi_streaming-0.0.4}/src/napari_zen_streaming/_tests/test_omezarr_viewer.py +59 -0
- {napari_zenapi_streaming-0.0.3 → napari_zenapi_streaming-0.0.4}/src/napari_zen_streaming/_tests/test_scene_mosaic.py +138 -0
- {napari_zenapi_streaming-0.0.3 → napari_zenapi_streaming-0.0.4/src/napari_zenapi_streaming.egg-info}/PKG-INFO +29 -15
- {napari_zenapi_streaming-0.0.3 → napari_zenapi_streaming-0.0.4}/LICENSE +0 -0
- {napari_zenapi_streaming-0.0.3 → napari_zenapi_streaming-0.0.4}/MANIFEST.in +0 -0
- {napari_zenapi_streaming-0.0.3 → napari_zenapi_streaming-0.0.4}/setup.cfg +0 -0
- {napari_zenapi_streaming-0.0.3 → napari_zenapi_streaming-0.0.4}/src/napari_zen_streaming/ZEN_config.py +0 -0
- {napari_zenapi_streaming-0.0.3 → napari_zenapi_streaming-0.0.4}/src/napari_zen_streaming/ZEN_init.py +0 -0
- {napari_zenapi_streaming-0.0.3 → napari_zenapi_streaming-0.0.4}/src/napari_zen_streaming/ZEN_pipeline.py +0 -0
- {napari_zenapi_streaming-0.0.3 → napari_zenapi_streaming-0.0.4}/src/napari_zen_streaming/ZEN_utils.py +0 -0
- {napari_zenapi_streaming-0.0.3 → napari_zenapi_streaming-0.0.4}/src/napari_zen_streaming/_logging.py +0 -0
- {napari_zenapi_streaming-0.0.3 → napari_zenapi_streaming-0.0.4}/src/napari_zen_streaming/_scene_geometry.py +0 -0
- {napari_zenapi_streaming-0.0.3 → napari_zenapi_streaming-0.0.4}/src/napari_zen_streaming/_tests/__init__.py +0 -0
- {napari_zenapi_streaming-0.0.3 → napari_zenapi_streaming-0.0.4}/src/napari_zen_streaming/_tests/test_config.py +0 -0
- {napari_zenapi_streaming-0.0.3 → napari_zenapi_streaming-0.0.4}/src/napari_zen_streaming/_tests/test_display_completion.py +0 -0
- {napari_zenapi_streaming-0.0.3 → napari_zenapi_streaming-0.0.4}/src/napari_zen_streaming/_tests/test_experiment_stream_filter.py +0 -0
- {napari_zenapi_streaming-0.0.3 → napari_zenapi_streaming-0.0.4}/src/napari_zen_streaming/_tests/test_hcs_ui_option.py +0 -0
- {napari_zenapi_streaming-0.0.3 → napari_zenapi_streaming-0.0.4}/src/napari_zen_streaming/_tests/test_live_preview.py +0 -0
- {napari_zenapi_streaming-0.0.3 → napari_zenapi_streaming-0.0.4}/src/napari_zen_streaming/_tests/test_logging.py +0 -0
- {napari_zenapi_streaming-0.0.3 → napari_zenapi_streaming-0.0.4}/src/napari_zen_streaming/_tests/test_progress_reporting.py +0 -0
- {napari_zenapi_streaming-0.0.3 → napari_zenapi_streaming-0.0.4}/src/napari_zen_streaming/_tests/test_runtime_pixel_type.py +0 -0
- {napari_zenapi_streaming-0.0.3 → napari_zenapi_streaming-0.0.4}/src/napari_zen_streaming/_tests/test_scene_geometry.py +0 -0
- {napari_zenapi_streaming-0.0.3 → napari_zenapi_streaming-0.0.4}/src/napari_zen_streaming/_widget.py +0 -0
- {napari_zenapi_streaming-0.0.3 → napari_zenapi_streaming-0.0.4}/src/napari_zen_streaming/main.py +0 -0
- {napari_zenapi_streaming-0.0.3 → napari_zenapi_streaming-0.0.4}/src/napari_zen_streaming/misc.py +0 -0
- {napari_zenapi_streaming-0.0.3 → napari_zenapi_streaming-0.0.4}/src/napari_zen_streaming/napari.yaml +0 -0
- {napari_zenapi_streaming-0.0.3 → napari_zenapi_streaming-0.0.4}/src/napari_zenapi_streaming.egg-info/SOURCES.txt +0 -0
- {napari_zenapi_streaming-0.0.3 → napari_zenapi_streaming-0.0.4}/src/napari_zenapi_streaming.egg-info/dependency_links.txt +0 -0
- {napari_zenapi_streaming-0.0.3 → napari_zenapi_streaming-0.0.4}/src/napari_zenapi_streaming.egg-info/entry_points.txt +0 -0
- {napari_zenapi_streaming-0.0.3 → napari_zenapi_streaming-0.0.4}/src/napari_zenapi_streaming.egg-info/requires.txt +0 -0
- {napari_zenapi_streaming-0.0.3 → napari_zenapi_streaming-0.0.4}/src/napari_zenapi_streaming.egg-info/top_level.txt +0 -0
|
@@ -1,5 +1,16 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 0.0.4 - 2026-11-18
|
|
4
|
+
|
|
5
|
+
### Fixed
|
|
6
|
+
|
|
7
|
+
- Carry active-channel names and actual ZEN XML colors through plugin and
|
|
8
|
+
configured CLI OME-Zarr acquisition. Persist per-image OMERO display
|
|
9
|
+
settings in stream/subset order for generic scenes, HCS wells, and retained
|
|
10
|
+
source tiles, and preserve them when generating pyramids so
|
|
11
|
+
`napari-ome-zarr` automatically restores channel colors. Missing or invalid
|
|
12
|
+
XML colors warn and fall back to neutral grayscale.
|
|
13
|
+
|
|
3
14
|
## 0.0.3 - 2026-11-18
|
|
4
15
|
|
|
5
16
|
### Fixed
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: napari-zenapi-streaming
|
|
3
|
-
Version: 0.0.
|
|
3
|
+
Version: 0.0.4
|
|
4
4
|
Summary: ZEN API streaming plugin for napari
|
|
5
5
|
Author-email: "Krijn H. van der Steen" <k.h.vandersteen@umcutrecht.nl>, Sebastian Rhode <sebastian.rhode@zeiss.com>
|
|
6
6
|
License-Expression: BSD-3-Clause
|
|
@@ -94,21 +94,23 @@ When finished the resulting OME-ZARR, created from the ZEN pixel stream can be s
|
|
|
94
94
|
|
|
95
95
|
## Current status
|
|
96
96
|
|
|
97
|
-
- Release: **0.0.
|
|
97
|
+
- Release: **0.0.4** ([release notes](_release_notes/v0.0.4.md)).
|
|
98
98
|
- Project phase: alpha / MVP
|
|
99
99
|
- Primary OS target: Windows for ZEN Blue and the ZEN API Gateway
|
|
100
100
|
- Python target: `>=3.12, <3.15`
|
|
101
101
|
|
|
102
|
-
### What's new in 0.0.
|
|
102
|
+
### What's new in 0.0.4
|
|
103
103
|
|
|
104
|
-
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
-
|
|
108
|
-
|
|
109
|
-
-
|
|
110
|
-
|
|
111
|
-
|
|
104
|
+
- Configured OME-ZARR acquisition preserves active channel names and actual
|
|
105
|
+
display colors from the selected ZEN experiment.
|
|
106
|
+
- Per-image OMERO display metadata follows channel subscriptions and
|
|
107
|
+
single-channel selections across generic scenes, HCS wells, and retained
|
|
108
|
+
source tiles.
|
|
109
|
+
- Pyramid generation retains these settings so `napari-ome-zarr` opens new
|
|
110
|
+
output with the experiment's colors. Missing or invalid colors warn and
|
|
111
|
+
use neutral grayscale rather than guessing a biological color.
|
|
112
|
+
- See the [0.0.3 release notes](_release_notes/v0.0.3.md) for the preceding
|
|
113
|
+
stream-activation and shutdown fixes.
|
|
112
114
|
|
|
113
115
|
## Known limitations
|
|
114
116
|
|
|
@@ -253,17 +255,18 @@ without confirming redistribution rights.
|
|
|
253
255
|
For a published PyPI release:
|
|
254
256
|
|
|
255
257
|
```powershell
|
|
256
|
-
python -m pip install "napari-zenapi-streaming==0.0.
|
|
258
|
+
python -m pip install "napari-zenapi-streaming==0.0.4" "napari[pyqt6]" "PyQt6>=6.7,<6.10"
|
|
257
259
|
```
|
|
258
260
|
|
|
259
261
|
To upgrade an existing environment with compatible ZEN wheels installed:
|
|
260
262
|
|
|
261
263
|
```powershell
|
|
262
|
-
python -m pip install --upgrade "napari-zenapi-streaming==0.0.
|
|
264
|
+
python -m pip install --upgrade "napari-zenapi-streaming==0.0.4"
|
|
263
265
|
```
|
|
264
266
|
|
|
265
|
-
Restart napari after upgrading. Version 0.0.
|
|
266
|
-
automatically migrate older stores
|
|
267
|
+
Restart napari after upgrading. Version 0.0.4 writes OME-Zarr 0.6 and does not
|
|
268
|
+
automatically migrate older stores or add channel colors to existing output.
|
|
269
|
+
Use a reader that supports 0.6 and OMERO channel display metadata.
|
|
267
270
|
|
|
268
271
|
From this checkout, install the plugin:
|
|
269
272
|
|
|
@@ -637,6 +640,17 @@ and **Create pyramid after acquisition** in its UI. When enabled, choose how
|
|
|
637
640
|
many 2x Y/X downsampled levels to append after acquisition completes. Napari
|
|
638
641
|
opens the OME-Zarr only after pyramid generation finishes. Existing level `0`
|
|
639
642
|
is reused and is never rewritten.
|
|
643
|
+
Active channel names and display colors come from the selected experiment's
|
|
644
|
+
exported XML, in the same order as the channel subscriptions. ZEN's
|
|
645
|
+
`#AARRGGBB` colors are saved as OMERO `RRGGBB` colors on every image
|
|
646
|
+
(including HCS wells and retained source tiles), with display limits from
|
|
647
|
+
the runtime pixel type. Selecting a single channel retains that source
|
|
648
|
+
channel's name and color. Pyramid generation preserves these settings, so
|
|
649
|
+
`napari-ome-zarr` automatically opens the images with their ZEN colors.
|
|
650
|
+
Missing or invalid XML colors produce a warning and use neutral grayscale,
|
|
651
|
+
not an inferred fluorophore color. Direct writer configurations without
|
|
652
|
+
channel metadata keep the previous reader-default behavior.
|
|
653
|
+
|
|
640
654
|
Generic scene mosaics also expose **Keep individual source tiles**; unchecked
|
|
641
655
|
removes source groups only after mosaic creation succeeds. Advanced values
|
|
642
656
|
intentionally use fixed defaults declared at the top of `ZEN_omezarr.py`:
|
|
@@ -42,21 +42,23 @@ When finished the resulting OME-ZARR, created from the ZEN pixel stream can be s
|
|
|
42
42
|
|
|
43
43
|
## Current status
|
|
44
44
|
|
|
45
|
-
- Release: **0.0.
|
|
45
|
+
- Release: **0.0.4** ([release notes](_release_notes/v0.0.4.md)).
|
|
46
46
|
- Project phase: alpha / MVP
|
|
47
47
|
- Primary OS target: Windows for ZEN Blue and the ZEN API Gateway
|
|
48
48
|
- Python target: `>=3.12, <3.15`
|
|
49
49
|
|
|
50
|
-
### What's new in 0.0.
|
|
50
|
+
### What's new in 0.0.4
|
|
51
51
|
|
|
52
|
-
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
-
|
|
56
|
-
|
|
57
|
-
-
|
|
58
|
-
|
|
59
|
-
|
|
52
|
+
- Configured OME-ZARR acquisition preserves active channel names and actual
|
|
53
|
+
display colors from the selected ZEN experiment.
|
|
54
|
+
- Per-image OMERO display metadata follows channel subscriptions and
|
|
55
|
+
single-channel selections across generic scenes, HCS wells, and retained
|
|
56
|
+
source tiles.
|
|
57
|
+
- Pyramid generation retains these settings so `napari-ome-zarr` opens new
|
|
58
|
+
output with the experiment's colors. Missing or invalid colors warn and
|
|
59
|
+
use neutral grayscale rather than guessing a biological color.
|
|
60
|
+
- See the [0.0.3 release notes](_release_notes/v0.0.3.md) for the preceding
|
|
61
|
+
stream-activation and shutdown fixes.
|
|
60
62
|
|
|
61
63
|
## Known limitations
|
|
62
64
|
|
|
@@ -201,17 +203,18 @@ without confirming redistribution rights.
|
|
|
201
203
|
For a published PyPI release:
|
|
202
204
|
|
|
203
205
|
```powershell
|
|
204
|
-
python -m pip install "napari-zenapi-streaming==0.0.
|
|
206
|
+
python -m pip install "napari-zenapi-streaming==0.0.4" "napari[pyqt6]" "PyQt6>=6.7,<6.10"
|
|
205
207
|
```
|
|
206
208
|
|
|
207
209
|
To upgrade an existing environment with compatible ZEN wheels installed:
|
|
208
210
|
|
|
209
211
|
```powershell
|
|
210
|
-
python -m pip install --upgrade "napari-zenapi-streaming==0.0.
|
|
212
|
+
python -m pip install --upgrade "napari-zenapi-streaming==0.0.4"
|
|
211
213
|
```
|
|
212
214
|
|
|
213
|
-
Restart napari after upgrading. Version 0.0.
|
|
214
|
-
automatically migrate older stores
|
|
215
|
+
Restart napari after upgrading. Version 0.0.4 writes OME-Zarr 0.6 and does not
|
|
216
|
+
automatically migrate older stores or add channel colors to existing output.
|
|
217
|
+
Use a reader that supports 0.6 and OMERO channel display metadata.
|
|
215
218
|
|
|
216
219
|
From this checkout, install the plugin:
|
|
217
220
|
|
|
@@ -585,6 +588,17 @@ and **Create pyramid after acquisition** in its UI. When enabled, choose how
|
|
|
585
588
|
many 2x Y/X downsampled levels to append after acquisition completes. Napari
|
|
586
589
|
opens the OME-Zarr only after pyramid generation finishes. Existing level `0`
|
|
587
590
|
is reused and is never rewritten.
|
|
591
|
+
Active channel names and display colors come from the selected experiment's
|
|
592
|
+
exported XML, in the same order as the channel subscriptions. ZEN's
|
|
593
|
+
`#AARRGGBB` colors are saved as OMERO `RRGGBB` colors on every image
|
|
594
|
+
(including HCS wells and retained source tiles), with display limits from
|
|
595
|
+
the runtime pixel type. Selecting a single channel retains that source
|
|
596
|
+
channel's name and color. Pyramid generation preserves these settings, so
|
|
597
|
+
`napari-ome-zarr` automatically opens the images with their ZEN colors.
|
|
598
|
+
Missing or invalid XML colors produce a warning and use neutral grayscale,
|
|
599
|
+
not an inferred fluorophore color. Direct writer configurations without
|
|
600
|
+
channel metadata keep the previous reader-default behavior.
|
|
601
|
+
|
|
588
602
|
Generic scene mosaics also expose **Keep individual source tiles**; unchecked
|
|
589
603
|
removes source groups only after mosaic creation succeeds. Advanced values
|
|
590
604
|
intentionally use fixed defaults declared at the top of `ZEN_omezarr.py`:
|
|
@@ -116,7 +116,10 @@ def finalize_omezarr_output(zarr_path: Path) -> None:
|
|
|
116
116
|
converted_ome = converted.attrs["ome"]
|
|
117
117
|
if not isinstance(converted_ome, Mapping):
|
|
118
118
|
raise ValueError(f"Invalid converted OME-Zarr metadata: {path}")
|
|
119
|
-
|
|
119
|
+
merged_ome = {**ome, **converted_ome}
|
|
120
|
+
if "omero" in ome:
|
|
121
|
+
merged_ome["omero"] = ome["omero"]
|
|
122
|
+
converted.attrs.update({**attributes, "ome": merged_ome})
|
|
120
123
|
nz.from_ngff_zarr(path, validate=True, kind="multiscales")
|
|
121
124
|
image_count += 1
|
|
122
125
|
if not image_count:
|
|
@@ -135,6 +138,14 @@ def finalize_omezarr_output(zarr_path: Path) -> None:
|
|
|
135
138
|
)
|
|
136
139
|
|
|
137
140
|
|
|
141
|
+
@dataclass(frozen=True)
|
|
142
|
+
class ExperimentChannelMetadata:
|
|
143
|
+
"""Display metadata for one active ZEN channel in subscription order."""
|
|
144
|
+
|
|
145
|
+
name: str | None = None
|
|
146
|
+
color: str | None = None
|
|
147
|
+
|
|
148
|
+
|
|
138
149
|
@dataclass
|
|
139
150
|
class ExperimentConfig:
|
|
140
151
|
"""Parsed experiment configuration."""
|
|
@@ -166,6 +177,7 @@ class ExperimentConfig:
|
|
|
166
177
|
spatial_shard_size_chunks: int | None = 2
|
|
167
178
|
max_pending_frames: int = 4096
|
|
168
179
|
pyramid_levels: int = 0
|
|
180
|
+
channel_metadata: tuple[ExperimentChannelMetadata, ...] = ()
|
|
169
181
|
|
|
170
182
|
|
|
171
183
|
def create_plugin_experiment_config(
|
|
@@ -224,7 +236,7 @@ def create_plugin_experiment_config(
|
|
|
224
236
|
|
|
225
237
|
@dataclass(frozen=True)
|
|
226
238
|
class ExperimentAcquisitionMetadata:
|
|
227
|
-
"""
|
|
239
|
+
"""Dimensions, positions, and active channels exported by ZEN."""
|
|
228
240
|
|
|
229
241
|
experiment_name: str
|
|
230
242
|
time_points: int
|
|
@@ -234,6 +246,7 @@ class ExperimentAcquisitionMetadata:
|
|
|
234
246
|
tiles: int
|
|
235
247
|
scenes: int
|
|
236
248
|
positions: tuple[dict[str, object], ...] = ()
|
|
249
|
+
channel_metadata: tuple[ExperimentChannelMetadata, ...] = ()
|
|
237
250
|
|
|
238
251
|
|
|
239
252
|
def _xml_is_active(element: ET.Element | None, default: bool = True) -> bool:
|
|
@@ -469,11 +482,38 @@ def _parse_xml_tile_layout(block: ET.Element) -> tuple[int, int]:
|
|
|
469
482
|
return max(tile_counts), len(tile_counts)
|
|
470
483
|
|
|
471
484
|
|
|
485
|
+
def _extract_xml_channels(
|
|
486
|
+
block: ET.Element,
|
|
487
|
+
) -> tuple[ExperimentChannelMetadata, ...]:
|
|
488
|
+
"""Read active track/channel names and ZEN ARGB colors in stream order."""
|
|
489
|
+
channels = []
|
|
490
|
+
for track in block.findall(".//MultiTrackSetup/Track"):
|
|
491
|
+
if not _xml_is_active(track):
|
|
492
|
+
continue
|
|
493
|
+
for channel in track.findall("./Channels/Channel"):
|
|
494
|
+
if not _xml_is_active(channel):
|
|
495
|
+
continue
|
|
496
|
+
name = channel.get("Name") or None
|
|
497
|
+
value = _xml_text(channel, "Color")
|
|
498
|
+
color = None
|
|
499
|
+
if value is not None and re.fullmatch(r"#[0-9A-Fa-f]{8}", value):
|
|
500
|
+
color = value[3:].upper()
|
|
501
|
+
else:
|
|
502
|
+
logger.warning(
|
|
503
|
+
"Active channel %s has missing or invalid ZEN ARGB "
|
|
504
|
+
"Color %r; OME-Zarr display will use neutral grayscale.",
|
|
505
|
+
name or len(channels),
|
|
506
|
+
value,
|
|
507
|
+
)
|
|
508
|
+
channels.append(ExperimentChannelMetadata(name, color))
|
|
509
|
+
return tuple(channels)
|
|
510
|
+
|
|
511
|
+
|
|
472
512
|
def parse_experiment_xml(
|
|
473
513
|
xml: str,
|
|
474
514
|
experiment_name: str = "<experiment-export>",
|
|
475
515
|
) -> ExperimentAcquisitionMetadata:
|
|
476
|
-
"""Parse acquisition
|
|
516
|
+
"""Parse acquisition and channel metadata from ZEN ``.czexp`` XML."""
|
|
477
517
|
root = ET.fromstring(xml)
|
|
478
518
|
blocks = root.findall("./ExperimentBlocks/AcquisitionBlock")
|
|
479
519
|
active_blocks = [block for block in blocks if _xml_is_active(block)]
|
|
@@ -486,13 +526,7 @@ def parse_experiment_xml(
|
|
|
486
526
|
time_setup = _find_active_dimension_setup(block, "TimeSeriesSetup")
|
|
487
527
|
time_points = max(1, _xml_int(time_setup, "Duration/Cycles"))
|
|
488
528
|
|
|
489
|
-
|
|
490
|
-
1
|
|
491
|
-
for track in block.findall(".//MultiTrackSetup/Track")
|
|
492
|
-
if _xml_is_active(track)
|
|
493
|
-
for channel in track.findall("./Channels/Channel")
|
|
494
|
-
if _xml_is_active(channel)
|
|
495
|
-
)
|
|
529
|
+
channel_metadata = _extract_xml_channels(block)
|
|
496
530
|
|
|
497
531
|
z_setup = _find_active_dimension_setup(block, "ZStackSetup")
|
|
498
532
|
first = _xml_float(z_setup, "First/Distance/Value")
|
|
@@ -511,15 +545,71 @@ def parse_experiment_xml(
|
|
|
511
545
|
return ExperimentAcquisitionMetadata(
|
|
512
546
|
experiment_name=experiment_name,
|
|
513
547
|
time_points=time_points,
|
|
514
|
-
channels=max(1,
|
|
548
|
+
channels=max(1, len(channel_metadata)),
|
|
515
549
|
z_planes=z_planes,
|
|
516
550
|
z_spacing=z_spacing,
|
|
517
551
|
tiles=tiles,
|
|
518
552
|
scenes=scenes,
|
|
519
553
|
positions=positions,
|
|
554
|
+
channel_metadata=channel_metadata,
|
|
520
555
|
)
|
|
521
556
|
|
|
522
557
|
|
|
558
|
+
def write_omezarr_channel_metadata(
|
|
559
|
+
zarr_path: Path,
|
|
560
|
+
channels: tuple[ExperimentChannelMetadata, ...],
|
|
561
|
+
source_channels: list[int],
|
|
562
|
+
) -> None:
|
|
563
|
+
"""Persist OMERO display settings on every final and retained image.
|
|
564
|
+
|
|
565
|
+
Source indices are the explicit subscriptions, not XML channel IDs or
|
|
566
|
+
frame C values. Only array metadata is read; intensities are unchanged.
|
|
567
|
+
"""
|
|
568
|
+
import numpy as np
|
|
569
|
+
import zarr
|
|
570
|
+
|
|
571
|
+
if not channels:
|
|
572
|
+
return
|
|
573
|
+
if any(index < 0 or index >= len(channels) for index in source_channels):
|
|
574
|
+
raise ValueError("Selected stream channel has no experiment metadata")
|
|
575
|
+
selected = [channels[index] for index in source_channels]
|
|
576
|
+
for path, group in _omezarr_groups(zarr_path):
|
|
577
|
+
attributes: dict[str, Any] = dict(group.attrs)
|
|
578
|
+
ome = attributes.get("ome", {})
|
|
579
|
+
if not isinstance(ome, Mapping) or not ome.get("multiscales"):
|
|
580
|
+
continue
|
|
581
|
+
dataset = ome["multiscales"][0]["datasets"][0]["path"]
|
|
582
|
+
array = group[dataset]
|
|
583
|
+
if not isinstance(array, zarr.Array):
|
|
584
|
+
raise ValueError(f"Image dataset is not an array: {path}")
|
|
585
|
+
limits = np.iinfo(array.dtype)
|
|
586
|
+
display_channels = []
|
|
587
|
+
for source_index, channel in zip(
|
|
588
|
+
source_channels, selected, strict=True
|
|
589
|
+
):
|
|
590
|
+
display_channels.append(
|
|
591
|
+
{
|
|
592
|
+
"label": channel.name or f"channel_{source_index}",
|
|
593
|
+
"color": channel.color or "FFFFFF",
|
|
594
|
+
"active": True,
|
|
595
|
+
"window": {
|
|
596
|
+
"min": int(limits.min),
|
|
597
|
+
"max": int(limits.max),
|
|
598
|
+
"start": int(limits.min),
|
|
599
|
+
"end": int(limits.max),
|
|
600
|
+
},
|
|
601
|
+
}
|
|
602
|
+
)
|
|
603
|
+
writable = zarr.open_group(path, mode="a", use_consolidated=False)
|
|
604
|
+
writable.attrs["ome"] = {
|
|
605
|
+
**ome,
|
|
606
|
+
"omero": {
|
|
607
|
+
"channels": display_channels,
|
|
608
|
+
"rdefs": {"model": "color"},
|
|
609
|
+
},
|
|
610
|
+
}
|
|
611
|
+
|
|
612
|
+
|
|
523
613
|
def parse_experiment_file(
|
|
524
614
|
path: str | Path,
|
|
525
615
|
) -> ExperimentAcquisitionMetadata:
|
|
@@ -101,6 +101,7 @@ from napari_zen_streaming.ZEN_omezarr import (
|
|
|
101
101
|
open_in_ndv_viewer,
|
|
102
102
|
start_experiment,
|
|
103
103
|
validate_omezarr_version,
|
|
104
|
+
write_omezarr_channel_metadata,
|
|
104
105
|
)
|
|
105
106
|
from napari_zen_streaming.ZEN_utils import (
|
|
106
107
|
_decode_grayscale_frame,
|
|
@@ -695,6 +696,11 @@ def generate_omezarr_pyramids(
|
|
|
695
696
|
f"{len(image_paths)} image(s) ..."
|
|
696
697
|
)
|
|
697
698
|
for image_index, image_path in enumerate(image_paths, start=1):
|
|
699
|
+
image_group = zarr.open_group(
|
|
700
|
+
image_path, mode="a", use_consolidated=False
|
|
701
|
+
)
|
|
702
|
+
image_attributes: dict[str, Any] = dict(image_group.attrs)
|
|
703
|
+
omero = image_attributes.get("ome", {}).get("omero")
|
|
698
704
|
existing = nz.from_ngff_zarr(image_path, validate=True)
|
|
699
705
|
base_image = existing.images[0]
|
|
700
706
|
if not {"y", "x"}.issubset(base_image.dims):
|
|
@@ -733,6 +739,17 @@ def generate_omezarr_pyramids(
|
|
|
733
739
|
start_level=1,
|
|
734
740
|
chunks_per_shard=chunks_per_shard,
|
|
735
741
|
)
|
|
742
|
+
# to_multiscales creates fresh metadata; retain the exact display
|
|
743
|
+
# settings, including fields outside ngff-zarr's OMERO dataclasses.
|
|
744
|
+
if omero is not None:
|
|
745
|
+
image_group = zarr.open_group(
|
|
746
|
+
image_path, mode="a", use_consolidated=False
|
|
747
|
+
)
|
|
748
|
+
image_attributes = dict(image_group.attrs)
|
|
749
|
+
image_group.attrs["ome"] = {
|
|
750
|
+
**image_attributes["ome"],
|
|
751
|
+
"omero": omero,
|
|
752
|
+
}
|
|
736
753
|
logger.info(
|
|
737
754
|
f"Pyramid image {image_index}/{len(image_paths)} complete: "
|
|
738
755
|
f"{image_path}"
|
|
@@ -2020,6 +2037,9 @@ async def _stream_to_omezarr_with_config_connected(
|
|
|
2020
2037
|
)
|
|
2021
2038
|
|
|
2022
2039
|
finalize_omezarr_output(zarr_path)
|
|
2040
|
+
write_omezarr_channel_metadata(
|
|
2041
|
+
zarr_path, ecfg.channel_metadata, source_channels
|
|
2042
|
+
)
|
|
2023
2043
|
missing_coordinates = [
|
|
2024
2044
|
coordinate
|
|
2025
2045
|
for coordinate, index in coord_to_linear.items()
|
|
@@ -2189,6 +2209,7 @@ async def _run_configured_experiment(
|
|
|
2189
2209
|
ecfg.tiles = acquisition.tiles
|
|
2190
2210
|
ecfg.scenes = acquisition.scenes
|
|
2191
2211
|
ecfg.positions = list(acquisition.positions)
|
|
2212
|
+
ecfg.channel_metadata = acquisition.channel_metadata
|
|
2192
2213
|
return await stream_to_omezarr_with_config(
|
|
2193
2214
|
ecfg, inactivity_timeout=inactivity_timeout
|
|
2194
2215
|
)
|
|
@@ -8,11 +8,78 @@ import pytest
|
|
|
8
8
|
|
|
9
9
|
from napari_zen_streaming import ZEN_stream2omezarr as streamer
|
|
10
10
|
from napari_zen_streaming.ZEN_omezarr import (
|
|
11
|
+
ExperimentChannelMetadata,
|
|
12
|
+
load_experiment_acquisition,
|
|
11
13
|
load_experiment_config,
|
|
12
14
|
parse_experiment_xml,
|
|
13
15
|
)
|
|
14
16
|
|
|
15
17
|
|
|
18
|
+
def test_exported_active_channel_names_and_colors(caplog) -> None:
|
|
19
|
+
"""Track/channel filtering keeps exact ZEN names and ARGB-derived RGB."""
|
|
20
|
+
xml = """
|
|
21
|
+
<Experiment><ExperimentBlocks>
|
|
22
|
+
<AcquisitionBlock IsActivated="false">
|
|
23
|
+
<MultiTrackSetup><Track><Channels>
|
|
24
|
+
<Channel Name="Other"><Color>#FFFFFFFF</Color></Channel>
|
|
25
|
+
</Channels></Track></MultiTrackSetup>
|
|
26
|
+
</AcquisitionBlock>
|
|
27
|
+
<AcquisitionBlock IsActivated="true"><MultiTrackSetup>
|
|
28
|
+
<Track IsActivated="true"><Channels>
|
|
29
|
+
<Channel Name="AF568"><Color>#FFFF1800</Color></Channel>
|
|
30
|
+
<Channel Name="DAPI" IsActivated="false">
|
|
31
|
+
<Color>#FF00A1FF</Color>
|
|
32
|
+
</Channel>
|
|
33
|
+
</Channels></Track>
|
|
34
|
+
<Track IsActivated="false"><Channels>
|
|
35
|
+
<Channel Name="Inactive"><Color>#FFFFFFFF</Color></Channel>
|
|
36
|
+
</Channels></Track>
|
|
37
|
+
<Track><Channels>
|
|
38
|
+
<Channel Name="AF488"><Color>#ff00ff33</Color></Channel>
|
|
39
|
+
</Channels></Track>
|
|
40
|
+
</MultiTrackSetup></AcquisitionBlock>
|
|
41
|
+
</ExperimentBlocks></Experiment>
|
|
42
|
+
"""
|
|
43
|
+
|
|
44
|
+
class Service:
|
|
45
|
+
async def load(self, request):
|
|
46
|
+
assert request.experiment_name == "Selected experiment"
|
|
47
|
+
return SimpleNamespace(experiment_id="selected-id")
|
|
48
|
+
|
|
49
|
+
async def export(self, request):
|
|
50
|
+
assert request.experiment_id == "selected-id"
|
|
51
|
+
return SimpleNamespace(xml=xml)
|
|
52
|
+
|
|
53
|
+
metadata = asyncio.run(
|
|
54
|
+
load_experiment_acquisition(Service(), "Selected experiment")
|
|
55
|
+
)
|
|
56
|
+
|
|
57
|
+
assert metadata.channels == 2
|
|
58
|
+
assert metadata.channel_metadata == (
|
|
59
|
+
ExperimentChannelMetadata("AF568", "FF1800"),
|
|
60
|
+
ExperimentChannelMetadata("AF488", "00FF33"),
|
|
61
|
+
)
|
|
62
|
+
assert not caplog.records
|
|
63
|
+
|
|
64
|
+
|
|
65
|
+
@pytest.mark.parametrize("color", ["", "<Color>invalid</Color>"])
|
|
66
|
+
def test_missing_channel_color_does_not_invent_biological_color(
|
|
67
|
+
color: str, caplog
|
|
68
|
+
) -> None:
|
|
69
|
+
"""Missing/invalid colors retain names and explicitly warn of grayscale."""
|
|
70
|
+
xml = f"""
|
|
71
|
+
<Experiment><ExperimentBlocks><AcquisitionBlock><MultiTrackSetup>
|
|
72
|
+
<Track><Channels><Channel Name="Unknown">{color}</Channel></Channels>
|
|
73
|
+
</Track>
|
|
74
|
+
</MultiTrackSetup></AcquisitionBlock></ExperimentBlocks></Experiment>
|
|
75
|
+
"""
|
|
76
|
+
metadata = parse_experiment_xml(xml)
|
|
77
|
+
assert metadata.channel_metadata == (
|
|
78
|
+
ExperimentChannelMetadata("Unknown", None),
|
|
79
|
+
)
|
|
80
|
+
assert "neutral grayscale" in caplog.text
|
|
81
|
+
|
|
82
|
+
|
|
16
83
|
def test_tile_regions_map_to_scenes_and_per_scene_tiles() -> None:
|
|
17
84
|
"""Two active 3 by 2 regions describe two scenes of six tiles."""
|
|
18
85
|
xml = """
|
|
@@ -180,6 +247,11 @@ def test_configured_cli_exports_dimensions_before_streaming(
|
|
|
180
247
|
tiles=2,
|
|
181
248
|
scenes=2,
|
|
182
249
|
positions=positions,
|
|
250
|
+
channel_metadata=(
|
|
251
|
+
ExperimentChannelMetadata("AF568", "FF1800"),
|
|
252
|
+
ExperimentChannelMetadata("AF488", "00FF33"),
|
|
253
|
+
ExperimentChannelMetadata("DAPI", "00A1FF"),
|
|
254
|
+
),
|
|
183
255
|
)
|
|
184
256
|
monkeypatch.setattr(
|
|
185
257
|
streamer, "initialize_zenapi", lambda path: (Channel(), object())
|
|
@@ -206,6 +278,7 @@ def test_configured_cli_exports_dimensions_before_streaming(
|
|
|
206
278
|
) == (2, 3, 4, 2, 2)
|
|
207
279
|
assert ecfg.z_spacing == 0.5
|
|
208
280
|
assert ecfg.positions == list(positions)
|
|
281
|
+
assert ecfg.channel_metadata == acquisition.channel_metadata
|
|
209
282
|
assert closed == [True]
|
|
210
283
|
return tmp_path / "output.ome.zarr"
|
|
211
284
|
|
|
@@ -9,7 +9,10 @@ import pytest
|
|
|
9
9
|
|
|
10
10
|
from napari_zen_streaming import ZEN_stream2omezarr, _widget, main
|
|
11
11
|
from napari_zen_streaming.ZEN_config import ZENConfig
|
|
12
|
-
from napari_zen_streaming.ZEN_omezarr import
|
|
12
|
+
from napari_zen_streaming.ZEN_omezarr import (
|
|
13
|
+
ExperimentChannelMetadata,
|
|
14
|
+
create_plugin_experiment_config,
|
|
15
|
+
)
|
|
13
16
|
from napari_zen_streaming.ZEN_ui import StreamingViewer
|
|
14
17
|
|
|
15
18
|
|
|
@@ -324,6 +327,10 @@ def test_start_refreshes_selected_experiment_before_acquisition(
|
|
|
324
327
|
tiles=1,
|
|
325
328
|
scenes=1,
|
|
326
329
|
positions=[],
|
|
330
|
+
channel_metadata=tuple(
|
|
331
|
+
ExperimentChannelMetadata(f"ZEN channel {index}", "00FF33")
|
|
332
|
+
for index in range(5)
|
|
333
|
+
),
|
|
327
334
|
)
|
|
328
335
|
events: list[str] = []
|
|
329
336
|
|
|
@@ -381,6 +388,10 @@ def test_start_refreshes_selected_experiment_before_acquisition(
|
|
|
381
388
|
if mode == 2:
|
|
382
389
|
assert writer.await_args.args[0].channels == 5
|
|
383
390
|
assert writer.await_args.args[0].time_points == 3
|
|
391
|
+
assert (
|
|
392
|
+
writer.await_args.args[0].channel_metadata
|
|
393
|
+
== fresh.channel_metadata
|
|
394
|
+
)
|
|
384
395
|
assert callable(writer.await_args.kwargs["on_experiment_started"])
|
|
385
396
|
assert viewer.current_experiment_id is None
|
|
386
397
|
|
|
@@ -9,14 +9,73 @@ import pytest
|
|
|
9
9
|
import zarr
|
|
10
10
|
|
|
11
11
|
from napari_zen_streaming.ZEN_omezarr import (
|
|
12
|
+
ExperimentChannelMetadata,
|
|
12
13
|
open_in_napari_viewer,
|
|
13
14
|
read_omezarr_axis_names,
|
|
14
15
|
read_omezarr_axis_scales,
|
|
16
|
+
write_omezarr_channel_metadata,
|
|
15
17
|
)
|
|
18
|
+
from napari_zen_streaming.ZEN_stream2omezarr import generate_omezarr_pyramids
|
|
16
19
|
|
|
17
20
|
reader = pytest.importorskip("napari_ome_zarr.ome_zarr_reader")
|
|
18
21
|
|
|
19
22
|
|
|
23
|
+
@pytest.mark.parametrize("source_channels", [[0, 1], [1]])
|
|
24
|
+
@pytest.mark.parametrize("missing_color", [False, True])
|
|
25
|
+
def test_reader_uses_persisted_channel_colors_after_pyramids(
|
|
26
|
+
tmp_path: Path, source_channels: list[int], missing_color: bool
|
|
27
|
+
) -> None:
|
|
28
|
+
"""The real napari reader gets names/colors without viewer overrides."""
|
|
29
|
+
from napari.utils.colormaps import ensure_colormap
|
|
30
|
+
|
|
31
|
+
channels = (
|
|
32
|
+
ExperimentChannelMetadata("AF568", "FF1800"),
|
|
33
|
+
ExperimentChannelMetadata(
|
|
34
|
+
"AF488", None if missing_color else "00FF33"
|
|
35
|
+
),
|
|
36
|
+
)
|
|
37
|
+
shape = (2, 8, 8) if len(source_channels) == 2 else (8, 8)
|
|
38
|
+
dims = ("c", "y", "x") if len(source_channels) == 2 else ("y", "x")
|
|
39
|
+
image = nz.to_ngff_image(
|
|
40
|
+
np.full(shape, 3100, dtype=np.uint16),
|
|
41
|
+
dims=dims,
|
|
42
|
+
name="scene",
|
|
43
|
+
)
|
|
44
|
+
path = tmp_path / "colored.ome.zarr"
|
|
45
|
+
multiscales = nz.to_multiscales(image, scale_factors=[])
|
|
46
|
+
dataset = multiscales.metadata.datasets[0]
|
|
47
|
+
dataset.path = "0"
|
|
48
|
+
for transform in dataset.coordinateTransformations:
|
|
49
|
+
if transform.input is not None:
|
|
50
|
+
transform.input.path = "0"
|
|
51
|
+
nz.to_ome_zarr(
|
|
52
|
+
path,
|
|
53
|
+
multiscales,
|
|
54
|
+
version="0.6",
|
|
55
|
+
)
|
|
56
|
+
write_omezarr_channel_metadata(path, channels, source_channels)
|
|
57
|
+
original_omero = zarr.open_group(path).attrs["ome"]["omero"]
|
|
58
|
+
|
|
59
|
+
generate_omezarr_pyramids(path, 1, None)
|
|
60
|
+
|
|
61
|
+
assert zarr.open_group(path).attrs["ome"]["omero"] == original_omero
|
|
62
|
+
layer_data = reader.read_ome_zarr(zarr.open_group(path, mode="r"))()
|
|
63
|
+
assert len(layer_data) == len(source_channels)
|
|
64
|
+
for (pyramid, props, kind), source_index in zip(
|
|
65
|
+
layer_data, source_channels, strict=True
|
|
66
|
+
):
|
|
67
|
+
channel = channels[source_index]
|
|
68
|
+
assert kind == "image"
|
|
69
|
+
assert [array.shape for array in pyramid] == [(8, 8), (4, 4)]
|
|
70
|
+
assert props["name"].endswith(channel.name)
|
|
71
|
+
color = channel.color or "FFFFFF"
|
|
72
|
+
expected = [int(color[i : i + 2], 16) / 255 for i in (0, 2, 4)]
|
|
73
|
+
colormap = ensure_colormap(props["colormap"])
|
|
74
|
+
np.testing.assert_allclose(colormap.map([1.0])[0, :3], expected)
|
|
75
|
+
assert props["contrast_limits"] == [0, 65535]
|
|
76
|
+
assert props["visible"]
|
|
77
|
+
|
|
78
|
+
|
|
20
79
|
def _create_image(root_path: Path, name: str) -> None:
|
|
21
80
|
"""Create a small two-channel pyramid with physical axis metadata."""
|
|
22
81
|
image = nz.to_ngff_image(
|
|
@@ -22,6 +22,7 @@ from napari_zen_streaming._scene_geometry import (
|
|
|
22
22
|
from napari_zen_streaming.ZEN_omezarr import (
|
|
23
23
|
ExperimentConfig,
|
|
24
24
|
finalize_omezarr_output,
|
|
25
|
+
parse_experiment_xml,
|
|
25
26
|
)
|
|
26
27
|
from napari_zen_streaming.ZEN_stream2omezarr import (
|
|
27
28
|
_assemble_scene_mosaics,
|
|
@@ -80,6 +81,123 @@ def test_well_layout_can_be_written_as_hcs() -> None:
|
|
|
80
81
|
assert len(positions) == 2
|
|
81
82
|
|
|
82
83
|
|
|
84
|
+
@pytest.mark.parametrize("hcs", [False, True])
|
|
85
|
+
@pytest.mark.parametrize("channel_index", [None, 1])
|
|
86
|
+
def test_configured_stream_writes_channel_display_metadata(
|
|
87
|
+
tmp_path: Path, monkeypatch, hcs: bool, channel_index: int | None
|
|
88
|
+
) -> None:
|
|
89
|
+
"""Real writer retains XML channel order for scenes, HCS, and subsets."""
|
|
90
|
+
xml = """
|
|
91
|
+
<Experiment><ExperimentBlocks><AcquisitionBlock><MultiTrackSetup>
|
|
92
|
+
<Track><Channels>
|
|
93
|
+
<Channel Name="AF568"><Color>#FFFF1800</Color></Channel>
|
|
94
|
+
<Channel IsActivated="false" Name="DAPI">
|
|
95
|
+
<Color>#FF00A1FF</Color>
|
|
96
|
+
</Channel>
|
|
97
|
+
<Channel Name="AF488"><Color>#FF00FF33</Color></Channel>
|
|
98
|
+
</Channels></Track>
|
|
99
|
+
</MultiTrackSetup></AcquisitionBlock></ExperimentBlocks></Experiment>
|
|
100
|
+
"""
|
|
101
|
+
acquisition = parse_experiment_xml(xml)
|
|
102
|
+
config = _experiment_config(use_hcs_layout=hcs)
|
|
103
|
+
config.output_dir = str(tmp_path)
|
|
104
|
+
config.channels = acquisition.channels
|
|
105
|
+
config.channel_metadata = acquisition.channel_metadata
|
|
106
|
+
config.channel_index = channel_index
|
|
107
|
+
config.keep_source_tiles = not hcs
|
|
108
|
+
config.pyramid_levels = 1
|
|
109
|
+
# GRAY8 must set display limits from the stream, not this fallback.
|
|
110
|
+
config.dtype = "uint16"
|
|
111
|
+
|
|
112
|
+
class Channel:
|
|
113
|
+
def close(self):
|
|
114
|
+
pass
|
|
115
|
+
|
|
116
|
+
class ExperimentService:
|
|
117
|
+
async def get_status(self, _request):
|
|
118
|
+
raise GRPCError(
|
|
119
|
+
Status.FAILED_PRECONDITION, "No experiment is running"
|
|
120
|
+
)
|
|
121
|
+
|
|
122
|
+
class StreamingService:
|
|
123
|
+
def monitor_all_experiments(self, request):
|
|
124
|
+
async def responses():
|
|
125
|
+
for scene in range(2):
|
|
126
|
+
for tile in range(2):
|
|
127
|
+
yield SimpleNamespace(
|
|
128
|
+
frame_data=SimpleNamespace(
|
|
129
|
+
experiment_id="selected",
|
|
130
|
+
frame_position=SimpleNamespace(
|
|
131
|
+
t=0,
|
|
132
|
+
z=0,
|
|
133
|
+
m=tile,
|
|
134
|
+
s=scene,
|
|
135
|
+
c=99,
|
|
136
|
+
),
|
|
137
|
+
frame_size=SimpleNamespace(width=8, height=8),
|
|
138
|
+
pixel_data=SimpleNamespace(
|
|
139
|
+
pixel_type=PixelType.GRAY8,
|
|
140
|
+
raw_data=np.full(
|
|
141
|
+
(8, 8),
|
|
142
|
+
request.channel_index + 11,
|
|
143
|
+
dtype=np.uint8,
|
|
144
|
+
).tobytes(),
|
|
145
|
+
),
|
|
146
|
+
scaling=SimpleNamespace(x=1e-6, y=1e-6),
|
|
147
|
+
frame_stage_position=SimpleNamespace(
|
|
148
|
+
x=(3.5 + tile * 8) * 1e-6,
|
|
149
|
+
y=3.5e-6,
|
|
150
|
+
z=0.0,
|
|
151
|
+
),
|
|
152
|
+
)
|
|
153
|
+
)
|
|
154
|
+
|
|
155
|
+
return responses()
|
|
156
|
+
|
|
157
|
+
monkeypatch.setattr(
|
|
158
|
+
stream_module, "initialize_zenapi", lambda _: (Channel(), None)
|
|
159
|
+
)
|
|
160
|
+
monkeypatch.setattr(
|
|
161
|
+
stream_module,
|
|
162
|
+
"ExperimentServiceStub",
|
|
163
|
+
lambda **_: ExperimentService(),
|
|
164
|
+
)
|
|
165
|
+
monkeypatch.setattr(
|
|
166
|
+
stream_module,
|
|
167
|
+
"ExperimentStreamingServiceStub",
|
|
168
|
+
lambda **_: StreamingService(),
|
|
169
|
+
)
|
|
170
|
+
path = asyncio.run(
|
|
171
|
+
stream_module.stream_to_omezarr_with_config(
|
|
172
|
+
config, progress_callback=lambda *_: None
|
|
173
|
+
)
|
|
174
|
+
)
|
|
175
|
+
image_paths = stream_module._find_omezarr_image_paths(path)
|
|
176
|
+
assert len(image_paths) == (6 if not hcs else 2)
|
|
177
|
+
expected_channels = (
|
|
178
|
+
config.channel_metadata
|
|
179
|
+
if channel_index is None
|
|
180
|
+
else (config.channel_metadata[channel_index],)
|
|
181
|
+
)
|
|
182
|
+
for image_path in image_paths:
|
|
183
|
+
image = zarr.open_group(image_path, mode="r")
|
|
184
|
+
channels = image.attrs["ome"]["omero"]["channels"]
|
|
185
|
+
assert [(ch["label"], ch["color"]) for ch in channels] == [
|
|
186
|
+
(channel.name, channel.color) for channel in expected_channels
|
|
187
|
+
]
|
|
188
|
+
assert all(
|
|
189
|
+
ch["window"] == {"min": 0, "max": 255, "start": 0, "end": 255}
|
|
190
|
+
and ch["active"]
|
|
191
|
+
for ch in channels
|
|
192
|
+
)
|
|
193
|
+
assert len(image.attrs["ome"]["multiscales"][0]["datasets"]) == 2
|
|
194
|
+
pixels = image["0"][:]
|
|
195
|
+
assert pixels.dtype == np.uint8
|
|
196
|
+
assert set(np.unique(pixels)) == (
|
|
197
|
+
{11, 12} if channel_index is None else {12}
|
|
198
|
+
)
|
|
199
|
+
|
|
200
|
+
|
|
83
201
|
def test_output_directory_probe_cleans_up(tmp_path: Path) -> None:
|
|
84
202
|
"""A writable output folder is created and retains no probe files."""
|
|
85
203
|
output = tmp_path / "new-output"
|
|
@@ -661,6 +779,24 @@ def test_finalize_output_converts_schema_and_preserves_pixels(
|
|
|
661
779
|
if not hcs:
|
|
662
780
|
_create_raw_tile(root, 1, 120, path="raw_source")
|
|
663
781
|
root[image_name].attrs["zen_scene"] = {"source_tiles_retained": False}
|
|
782
|
+
omero = {
|
|
783
|
+
"channels": [
|
|
784
|
+
{
|
|
785
|
+
"label": "AF488",
|
|
786
|
+
"color": "00FF33",
|
|
787
|
+
"active": True,
|
|
788
|
+
"window": {
|
|
789
|
+
"min": 0,
|
|
790
|
+
"max": 65535,
|
|
791
|
+
"start": 120,
|
|
792
|
+
"end": 4200,
|
|
793
|
+
},
|
|
794
|
+
}
|
|
795
|
+
],
|
|
796
|
+
"rdefs": {"model": "color"},
|
|
797
|
+
}
|
|
798
|
+
image_ome = dict(root[image_name].attrs["ome"])
|
|
799
|
+
root[image_name].attrs["ome"] = {**image_ome, "omero": omero}
|
|
664
800
|
chunks = {
|
|
665
801
|
file.relative_to(path): file.read_bytes()
|
|
666
802
|
for file in path.rglob("*")
|
|
@@ -677,6 +813,7 @@ def test_finalize_output_converts_schema_and_preserves_pixels(
|
|
|
677
813
|
image_path = path / image_name
|
|
678
814
|
image = zarr.open_group(image_path, mode="r")
|
|
679
815
|
assert image.attrs["zen_scene"] == {"source_tiles_retained": False}
|
|
816
|
+
assert image.attrs["ome"]["omero"] == omero
|
|
680
817
|
multiscale = image.attrs["ome"]["multiscales"][0]
|
|
681
818
|
assert "coordinateSystems" in multiscale
|
|
682
819
|
assert "axes" not in multiscale
|
|
@@ -688,6 +825,7 @@ def test_finalize_output_converts_schema_and_preserves_pixels(
|
|
|
688
825
|
stream_module.generate_omezarr_pyramids(path, 1, None)
|
|
689
826
|
|
|
690
827
|
reopened = nz.from_ngff_zarr(image_path, validate=True, kind="multiscales")
|
|
828
|
+
assert zarr.open_group(image_path).attrs["ome"]["omero"] == omero
|
|
691
829
|
assert len(reopened.images) == 2
|
|
692
830
|
assert all(
|
|
693
831
|
level.data.dtype == np.dtype(np.uint16) for level in reopened.images
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: napari-zenapi-streaming
|
|
3
|
-
Version: 0.0.
|
|
3
|
+
Version: 0.0.4
|
|
4
4
|
Summary: ZEN API streaming plugin for napari
|
|
5
5
|
Author-email: "Krijn H. van der Steen" <k.h.vandersteen@umcutrecht.nl>, Sebastian Rhode <sebastian.rhode@zeiss.com>
|
|
6
6
|
License-Expression: BSD-3-Clause
|
|
@@ -94,21 +94,23 @@ When finished the resulting OME-ZARR, created from the ZEN pixel stream can be s
|
|
|
94
94
|
|
|
95
95
|
## Current status
|
|
96
96
|
|
|
97
|
-
- Release: **0.0.
|
|
97
|
+
- Release: **0.0.4** ([release notes](_release_notes/v0.0.4.md)).
|
|
98
98
|
- Project phase: alpha / MVP
|
|
99
99
|
- Primary OS target: Windows for ZEN Blue and the ZEN API Gateway
|
|
100
100
|
- Python target: `>=3.12, <3.15`
|
|
101
101
|
|
|
102
|
-
### What's new in 0.0.
|
|
102
|
+
### What's new in 0.0.4
|
|
103
103
|
|
|
104
|
-
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
-
|
|
108
|
-
|
|
109
|
-
-
|
|
110
|
-
|
|
111
|
-
|
|
104
|
+
- Configured OME-ZARR acquisition preserves active channel names and actual
|
|
105
|
+
display colors from the selected ZEN experiment.
|
|
106
|
+
- Per-image OMERO display metadata follows channel subscriptions and
|
|
107
|
+
single-channel selections across generic scenes, HCS wells, and retained
|
|
108
|
+
source tiles.
|
|
109
|
+
- Pyramid generation retains these settings so `napari-ome-zarr` opens new
|
|
110
|
+
output with the experiment's colors. Missing or invalid colors warn and
|
|
111
|
+
use neutral grayscale rather than guessing a biological color.
|
|
112
|
+
- See the [0.0.3 release notes](_release_notes/v0.0.3.md) for the preceding
|
|
113
|
+
stream-activation and shutdown fixes.
|
|
112
114
|
|
|
113
115
|
## Known limitations
|
|
114
116
|
|
|
@@ -253,17 +255,18 @@ without confirming redistribution rights.
|
|
|
253
255
|
For a published PyPI release:
|
|
254
256
|
|
|
255
257
|
```powershell
|
|
256
|
-
python -m pip install "napari-zenapi-streaming==0.0.
|
|
258
|
+
python -m pip install "napari-zenapi-streaming==0.0.4" "napari[pyqt6]" "PyQt6>=6.7,<6.10"
|
|
257
259
|
```
|
|
258
260
|
|
|
259
261
|
To upgrade an existing environment with compatible ZEN wheels installed:
|
|
260
262
|
|
|
261
263
|
```powershell
|
|
262
|
-
python -m pip install --upgrade "napari-zenapi-streaming==0.0.
|
|
264
|
+
python -m pip install --upgrade "napari-zenapi-streaming==0.0.4"
|
|
263
265
|
```
|
|
264
266
|
|
|
265
|
-
Restart napari after upgrading. Version 0.0.
|
|
266
|
-
automatically migrate older stores
|
|
267
|
+
Restart napari after upgrading. Version 0.0.4 writes OME-Zarr 0.6 and does not
|
|
268
|
+
automatically migrate older stores or add channel colors to existing output.
|
|
269
|
+
Use a reader that supports 0.6 and OMERO channel display metadata.
|
|
267
270
|
|
|
268
271
|
From this checkout, install the plugin:
|
|
269
272
|
|
|
@@ -637,6 +640,17 @@ and **Create pyramid after acquisition** in its UI. When enabled, choose how
|
|
|
637
640
|
many 2x Y/X downsampled levels to append after acquisition completes. Napari
|
|
638
641
|
opens the OME-Zarr only after pyramid generation finishes. Existing level `0`
|
|
639
642
|
is reused and is never rewritten.
|
|
643
|
+
Active channel names and display colors come from the selected experiment's
|
|
644
|
+
exported XML, in the same order as the channel subscriptions. ZEN's
|
|
645
|
+
`#AARRGGBB` colors are saved as OMERO `RRGGBB` colors on every image
|
|
646
|
+
(including HCS wells and retained source tiles), with display limits from
|
|
647
|
+
the runtime pixel type. Selecting a single channel retains that source
|
|
648
|
+
channel's name and color. Pyramid generation preserves these settings, so
|
|
649
|
+
`napari-ome-zarr` automatically opens the images with their ZEN colors.
|
|
650
|
+
Missing or invalid XML colors produce a warning and use neutral grayscale,
|
|
651
|
+
not an inferred fluorophore color. Direct writer configurations without
|
|
652
|
+
channel metadata keep the previous reader-default behavior.
|
|
653
|
+
|
|
640
654
|
Generic scene mosaics also expose **Keep individual source tiles**; unchecked
|
|
641
655
|
removes source groups only after mosaic creation succeeds. Advanced values
|
|
642
656
|
intentionally use fixed defaults declared at the top of `ZEN_omezarr.py`:
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{napari_zenapi_streaming-0.0.3 → napari_zenapi_streaming-0.0.4}/src/napari_zen_streaming/ZEN_init.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
{napari_zenapi_streaming-0.0.3 → napari_zenapi_streaming-0.0.4}/src/napari_zen_streaming/_logging.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{napari_zenapi_streaming-0.0.3 → napari_zenapi_streaming-0.0.4}/src/napari_zen_streaming/_widget.py
RENAMED
|
File without changes
|
{napari_zenapi_streaming-0.0.3 → napari_zenapi_streaming-0.0.4}/src/napari_zen_streaming/main.py
RENAMED
|
File without changes
|
{napari_zenapi_streaming-0.0.3 → napari_zenapi_streaming-0.0.4}/src/napari_zen_streaming/misc.py
RENAMED
|
File without changes
|
{napari_zenapi_streaming-0.0.3 → napari_zenapi_streaming-0.0.4}/src/napari_zen_streaming/napari.yaml
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|