Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Scale dict #103

Merged
merged 5 commits into from
Feb 11, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ def get_long_description() -> str:
author="The Open Microscopy Team",
author_email="",
python_requires=">=3",
install_requires=["omero-py>=5.6.0", "ome-zarr>=0.3a1"],
install_requires=["omero-py>=5.6.0", "ome-zarr>=0.3a2"],
long_description=long_description,
keywords=["OMERO.CLI", "plugin"],
url="https://github.com/ome/omero-cli-zarr/",
Expand Down
7 changes: 5 additions & 2 deletions src/omero_zarr/masks.py
Original file line number Diff line number Diff line change
Expand Up @@ -307,7 +307,6 @@ def save(self, masks: List[omero.model.Shape], name: str) -> None:
)

axes = marshal_axes(self.image)
transformations = marshal_transformations(self.image, levels=1)

# For v0.3+ ngff we want to reduce the number of dimensions to
# match the dims of the Image.
Expand All @@ -320,9 +319,13 @@ def save(self, masks: List[omero.model.Shape], name: str) -> None:
scaler = Scaler(max_layer=input_pyramid_levels)
label_pyramid = scaler.nearest(labels)
pyramid_grp = out_labels.require_group(name)
transformations = marshal_transformations(self.image, levels=len(label_pyramid))

write_multiscale(
label_pyramid, pyramid_grp, axes=axes, transformations=transformations
label_pyramid,
pyramid_grp,
axes=axes,
coordinate_transformations=transformations,
) # TODO: dtype, chunks, overwite

# Specify and store metadata
Expand Down
8 changes: 5 additions & 3 deletions src/omero_zarr/raw_pixels.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,9 +98,11 @@ def planeGen() -> np.ndarray:
axes = marshal_axes(image)
transformations = marshal_transformations(image, len(paths))

write_multiscales_metadata(
parent, paths, axes=axes, transformations=transformations
)
datasets: List[Dict[Any, Any]] = [{"path": path} for path in paths]
for dataset, transform in zip(datasets, transformations):
dataset["coordinateTransformations"] = transform

write_multiscales_metadata(parent, datasets, axes=axes)

return (level_count, axes)

Expand Down
17 changes: 7 additions & 10 deletions src/omero_zarr/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,21 +96,18 @@ def marshal_transformations(

# Each path needs a transformations list...
transformations = []
zooms = {"x": 1.0, "y": 1.0, "z": 1.0}
zooms = {"x": 1.0, "y": 1.0, "z": 1.0, "c": 1.0, "t": 1.0}
for level in range(levels):
# {"type": "scale", "scale": [2.0, 2.0, 2.0], "axisIndices": [2, 3, 4]}
# {"type": "scale", "scale": [1, 1, 0.3, 0.5, 0.5]
scales = []
axisIndices = []
for index, axis in enumerate(axes):
pixel_size = 1
if axis["name"] in pixel_sizes:
scales.append(zooms[axis["name"]] * pixel_sizes[axis["name"]]["value"])
axisIndices.append(index)
pixel_size = pixel_sizes[axis["name"]].get("value", 1)
scales.append(zooms[axis["name"]] * pixel_size)
# ...with a single 'scale' transformation each
if len(scales) > 0:
transformations.append(
[{"type": "scale", "scale": scales, "axisIndices": axisIndices}]
)
# NB we rescale X and Y for each level, but not Z
transformations.append([{"type": "scale", "scale": scales}])
# NB we rescale X and Y for each level, but not Z, C, T
zooms["x"] = zooms["x"] * multiscales_zoom
zooms["y"] = zooms["y"] * multiscales_zoom

Expand Down