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

Fixes dtype('>u2') key error when extracting 2d image #82

Merged
merged 1 commit into from
Oct 2, 2023
Merged
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
15 changes: 8 additions & 7 deletions pytools/HedwigZarrImage.py
Original file line number Diff line number Diff line change
Expand Up @@ -157,17 +157,18 @@ def extract_2d(

zarr_request_size = [1, 0, 1, target_size_y * size_factor, target_size_x * size_factor]

arr = self._ome_ngff_get_array_from_size(zarr_request_size)
logger.debug(arr.info)
z_arr = self._ome_ngff_get_array_from_size(zarr_request_size)
logger.debug(z_arr.info)

arr = dask.array.from_zarr(arr.astype(arr.dtype.newbyteorder("=")))
d_arr = dask.array.from_zarr(z_arr)
d_arr = d_arr.astype(d_arr.dtype.newbyteorder("="))
if is_vector:
arr = dask.array.squeeze(arr, axis=(0, 2)) # Output CYX
arr = dask.array.moveaxis(arr, 0, -1) # transpose to YXC
d_arr = dask.array.squeeze(d_arr, axis=(0, 2)) # Output CYX
d_arr = dask.array.moveaxis(d_arr, 0, -1) # transpose to YXC
else:
arr = dask.array.squeeze(arr, axis=(0, 1, 2))
d_arr = dask.array.squeeze(d_arr, axis=(0, 1, 2))

img = sitk.GetImageFromArray(arr.compute(), isVector=is_vector)
img = sitk.GetImageFromArray(d_arr.compute(), isVector=is_vector)

logger.debug(img)

Expand Down