Skip to content

Commit 5aab14e

Browse files
committed
BUG: Support scikit-image label images
scikit-image label images are np.int64 type, which we need to cast to np.float32 for support in JavaScript / itk.
1 parent 031956f commit 5aab14e

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

itkwidgets/_transform_types.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -237,11 +237,16 @@ def to_itk_image(image_like):
237237

238238
if is_arraylike(image_like):
239239
array = np.asarray(image_like)
240-
case_use_view = array.flags['OWNDATA']
240+
can_use_view = array.flags['OWNDATA']
241241
if have_dask and isinstance(image_like, dask.array.core.Array):
242-
case_use_view = False
242+
can_use_view = False
243243
array = np.ascontiguousarray(array)
244-
if case_use_view:
244+
# JavaScript does not support 64-bit integers
245+
if array.dtype == np.int64:
246+
array = array.astype(np.float32)
247+
elif array.dtype == np.uint64:
248+
array = array.astype(np.float32)
249+
if can_use_view:
245250
image_from_array = itk.image_view_from_array(array)
246251
else:
247252
image_from_array = itk.image_from_array(array)

0 commit comments

Comments
 (0)