Skip to content

Commit

Permalink
Fixed error when input image has multiple spatial dimensions of size 1
Browse files Browse the repository at this point in the history
  • Loading branch information
fercer committed Jul 22, 2024
1 parent ecf287b commit 0cfbd1a
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 11 deletions.
2 changes: 1 addition & 1 deletion src/napari_activelearning/_interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -392,7 +392,7 @@ def _modify_patch_size(self, scale: int, ax_idx: int = 0):

def _set_patch_size(self):
patch_sizes = [
int(scale_le.text())
int(scale_le.text()) if scale_le.text() else 1
for scale_le in self._curr_scale_le_list
]

Expand Down
20 changes: 10 additions & 10 deletions src/napari_activelearning/_layers.py
Original file line number Diff line number Diff line change
Expand Up @@ -437,7 +437,8 @@ def remove_layer(self, layer_channel: LayerChannel):
if curr_layer_channel.channel > removed_channel:
curr_layer_channel.channel = curr_layer_channel.channel - 1

self.parent().parent().remove_layer_channel(layer_channel)
if self.parent() is not None and self.parent().parent() is not None:
self.parent().parent().remove_layer_channel(layer_channel)

self._update_source_axes()
self.updated = True
Expand Down Expand Up @@ -1087,26 +1088,25 @@ def _update_reference_info(self):
im_shape = self._active_layer_channel.shape
im_scale = self._active_layer_channel.scale
im_translate = self._active_layer_channel.translate
im_source_axes = self._active_layers_group.source_axes

self._im_source_axes = [
im_source_axes = "".join([
ax
for ax in im_source_axes
if ax != "C" or (len(im_shape) == len(im_source_axes))
]
for ax in self._active_layers_group.source_axes
if (ax != "C"
or len(self._active_layers_group.source_axes) == len(im_shape))
])

self._mask_axes = "".join([
ax
for ax in self._im_source_axes
if ax != "C"
for ax, ax_s in zip(im_source_axes, im_shape)
if ax != "C" and ax_s > 1
])

(self._im_source_axes,
self._im_shape,
self._im_scale,
self._im_translate) = list(zip(*filter(
lambda ax_props: ax_props[0] in self._mask_axes,
zip(self._im_source_axes, im_shape, im_scale, im_translate)
zip(im_source_axes, im_shape, im_scale, im_translate)
)))

self._patch_sizes = [
Expand Down

0 comments on commit 0cfbd1a

Please sign in to comment.