15bonte / cut-detector

Automatic micro-tubules cut detector.
BSD 3-Clause "New" or "Revised" License
1 stars 1 forks source link

KeyError: 215 happened when running the whole process #4

Closed Tadvedissian closed 10 months ago

Tadvedissian commented 10 months ago

We obtained this newerror message while running the analysis:

Detect MT cut (28/33)... Detect MT cut (29/33)...

KeyError Traceback (most recent call last) File src\psygnal_signal.py:990, in _run_emit_loop()

File src\psygnal_weak_callback.py:321, in cb()

File C:\ProgramData\anaconda3\envs\cut_detector_7\lib\site-packages\magicgui\widgets_function_gui.py:224, in FunctionGui.init.._disable_button_and_call() 223 try: --> 224 self.call() self = <FunctionGui whole_process(img_layer: napari.layers.image.image.Image = <Image layer 'siSpastin-2' at 0x213db39a2f0>, img_viewer: napari.viewer.Viewer = Viewer(camera=Camera(center=(0.0, 549.5, 799.5), zoom=0.1045, angles=(0.0, 0.0, 90.0), perspective=0.0, mouse_pan=True, mouse_zoom=True), cursor=Cursor(position=(142.0, 1.0, -546.1938136226956, 1593.7583249897527), scaled=True, size=1, style=<CursorStyle.STANDARD: 'standard'>), dims=Dims(ndim=4, ndisplay=2, last_used=0, range=((0.0, 285.0, 1.0), (0.0, 3.0, 1.0), (0.0, 1100.0, 1.0), (0.0, 1600.0, 1.0)), current_step=(142, 1, 549, 799), order=(0, 1, 2, 3), axis_labels=('0', '1', '2', '3')), grid=GridCanvas(stride=1, shape=(-1, -1), enabled=False), layers=[<Image layer 'siSpastin-2' at 0x213db39a2f0>], help='use <2> for transform', status='', tooltip=Tooltip(visible=False, text=''), theme='dark', title='napari', mouse_over_canvas=False, mouse_move_callbacks=[], mouse_drag_callbacks=[], mouse_double_click_callbacks=[], mouse_wheel_callbacks=[<function dims_scroll at 0x00000213B34D3B50>], _persisted_mouse_event={}, _mouse_drag_gen={}, _mouse_wheel_gen={}, keymap={}), fiji_dir: str = WindowsPath('C:/Users/Public/Downloads/Fiji.app'), default_model_check_box: str = True, segmentation_model: str = WindowsPath('.'), fast_mode_check_box: bool = True, save_check_box: bool = True, movies_save_dir: str = WindowsPath('C:/Users/taadvedi/Desktop/siSpastin-2'), results_save_dir: str = WindowsPath('C:/Users/taadvedi/Desktop/siSpastin-2'))> 225 finally:

File C:\ProgramData\anaconda3\envs\cut_detector_7\lib\site-packages\magicgui\widgets_function_gui.py:342, in FunctionGui.call(self=<FunctionGui whole_process(img_layer: napari.lay...wsPath('C:/Users/taadvedi/Desktop/siSpastin-2'))>, *args=(), *kwargs={}) 341 with _function_name_pointing_to_widget(self): --> 342 value = self._function(bound.args, **bound.kwargs) self = <FunctionGui whole_process(img_layer: napari.layers.image.image.Image = <Image layer 'siSpastin-2' at 0x213db39a2f0>, img_viewer: napari.viewer.Viewer = Viewer(camera=Camera(center=(0.0, 549.5, 799.5), zoom=0.1045, angles=(0.0, 0.0, 90.0), perspective=0.0, mouse_pan=True, mouse_zoom=True), cursor=Cursor(position=(142.0, 1.0, -546.1938136226956, 1593.7583249897527), scaled=True, size=1, style=<CursorStyle.STANDARD: 'standard'>), dims=Dims(ndim=4, ndisplay=2, last_used=0, range=((0.0, 285.0, 1.0), (0.0, 3.0, 1.0), (0.0, 1100.0, 1.0), (0.0, 1600.0, 1.0)), current_step=(142, 1, 549, 799), order=(0, 1, 2, 3), axis_labels=('0', '1', '2', '3')), grid=GridCanvas(stride=1, shape=(-1, -1), enabled=False), layers=[<Image layer 'siSpastin-2' at 0x213db39a2f0>], help='use <2> for transform', status='', tooltip=Tooltip(visible=False, text=''), theme='dark', title='napari', mouse_over_canvas=False, mouse_move_callbacks=[], mouse_drag_callbacks=[], mouse_double_click_callbacks=[], mouse_wheel_callbacks=[<function dims_scroll at 0x00000213B34D3B50>], _persisted_mouse_event={}, _mouse_drag_gen={}, _mouse_wheel_gen={}, keymap={}), fiji_dir: str = WindowsPath('C:/Users/Public/Downloads/Fiji.app'), default_model_check_box: str = True, segmentation_model: str = WindowsPath('.'), fast_mode_check_box: bool = True, save_check_box: bool = True, movies_save_dir: str = WindowsPath('C:/Users/taadvedi/Desktop/siSpastin-2'), results_save_dir: str = WindowsPath('C:/Users/taadvedi/Desktop/siSpastin-2'))> bound = <BoundArguments (img_layer=<Image layer 'siSpastin-2' at 0x213db39a2f0>, img_viewer=Viewer(camera=Camera(center=(0.0, 549.5, 799.5), zoom=0.1045, angles=(0.0, 0.0, 90.0), perspective=0.0, mouse_pan=True, mouse_zoom=True), cursor=Cursor(position=(142.0, 1.0, -546.1938136226956, 1593.7583249897527), scaled=True, size=1, style=<CursorStyle.STANDARD: 'standard'>), dims=Dims(ndim=4, ndisplay=2, last_used=0, range=((0.0, 285.0, 1.0), (0.0, 3.0, 1.0), (0.0, 1100.0, 1.0), (0.0, 1600.0, 1.0)), current_step=(142, 1, 549, 799), order=(0, 1, 2, 3), axis_labels=('0', '1', '2', '3')), grid=GridCanvas(stride=1, shape=(-1, -1), enabled=False), layers=[<Image layer 'siSpastin-2' at 0x213db39a2f0>], help='use <2> for transform', status='', tooltip=Tooltip(visible=False, text=''), theme='dark', title='napari', mouse_over_canvas=False, mouse_move_callbacks=[], mouse_drag_callbacks=[], mouse_double_click_callbacks=[], mouse_wheel_callbacks=[<function dims_scroll at 0x00000213B34D3B50>], _persisted_mouse_event={}, _mouse_drag_gen={}, _mouse_wheel_gen={}, keymap={}), fiji_dir=WindowsPath('C:/Users/Public/Downloads/Fiji.app'), default_model_check_box=True, segmentation_model=WindowsPath('.'), fast_mode_check_box=True, save_check_box=True, movies_save_dir=WindowsPath('C:/Users/taadvedi/Desktop/siSpastin-2'), results_save_dir=WindowsPath('C:/Users/taadvedi/Desktop/siSpastin-2'))> self._function = <function whole_process at 0x00000213DB303AC0> 344 self._call_count += 1

File C:\ProgramData\anaconda3\envs\cut_detector_7\lib\site-packages\cut_detector_widget.py:126, in whole_process(img_layer=<Image layer 'siSpastin-2'>, img_viewer=Viewer(camera=Camera(center=(0.0, 549.5, 799.5),...ouse_drag_gen={}, _mouse_wheel_gen={}, keymap={}), fiji_dir=WindowsPath('C:/Users/Public/Downloads/Fiji.app'), default_model_check_box=True, segmentation_model='.', fast_mode_check_box=True, save_check_box=True, movies_save_dir=WindowsPath('C:/Users/taadvedi/Desktop/siSpastin-2'), results_save_dir=WindowsPath('C:/Users/taadvedi/Desktop/siSpastin-2')) 125 # MT cut detection --> 126 perform_mt_cut_detection(raw_video, img_layer.name, exported_mitoses_dir) exported_mitoses_dir = 'C:\Users\taadvedi\AppData\Local\Temp\tmpnoud8ko2' raw_video = <class 'numpy.ndarray'> (285, 1100, 1600, 3) uint16 img_layer = <Image layer 'siSpastin-2' at 0x213db39a2f0> 128 # Results saving

File C:\ProgramData\anaconda3\envs\cut_detector_7\lib\site-packages\cut_detector\widget_functions\mt_cut_detection.py:38, in perform_mt_cut_detection(raw_video=<class 'numpy.ndarray'> (285, 1100, 1600, 3) uint16, video_name='siSpastin-2', exported_mitoses_dir=r'C:\Users\taadvedi\AppData\Local\Temp\tmpnoud8ko2', scaler_path=r'C:\ProgramData\anaconda3\envs\cut_detector_7\lib...ckages\cut_detector\models\svc_bridges/scaler.pkl', model_path=r'C:\ProgramData\anaconda3\envs\cut_detector_7\lib...ackages\cut_detector\models\svc_bridges/model.pkl', hmm_bridges_parameters_file=r'C:\ProgramData\anaconda3\envs\cut_detector_7\lib...es\cut_detector\models\hmm_bridges_parameters.npz') 37 # Perform cut detection ---> 38 mt_cut_detector.update_mt_cut_detection( mt_cut_detector = <cut_detector.factories.mt_cut_detection_factory.MtCutDetectionFactory object at 0x0000021763F64BB0> mitosis_track = <cut_detector.utils.mitosis_track.MitosisTrack object at 0x0000021523A613F0> raw_video = <class 'numpy.ndarray'> (285, 1100, 1600, 3) uint16 scaler_path = 'C:\ProgramData\anaconda3\envs\cut_detector_7\lib\site-packages\cut_detector\models\svc_bridges/scaler.pkl' model_path = 'C:\ProgramData\anaconda3\envs\cut_detector_7\lib\site-packages\cut_detector\models\svc_bridges/model.pkl' hmm_bridges_parameters_file = 'C:\ProgramData\anaconda3\envs\cut_detector_7\lib\site-packages\cut_detector\models\hmm_bridges_parameters.npz' 39 mitosis_track, raw_video, scaler_path, model_path, hmm_bridges_parameters_file 40 ) 42 # Save updated mitosis track

File C:\ProgramData\anaconda3\envs\cut_detector_7\lib\site-packages\cut_detector\factories\mt_cut_detection_factory.py:697, in MtCutDetectionFactory.update_mt_cut_detection(self=, mitosis_track=, video=<class 'numpy.ndarray'> (285, 1100, 1600, 3) uint16, scaler_path=r'C:\ProgramData\anaconda3\envs\cut_detector_7\lib...ckages\cut_detector\models\svc_bridges/scaler.pkl', model_path=r'C:\ProgramData\anaconda3\envs\cut_detector_7\lib...ackages\cut_detector\models\svc_bridges/model.pkl', hmm_bridges_parameters_file=r'C:\ProgramData\anaconda3\envs\cut_detector_7\lib...es\cut_detector\models\hmm_bridges_parameters.npz') 696 first_mt_cut_frame_abs = first_frame + first_mt_cut_frame_rel --> 697 if mitosis_track.light_spot_detected( mitosis_track = <cut_detector.utils.mitosis_track.MitosisTrack object at 0x0000021523A613F0> video = <class 'numpy.ndarray'> (285, 1100, 1600, 3) uint16 first_mt_cut_frame_abs = 220 self.length_light_spot = 10 self = <cut_detector.factories.mt_cut_detection_factory.MtCutDetectionFactory object at 0x0000021763F64BB0> self.crop_size_light_spot = 20 self.h_maxima_light_spot = 130 self.intensity_threshold_light_spot = 350 self.center_tolerance_light_spot = 5 self.min_percentage_light_spot = 0.1 698 video, 699 first_mt_cut_frame_abs, 700 self.length_light_spot, 701 self.crop_size_light_spot, 702 self.h_maxima_light_spot, 703 self.intensity_threshold_light_spot, 704 self.center_tolerance_light_spot, 705 self.min_percentage_light_spot, 706 ): 707 mitosis_track.key_events_frame["first_mt_cut"] = ImpossibleDetection.LIGHT_SPOT

File C:\ProgramData\anaconda3\envs\cut_detector_7\lib\site-packages\cut_detector\utils\mitosis_track.py:613, in MitosisTrack.light_spot_detected(self=, video=<class 'numpy.ndarray'> (285, 309, 448, 3) uint16, first_cut_frame=220, length_light_spot=10, crop_size_light_spot=20, h_maxima_light_spot=130, intensity_threshold_light_spot=350, center_tolerance_light_spot=5, min_percentage_light_spot=0.1, print_enabled=False) 612 # Get mid-body coordinates --> 613 x_pos, y_pos = self.mid_body_spots[frame].position frame = 215 self.mid_body_spots = {217: <cut_detector.utils.mid_body_spot.MidBodySpot object at 0x0000021763698490>, 218: <cut_detector.utils.mid_body_spot.MidBodySpot object at 0x000002176369AEC0>, 219: <cut_detector.utils.mid_body_spot.MidBodySpot object at 0x000002176369ADA0>, 220: <cut_detector.utils.mid_body_spot.MidBodySpot object at 0x000002176369AC80>, 221: <cut_detector.utils.mid_body_spot.MidBodySpot object at 0x000002176369AB60>, 222: <cut_detector.utils.mid_body_spot.MidBodySpot object at 0x000002176369AA40>, 223: <cut_detector.utils.mid_body_spot.MidBodySpot object at 0x000002176369A920>, 224: <cut_detector.utils.mid_body_spot.MidBodySpot object at 0x000002176369A800>, 225: <cut_detector.utils.mid_body_spot.MidBodySpot object at 0x000002176369A6E0>, 226: <cut_detector.utils.mid_body_spot.MidBodySpot object at 0x000002176369A5C0>, 227: <cut_detector.utils.mid_body_spot.MidBodySpot object at 0x000002176369A4A0>, 228: <cut_detector.utils.mid_body_spot.MidBodySpot object at 0x000002176369A230>, 229: <cut_detector.utils.mid_body_spot.MidBodySpot object at 0x0000021763699FF0>, 230: <cut_detector.utils.mid_body_spot.MidBodySpot object at 0x0000021763699B70>, 231: <cut_detector.utils.mid_body_spot.MidBodySpot object at 0x00000217636996F0>, 232: <cut_detector.utils.mid_body_spot.MidBodySpot object at 0x0000021763698910>, 233: <cut_detector.utils.mid_body_spot.MidBodySpot object at 0x000002176369B850>, 234: <cut_detector.utils.mid_body_spot.MidBodySpot object at 0x000002176369B730>} self = <cut_detector.utils.mitosis_track.MitosisTrack object at 0x0000021523A613F0> 615 # Extract image and crop on the midbody

KeyError: 215

The above exception was the direct cause of the following exception:

EmitLoopError Traceback (most recent call last) File C:\ProgramData\anaconda3\envs\cut_detector_7\lib\site-packages\magicgui\widgets\bases_value_widget.py:71, in ValueWidget._on_value_change(self=PushButton(value=False, annotation=None, name='call_button'), value=False) 69 if value is self.null_value and not self._nullable: 70 return ---> 71 self.changed.emit(value) value = False self.changed = <SignalInstance 'changed' on PushButton(value=False, annotation=None, name='call_button')> self = PushButton(value=False, annotation=None, name='call_button')

File src\psygnal_signal.py:945, in emit()

File src\psygnal_signal.py:992, in _run_emit_loop()

EmitLoopError: While emitting signal 'magicgui.widgets.PushButton.changed', an error occurred in callback 'magicgui.widgets._function_gui.FunctionGui.init.._disable_button_and_call'. The args passed to the callback were: (False,) This is not a bug in psygnal. See 'KeyError' above for details.

15bonte commented 10 months ago

Will be solved in v0.0.10