Skip to content

Commit 611819e

Browse files
authored
Upgrade ome-zarr package (#315)
* Upgrade ome-zarr package * Sphinx fixes * Pin pulp version for snakemake * Fix test * Lint
1 parent 8934187 commit 611819e

File tree

4 files changed

+78
-63
lines changed

4 files changed

+78
-63
lines changed

.github/workflows/test_demos.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ jobs:
1111
with:
1212
python-version: '3.9'
1313
- run: |
14+
pip install "pulp==2.7.0"
1415
pip install snakemake
1516
pip install pyyaml
1617
- name: Install vitessce

pyproject.toml

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ dependencies = [
3434
'numpy>=1.21.2',
3535
'anndata>=0.7.8,<0.9',
3636
'scanpy>=1.9.3',
37-
'ome-zarr==0.2.1',
37+
'ome-zarr==0.8.3',
3838
'tifffile>=2020.10.1',
3939
'jsonschema>=3.2'
4040
]
@@ -50,6 +50,16 @@ dev = [
5050
docs = [
5151
'sphinx==4.2.0',
5252
'sphinx-rtd-theme==1.0.0',
53+
54+
# Pin sub-dependencies of sphinx
55+
# Reference: https://github.com/sphinx-doc/sphinx/issues/11130
56+
'sphinxcontrib-applehelp==1.0.4',
57+
'sphinxcontrib-devhelp==1.0.2',
58+
'sphinxcontrib-htmlhelp==2.0.1',
59+
'sphinxcontrib-jsmath==1.0.1',
60+
'sphinxcontrib-qthelp==1.0.3',
61+
'sphinxcontrib-serializinghtml==1.1.5',
62+
5363
'nbsphinx==0.8.8',
5464
'nbclean==0.3.2',
5565
# Pin sqlalchemy to before 1.4 to fix issue importing nbclean.NotebookCleaner

tests/test_ome_utils.py

Lines changed: 26 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -50,41 +50,44 @@ def setUp(self):
5050
def test_rgb_img_to_ome_zarr(self):
5151
img_arr = self.img_arr
5252
out_path = data_path / "rgb_out.ome.zarr"
53-
rgb_img_to_ome_zarr(img_arr, out_path, img_name="Test", axes="cyx", chunks=(1, 3, 3))
53+
rgb_img_to_ome_zarr(img_arr, out_path, img_name="Test", axes="cyx", chunks=(1, 3, 3), scaler=None)
5454

5555
z_root = zarr.open(out_path, mode="r")
5656

5757
assert dict(z_root.attrs) == {
5858
'multiscales': [
5959
{
60-
'axes': ['c', 'y', 'x'],
60+
'axes': [
61+
{'name': 'c', 'type': 'channel'},
62+
{'name': 'y', 'type': 'space'},
63+
{'name': 'x', 'type': 'space'}
64+
],
6165
'datasets': [
62-
{'path': '0'},
63-
{'path': '1'},
64-
{'path': '2'},
65-
{'path': '3'},
66-
{'path': '4'}
66+
{
67+
'coordinateTransformations': [
68+
{'scale': [1.0, 1.0, 1.0], 'type': 'scale'}
69+
],
70+
'path': '0'
71+
}
6772
],
68-
'version': '0.3'
73+
'name': '/',
74+
'version': '0.4'
6975
}
7076
],
7177
'omero': {
7278
'channels': [
73-
{
74-
'color': 'FF0000',
75-
'label': 'R',
76-
'window': {'end': 255, 'max': 255, 'min': 0, 'start': 0}
77-
},
78-
{
79-
'color': '00FF00',
80-
'label': 'G',
81-
'window': {'end': 255, 'max': 255, 'min': 0, 'start': 0}
82-
},
83-
{
84-
'color': '0000FF',
85-
'label': 'B',
86-
'window': {'end': 255, 'max': 255, 'min': 0, 'start': 0}
87-
}
79+
{'color': 'FF0000',
80+
'label': 'R',
81+
'window': {'end': 255, 'max': 255, 'min': 0, 'start': 0}
82+
},
83+
{'color': '00FF00',
84+
'label': 'G',
85+
'window': {'end': 255, 'max': 255, 'min': 0, 'start': 0}
86+
},
87+
{'color': '0000FF',
88+
'label': 'B',
89+
'window': {'end': 255, 'max': 255, 'min': 0, 'start': 0}
90+
}
8891
],
8992
'name': 'Test',
9093
'rdefs': {},

vitessce/data_utils/ome.py

Lines changed: 40 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ def multiplex_img_to_ome_tiff(img_arr, channel_names, output_path, axes="CYX"):
4949
tiff_writer.close()
5050

5151

52-
def rgb_img_to_ome_zarr(img_arr, output_path, img_name="Image", chunks=(1, 256, 256), axes="cyx"):
52+
def rgb_img_to_ome_zarr(img_arr, output_path, img_name="Image", chunks=(1, 256, 256), axes="cyx", **kwargs):
5353
"""
5454
Convert an RGB image to OME-Zarr v0.3.
5555
@@ -75,30 +75,31 @@ def rgb_img_to_ome_zarr(img_arr, output_path, img_name="Image", chunks=(1, 256,
7575
image=img_arr,
7676
group=z_root,
7777
axes=axes,
78-
omero={
79-
"name": img_name,
80-
"version": "0.3",
81-
"rdefs": {},
82-
"channels": [
83-
{
84-
"label": "R",
85-
"color": "FF0000",
86-
"window": default_window
87-
},
88-
{
89-
"label": "G",
90-
"color": "00FF00",
91-
"window": default_window
92-
},
93-
{
94-
"label": "B",
95-
"color": "0000FF",
96-
"window": default_window
97-
}
98-
]
99-
},
100-
chunks=chunks
78+
storage_options=dict(chunks=chunks),
79+
**kwargs,
10180
)
81+
z_root.attrs["omero"] = {
82+
"name": img_name,
83+
"version": "0.3",
84+
"rdefs": {},
85+
"channels": [
86+
{
87+
"label": "R",
88+
"color": "FF0000",
89+
"window": default_window
90+
},
91+
{
92+
"label": "G",
93+
"color": "00FF00",
94+
"window": default_window
95+
},
96+
{
97+
"label": "B",
98+
"color": "0000FF",
99+
"window": default_window
100+
}
101+
]
102+
}
102103

103104

104105
def multiplex_img_to_ome_zarr(img_arr, channel_names, output_path, img_name="Image", chunks=(1, 256, 256), axes="cyx", channel_colors=None):
@@ -132,19 +133,19 @@ def multiplex_img_to_ome_zarr(img_arr, channel_names, output_path, img_name="Ima
132133
image=img_arr,
133134
group=z_root,
134135
axes=axes,
135-
omero={
136-
"name": img_name,
137-
"version": "0.3",
138-
"rdefs": {},
139-
"channels": [
140-
{
141-
"label": channel_name,
142-
"color": channel_colors[channel_name] if channel_colors is not None else "FFFFFF",
143-
"window": default_window
144-
}
145-
for channel_name
146-
in channel_names
147-
]
148-
},
149-
chunks=chunks
136+
storage_options=dict(chunks=chunks)
150137
)
138+
z_root.attrs["omero"] = {
139+
"name": img_name,
140+
"version": "0.3",
141+
"rdefs": {},
142+
"channels": [
143+
{
144+
"label": channel_name,
145+
"color": channel_colors[channel_name] if channel_colors is not None else "FFFFFF",
146+
"window": default_window
147+
}
148+
for channel_name
149+
in channel_names
150+
]
151+
}

0 commit comments

Comments
 (0)