@@ -130,6 +130,7 @@ def __init__(
130130 self ._model_type .changed .connect (self ._model_type_changed )
131131 self ._model_pretrained .changed .connect (self ._update_model )
132132 self ._model_path .changed .connect (self ._update_model )
133+ self ._linking_mode .changed .connect (self ._update_linking_mode )
133134 self ._run_button .changed .connect (self ._run )
134135
135136 # self._save_path.changed.connect(self._save)
@@ -171,6 +172,20 @@ def _update_model(self, event=None):
171172 self ._model_path .value , device = self ._device
172173 )
173174
175+ def _update_linking_mode (self , event = None ):
176+ if self ._linking_mode .value == "ilp" :
177+ try :
178+ import motile # noqa F401
179+
180+ return True
181+ except ModuleNotFoundError :
182+ napari .utils .notifications .show_warning (
183+ "For tracking with an ILP, please conda install the optional `motile`"
184+ " dependency following https://funkelab.github.io/motile/install.html."
185+ )
186+ return False
187+ return True
188+
174189 def _show_activity_dock (self , state = True ):
175190 # show/hide activity dock if there is actual progress to see
176191 self ._viewer .window ._status_bar ._toggle_activity_dock (state )
@@ -181,6 +196,9 @@ def _run(self, event=None):
181196 if self .model is None :
182197 raise ValueError ("Model not loaded" )
183198
199+ if not self ._update_linking_mode ():
200+ return
201+
184202 imgs = np .asarray (self ._image_layer .value .data )
185203 masks = np .asarray (self ._mask_layer .value .data )
186204
0 commit comments