Skip to content

Commit

Permalink
save labels as np.int32
Browse files Browse the repository at this point in the history
Mac defaults to np.int64 on label creation, this is incompatible with AICSImage (perhaps I will pull this later), so force np.int32. see napari/napari#5545
  • Loading branch information
TimMonko committed Jan 30, 2024
1 parent 40f35e5 commit da06531
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions src/napari_ndev/_utilities_container.py
Original file line number Diff line number Diff line change
Expand Up @@ -278,8 +278,12 @@ def save_labels(self) -> None:
label_data = self._labels_layer.value.data
label_save_loc = self._get_save_loc("Labels")

# AICSImage does not allow saving labels as np.int64
# napari generates labels differently depending on the OS
# so we need to convert to np.int32 in case np.int64 generated
# see: https://github.com/napari/napari/issues/5545
self._common_save_logic(
data=label_data,
data=label_data.astype(np.int32),
uri=label_save_loc,
dim_order=self._label_save_dims,
channel_names=["Labels"],
Expand All @@ -302,8 +306,9 @@ def save_shapes_as_labels(self) -> None:

shapes_save_loc = self._get_save_loc("Shapes")

# see: https://github.com/napari/napari/issues/5545
self._common_save_logic(
data=shapes_as_labels,
data=shapes_as_labels.astype(np.int32),
uri=shapes_save_loc,
dim_order=self._label_save_dims,
channel_names=["Shapes"],
Expand Down

0 comments on commit da06531

Please sign in to comment.