@@ -30,13 +30,6 @@ def _run_segmentation(
3030 if verbose :
3131 print ("Compute connected components in" , time .time () - t0 , "s" )
3232
33- # import napari
34- # v = napari.Viewer()
35- # v.add_image(boundaries)
36- # v.add_image(dist)
37- # v.add_labels(seeds)
38- # napari.run()
39-
4033 t0 = time .time ()
4134 hmap = boundaries + ((dist .max () - dist ) / dist .max ())
4235 mask = (foreground + boundaries ) > 0.5
@@ -66,6 +59,8 @@ def segment_mitochondria(
6659 scale : Optional [List [float ]] = None ,
6760 mask : Optional [np .ndarray ] = None ,
6861 seed_distance : int = 6 ,
62+ ws_block_shape = (128 , 256 , 256 ),
63+ ws_halo = (48 , 48 , 48 ),
6964) -> Union [np .ndarray , Tuple [np .ndarray , np .ndarray ]]:
7065 """Segment mitochondria in an input volume.
7166
@@ -80,6 +75,9 @@ def segment_mitochondria(
8075 return_predictions: Whether to return the predictions (foreground, boundaries) alongside the segmentation.
8176 scale: The scale factor to use for rescaling the input volume before prediction.
8277 mask: An optional mask that is used to restrict the segmentation.
78+ seed_distance: The distance threshold for the seeded watershed.
79+ ws_block_shape: The block shape for the seeded watershed.
80+ ws_halo: The halo for the seeded watershed.
8381
8482 Returns:
8583 The segmentation mask as a numpy array, or a tuple containing the segmentation mask
@@ -98,7 +96,8 @@ def segment_mitochondria(
9896
9997 # Run segmentation and rescale the result if necessary.
10098 foreground , boundaries = pred [:2 ]
101- seg = _run_segmentation (foreground , boundaries , verbose = verbose , min_size = min_size , seed_distance = seed_distance )
99+ seg = _run_segmentation (foreground , boundaries , verbose = verbose , min_size = min_size , seed_distance = seed_distance ,
100+ block_shape = ws_block_shape , halo = ws_halo )
102101 seg = scaler .rescale_output (seg , is_segmentation = True )
103102
104103 if return_predictions :
0 commit comments