mpi-dortmund / napari-tomotwin Goto Github PK
View Code? Open in Web Editor NEWTool for the work with TomoTwin
License: Mozilla Public License 2.0
Tool for the work with TomoTwin
License: Mozilla Public License 2.0
I am following the tutorial steps, and have napari-tomotwin installed using the following command:
mamba env create -n napari-tomotwin -f https://raw.githubusercontent.com/MPI-Dortmund/napari-tomotwin/main/conda_env.yml
I can load the UMAP data into napari. At this point, my napari window looks like:
Now, when I click on the tomogram, I immediately get the error message:
------------------------------------------------------------------------
AttributeError Traceback (most recent call last)
File /hpc/projects/group.czii/saugat.kandel/miniforge3/envs/napari-tomotwin/lib/python3.10/site-packages/vispy/app/backends/_qt.py:496, in QtBaseCanvasBackend.mousePressEvent(self=<vispy.app.backends._qt.CanvasBackendDesktop object>, ev=<PyQt5.QtGui.QMouseEvent object>)
494 if self._vispy_canvas is None:
495 return
--> 496 self._vispy_mouse_press(
self = <vispy.app.backends._qt.CanvasBackendDesktop object at 0x7f0c800ae290>
ev = <PyQt5.QtGui.QMouseEvent object at 0x7f0c2a556d40>
BUTTONMAP = {0: 0, 1: 1, 2: 2, 4: 3, 8: 4, 16: 5}
497 native=ev,
498 pos=_get_event_xy(ev),
499 button=BUTTONMAP.get(ev.button(), 0),
500 modifiers=self._modifiers(ev),
501 )
File /hpc/projects/group.czii/saugat.kandel/miniforge3/envs/napari-tomotwin/lib/python3.10/site-packages/vispy/app/base.py:184, in BaseCanvasBackend._vispy_mouse_press(self=<vispy.app.backends._qt.CanvasBackendDesktop object>, **kwargs={'button': 1, 'buttons': [], 'last_event': <MouseEvent blocked=False button=None buttons=[]...urces=[] time=1716403732.2130306 type=mouse_move>, 'last_mouse_press': None, 'modifiers': (), 'native': <PyQt5.QtGui.QMouseEvent object>, 'pos': (692, 600), 'press_event': None})
181 def _vispy_mouse_press(self, **kwargs):
182 # default method for delivering mouse press events to the canvas
183 kwargs.update(self._vispy_mouse_data)
--> 184 ev = self._vispy_canvas.events.mouse_press(**kwargs)
self._vispy_canvas.events.mouse_press = <vispy.util.event.EventEmitter object at 0x7f0c800bc1f0>
kwargs = {'native': <PyQt5.QtGui.QMouseEvent object at 0x7f0c2a556d40>, 'pos': (692, 600), 'button': 1, 'modifiers': (), 'buttons': [], 'press_event': None, 'last_event': <MouseEvent blocked=False button=None buttons=[] delta=[0. 0.] handled=False is_dragging=False last_event=None modifiers=() native=<PyQt5.QtGui.QMouseEvent object at 0x7f0c2a556d40> pos=[692 600] press_event=None source=None sources=[] time=1716403732.2130306 type=mouse_move>, 'last_mouse_press': None}
self = <vispy.app.backends._qt.CanvasBackendDesktop object at 0x7f0c800ae290>
self._vispy_canvas.events = <vispy.util.event.EmitterGroup object at 0x7f0c800bc1c0>
self._vispy_canvas = <VispyCanvas (PyQt5) at 0x7f0c800ab850>
185 if self._vispy_mouse_data['press_event'] is None:
186 self._vispy_mouse_data['press_event'] = ev
File /hpc/projects/group.czii/saugat.kandel/miniforge3/envs/napari-tomotwin/lib/python3.10/site-packages/vispy/util/event.py:453, in EventEmitter.__call__(self=<vispy.util.event.EventEmitter object>, *args=(), **kwargs={'button': 1, 'buttons': [], 'last_event': <MouseEvent blocked=False button=None buttons=[]...urces=[] time=1716403732.2130306 type=mouse_move>, 'last_mouse_press': None, 'modifiers': (), 'native': <PyQt5.QtGui.QMouseEvent object>, 'pos': (692, 600), 'press_event': None})
450 if self._emitting > 1:
451 raise RuntimeError('EventEmitter loop detected!')
--> 453 self._invoke_callback(cb, event)
event = <MouseEvent blocked=False button=1 buttons=[1] delta=[0. 0.] handled=False is_dragging=False last_event=MouseEvent modifiers=() native=<PyQt5.QtGui.QMouseEvent object at 0x7f0c2a556d40> pos=[692 600] press_event=None source=None sources=[] time=1716403732.224965 type=mouse_press>
self = <vispy.util.event.EventEmitter object at 0x7f0c800bc1f0>
cb = <bound method QtViewer.on_mouse_press of <napari._qt.qt_viewer.QtViewer object at 0x7f0c800a2b90>>
454 if event.blocked:
455 break
File /hpc/projects/group.czii/saugat.kandel/miniforge3/envs/napari-tomotwin/lib/python3.10/site-packages/vispy/util/event.py:471, in EventEmitter._invoke_callback(self=<vispy.util.event.EventEmitter object>, cb=<bound method QtViewer.on_mouse_press of <napari._qt.qt_viewer.QtViewer object>>, event=<MouseEvent blocked=False button=1 buttons=[1] d...urces=[] time=1716403732.224965 type=mouse_press>)
469 cb(event)
470 except Exception:
--> 471 _handle_exception(self.ignore_callback_errors,
self = <vispy.util.event.EventEmitter object at 0x7f0c800bc1f0>
cb = <bound method QtViewer.on_mouse_press of <napari._qt.qt_viewer.QtViewer object at 0x7f0c800a2b90>>
event = <MouseEvent blocked=False button=1 buttons=[1] delta=[0. 0.] handled=False is_dragging=False last_event=MouseEvent modifiers=() native=<PyQt5.QtGui.QMouseEvent object at 0x7f0c2a556d40> pos=[692 600] press_event=None source=None sources=[] time=1716403732.224965 type=mouse_press>
(cb, event) = (<bound method QtViewer.on_mouse_press of <napari._qt.qt_viewer.QtViewer object at 0x7f0c800a2b90>>, <MouseEvent blocked=False button=1 buttons=[1] delta=[0. 0.] handled=False is_dragging=False last_event=MouseEvent modifiers=() native=<PyQt5.QtGui.QMouseEvent object at 0x7f0c2a556d40> pos=[692 600] press_event=None source=None sources=[] time=1716403732.224965 type=mouse_press>)
472 self.print_callback_errors,
473 self, cb_event=(cb, event))
File /hpc/projects/group.czii/saugat.kandel/miniforge3/envs/napari-tomotwin/lib/python3.10/site-packages/vispy/util/event.py:469, in EventEmitter._invoke_callback(self=<vispy.util.event.EventEmitter object>, cb=<bound method QtViewer.on_mouse_press of <napari._qt.qt_viewer.QtViewer object>>, event=<MouseEvent blocked=False button=1 buttons=[1] d...urces=[] time=1716403732.224965 type=mouse_press>)
467 def _invoke_callback(self, cb, event):
468 try:
--> 469 cb(event)
cb = <bound method QtViewer.on_mouse_press of <napari._qt.qt_viewer.QtViewer object at 0x7f0c800a2b90>>
event = <MouseEvent blocked=False button=1 buttons=[1] delta=[0. 0.] handled=False is_dragging=False last_event=MouseEvent modifiers=() native=<PyQt5.QtGui.QMouseEvent object at 0x7f0c2a556d40> pos=[692 600] press_event=None source=None sources=[] time=1716403732.224965 type=mouse_press>
470 except Exception:
471 _handle_exception(self.ignore_callback_errors,
472 self.print_callback_errors,
473 self, cb_event=(cb, event))
File /hpc/projects/group.czii/saugat.kandel/miniforge3/envs/napari-tomotwin/lib/python3.10/site-packages/napari/_qt/qt_viewer.py:1201, in QtViewer.on_mouse_press(self=<napari._qt.qt_viewer.QtViewer object>, event=<MouseEvent blocked=False button=1 buttons=[1] d...urces=[] time=1716403732.224965 type=mouse_press>)
1193 def on_mouse_press(self, event):
1194 """Called whenever mouse pressed in canvas.
1195
1196 Parameters
(...)
1199 The vispy event that triggered this method.
1200 """
-> 1201 self._process_mouse_event(mouse_press_callbacks, event)
event = <MouseEvent blocked=False button=1 buttons=[1] delta=[0. 0.] handled=False is_dragging=False last_event=MouseEvent modifiers=() native=<PyQt5.QtGui.QMouseEvent object at 0x7f0c2a556d40> pos=[692 600] press_event=None source=None sources=[] time=1716403732.224965 type=mouse_press>
self = <napari._qt.qt_viewer.QtViewer object at 0x7f0c800a2b90>
File /hpc/projects/group.czii/saugat.kandel/miniforge3/envs/napari-tomotwin/lib/python3.10/site-packages/napari/_qt/qt_viewer.py:1156, in QtViewer._process_mouse_event(self=<napari._qt.qt_viewer.QtViewer object>, mouse_callbacks=<function mouse_press_callbacks>, event=<ReadOnlyWrapper at 0x7f0c01647040 for MouseEvent>)
1154 # Put a read only wrapper on the event
1155 event = ReadOnlyWrapper(event, exceptions=('handled',))
-> 1156 mouse_callbacks(self.viewer, event)
event = <ReadOnlyWrapper at 0x7f0c01647040 for MouseEvent at 0x7f0c288d1ed0>
mouse_callbacks = <function mouse_press_callbacks at 0x7f0c89d52cb0>
self.viewer = Viewer(camera=Camera(center=(0.0, 314.5, 314.5), zoom=1.019353960150897, angles=(0.0, 0.0, 90.0), perspective=0.0, mouse_pan=True, mouse_zoom=True), cursor=Cursor(position=(91.0, 763.3136607686552, 462.14252269423287), scaled=True, size=10, style=<CursorStyle.STANDARD: 'standard'>), dims=Dims(ndim=3, ndisplay=2, last_used=0, range=((0.0, 184.0, 1.0), (0.0, 630.0, 1.0), (0.0, 630.0, 1.0)), current_step=(91, 314, 314), order=(0, 1, 2), axis_labels=('0', '1', '2')), grid=GridCanvas(stride=1, shape=(-1, -1), enabled=False), layers=[<Image layer '...ddings/TS_1_1/TS_1_1_noctf.mrc' at 0x7f0c2a582e00>, <Labels layer 'UMAP' at 0x7f0b19471ff0>], help='use <1> for activate the label eraser, use <2> for activate the paint brush, use <3> for activate the fill bucket, use <4> for pick mode', status={'layer_base': 'UMAP', 'source_type': '', 'plugin': '', 'coordinates': ' [91 763 462]'}, tooltip=Tooltip(visible=False, text=''), theme='dark', title='napari', mouse_over_canvas=True, mouse_move_callbacks=[], mouse_drag_callbacks=[functools.partial(<function drag_circle_callback at 0x7f0c2a5563b0>, <napari_clusters_plotter._plotter.PlotterWidget object at 0x7f0c2875e560>)], mouse_double_click_callbacks=[], mouse_wheel_callbacks=[<function dims_scroll at 0x7f0c88d2a170>], _persisted_mouse_event={}, _mouse_drag_gen={}, _mouse_wheel_gen={}, keymap={})
self = <napari._qt.qt_viewer.QtViewer object at 0x7f0c800a2b90>
1158 layer = self.viewer.layers.selection.active
1159 if layer is not None:
File /hpc/projects/group.czii/saugat.kandel/miniforge3/envs/napari-tomotwin/lib/python3.10/site-packages/napari/utils/interactions.py:121, in mouse_press_callbacks(obj=Viewer(camera=Camera(center=(0.0, 314.5, 314.5),...ouse_drag_gen={}, _mouse_wheel_gen={}, keymap={}), event=<ReadOnlyWrapper at 0x7f0c01647040 for MouseEvent>)
118 # iterate through drag callback functions
119 for mouse_drag_func in obj.mouse_drag_callbacks:
120 # execute function to run press event code
--> 121 gen = mouse_drag_func(obj, event)
mouse_drag_func = functools.partial(<function drag_circle_callback at 0x7f0c2a5563b0>, <napari_clusters_plotter._plotter.PlotterWidget object at 0x7f0c2875e560>)
obj = Viewer(camera=Camera(center=(0.0, 314.5, 314.5), zoom=1.019353960150897, angles=(0.0, 0.0, 90.0), perspective=0.0, mouse_pan=True, mouse_zoom=True), cursor=Cursor(position=(91.0, 763.3136607686552, 462.14252269423287), scaled=True, size=10, style=<CursorStyle.STANDARD: 'standard'>), dims=Dims(ndim=3, ndisplay=2, last_used=0, range=((0.0, 184.0, 1.0), (0.0, 630.0, 1.0), (0.0, 630.0, 1.0)), current_step=(91, 314, 314), order=(0, 1, 2), axis_labels=('0', '1', '2')), grid=GridCanvas(stride=1, shape=(-1, -1), enabled=False), layers=[<Image layer '...ddings/TS_1_1/TS_1_1_noctf.mrc' at 0x7f0c2a582e00>, <Labels layer 'UMAP' at 0x7f0b19471ff0>], help='use <1> for activate the label eraser, use <2> for activate the paint brush, use <3> for activate the fill bucket, use <4> for pick mode', status={'layer_base': 'UMAP', 'source_type': '', 'plugin': '', 'coordinates': ' [91 763 462]'}, tooltip=Tooltip(visible=False, text=''), theme='dark', title='napari', mouse_over_canvas=True, mouse_move_callbacks=[], mouse_drag_callbacks=[functools.partial(<function drag_circle_callback at 0x7f0c2a5563b0>, <napari_clusters_plotter._plotter.PlotterWidget object at 0x7f0c2875e560>)], mouse_double_click_callbacks=[], mouse_wheel_callbacks=[<function dims_scroll at 0x7f0c88d2a170>], _persisted_mouse_event={}, _mouse_drag_gen={}, _mouse_wheel_gen={}, keymap={})
event = <ReadOnlyWrapper at 0x7f0c01647040 for MouseEvent at 0x7f0c288d1ed0>
122 # if function returns a generator then try to iterate it
123 if inspect.isgenerator(gen):
File ~/.local/lib/python3.10/site-packages/napari_tomotwin/anchor_tool.py:50, in drag_circle_callback(plotter_widget=<napari_clusters_plotter._plotter.PlotterWidget object>, viewer=Viewer(camera=Camera(center=(0.0, 314.5, 314.5),...ouse_drag_gen={}, _mouse_wheel_gen={}, keymap={}), event=<ReadOnlyWrapper at 0x7f0c01647040 for MouseEvent>)
49 def drag_circle_callback(plotter_widget, viewer, event):
---> 50 data_coordinates = plotter_widget.layer_select.value.world_to_data(
plotter_widget = <napari_clusters_plotter._plotter.PlotterWidget object at 0x7f0c2875e560>
event = <ReadOnlyWrapper at 0x7f0c01647040 for MouseEvent at 0x7f0c288d1ed0>
51 event.position
52 )
53 _draw_circle(
54 plotter_widget,
55 data_coordinates,
56 plotter_widget.layer_select.value,
57 plotter_widget.layer_select.value.features,
58 )
AttributeError: 'PlotterWidget' object has no attribute 'layer_select'
Do you have any suggestions on how to resolve this?
Hi team!
While working on conda-forge/napari-tomotwin-feedstock#7, we found that magicgui
is directly imported by the code (see https://github.com/search?q=repo%3AMPI-Dortmund%2Fnapari-tomotwin%20magicgui&type=code) but it is not currently being declared as a requirement.
Could you please fix this for the next release?
Cheers ๐
So here is what I did:
napari path/to/tomo.mrc path/to/umap/tomo_label_mask.mrci
Then: Plugins -> Cluster UMAP Embeddings -> Select File (umap) -> Load
I dont see any problem here. And yes, you need to provide the label_mask!
Originally posted by @thorstenwagner in MPI-Dortmund/tomotwin-cryoet#15 (reply in thread)
The plugin should check if a label mask is provided. Otherwise, load should not be clickable.
If you click in the tomogram to see the position of the embedding it crashes with an exception:
Error
File "/mnt/data/twagner/Projects/napari-tomotwin/src/napari_tomotwin/load_umap.py", line 24, in _draw_circle
umap['label'] == val, [plotter_widget.plot_x_axis.currentText(), plotter_widget.plot_y_axis.currentText()]]
AttributeError: 'NoneType' object has no attribute 'plot_x_axis'
Observed that on 11k x 8k micrographs when picking particles manually.
On the non low pass filtered image stack it works fine. On the band pass filtered stack each pick takes 3-5 seconds to appear.
Any idea @mstabrin ? Could it be related to your proxy?
Data is here: agraunser/transfer/Thorsten/Oleg (not public)
But I also confirmed on another system that there's a problem with the PyQt bits
label_layer.visible = 1 AttributeError: 'NoneType' object has no attribute 'visible'
When does that happen? I need to reproduce it to fix it.
Originally posted by @thorstenwagner in MPI-Dortmund/tomotwin-cryoet#15 (comment)
"Your cluster size (50000) is bigger then 50000. Make a random sample to calculate medoid."
Cluster size is wrong...
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.