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

Show user feedback for when no label layer is loaded, but classifier is tried to be loaded #52

Closed
jluethi opened this issue Sep 16, 2024 · 0 comments · Fixed by #55
Closed

Comments

@jluethi
Copy link
Collaborator

jluethi commented Sep 16, 2024

Traceback:

---------------------------------------------------------------------------
NotImplementedError                       Traceback (most recent call last)
File ~/mambaforge/envs/napari-ome-zarr-navigator/lib/python3.10/site-packages/psygnal/_signal.py:990, in SignalInstance._run_emit_loop(self=<SignalInstance 'changed' on PushButton(value=False, annotation=None, name='')>, args=(False,))
    989 try:
--> 990     caller.cb(args)
        caller = <WeakMethod on napari_feature_classifier.classifier_widget.LoadClassifierContainer.load>
        args = (False,)
    991 except Exception as e:

File ~/mambaforge/envs/napari-ome-zarr-navigator/lib/python3.10/site-packages/psygnal/_weak_callback.py:418, in WeakMethod.cb(self=<WeakMethod on napari_feature_classifier.classifier_widget.LoadClassifierContainer.load>, args=())
    417     args = args[: self._max_args]
--> 418 func(obj, *self._args, *args, **self._kwargs)
        obj = <Container ()>
        func = <function LoadClassifierContainer.load at 0x33adc3400>
        args = ()
        self = <WeakMethod on napari_feature_classifier.classifier_widget.LoadClassifierContainer.load>
        self._args = ()
        self._kwargs = {}

File ~/Documents/Code/napari-feature-classifier/src/napari_feature_classifier/classifier_widget.py:616, in LoadClassifierContainer.load(self=<Container ()>)
    614     clf = pickle.load(f)
--> 616 self._run_container = ClassifierRunContainer(
        self._run_container = None
        self = <Container ()>
        ClassifierRunContainer = <class 'napari_feature_classifier.classifier_widget.ClassifierRunContainer'>
        self._viewer = Viewer(camera=Camera(center=(0.0, 645.216191352346, 1291.0303587856483), zoom=0.4173994836182336, angles=(0.0, 0.0, 90.0), perspective=0.0, mouse_pan=True, mouse_zoom=True), cursor=Cursor(position=(0.0, -295.12993963915505, 2648.243266641215), scaled=True, size=1, style=<CursorStyle.STANDARD: 'standard'>), dims=Dims(ndim=3, ndisplay=2, last_used=0, range=((0.0, 1.0, 1.0), (0.0, 1291.6283348666054, 1.1959521619135234), (0.0, 2583.2566697332104, 1.1959521619135234)), current_step=(0, 539, 1079), order=(0, 1, 2), axis_labels=('0', '1', '2')), grid=GridCanvas(stride=1, shape=(-1, -1), enabled=False), layers=[<Image layer 'Fluorescein (FITC)' at 0x3245a3f10>], 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 0x301287d90>], _persisted_mouse_event={}, _mouse_drag_gen={}, _mouse_wheel_gen={}, keymap={})
        clf = Classifier
                                                          annotations   area  solidity      hash
roi_id                                             label                                        
/Users/joel/Documents/Code/testing/operetta_pla... 9                1  163.0  0.970238  0.355685
                                                   50               1  191.0  0.955000  0.701877
                                                   138              2   95.0  0.931373  0.612604
                                                   158              2  134.0  0.937063  0.710748
                                                   214              1  147.0  0.924528  0.325066
                                                   297              1  208.0  0.954128  0.472246
                                                   433              1  169.0  0.949438  0.820502
                                                   454              1  207.0  0.945205  0.309140
                                                   643              2   77.0  0.950617  0.693952
                                                   1097             2   38.0  0.883721  0.185758
                                                   1129             2   43.0  0.934783  0.451107
                                                   1296             2   42.0  0.875000  0.024236
                                                   1562             2   53.0  0.868852  0.196926
                                                   1622             2   35.0  0.972222  0.598441
                                                   1711             2   32.0  0.969697  0.212667
                                                   1742             2   30.0  0.967742  0.816918
                                                   1845             2   29.0  0.966667  0.834062
        clf_path = PosixPath('/Users/joel/Documents/Code/napari-ome-zarr-navigator/C3_0_nuclei_classifier.clf')
    617     self._viewer,
    618     clf,
    619     classifier_save_path=clf_path,
    620     auto_save=True,
    621 )
    622 self.clear()

File ~/Documents/Code/napari-feature-classifier/src/napari_feature_classifier/classifier_widget.py:223, in ClassifierRunContainer.__init__(self=<Container ()>, viewer=Viewer(camera=Camera(center=(0.0, 645.2161913523...ouse_drag_gen={}, _mouse_wheel_gen={}, keymap={}), classifier=Classifier
                                     ...    1845             2   29.0  0.966667  0.834062, class_names=None, feature_names=None, classifier_save_path=PosixPath('/Users/joel/Documents/Code/napari-ome-zarr-navigator/C3_0_nuclei_classifier.clf'), auto_save=True)
    222 self.auto_save = auto_save
--> 223 self._last_selected_label_layer = get_selected_or_valid_label_layer(
        self = <Container ()>
        self._viewer = Viewer(camera=Camera(center=(0.0, 645.216191352346, 1291.0303587856483), zoom=0.4173994836182336, angles=(0.0, 0.0, 90.0), perspective=0.0, mouse_pan=True, mouse_zoom=True), cursor=Cursor(position=(0.0, -295.12993963915505, 2648.243266641215), scaled=True, size=1, style=<CursorStyle.STANDARD: 'standard'>), dims=Dims(ndim=3, ndisplay=2, last_used=0, range=((0.0, 1.0, 1.0), (0.0, 1291.6283348666054, 1.1959521619135234), (0.0, 2583.2566697332104, 1.1959521619135234)), current_step=(0, 539, 1079), order=(0, 1, 2), axis_labels=('0', '1', '2')), grid=GridCanvas(stride=1, shape=(-1, -1), enabled=False), layers=[<Image layer 'Fluorescein (FITC)' at 0x3245a3f10>], 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 0x301287d90>], _persisted_mouse_event={}, _mouse_drag_gen={}, _mouse_wheel_gen={}, keymap={})
    224     viewer=self._viewer
    225 )
    226 # Initialize the classifier

File ~/Documents/Code/napari-feature-classifier/src/napari_feature_classifier/utils.py:160, in get_selected_or_valid_label_layer(viewer=Viewer(camera=Camera(center=(0.0, 645.2161913523...ouse_drag_gen={}, _mouse_wheel_gen={}, keymap={}))
    159     return valid_layers[0]
--> 160 raise NotImplementedError("No valid label layers were found")

NotImplementedError: No valid label layers were found

=> show as user facing message

@jluethi jluethi linked a pull request Sep 16, 2024 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant