Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error is raised if no cells are detected. #306

Open
adamltyson opened this issue May 23, 2023 · 0 comments
Open

Error is raised if no cells are detected. #306

adamltyson opened this issue May 23, 2023 · 0 comments
Labels
bug Something isn't working cellfinder-napari Issue concerns the napari plugin

Comments

@adamltyson
Copy link
Member

Full traceback
---------------------------------------------------------------------------
KeyError                                  Traceback (most recent call last)
File ~/miniconda3/envs/image-analysis3/lib/python3.10/site-packages/cellfinder_napari/detect/detect.py:190, in detect_widget.<locals>.widget.<locals>.<lambda>(points=[])
    179 misc_inputs = MiscInputs(
    180     start_plane, end_plane, n_free_cpus, analyse_local, debug
    181 )
    183 worker = Worker(
    184     data_inputs,
    185     detection_inputs,
    186     classification_inputs,
    187     misc_inputs,
    188 )
    189 worker.returned.connect(
--> 190     lambda points: add_layers(points, viewer=viewer)
        points = []
        viewer = Viewer(axes=Axes(visible=False, labels=True, colored=True, dashed=False, arrows=True), camera=Camera(center=(0.0, 1933.5, 2707.5), zoom=0.20065020022629942, angles=(0.0, 0.0, 90.0), perspective=0.0, interactive=True), cursor=Cursor(position=(15.0, 3802.424157249758, -659.055301633289), scaled=True, size=1, style=<CursorStyle.STANDARD: 'standard'>), dims=Dims(ndim=3, ndisplay=2, last_used=0, range=((0.0, 30.0, 1.0), (0.0, 3868.0, 1.0), (0.0, 5416.0, 1.0)), current_step=(15, 1934, 2708), order=(0, 1, 2), axis_labels=('0', '1', '2')), grid=GridCanvas(stride=1, shape=(-1, -1), enabled=False), layers=[<Image layer 'ch02' at 0x7f707f2507f0>, <Image layer 'ch00' at 0x7f707dd48ac0>], scale_bar=ScaleBar(visible=False, colored=False, color=<class 'numpy.ndarray'> (4,) float32, ticks=True, position=<Position.BOTTOM_RIGHT: 'bottom_right'>, font_size=10.0, box=False, box_color=<class 'numpy.ndarray'> (4,) float32, unit=None), text_overlay=TextOverlay(visible=False, color=<class 'numpy.ndarray'> (4,) float32, font_size=10.0, position=<TextOverlayPosition.TOP_LEFT: 'top_left'>, text=''), overlays=Overlays(interaction_box=InteractionBox(points=None, show=False, show_handle=False, show_vertices=False, selection_box_drag=None, selection_box_final=None, transform_start=<napari.utils.transforms.transforms.Affine object at 0x7f7035072800>, transform_drag=<napari.utils.transforms.transforms.Affine object at 0x7f7035072860>, transform_final=<napari.utils.transforms.transforms.Affine object at 0x7f70350728c0>, transform=<napari.utils.transforms.transforms.Affine object at 0x7f7035072920>, allow_new_selection=True, selected_vertex=None)), help='', status='', tooltip=Tooltip(visible=False, text=''), theme='dark', title='napari', mouse_over_canvas=False, mouse_move_callbacks=[<function InteractionBoxMouseBindings.initialize_mouse_events.<locals>.mouse_move at 0x7f70bbe441f0>], mouse_drag_callbacks=[<function InteractionBoxMouseBindings.initialize_mouse_events.<locals>.mouse_drag at 0x7f70bbe45090>], mouse_double_click_callbacks=[], mouse_wheel_callbacks=[<function dims_scroll at 0x7f7037d33880>], _persisted_mouse_event={}, _mouse_drag_gen={}, _mouse_wheel_gen={}, keymap={'Shift': <function InteractionBoxMouseBindings.initialize_key_events.<locals>.hold_to_lock_aspect_ratio at 0x7f70bbe87910>, 'Control-Shift-R': <function InteractionBoxMouseBindings._reset_active_layer_affine at 0x7f70bbf1d630>, 'Control-Shift-A': <function InteractionBoxMouseBindings._transform_active_layer at 0x7f70bbf1d5a0>})
    191 )
    193 # Make sure if the worker emits an error, it is propagated to this thread
    194 def reraise(e):

File ~/miniconda3/envs/image-analysis3/lib/python3.10/site-packages/cellfinder_napari/utils.py:55, in add_layers(points=[], viewer=Viewer(axes=Axes(visible=False, labels=True, col...ings._transform_active_layer at 0x7f70bbf1d5a0>}))
     51 def add_layers(points: List[Cell], viewer: napari.Viewer) -> None:
     52     """
     53     Adds classified cell candidates as two separate point layers to the napari viewer.
     54     """
---> 55     detected, rejected = cells_to_array(points)
        points = []
     57     viewer.add_points(
     58         rejected,
     59         name="Rejected",
   (...)
     66         metadata=dict(point_type=Cell.UNKNOWN),
     67     )
     68     viewer.add_points(
     69         detected,
     70         name="Detected",
   (...)
     76         metadata=dict(point_type=Cell.CELL),
     77     )

File ~/miniconda3/envs/image-analysis3/lib/python3.10/site-packages/cellfinder_napari/utils.py:97, in cells_to_array(cells=[])
     95 def cells_to_array(cells: List[Cell]) -> Tuple[np.ndarray, np.ndarray]:
     96     df = pd.DataFrame([c.to_dict() for c in cells])
---> 97     points = cells_df_as_np(df[df["type"] == Cell.CELL])
        df = Empty DataFrame
Columns: []
Index: []
        Cell.CELL = 2
     98     rejected = cells_df_as_np(df[df["type"] == Cell.UNKNOWN])
     99     return points, rejected

File ~/miniconda3/envs/image-analysis3/lib/python3.10/site-packages/pandas/core/frame.py:3761, in DataFrame.__getitem__(self=Empty DataFrame
Columns: []
Index: [], key='type')
   3759 if self.columns.nlevels > 1:
   3760     return self._getitem_multilevel(key)
-> 3761 indexer = self.columns.get_loc(key)
        key = 'type'
        self = Empty DataFrame
Columns: []
Index: []
   3762 if is_integer(indexer):
   3763     indexer = [indexer]

File ~/miniconda3/envs/image-analysis3/lib/python3.10/site-packages/pandas/core/indexes/range.py:349, in RangeIndex.get_loc(self=RangeIndex(start=0, stop=0, step=1), key='type')
    347         raise KeyError(key) from err
    348 if isinstance(key, Hashable):
--> 349     raise KeyError(key)
        key = 'type'
    350 self._check_indexing_error(key)
    351 raise KeyError(key)

KeyError: 'type'

@adamltyson adamltyson added the bug Something isn't working label May 23, 2023
@willGraham01 willGraham01 added the cellfinder-napari Issue concerns the napari plugin label Jan 3, 2024
@willGraham01 willGraham01 transferred this issue from brainglobe/cellfinder-napari Jan 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working cellfinder-napari Issue concerns the napari plugin
Projects
Status: Backlog
Development

No branches or pull requests

2 participants