sanderslab / magellanmapper

MagellanMapper is a graphical interface for 3D bioimage annotation, atlas registration, and regional quantification
BSD 3-Clause "New" or "Revised" License
21 stars 3 forks source link

Crashes at Basic Protocol 3 step 6 "Save/restore detections" #10

Closed SaibotMagd closed 3 years ago

SaibotMagd commented 3 years ago

Hello, I go through the basic protocols right now and it crashes when I try to reload the ROI I set before: Started Mag with: python run.py --img sample_region.czi --roi_profile lightsheet --offset 30,35,30 --size 25,25,12

I tried to save a second ROI, so the ROI list would be longer, so maybe the "out-of-range" doesn't match but it gave me the same result.

Full output:

Set filenames to ['/home/tgottsch/Atlas_project/magellanmapper/examples/sample_region/sample_region.czi'], current filename /home/tgottsch/Atlas_project/magellanmapper/examples/sample_region/sample_region.czi
Set ROI offsets to [(30, 35, 30)], current offset (30, 35, 30) (x,y,z)
Set ROI sizes to [(25, 25, 12)], current size (25, 25, 12) (x,y,z)
Updating ROI profile for channel 0
Set default (channel 0) ROI profile: default,lightsheet
Set atlas profile to default
setting up Matplotlib style default
applying theme DEFAULT
Loaded database from magmap.db
set multiprocessing start method to fork
Loading main image
filename: /home/tgottsch/Atlas_project/magellanmapper/examples/sample_region/sample_region.czi
filename_base: /home/tgottsch/Atlas_project/magellanmapper/examples/sample_region/sample_region
Reading image metadata from /home/tgottsch/Atlas_project/magellanmapper/examples/sample_region/sample_region_meta.npz
unable to load scaling from archive, will ignore
unable to load plane from archive, will ignore
loaded image5d version number 14
names: ['sample_region']
sizes [[  1  51 200 200   2]]
set resolutions to [[5.488412   1.13827774 1.13827774]]
magnification: 5.0
zoom: 0.8
set near_min to [236. 198.]
set near_max to [4374.  902.]
Set vmax_overview to [4811.4  992.2]
image5d shape: (1, 51, 200, 200, 2)
set border to zeros
set border to [0. 0. 0.]
setting up Matplotlib style seaborn
applying theme DEFAULT
stale {<ViewerTabs.ROI_ED: 1>: True, <ViewerTabs.ATLAS_ED: 2>: True, <ViewerTabs.MAYAVI: 3>: True}
got None selected
no roi found
Changed channel to [0, 1]
x: 30, y: 0, z: 0
x: 30, y: 35, z: 0
x: 30, y: 35, z: 30
camera: {'view': (0.0, 0.0, 1.0, array([0., 0., 0.])), 'roll': 0.0}
view: (75.00000000000001, 140.0, 100.0, array([0., 0., 0.]))
roll: -175.0
using ROI offset [30, 35, 30], size of [25 25 12] (x,y,z)
Initiating ROI Editor
margin: None, savefig: png
zoom_levels: [1.         1.69947907] max_zoom: 2.6666666666666665
2D border: [0. 0. 0.]
z_overview: 30
plane xy downsampling factors by image: [1, 1, 1]
plane xy downsampling factors by image: [1, 1, 1]
2D plot time: 0.4261758327484131
findfont: Font family ['sans-serif'] not found. Falling back to DejaVu Sans.
findfont: Font family ['sans-serif'] not found. Falling back to DejaVu Sans.
got offset (30,35,30) of size (25,25,12)
got None selected
no roi found
Changed channel to [0]
Exception occurred in traits notification handler for object: <magmap.gui.visualizer.Visualization object at 0x7fb3f97138e0>, trait: rois_check_list, old value: None selected, new value: offset (30,35,30) of size (25,25,12)
Traceback (most recent call last):
  File "/home/tgottsch/anaconda3/envs/mag/lib/python3.6/site-packages/traits/trait_notifiers.py", line 522, in _dispatch_change_event
    self.dispatch(handler, *args)
  File "/home/tgottsch/anaconda3/envs/mag/lib/python3.6/site-packages/traits/trait_notifiers.py", line 484, in dispatch
    handler(*args)
  File "/home/tgottsch/Atlas_project/magellanmapper/magmap/gui/visualizer.py", line 2306, in load_roi
    blob_matches = config.db.select_blob_matches(roi_id)
  File "/home/tgottsch/Atlas_project/magellanmapper/magmap/io/sqlite.py", line 905, in select_blob_matches
    return self._parse_blob_matches(self.cur.fetchall())
  File "/home/tgottsch/Atlas_project/magellanmapper/magmap/io/sqlite.py", line 887, in _parse_blob_matches
    df = df_io.dict_to_data_frame(rows, records_cols=rows[0].keys())
IndexError: list index out of range
Traceback (most recent call last):
  File "/home/tgottsch/anaconda3/envs/mag/lib/python3.6/site-packages/traitsui/qt4/check_list_editor.py", line 129, in update_object
    self.value = value
  File "/home/tgottsch/anaconda3/envs/mag/lib/python3.6/site-packages/traitsui/editor.py", line 731, in _set_value
    self.ui.do_undoable(self.__set_value, value)
  File "/home/tgottsch/anaconda3/envs/mag/lib/python3.6/site-packages/traitsui/ui.py", line 658, in do_undoable
    action(*args, **kw)
  File "/home/tgottsch/anaconda3/envs/mag/lib/python3.6/site-packages/traitsui/editor.py", line 685, in __set_value
    method(self.ui.info, self.object, name, value)
  File "/home/tgottsch/anaconda3/envs/mag/lib/python3.6/site-packages/traitsui/handler.py", line 286, in setattr
    setattr(object, name, value)
  File "/home/tgottsch/anaconda3/envs/mag/lib/python3.6/site-packages/traits/trait_notifiers.py", line 476, in __call__
    self.notify_listener(self, object, trait_name, old, new)
  File "/home/tgottsch/anaconda3/envs/mag/lib/python3.6/site-packages/traits/trait_notifiers.py", line 550, in _notify_method_listener
    object, trait_name, old, new, listener
  File "/home/tgottsch/anaconda3/envs/mag/lib/python3.6/site-packages/traits/trait_notifiers.py", line 530, in _dispatch_change_event
    handle_exception(object, trait_name, old, new)
  File "/home/tgottsch/anaconda3/envs/mag/lib/python3.6/site-packages/traits/trait_notifiers.py", line 148, in _handle_exception
    raise excp
  File "/home/tgottsch/anaconda3/envs/mag/lib/python3.6/site-packages/traits/trait_notifiers.py", line 522, in _dispatch_change_event
    self.dispatch(handler, *args)
  File "/home/tgottsch/anaconda3/envs/mag/lib/python3.6/site-packages/traits/trait_notifiers.py", line 484, in dispatch
    handler(*args)
  File "/home/tgottsch/Atlas_project/magellanmapper/magmap/gui/visualizer.py", line 2306, in load_roi
    blob_matches = config.db.select_blob_matches(roi_id)
  File "/home/tgottsch/Atlas_project/magellanmapper/magmap/io/sqlite.py", line 905, in select_blob_matches
    return self._parse_blob_matches(self.cur.fetchall())
  File "/home/tgottsch/Atlas_project/magellanmapper/magmap/io/sqlite.py", line 887, in _parse_blob_matches
    df = df_io.dict_to_data_frame(rows, records_cols=rows[0].keys())
IndexError: list index out of range
Aborted
SaibotMagd commented 3 years ago

Update: I tried the same procedure on another OS (Ubuntu 20 instead of Debian 8) using a fresh installation. Result stays the same but the error changed:


traits - ERROR - Exception occurred in traits notification handler for object: <magmap.gui.visualizer.Visualization object at 0x7f0e7dd15eb8>, trait: rois_check_list, old value: None selected, new value: offset (30,35,30) of size (25,25,12)
Traceback (most recent call last):
  File "/home/nrd/anaconda3/envs/mag/lib/python3.6/site-packages/traits/trait_notifiers.py", line 524, in _dispatch_change_event
    self.dispatch(handler, *args)
  File "/home/nrd/anaconda3/envs/mag/lib/python3.6/site-packages/traits/trait_notifiers.py", line 486, in dispatch
    handler(*args)
  File "/home/nrd/magellanmapper/magmap/gui/visualizer.py", line 2598, in load_roi
    self.detect_blobs(segs=blobs, blob_matches=blob_matches)
  File "/home/nrd/magellanmapper/magmap/gui/visualizer.py", line 2158, in detect_blobs
    self.redraw_selected_viewer(clear=False)
  File "/home/nrd/magellanmapper/magmap/gui/visualizer.py", line 1937, in redraw_selected_viewer
    self._launch_roi_editor()
  File "/home/nrd/magellanmapper/magmap/gui/visualizer.py", line 2374, in _launch_roi_editor
    *stack_args, **stack_args_named, zoom_levels=2)
  File "/home/nrd/magellanmapper/magmap/gui/roi_editor.py", line 905, in plot_2d_stack
    cmap_labels=cmap_labels)
  File "/home/nrd/magellanmapper/magmap/gui/roi_editor.py", line 1309, in show_subplot
    self.blobs.blob_matches.get_blobs(1),
  File "/home/nrd/magellanmapper/magmap/cv/colocalizer.py", line 106, in get_blobs
    if col.value not in self.df:
TypeError: argument of type 'NoneType' is not iterable
Unhandled Python exception
Aborted (core dumped)
yoda-vid commented 3 years ago

Thanks for finding this, @SaibotMagd ! I reproduced it on my end as well, a regression from a new feature added since the Current Protocols. I had partially fixed it (the error in your first stacktrace) but evidently not completely...thanks for reporting it.

I pushed a fix in PR #12 . If you are on Git, you can access it by grabbing the branch: git fetch; git checkout fix_absent_blob_matches

Please let me know if it works for you and I can merge it.

SaibotMagd commented 3 years ago

It seems to work pretty well. I checked the reloading of cell detection after switch to another roi and the reload after complete restart of mag. Both works great. Thanks alot!

yoda-vid commented 3 years ago

Great, thanks for testing it and glad it worked for you!