@@ -569,9 +569,9 @@ def _filter_lineages(lineages, tracking_result):
569569 return filtered_lineages
570570
571571
572- def _tracking_impl (timeseries , segmentation , mode , min_time_extent , output_folder = None ):
572+ def _tracking_impl (timeseries , segmentation , mode , min_time_extent , tracking_model = "general_2d" , output_folder = None ):
573573 device = "cuda" if torch .cuda .is_available () else "cpu"
574- model = Trackastra .from_pretrained ("general_2d" , device = device )
574+ model = Trackastra .from_pretrained (tracking_model , device = device )
575575 result = model .track (timeseries , segmentation , mode = mode )
576576 try :
577577 lineage_graph , _ = result
@@ -609,6 +609,8 @@ def track_across_frames(
609609 segmentation : np .ndarray ,
610610 gap_closing : Optional [int ] = None ,
611611 min_time_extent : Optional [int ] = None ,
612+ mode : str = "greedy" ,
613+ tracking_model : str = "general_2d" ,
612614 verbose : bool = True ,
613615 pbar_init : Optional [callable ] = None ,
614616 pbar_update : Optional [callable ] = None ,
@@ -626,6 +628,9 @@ def track_across_frames(
626628 gap_closing: If given, gaps in the segmentation are closed with a binary closing
627629 operation. The value is used to determine the number of iterations for the closing.
628630 min_time_extent: Require a minimal extent in time for the tracked objects.
631+ mode: The trackastra linking solver. One of 'greedy_nodiv', 'greedy' or 'ilp'.
632+ 'ilp' uses the motile solver. By default, set to 'greedy'.
633+ tracking_model: The pretrained trackastra model to use. By default, set to 'general_2d'.
629634 verbose: Verbosity flag. By default, set to 'True'.
630635 pbar_init: Function to initialize the progress bar.
631636 pbar_update: Function to update the progress bar.
@@ -650,8 +655,9 @@ def track_across_frames(
650655 segmentation , lineage = _tracking_impl (
651656 timeseries = np .asarray (timeseries ),
652657 segmentation = segmentation ,
653- mode = "greedy" ,
658+ mode = mode ,
654659 min_time_extent = min_time_extent ,
660+ tracking_model = tracking_model ,
655661 output_folder = output_folder ,
656662 )
657663 return segmentation , lineage
@@ -664,6 +670,8 @@ def automatic_tracking_implementation(
664670 embedding_path : Optional [Union [str , os .PathLike ]] = None ,
665671 gap_closing : Optional [int ] = None ,
666672 min_time_extent : Optional [int ] = None ,
673+ mode : str = "greedy" ,
674+ tracking_model : str = "general_2d" ,
667675 tile_shape : Optional [Tuple [int , int ]] = None ,
668676 halo : Optional [Tuple [int , int ]] = None ,
669677 verbose : bool = True ,
@@ -685,6 +693,9 @@ def automatic_tracking_implementation(
685693 gap_closing: If given, gaps in the segmentation are closed with a binary closing
686694 operation. The value is used to determine the number of iterations for the closing.
687695 min_time_extent: Require a minimal extent in time for the tracked objects.
696+ mode: The trackastra linking solver. One of 'greedy_nodiv', 'greedy' or 'ilp'.
697+ 'ilp' uses the motile solver. By default, set to 'greedy'.
698+ tracking_model: The pretrained trackastra model to use. By default, set to 'general_2d'.
688699 tile_shape: Shape of the tiles for tiled prediction. By default prediction is run without tiling.
689700 halo: Overlap of the tiles for tiled prediction. By default prediction is run without tiling.
690701 verbose: Verbosity flag. By default, set to 'True'.
@@ -715,6 +726,8 @@ def automatic_tracking_implementation(
715726 segmentation = segmentation ,
716727 gap_closing = gap_closing ,
717728 min_time_extent = min_time_extent ,
729+ mode = mode ,
730+ tracking_model = tracking_model ,
718731 verbose = verbose ,
719732 output_folder = output_folder ,
720733 )
0 commit comments