clEsperanto / napari_pyclesperanto_assistant

GPU-accelerated general purpose image processing and image analysis in napari
http://clesperanto.net
BSD 3-Clause "New" or "Revised" License
31 stars 9 forks source link

Bugs when using functions from nsbatwm #51

Closed Cryaaa closed 2 years ago

Cryaaa commented 2 years ago

When using background subtraction functions tagged with nsbatwm I get an Error message:

`2022-02-20 21:06:53.908 | DEBUG | napari_pyclesperanto_assistant._gui._category_widget:_show_result:223 - creating new layer for id: 2456101371712 2022-02-20 21:06:56.043 | DEBUG | napari_pyclesperanto_assistant._gui._category_widget:_show_result:217 - updating existing layer: Result of Gaussian (scikit-image, nsbatwm), with id: 2456101371712 2022-02-20 21:06:56.226 | DEBUG | napari_pyclesperanto_assistant._gui._category_widget:_show_result:217 - updating existing layer: Result of Gaussian (scikit-image, nsbatwm), with id: 2456101371712 2022-02-20 21:06:56.407 | DEBUG | napari_pyclesperanto_assistant._gui._category_widget:_show_result:217 - updating existing layer: Result of Gaussian (scikit-image, nsbatwm), with id: 2456101371712 2022-02-20 21:06:57.952 | ERROR | napari_pyclesperanto_assistant._gui._category_widget:gui_function:328 - An error has been caught in function 'gui_function', process 'MainProcess' (20716), thread 'MainThread' (3616): Traceback (most recent call last):

File "C:\Users\ryans\anaconda3\envs\np_workflows_v1\lib\runpy.py", line 196, in _run_module_as_main return _run_code(code, main_globals, None, │ │ └ {'name': 'main', 'doc': None, 'package': '', 'loader': <zipimporter object "C:\Users\ryans\anaconda3\envs... │ └ <code object at 0x0000023BA0990F50, file "C:\Users\ryans\anaconda3\envs\np_workflows_v1\Scripts\napari.exe__main__.... └ <function _run_code at 0x0000023BA096A7A0>

File "C:\Users\ryans\anaconda3\envs\np_workflows_v1\lib\runpy.py", line 86, in _run_code exec(code, run_globals) │ └ {'name': 'main', 'doc': None, 'package': '', 'loader': <zipimporter object "C:\Users\ryans\anaconda3\envs... └ <code object at 0x0000023BA0990F50, file "C:\Users\ryans\anaconda3\envs\np_workflows_v1\Scripts\napari.exe__main__....

File "C:\Users\ryans\anaconda3\envs\np_workflows_v1\Scripts\napari.exe__main__.py", line 7, in

File "C:\Users\ryans\anaconda3\envs\np_workflows_v1\lib\site-packages\napari__main__.py", line 449, in main _run() └ <function _run at 0x0000023BC1A52200>

File "C:\Users\ryans\anaconda3\envs\np_workflows_v1\lib\site-packages\napari__main__.py", line 338, in _run run(gui_exceptions=True) └ <function run at 0x0000023BC1C80820>

File "C:\Users\ryans\anaconda3\envs\np_workflows_v1\lib\site-packages\napari_qt\qt_eventloop.py", line 402, in run app.exec() │ └ └ <PyQt5.QtWidgets.QApplication object at 0x0000023BC1F757E0>

File "c:\users\ryans\onedrive\documents\bia pol stuff\napari workflow repositories\napari_pyclesperanto_assistant\napari_pyclesperanto_assistant_gui_Assistant.py", line 188, in _on_item_clicked self._activate(CATEGORIES.get(item.text())) │ │ │ │ │ └ │ │ │ │ └ <PyQt5.QtWidgets.QListWidgetItem object at 0x0000023BDB0CA950> │ │ │ └ <method 'get' of 'dict' objects> │ │ └ {'Remove noise': Category(name='Removal noise', description='Remove noise from images, e.g. by local averaging and blurring.'... │ └ <function Assistant._activate at 0x0000023BD55EAB00> └ <napari_pyclesperanto_assistant._gui._Assistant.Assistant object at 0x0000023BDB0AE710>

File "c:\users\ryans\onedrive\documents\bia pol stuff\napari workflow repositories\napari_pyclesperanto_assistant\napari_pyclesperanto_assistant_gui_Assistant.py", line 219, in _activate self._layers[gui()] = (dw, gui) │ │ │ │ └ <FunctionGui do_remove_background(, input0: napari.layers.image.image.Image = <Image layer 'Result of Gaussian (scikit-image... │ │ │ └ <napari._qt.widgets.qt_viewer_dock_widget.QtViewerDockWidget object at 0x0000023BE3ECA320> │ │ └ <FunctionGui do_remove_background(, input0: napari.layers.image.image.Image = <Image layer 'Result of Gaussian (scikit-image... │ └ {<Image layer 'Result of Gaussian (scikit-image, nsbatwm)' at 0x23bdb2a34f0>: (<napari._qt.widgets.qt_viewer_dock_widget.QtVi... └ <napari_pyclesperanto_assistant._gui._Assistant.Assistant object at 0x0000023BDB0AE710>

File "C:\Users\ryans\anaconda3\envs\np_workflows_v1\lib\site-packages\magicgui\widgets_function_gui.py", line 303, in call value = self._function(*bound.args, *bound.kwargs) │ │ │ │ │ └ <property object at 0x0000023BA0E0D990> │ │ │ │ └ <BoundArguments (input0=<Image layer 'Result of Gaussian (scikit-image, nsbatwm)' at 0x23bdb2a34f0>, op_name='Black top-hat (... │ │ │ └ <property object at 0x0000023BA0E0D940> │ │ └ <BoundArguments (input0=<Image layer 'Result of Gaussian (scikit-image, nsbatwm)' at 0x23bdb2a34f0>, op_name='Black top-hat (... │ └ <function make_gui_for_category..gui_function at 0x0000023BE3E9A170> └ <FunctionGui do_remove_background(, input0: napari.layers.image.image.Image = <Image layer 'Result of Gaussian (scikit-image...

File "c:\users\ryans\onedrive\documents\bia pol stuff\napari workflow repositories\napari_pyclesperanto_assistant\napari_pyclesperanto_assistant_gui_category_widget.py", line 328, in gui_function result, used_args = call_op(op_name, inputs, t_position, viewer, **kwargs) │ │ │ │ │ └ {'x': 10.0, 'y': 10.0, 'z': 0.0, 'u': 0.0, 'v': 0.0, 'w': 0.0, 'a': False, 'b': False, 'c': False, 'k': '', 'l': '', 'm': ''} │ │ │ │ └ Viewer(axes=Axes(visible=False, labels=True, colored=True, dashed=False, arrows=True), camera=Camera(center=(0.0, 126.5, 127.... │ │ │ └ None │ │ └ [<Image layer 'Result of Gaussian (scikit-image, nsbatwm)' at 0x23bdb2a34f0>] │ └ 'Black top-hat (scipy, nsbatwm)' └ <function call_op at 0x0000023BD55E9FC0>

File "c:\users\ryans\onedrive\documents\bia pol stuff\napari workflow repositories\napari_pyclesperanto_assistant\napari_pyclesperanto_assistant_gui_category_widget.py", line 154, in call_op gpu_out = cle_function(*args, **kwargs) │ │ └ {} │ └ [array([[0.14280938, 0.13814596, 0.1335724 , ..., 0.88336891, 0.87451825, │ 0.86551713], │ [0.14465108, 0.14062554... └ <function black_tophat at 0x0000023BCD436440>

File "C:\Users\ryans\anaconda3\envs\np_workflows_v1\lib\site-packages\napari_time_slicer__init__.py", line 49, in worker_function result = function(*bound.args, **bound.kwargs) │ │ │ │ └ <property object at 0x0000023BA0E0D990> │ │ │ └ <BoundArguments (image=array([[0.14280938, 0.13814596, 0.1335724 , ..., 0.88336891, 0.87451825, │ │ │ 0.86551713], │ │ │ [... │ │ └ <property object at 0x0000023BA0E0D940> │ └ <BoundArguments (image=array([[0.14280938, 0.13814596, 0.1335724 , ..., 0.88336891, 0.87451825, │ 0.86551713], │ [... └ <function black_tophat at 0x0000023BCD4363B0>

File "C:\Users\ryans\anaconda3\envs\np_workflows_v1\lib\site-packages\napari_segment_blobs_and_things_with_membranes__init.py", line 215, in black_tophat return scipy.ndimage.black_tophat(image.astype(float), size=radius * 2 + 1) │ │ │ │ │ └ 10.0 │ │ │ │ └ <method 'astype' of 'numpy.ndarray' objects> │ │ │ └ array([[0.14280938, 0.13814596, 0.1335724 , ..., 0.88336891, 0.87451825, │ │ │ 0.86551713], │ │ │ [0.14465108, 0.14062554,... │ │ └ <function black_tophat at 0x0000023BBE776950> │ └ <module 'scipy.ndimage' from 'C:\Users\ryans\anaconda3\envs\np_workflows_v1\lib\site-packages\scipy\ndimage\_init... └ <module 'scipy' from 'C:\Users\ryans\anaconda3\envs\np_workflows_v1\lib\site-packages\scipy\init__.py'>

File "C:\Users\ryans\anaconda3\envs\np_workflows_v1\lib\site-packages\scipy\ndimage\morphology.py", line 1840, in black_tophat tmp = grey_dilation(input, size, footprint, structure, None, mode, │ │ │ │ │ └ 'reflect' │ │ │ │ └ None │ │ │ └ None │ │ └ 21.0 │ └ array([[0.14280938, 0.13814596, 0.1335724 , ..., 0.88336891, 0.87451825, │ 0.86551713], │ [0.14465108, 0.14062554,... └ <function grey_dilation at 0x0000023BBE7765F0>

File "C:\Users\ryans\anaconda3\envs\np_workflows_v1\lib\site-packages\scipy\ndimage\morphology.py", line 1366, in grey_dilation if not sz & 1: └ 21.0

TypeError: unsupported operand type(s) for &: 'float' and 'int'`

This can also be seen with other categories like filter where I also get : TypeError: unsupported operand type(s) for &: 'float' and 'int' For the combine category I get the error: TypeError: missing a required argument: 'image2', although two images are selected in the widget. I hope this helps and if you need further command line readouts I am happy to try and reproduce these errors. For reference: I am using the main branch of this repository as an install rather than installing it with Pypi or napari.

haesleinhuepf commented 2 years ago

Hi Ryan @Cryaaa ,

Thanks for reporting this! Can you please check which version of nsbatwm you have installed at the moment? You can see this for example in napari menu Help > Napari info. Copying the whole content of this list here might be helpful.

I'm asking because this bug was intended to be fixed with version 0.2.16.

Thanks again!

Best, Robert

Cryaaa commented 2 years ago

Okay so I will only be able to send the information after I have fixed napari in this environment as it still crashes when I try to click the info button. The version 0.2.16 that you mentioned definitely fixed most categories now (although I have a feeling that some functions are behaving strangely: maybe we should look at that together though). One category which still doesn't work though is the combine catergory which just gives the error: TypeError: missing a required argument: 'image2'. I'll give more info's as soon as I have a stable environment.

haesleinhuepf commented 2 years ago

Ok, I can reproduce this error!

  1. enter "nsbatwm" in the assistant's search field
  2. click on "combine"
  3. The divide_images function in nsbatwm crashes (and it should not) https://github.com/haesleinhuepf/napari-segment-blobs-and-things-with-membranes/blob/313d46e99785af7a9d0b564906e96dd840d3963e/napari_segment_blobs_and_things_with_membranes/__init__.py#L453
haesleinhuepf commented 2 years ago

Hi Ryan @Cryaaa ,

this should be fixed in the napari-pyclesperanto-assistant 0.15.5. Would you mind checking and confirming? (no hurry though)

Thanks for reporting!

Best, Robert

Cryaaa commented 2 years ago

Hey Robert, I just tried it with the new release and it seems to be working as normal! Thanks for the quick fix!