22import magicgui
33import numpy as np
44from magicgui .widgets import Container , Label , LineEdit , SpinBox , ComboBox
5+ from magicgui .application import use_app
56from PyQt5 .QtWidgets import QFileDialog , QMessageBox
67
78from ..util import load_image_data
89from .annotator_2d import annotator_2d
910from .annotator_3d import annotator_3d
1011from .image_series_annotator import image_folder_annotator
12+ from .annotator_tracking import annotator_tracking
1113
1214config_dict = {}
1315main_widget = None
@@ -109,7 +111,7 @@ def on_start():
109111 args ["halo" ] = halo
110112 args ["model_type" ] = cb_model .value
111113 sub_widget .close ()
112- annotator_2d ( show_embeddings = False , ** args )
114+ config_dict [ "workflow" ] = "2d"
113115 except Exception as e :
114116 show_error (str (e ))
115117
@@ -224,7 +226,7 @@ def on_start():
224226 args ["halo" ] = halo
225227 args ["model_type" ] = cb_model .value
226228 sub_widget .close ()
227- annotator_3d ( show_embeddings = False , ** args )
229+ config_dict [ "workflow" ] = "3d"
228230 except Exception as e :
229231 show_error (str (e ))
230232
@@ -313,7 +315,7 @@ def on_start():
313315 args ["halo" ] = halo
314316 args ["model_type" ] = cb_model .value
315317 sub_widget .close ()
316- image_folder_annotator ( ** args )
318+ config_dict [ "workflow" ] = "series"
317319 except Exception as e :
318320 show_error (str (e ))
319321
@@ -428,7 +430,7 @@ def on_start():
428430 args ["halo" ] = halo
429431 args ["model_type" ] = cb_model .value
430432 sub_widget .close ()
431- annotator_3d ( show_embeddings = False , ** args )
433+ config_dict [ "workflow" ] = "tracking"
432434 except Exception as e :
433435 show_error (str (e ))
434436
@@ -440,13 +442,30 @@ def on_start():
440442
441443
442444def annotator ():
443- global main_widget
445+ global main_widget , config_dict
446+ config_dict ["workflow" ] = ""
444447 sub_container1 = Container (widgets = [on_2d , on_series ], labels = False )
445448 sub_container2 = Container (widgets = [on_3d , on_tracking ], labels = False )
446449 sub_container3 = Container (widgets = [sub_container1 , sub_container2 ], layout = "horizontal" , labels = False )
447450 main_widget = Container (widgets = [Label (value = "Segment Anything for Microscopy" ), sub_container3 ], labels = False )
448451 main_widget .show (run = True )
449452
453+ if config_dict ["workflow" ] == "2d" :
454+ use_app ().quit ()
455+ annotator_2d (show_embeddings = False , ** config_dict ["args" ])
456+ elif config_dict ["workflow" ] == "3d" :
457+ use_app ().quit ()
458+ annotator_3d (show_embeddings = False , ** config_dict ["args" ])
459+ elif config_dict ["workflow" ] == "series" :
460+ use_app ().quit ()
461+ image_folder_annotator (** config_dict ["args" ])
462+ elif config_dict ["workflow" ] == "tracking" :
463+ use_app ().quit ()
464+ annotator_tracking (show_embeddings = False , ** config_dict ["args" ])
465+ else :
466+ show_error ("No workflow selected." )
467+ use_app ().quit ()
468+
450469
451470def main ():
452471 annotator ()
0 commit comments