Closed bnmajor closed 1 year ago
@thewtex Testing this out with the notebook that Paul shared and I get back the following:
---------------------------------------------------------------------------
KeyError Traceback (most recent call last)
Input In [6], in <cell line: 1>()
----> 1 viewer = view(image=outputImage)
File ~/itkwidgets/itkwidgets/viewer.py:451, in view(data, **kwargs)
337 def view(data=None, **kwargs):
338 """View the image and/or point set.
339
340 Creates and returns an ImJoy plugin ipywidget to visualize an image, and/or
(...)
449 properties on the object to change the visualization.
450 """
--> 451 viewer = Viewer(data=data, **kwargs)
453 return viewer
File ~/itkwidgets/itkwidgets/viewer.py:147, in Viewer.__init__(self, ui_collapsed, rotate, ui, **add_data_kwargs)
143 def __init__(
144 self, ui_collapsed=True, rotate=False, ui="pydata-sphinx", **add_data_kwargs
145 ):
146 input_data = self.input_data(add_data_kwargs)
--> 147 data = self.init_data(input_data)
148 """Create a viewer."""
149 self.viewer_rpc = ViewerRPC(
150 ui_collapsed=ui_collapsed, rotate=rotate, ui=ui, data=data
151 )
File ~/itkwidgets/itkwidgets/viewer.py:186, in Viewer.init_data(self, input_data)
184 render_type = RenderType.LABELIMAGE
185 else:
--> 186 result = _get_viewer_image(data, label=False)
187 elif render_type is RenderType.POINT_SET:
188 result = _get_viewer_point_set(data)
File ~/itkwidgets/itkwidgets/integrations/__init__.py:78, in _get_viewer_image(image, label)
76 if isinstance(image, itk.Image) or isinstance(image, itk.VectorImage):
77 ngff_image = itk_image_to_ngff_image(image)
---> 78 multiscales = to_multiscales(ngff_image, method=method)
79 to_ngff_zarr(store, multiscales, chunk_store=chunk_store)
80 return store
File ~/.virtualenvs/test-itkwidgets/lib/python3.8/site-packages/ngff_zarr/to_multiscales.py:118, in to_multiscales(data, scale_factors, method, chunks)
115 method = Methods.DASK_IMAGE_GAUSSIAN
117 if method is Methods.DASK_IMAGE_GAUSSIAN:
--> 118 images = _downsample_dask_image(
119 ngff_image, default_chunks, out_chunks, scale_factors, label=False
120 )
121 elif method is Methods.DASK_IMAGE_NEAREST:
122 images = _downsample_dask_image(
123 ngff_image, default_chunks, out_chunks, scale_factors, label="nearest"
124 )
File ~/.virtualenvs/test-itkwidgets/lib/python3.8/site-packages/ngff_zarr/methods/_dask_image.py:128, in _downsample_dask_image(ngff_image, default_chunks, out_chunks, scale_factors, label)
121 # Compute output shape and metadata
122 output_shape = [
123 int(image_len / shrink_factor)
124 for image_len, shrink_factor in zip(
125 previous_image.data.shape, shrink_factors
126 )
127 ]
--> 128 output_scale = _compute_next_scale(previous_image, dim_factors)
129 output_translation = _compute_next_translation(previous_image, dim_factors)
131 if label == "mode":
File ~/.virtualenvs/test-itkwidgets/lib/python3.8/site-packages/ngff_zarr/methods/_dask_image.py:21, in _compute_next_scale(previous_image, dim_factors)
8 """Helper method to manually compute output image spacing.
9
10 previous_image: _NgffImage
(...)
18 Example {'x': 2.0, 'y': 1.0}
19 """
20 input_scale = previous_image.scale
---> 21 return {dim: input_scale[dim] * dim_factors[dim] for dim in previous_image.dims}
File ~/.virtualenvs/test-itkwidgets/lib/python3.8/site-packages/ngff_zarr/methods/_dask_image.py:21, in <dictcomp>(.0)
8 """Helper method to manually compute output image spacing.
9
10 previous_image: _NgffImage
(...)
18 Example {'x': 2.0, 'y': 1.0}
19 """
20 input_scale = previous_image.scale
---> 21 return {dim: input_scale[dim] * dim_factors[dim] for dim in previous_image.dims}
KeyError: 'c'
Any ideas?
@bnmajor I rebased, added a commit to your branch that bumps ngff-zarr -- it brings in a fix for the backtrace but also performance improvements.
Addresses #613