haesleinhuepf / napari-manual-split-and-merge-labels

BSD 3-Clause "New" or "Revised" License
4 stars 2 forks source link

napari-manual-split-and-merge doesn't work on clEsperanto backed layers #1

Open haesleinhuepf opened 3 years ago

haesleinhuepf commented 3 years ago

When using manual split on a layer that was created using clEsperanto, this error pops up:

---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
c:\users\rober\miniconda3\envs\bio1\lib\site-packages\magicgui\widgets\_bases\value_widget.py in _on_value_change(self=PushButton(value=False, annotation=None, name='call_button'), *args=(False,))
     53     def _on_value_change(self, *args):
     54         """Called when the widget value changes.  args come from the widget itself."""
---> 55         self.changed(value=args[0] if args else None)
        self.changed = <magicgui.events.EventEmitter object at 0x0000024AE34A2C70>
        global value = undefined
        args = (False,)
     56
     57     def get_value(self):

c:\users\rober\miniconda3\envs\bio1\lib\site-packages\magicgui\events.py in __call__(self=<magicgui.events.EventEmitter object>, *args=(), **kwargs={'value': False})
    651                     continue
    652
--> 653                 self._invoke_callback(cb, event)
        self._invoke_callback = <bound method EventEmitter._invoke_callback of <magicgui.events.EventEmitter object at 0x0000024AE34A2C70>>
        cb = <function FunctionGui.__init__.<locals>._disable_button_and_call at 0x0000024AE34A49D0>
        event = <Event blocked=False handled=False native=None source=None sources=[] type=changed>
    654                 if event.blocked:
    655                     break

c:\users\rober\miniconda3\envs\bio1\lib\site-packages\magicgui\events.py in _invoke_callback(self=<magicgui.events.EventEmitter object>, cb=<function FunctionGui.__init__.<locals>._disable_button_and_call>, event=<Event blocked=False handled=False native=None source=None sources=[] type=changed>)
    672             cb(event)
    673         except Exception:
--> 674             _handle_exception(
        global _handle_exception = <function _handle_exception at 0x0000024AB07EE280>
        self.ignore_callback_errors = False
        self.print_callback_errors = 'reminders'
        self = <magicgui.events.EventEmitter object at 0x0000024AE34A2C70>
        global cb_event = undefined
        cb = <function FunctionGui.__init__.<locals>._disable_button_and_call at 0x0000024AE34A49D0>
        event = <Event blocked=False handled=False native=None source=None sources=[] type=changed>
    675                 self.ignore_callback_errors,
    676                 self.print_callback_errors,

c:\users\rober\miniconda3\envs\bio1\lib\site-packages\magicgui\events.py in _handle_exception(ignore_callback_errors=False, print_callback_errors='reminders', obj=<magicgui.events.EventEmitter object>, cb_event=(<function FunctionGui.__init__.<locals>._disable_button_and_call>, <Event blocked=False handled=False native=None source=None sources=[] type=changed>), node=None)
    139     # Handle
    140     if value and not ignore_callback_errors:
--> 141         raise value
        value = AttributeError("'OCLArray' object has no attribute 'item'")
    142     if print_callback_errors != "never":
    143         this_print: Optional[str] = "full"

c:\users\rober\miniconda3\envs\bio1\lib\site-packages\magicgui\events.py in _invoke_callback(self=<magicgui.events.EventEmitter object>, cb=<function FunctionGui.__init__.<locals>._disable_button_and_call>, event=<Event blocked=False handled=False native=None source=None sources=[] type=changed>)
    670     def _invoke_callback(self, cb: Callback, event: Event):
    671         try:
--> 672             cb(event)
        cb = <function FunctionGui.__init__.<locals>._disable_button_and_call at 0x0000024AE34A49D0>
        event = <Event blocked=False handled=False native=None source=None sources=[] type=changed>
    673         except Exception:
    674             _handle_exception(

c:\users\rober\miniconda3\envs\bio1\lib\site-packages\magicgui\widgets\_function_gui.py in _disable_button_and_call(val=<Event blocked=False handled=False native=None source=None sources=[] type=changed>)
    185                     self._call_button.enabled = False
    186                     try:
--> 187                         self.__call__()
        global self.__call__ = undefined
    188                     finally:
    189                         self._call_button.enabled = True

c:\users\rober\miniconda3\envs\bio1\lib\site-packages\magicgui\widgets\_function_gui.py in __call__(self=<FunctionGui Manually_split_labels(labels_layer:...iewer.QtViewer object at 0x0000024AB1066040>>}))>, *args=(), **kwargs={})
    283         self._tqdm_depth = 0  # reset the tqdm stack count
    284         with _function_name_pointing_to_widget(self):
--> 285             value = self._function(*bound.args, **bound.kwargs)
        value = undefined
        self._function = <function Manually_split_labels at 0x0000024ADB4AB5E0>
        bound.args = (<Labels layer 'Result of voronoi_otsu_labeling' at 0x24ae32b5f10>, <Points layer 'Points' at 0x24ae34a2d60>, Viewer(axes=Axes(visible=False, labels=True, colored=True, dashed=False, arrows=True), camera=Camera(center=(0.0, 126.5, 127.5), zoom=1.5615199157178166, angles=(0.0, 0.0, 90.0), perspective=0.0, interactive=True), cursor=Cursor(position=(138.98783981467867, 334.66996402314743), scaled=True, size=1, style='pointing'), dims=Dims(ndim=2, ndisplay=2, last_used=1, range=((0.0, 253.0, 1.0), (0.0, 255.0, 1.0)), current_step=(0, 0), order=(0, 1), axis_labels=('0', '1')), grid=GridCanvas(enabled=False, stride=1, shape=(-1, -1)), layers=[<Image layer 'blobs' at 0x24adb63d9d0>, <Labels layer 'Result of voronoi_otsu_labeling' at 0x24ae32b5f10>, <Points layer 'Points' at 0x24ae34a2d60>], scale_bar=ScaleBar(visible=False, colored=False, ticks=True, position='bottom_right', font_size=10.0, unit=None), text_overlay=TextOverlay(visible=False, color=array([1., 1., 1., 1.]), font_size=10.0, position='top_left', text=''), help='hold <space> to pan/zoom', status='Points [139 335]', tooltip=Tooltip(visible=False, text=''), theme='dark', title='napari', mouse_move_callbacks=[], mouse_drag_callbacks=[], mouse_wheel_callbacks=[<function dims_scroll at 0x0000024AB07A55E0>], _persisted_mouse_event={}, _mouse_drag_gen={}, _mouse_wheel_gen={}, keymap={'Control-Shift-C': <bound method QtViewer.toggle_console_visibility of <napari._qt.qt_viewer.QtViewer object at 0x0000024AB1066040>>}))
        bound.kwargs = {}
    286
    287         self._call_count += 1

c:\structure\code\napari-manual-split-and-merge-labels\napari_manual_split_and_merge_labels\_function.py in Manually_split_labels(labels_layer=<Labels layer 'Result of voronoi_otsu_labeling'>, points_layer=<Points layer 'Points'>, viewer=Viewer(axes=Axes(visible=False, labels=True, col..._viewer.QtViewer object at 0x0000024AB1066040>>}))
     43     points = points_layer.data
     44
---> 45     label_ids = [labels.item(tuple([int(j) for j in i])) for i in points]
        label_ids = undefined
        global labels.item = undefined
        global tuple = undefined
        global int = undefined
        global j = undefined
        i = undefined
        points = array([[143.47065183,  90.03650819],
       [151.15547243,  97.72132879]])
     46
     47     # make a binary image first

c:\structure\code\napari-manual-split-and-merge-labels\napari_manual_split_and_merge_labels\_function.py in <listcomp>(.0=<iterator object>)
     43     points = points_layer.data
     44
---> 45     label_ids = [labels.item(tuple([int(j) for j in i])) for i in points]
        global label_ids = undefined
        global labels.item = undefined
        global tuple = undefined
        global int = undefined
        global j = undefined
        i = array([143.47065183,  90.03650819])
        global points = undefined
     46
     47     # make a binary image first

AttributeError: 'OCLArray' object has no attribute 'item'