Skip to content

Commit

Permalink
Merge pull request #103 from will-moore/scale_dict
Browse files Browse the repository at this point in the history
Scale dict
  • Loading branch information
sbesson authored Feb 11, 2022
2 parents e991734 + b5c9886 commit 9cce537
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 16 deletions.
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

0 comments on commit 9cce537

Please sign in to comment.