Describe the bug
When small single cell objects are in the input list and contour_sample_num is small, there is a chance to trigger the bug. Low number of vertices sampled is likely to cause the problem.
To Reproduce
Traceback (most recent call last):
File "D:\LiveCellTracker-dev\livecellx\core\sct_operator.py", line 1163, in _move_span
sct_operator.setup_by_timespan(cur_span, contour_sample_key=contour_sample_num_key)
File "D:\LiveCellTracker-dev\livecellx\core\sct_operator.py", line 392, in setup_by_timespan
shape_layer = NapariVisualizer.gen_trajectories_shapes(
File "D:\LiveCellTracker-dev\livecellx\core\napari_visualizer.py", line 72, in gen_trajectories_shapes
shape_layer = viewer.add_shapes(
File "c:\Users\dummy\anaconda3\envs\livecell-work\lib\site-packages\napari\components\viewer_model.py", line 4, in add_shapes
import itertools
File "c:\Users\dummy\anaconda3\envs\livecell-work\lib\site-packages\napari\layers\shapes\shapes.py", line 532, in init
self._init_shapes(
File "c:\Users\dummy\anaconda3\envs\livecell-work\lib\site-packages\napari\layers\shapes\shapes.py", line 2102, in _init_shapes
self._add_shapes(
File "c:\Users\dummy\anaconda3\envs\livecell-work\lib\site-packages\napari\layers\shapes\shapes.py", line 2217, in _add_shapes
self._add_shapes_to_view(shape_inputs, self._data_view)
File "c:\Users\dummy\anaconda3\envs\livecell-work\lib\site-packages\napari\layers\shapes\shapes.py", line 2229, in _add_shapes_to_view
sh_inp = tuple(
File "c:\Users\dummy\anaconda3\envs\livecell-work\lib\site-packages\napari\layers\shapes\shapes.py", line 2231, in
shape_classes[ShapeType(st)](
File "c:\Users\dummy\anaconda3\envs\livecell-work\lib\site-packages\napari\layers\shapes_shapes_models\polygon.py", line 30, in init
super().init(
File "c:\Users\dummy\anaconda3\envs\livecell-work\lib\site-packages\napari\layers\shapes_shapes_models_polgyon_base.py", line 59, in init
self.data = data
File "c:\Users\dummy\anaconda3\envs\livecell-work\lib\site-packages\napari\layers\shapes_shapes_models_polgyon_base.py", line 83, in data
self._update_displayed_data()
File "c:\Users\dummy\anaconda3\envs\livecell-work\lib\site-packages\napari\layers\shapes_shapes_models_polgyon_base.py", line 117, in _update_displayed_data
self._set_meshes(data, face=self._filled, closed=self._closed)
File "c:\Users\dummy\anaconda3\envs\livecell-work\lib\site-packages\napari\layers\shapes_shapes_models\shape.py", line 223, in _set_meshes
vertices, triangles = triangulate_face(clean_data)
File "c:\Users\dummy\anaconda3\envs\livecell-work\lib\site-packages\napari\layers\shapes_shapes_utils.py", line 563, in triangulate_face
vertices, triangles = PolygonData(vertices=data).triangulate()
File "c:\Users\dummy\anaconda3\envs\livecell-work\lib\site-packages\vispy\geometry\polygon.py", line 125, in triangulate
tri.triangulate()
File "c:\Users\dummy\anaconda3\envs\livecell-work\lib\site-packages\vispy\geometry\triangulation.py", line 186, in triangulate
self._edge_event(i, j)
File "c:\Users\dummy\anaconda3\envs\livecell-work\lib\site-packages\vispy\geometry\triangulation.py", line 322, in _edge_event
next_tri = self._adjacent_tri(last_edge, last_tri)
File "c:\Users\dummy\anaconda3\envs\livecell-work\lib\site-packages\vispy\geometry\triangulation.py", line 460, in _adjacent_tri
i = [x for x in i if x not in edge][0]
File "c:\Users\dummy\anaconda3\envs\livecell-work\lib\site-packages\vispy\geometry\triangulation.py", line 460, in
i = [x for x in i if x not in edge][0]
TypeError: argument of type 'NoneType' is not iterable
Expected behavior
A clear and concise description of what you expected to happen.
Screenshots
Desktop (please complete the following information):
Describe the bug When small single cell objects are in the input list and contour_sample_num is small, there is a chance to trigger the bug. Low number of vertices sampled is likely to cause the problem.
To Reproduce Traceback (most recent call last): File "D:\LiveCellTracker-dev\livecellx\core\sct_operator.py", line 1163, in _move_span sct_operator.setup_by_timespan(cur_span, contour_sample_key=contour_sample_num_key) File "D:\LiveCellTracker-dev\livecellx\core\sct_operator.py", line 392, in setup_by_timespan shape_layer = NapariVisualizer.gen_trajectories_shapes( File "D:\LiveCellTracker-dev\livecellx\core\napari_visualizer.py", line 72, in gen_trajectories_shapes shape_layer = viewer.add_shapes( File "c:\Users\dummy\anaconda3\envs\livecell-work\lib\site-packages\napari\components\viewer_model.py", line 4, in add_shapes import itertools File "c:\Users\dummy\anaconda3\envs\livecell-work\lib\site-packages\napari\layers\shapes\shapes.py", line 532, in init self._init_shapes( File "c:\Users\dummy\anaconda3\envs\livecell-work\lib\site-packages\napari\layers\shapes\shapes.py", line 2102, in _init_shapes self._add_shapes( File "c:\Users\dummy\anaconda3\envs\livecell-work\lib\site-packages\napari\layers\shapes\shapes.py", line 2217, in _add_shapes self._add_shapes_to_view(shape_inputs, self._data_view) File "c:\Users\dummy\anaconda3\envs\livecell-work\lib\site-packages\napari\layers\shapes\shapes.py", line 2229, in _add_shapes_to_view sh_inp = tuple( File "c:\Users\dummy\anaconda3\envs\livecell-work\lib\site-packages\napari\layers\shapes\shapes.py", line 2231, in
shape_classes[ShapeType(st)](
File "c:\Users\dummy\anaconda3\envs\livecell-work\lib\site-packages\napari\layers\shapes_shapes_models\polygon.py", line 30, in init
super().init(
File "c:\Users\dummy\anaconda3\envs\livecell-work\lib\site-packages\napari\layers\shapes_shapes_models_polgyon_base.py", line 59, in init
self.data = data
File "c:\Users\dummy\anaconda3\envs\livecell-work\lib\site-packages\napari\layers\shapes_shapes_models_polgyon_base.py", line 83, in data
self._update_displayed_data()
File "c:\Users\dummy\anaconda3\envs\livecell-work\lib\site-packages\napari\layers\shapes_shapes_models_polgyon_base.py", line 117, in _update_displayed_data
self._set_meshes(data, face=self._filled, closed=self._closed)
File "c:\Users\dummy\anaconda3\envs\livecell-work\lib\site-packages\napari\layers\shapes_shapes_models\shape.py", line 223, in _set_meshes
vertices, triangles = triangulate_face(clean_data)
File "c:\Users\dummy\anaconda3\envs\livecell-work\lib\site-packages\napari\layers\shapes_shapes_utils.py", line 563, in triangulate_face
vertices, triangles = PolygonData(vertices=data).triangulate()
File "c:\Users\dummy\anaconda3\envs\livecell-work\lib\site-packages\vispy\geometry\polygon.py", line 125, in triangulate
tri.triangulate()
File "c:\Users\dummy\anaconda3\envs\livecell-work\lib\site-packages\vispy\geometry\triangulation.py", line 186, in triangulate
self._edge_event(i, j)
File "c:\Users\dummy\anaconda3\envs\livecell-work\lib\site-packages\vispy\geometry\triangulation.py", line 322, in _edge_event
next_tri = self._adjacent_tri(last_edge, last_tri)
File "c:\Users\dummy\anaconda3\envs\livecell-work\lib\site-packages\vispy\geometry\triangulation.py", line 460, in _adjacent_tri
i = [x for x in i if x not in edge][0]
File "c:\Users\dummy\anaconda3\envs\livecell-work\lib\site-packages\vispy\geometry\triangulation.py", line 460, in
i = [x for x in i if x not in edge][0]
TypeError: argument of type 'NoneType' is not iterable
Expected behavior A clear and concise description of what you expected to happen.
Screenshots
Desktop (please complete the following information):