Skip to content

Commit

Permalink
Merge branch 'main' of github.com:vitessce/vitessce-python into kelle…
Browse files Browse the repository at this point in the history
…r-mark/image-wrappers
  • Loading branch information
keller-mark committed Jan 24, 2024
2 parents 7c671c3 + 611819e commit 2ed3f5e
Show file tree
Hide file tree
Showing 4 changed files with 78 additions and 63 deletions.
1 change: 1 addition & 0 deletions .github/workflows/test_demos.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ jobs:
with:
python-version: '3.9'
- run: |
pip install "pulp==2.7.0"
pip install snakemake
pip install pyyaml
- name: Install vitessce
Expand Down
12 changes: 11 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ dependencies = [
'numpy>=1.21.2',
'anndata>=0.7.8,<0.9',
'scanpy>=1.9.3',
'ome-zarr==0.2.1',
'ome-zarr==0.8.3',
'tifffile>=2020.10.1',
'jsonschema>=3.2'
]
Expand All @@ -50,6 +50,16 @@ dev = [
docs = [
'sphinx==4.2.0',
'sphinx-rtd-theme==1.0.0',

# Pin sub-dependencies of sphinx
# Reference: https://github.com/sphinx-doc/sphinx/issues/11130
'sphinxcontrib-applehelp==1.0.4',
'sphinxcontrib-devhelp==1.0.2',
'sphinxcontrib-htmlhelp==2.0.1',
'sphinxcontrib-jsmath==1.0.1',
'sphinxcontrib-qthelp==1.0.3',
'sphinxcontrib-serializinghtml==1.1.5',

'nbsphinx==0.8.8',
'nbclean==0.3.2',
# Pin sqlalchemy to before 1.4 to fix issue importing nbclean.NotebookCleaner
Expand Down
49 changes: 26 additions & 23 deletions tests/test_ome_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,41 +50,44 @@ def setUp(self):
def test_rgb_img_to_ome_zarr(self):
img_arr = self.img_arr
out_path = data_path / "rgb_out.ome.zarr"
rgb_img_to_ome_zarr(img_arr, out_path, img_name="Test", axes="cyx", chunks=(1, 3, 3))
rgb_img_to_ome_zarr(img_arr, out_path, img_name="Test", axes="cyx", chunks=(1, 3, 3), scaler=None)

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

assert dict(z_root.attrs) == {
'multiscales': [
{
'axes': ['c', 'y', 'x'],
'axes': [
{'name': 'c', 'type': 'channel'},
{'name': 'y', 'type': 'space'},
{'name': 'x', 'type': 'space'}
],
'datasets': [
{'path': '0'},
{'path': '1'},
{'path': '2'},
{'path': '3'},
{'path': '4'}
{
'coordinateTransformations': [
{'scale': [1.0, 1.0, 1.0], 'type': 'scale'}
],
'path': '0'
}
],
'version': '0.3'
'name': '/',
'version': '0.4'
}
],
'omero': {
'channels': [
{
'color': 'FF0000',
'label': 'R',
'window': {'end': 255, 'max': 255, 'min': 0, 'start': 0}
},
{
'color': '00FF00',
'label': 'G',
'window': {'end': 255, 'max': 255, 'min': 0, 'start': 0}
},
{
'color': '0000FF',
'label': 'B',
'window': {'end': 255, 'max': 255, 'min': 0, 'start': 0}
}
{'color': 'FF0000',
'label': 'R',
'window': {'end': 255, 'max': 255, 'min': 0, 'start': 0}
},
{'color': '00FF00',
'label': 'G',
'window': {'end': 255, 'max': 255, 'min': 0, 'start': 0}
},
{'color': '0000FF',
'label': 'B',
'window': {'end': 255, 'max': 255, 'min': 0, 'start': 0}
}
],
'name': 'Test',
'rdefs': {},
Expand Down
79 changes: 40 additions & 39 deletions vitessce/data_utils/ome.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ def multiplex_img_to_ome_tiff(img_arr, channel_names, output_path, axes="CYX"):
tiff_writer.close()


def rgb_img_to_ome_zarr(img_arr, output_path, img_name="Image", chunks=(1, 256, 256), axes="cyx"):
def rgb_img_to_ome_zarr(img_arr, output_path, img_name="Image", chunks=(1, 256, 256), axes="cyx", **kwargs):
"""
Convert an RGB image to OME-Zarr v0.3.
Expand All @@ -75,30 +75,31 @@ def rgb_img_to_ome_zarr(img_arr, output_path, img_name="Image", chunks=(1, 256,
image=img_arr,
group=z_root,
axes=axes,
omero={
"name": img_name,
"version": "0.3",
"rdefs": {},
"channels": [
{
"label": "R",
"color": "FF0000",
"window": default_window
},
{
"label": "G",
"color": "00FF00",
"window": default_window
},
{
"label": "B",
"color": "0000FF",
"window": default_window
}
]
},
chunks=chunks
storage_options=dict(chunks=chunks),
**kwargs,
)
z_root.attrs["omero"] = {
"name": img_name,
"version": "0.3",
"rdefs": {},
"channels": [
{
"label": "R",
"color": "FF0000",
"window": default_window
},
{
"label": "G",
"color": "00FF00",
"window": default_window
},
{
"label": "B",
"color": "0000FF",
"window": default_window
}
]
}


def multiplex_img_to_ome_zarr(img_arr, channel_names, output_path, img_name="Image", chunks=(1, 256, 256), axes="cyx", channel_colors=None):
Expand Down Expand Up @@ -132,19 +133,19 @@ def multiplex_img_to_ome_zarr(img_arr, channel_names, output_path, img_name="Ima
image=img_arr,
group=z_root,
axes=axes,
omero={
"name": img_name,
"version": "0.3",
"rdefs": {},
"channels": [
{
"label": channel_name,
"color": channel_colors[channel_name] if channel_colors is not None else "FFFFFF",
"window": default_window
}
for channel_name
in channel_names
]
},
chunks=chunks
storage_options=dict(chunks=chunks)
)
z_root.attrs["omero"] = {
"name": img_name,
"version": "0.3",
"rdefs": {},
"channels": [
{
"label": channel_name,
"color": channel_colors[channel_name] if channel_colors is not None else "FFFFFF",
"window": default_window
}
for channel_name
in channel_names
]
}

0 comments on commit 2ed3f5e

Please sign in to comment.