@@ -138,10 +138,12 @@ def _get_viewer_point_sets(point_sets):
138
138
import torch
139
139
if isinstance (point_sets , torch .Tensor ):
140
140
return point_sets .numpy ()
141
- if isinstance (point_sets , xr .DataArray ):
142
- return xarray_data_array_to_numpy (point_sets )
143
- if isinstance (point_sets , xr .Dataset ):
144
- return xarray_data_set_to_numpy (point_sets )
141
+ if HAVE_XARRAY :
142
+ import xarray as xr
143
+ if isinstance (point_sets , xr .DataArray ):
144
+ return xarray_data_array_to_numpy (point_sets )
145
+ if isinstance (point_sets , xr .Dataset ):
146
+ return xarray_data_set_to_numpy (point_sets )
145
147
return point_sets
146
148
147
149
@@ -151,6 +153,7 @@ def _detect_render_type(data, input_type) -> RenderType:
151
153
elif isinstance (data , itkwasm .PointSet ):
152
154
return RenderType .POINT_SET
153
155
elif HAVE_MULTISCALE_SPATIAL_IMAGE :
156
+ from multiscale_spatial_image import MultiscaleSpatialImage
154
157
if isinstance (data , MultiscaleSpatialImage ):
155
158
return RenderType .IMAGE
156
159
elif isinstance (data , (zarr .Array , zarr .Group )):
@@ -190,11 +193,13 @@ def _detect_render_type(data, input_type) -> RenderType:
190
193
return RenderType .POINT_SET
191
194
else :
192
195
return RenderType .IMAGE
193
- if isinstance (data , xr .DataArray ):
194
- if input_type == 'point_sets' :
195
- return RenderType .POINT_SET
196
- else :
197
- return RenderType .IMAGE
196
+ if HAVE_XARRAY :
197
+ import xarray as xr
198
+ if isinstance (data , xr .DataArray ):
199
+ if input_type == 'point_sets' :
200
+ return RenderType .POINT_SET
201
+ else :
202
+ return RenderType .IMAGE
198
203
if isinstance (data , xr .Dataset ):
199
204
if input_type == 'point_sets' :
200
205
return RenderType .POINT_SET
0 commit comments