jluethi / napari-feature-visualization

Visualizing feature measurements on label images in napari
BSD 3-Clause "New" or "Revised" License
10 stars 4 forks source link

regionprops widget doesn't work for 3D images #6

Closed jluethi closed 3 years ago

jluethi commented 3 years ago

When using the regionprops widget with 3D images, I get the following traceback. @haesleinhuepf

Traceback (most recent call last):
  File "/Users/joel/opt/miniconda3/envs/napari-tests/lib/python3.9/site-packages/magicgui/widgets/_bases/value_widget.py", line 44, in <lambda>
    lambda *x: self.changed(value=x[0] if x else None)
  File "/Users/joel/opt/miniconda3/envs/napari-tests/lib/python3.9/site-packages/magicgui/events.py", line 655, in __call__
    self._invoke_callback(cb, event)
  File "/Users/joel/opt/miniconda3/envs/napari-tests/lib/python3.9/site-packages/magicgui/events.py", line 676, in _invoke_callback
    _handle_exception(
  File "/Users/joel/opt/miniconda3/envs/napari-tests/lib/python3.9/site-packages/magicgui/events.py", line 140, in _handle_exception
    raise value
  File "/Users/joel/opt/miniconda3/envs/napari-tests/lib/python3.9/site-packages/magicgui/events.py", line 674, in _invoke_callback
    cb(event)
  File "/Users/joel/opt/miniconda3/envs/napari-tests/lib/python3.9/site-packages/magicgui/widgets/_function_gui.py", line 187, in _disable_button_and_call
    self.__call__()
  File "/Users/joel/opt/miniconda3/envs/napari-tests/lib/python3.9/site-packages/magicgui/widgets/_function_gui.py", line 285, in __call__
    value = self._function(*bound.args, **bound.kwargs)
  File "/Users/joel/Dropbox/Joel/PelkmansLab/Code/napari_tests/napari-feature-visualization/napari_feature_visualization/_regionprops.py", line 59, in regionprops
    table = regionprops_table(np.asarray(labels).astype(int), intensity_image=np.asarray(image),
  File "/Users/joel/opt/miniconda3/envs/napari-tests/lib/python3.9/site-packages/skimage/measure/_regionprops.py", line 862, in regionprops_table
    return _props_to_dict(
  File "/Users/joel/opt/miniconda3/envs/napari-tests/lib/python3.9/site-packages/skimage/measure/_regionprops.py", line 671, in _props_to_dict
    rp = getattr(r, prop)
  File "/Users/joel/opt/miniconda3/envs/napari-tests/lib/python3.9/site-packages/skimage/measure/_regionprops.py", line 186, in wrapper
    cache[prop] = f(obj)
  File "/Users/joel/opt/miniconda3/envs/napari-tests/lib/python3.9/site-packages/skimage/measure/_regionprops.py", line 302, in convex_area
    return np.sum(self.convex_image)
  File "/Users/joel/opt/miniconda3/envs/napari-tests/lib/python3.9/site-packages/skimage/measure/_regionprops.py", line 186, in wrapper
    cache[prop] = f(obj)
  File "/Users/joel/opt/miniconda3/envs/napari-tests/lib/python3.9/site-packages/skimage/measure/_regionprops.py", line 308, in convex_image
    return convex_hull_image(self.image)
  File "/Users/joel/opt/miniconda3/envs/napari-tests/lib/python3.9/site-packages/skimage/morphology/convex_hull.py", line 118, in convex_hull_image
    hull0 = ConvexHull(coords)
  File "qhull.pyx", line 2433, in scipy.spatial.qhull.ConvexHull.__init__
  File "qhull.pyx", line 356, in scipy.spatial.qhull._Qhull.__init__
scipy.spatial.qhull.QhullError: QH6013 qhull input error: input is less than 3-dimensional since all points have the same x coordinate    0

While executing:  | qhull i Qt
Options selected for Qhull 2019.1.r 2019/06/21:
  run-id 1654776135  incidence  Qtriangulate  _pre-merge  _zero-centrum
  _max-width  4  Error-roundoff 5,5e-15  _one-merge 3,9e-14
  _near-inside 1,9e-13  Visible-distance 1,1e-14  U-max-coplanar 1,1e-14
  Width-outside 2,2e-14  _wide-facet 6,7e-14  _maxoutside 4,4e-14

(done with the example data in the napari-feature-vis_test_case.ipynb notebook)

haesleinhuepf commented 3 years ago

I'm just adding a link to a related issue. If this one is resolved, also our 3D-measurements can include the convex hull-related measurements again: https://github.com/scikit-image/scikit-image/issues/5363