@@ -371,7 +371,7 @@ def components_sgn(
371371 threshold_erode : Optional [float ] = None ,
372372 min_component_length : int = 50 ,
373373 max_edge_distance : float = 30 ,
374- iterations_erode : Optional [ int ] = None ,
374+ iterations_erode : int = 0 ,
375375 postprocess_threshold : Optional [float ] = None ,
376376 postprocess_components : Optional [List [int ]] = None ,
377377) -> List [List [int ]]:
@@ -383,7 +383,7 @@ def components_sgn(
383383 threshold_erode: Threshold of column value after erosion step with spatial statistics.
384384 min_component_length: Minimal length for filtering out connected components.
385385 max_edge_distance: Maximal distance in micrometer between points to create edges for connected components.
386- iterations_erode: Number of iterations for erosion, normally determined automatically .
386+ iterations_erode: Number of iterations for erosion.
387387 postprocess_threshold: Post-process graph connected components by searching for points closer than threshold.
388388 postprocess_components: Post-process specific graph connected components ([0] for largest component only).
389389
@@ -392,7 +392,7 @@ def components_sgn(
392392 """
393393 if keyword not in table :
394394 distance_avg = nearest_neighbor_distance (table , n_neighbors = 100 )
395- table [ keyword ] = list (distance_avg )
395+ table . loc [:, keyword ] = list (distance_avg )
396396
397397 centroids = list (zip (table ["anchor_x" ], table ["anchor_y" ], table ["anchor_z" ]))
398398 labels = [int (i ) for i in list (table ["label_id" ])]
@@ -401,18 +401,16 @@ def components_sgn(
401401 distance_nn .sort ()
402402
403403 if len (table ) < 20000 :
404- iterations = iterations_erode if iterations_erode is not None else 0
405404 min_cells = None
406405 average_dist = int (distance_nn [int (len (table ) * 0.8 )])
407406 threshold = threshold_erode if threshold_erode is not None else average_dist
408407 else :
409- iterations = iterations_erode if iterations_erode is not None else 15
410408 min_cells = 20000
411409 threshold = threshold_erode if threshold_erode is not None else 40
412410
413- if iterations != 0 :
411+ if iterations_erode != 0 :
414412 print (f"Using threshold of { threshold } micrometer for eroding segmentation with keyword { keyword } ." )
415- new_subset = erode_subset (table .copy (), iterations = iterations ,
413+ new_subset = erode_subset (table .copy (), iterations = iterations_erode ,
416414 threshold = threshold , min_cells = min_cells , keyword = keyword )
417415 else :
418416 new_subset = table .copy ()
@@ -458,7 +456,7 @@ def label_components_sgn(
458456 threshold_erode : Optional [float ] = None ,
459457 min_component_length : int = 50 ,
460458 max_edge_distance : float = 30 ,
461- iterations_erode : Optional [ int ] = None ,
459+ iterations_erode : int = 0 ,
462460 postprocess_threshold : Optional [float ] = None ,
463461 postprocess_components : Optional [List [int ]] = None ,
464462) -> List [int ]:
@@ -470,7 +468,7 @@ def label_components_sgn(
470468 threshold_erode: Threshold of column value after erosion step with spatial statistics.
471469 min_component_length: Minimal length for filtering out connected components.
472470 max_edge_distance: Maximal distance in micrometer between points to create edges for connected components.
473- iterations_erode: Number of iterations for erosion, normally determined automatically .
471+ iterations_erode: Number of iterations for erosion.
474472 postprocess_threshold: Post-process graph connected components by searching for points closer than threshold.
475473 postprocess_components: Post-process specific graph connected components ([0] for largest component only).
476474
0 commit comments