Skip to content

Commit

Permalink
Merge pull request #69 from thewtex/to-zarr-mode
Browse files Browse the repository at this point in the history
BUG: Pass mode to to_zarr superclass method
  • Loading branch information
thewtex authored Jul 22, 2024
2 parents f89b18e + 3e31f85 commit eb0968f
Show file tree
Hide file tree
Showing 6 changed files with 187 additions and 50 deletions.
2 changes: 1 addition & 1 deletion multiscale_spatial_image/multiscale_spatial_image.py
Original file line number Diff line number Diff line change
Expand Up @@ -124,4 +124,4 @@ def to_zarr(
ngff_metadata = {"multiscales": multiscales, "multiscaleSpatialImageVersion": 1}
self._dt.ds = self._dt.ds.assign_attrs(**ngff_metadata)

self._dt.to_zarr(store, **kwargs)
self._dt.to_zarr(store, mode=mode, **kwargs)
Original file line number Diff line number Diff line change
Expand Up @@ -39,14 +39,15 @@ def itk_image_to_multiscale(
# Orient 3D image so that direction is identity wrt RAI coordinates
image_dimension = image.GetImageDimension()
input_direction = np.array(image.GetDirection())
oriented_image = image
if anatomical_axes and image_dimension == 3 and not (np.eye(image_dimension) == input_direction).all():
desired_orientation = itk.SpatialOrientationEnums.ValidCoordinateOrientations_ITK_COORDINATE_ORIENTATION_RAI
oriented_image = itk.orient_image_filter(image, use_image_direction=True, desired_coordinate_orientation=desired_orientation)

elif anatomical_axes and image_dimension != 3:
raise ValueError(f'Cannot use anatomical axes for input image of size {image_dimension}')

image_da = itk.xarray_from_image(image)
image_da = itk.xarray_from_image(oriented_image)
image_da.name = name

image_dims: Tuple[str, str, str, str] = ("x", "y", "z", "t") # ITK dims are in xyzt order
Expand Down
Loading

0 comments on commit eb0968f

Please sign in to comment.