@@ -367,7 +367,7 @@ def components_sgn(
367367 threshold_erode : Optional [float ] = None ,
368368 min_component_length : int = 50 ,
369369 max_edge_distance : float = 30 ,
370- iterations_erode : Optional [ int ] = None ,
370+ iterations_erode : int = 0 ,
371371 postprocess_threshold : Optional [float ] = None ,
372372 postprocess_components : Optional [List [int ]] = None ,
373373) -> List [List [int ]]:
@@ -379,7 +379,7 @@ def components_sgn(
379379 threshold_erode: Threshold of column value after erosion step with spatial statistics.
380380 min_component_length: Minimal length for filtering out connected components.
381381 max_edge_distance: Maximal distance in micrometer between points to create edges for connected components.
382- iterations_erode: Number of iterations for erosion, normally determined automatically .
382+ iterations_erode: Number of iterations for erosion.
383383 postprocess_threshold: Post-process graph connected components by searching for points closer than threshold.
384384 postprocess_components: Post-process specific graph connected components ([0] for largest component only).
385385
@@ -388,7 +388,7 @@ def components_sgn(
388388 """
389389 if keyword not in table :
390390 distance_avg = nearest_neighbor_distance (table , n_neighbors = 100 )
391- table [ keyword ] = list (distance_avg )
391+ table . loc [:, keyword ] = list (distance_avg )
392392
393393 centroids = list (zip (table ["anchor_x" ], table ["anchor_y" ], table ["anchor_z" ]))
394394 labels = [int (i ) for i in list (table ["label_id" ])]
@@ -397,18 +397,16 @@ def components_sgn(
397397 distance_nn .sort ()
398398
399399 if len (table ) < 20000 :
400- iterations = iterations_erode if iterations_erode is not None else 0
401400 min_cells = None
402401 average_dist = int (distance_nn [int (len (table ) * 0.8 )])
403402 threshold = threshold_erode if threshold_erode is not None else average_dist
404403 else :
405- iterations = iterations_erode if iterations_erode is not None else 15
406404 min_cells = 20000
407405 threshold = threshold_erode if threshold_erode is not None else 40
408406
409- if iterations != 0 :
407+ if iterations_erode != 0 :
410408 print (f"Using threshold of { threshold } micrometer for eroding segmentation with keyword { keyword } ." )
411- new_subset = erode_subset (table .copy (), iterations = iterations ,
409+ new_subset = erode_subset (table .copy (), iterations = iterations_erode ,
412410 threshold = threshold , min_cells = min_cells , keyword = keyword )
413411 else :
414412 new_subset = table .copy ()
@@ -454,7 +452,7 @@ def label_components_sgn(
454452 threshold_erode : Optional [float ] = None ,
455453 min_component_length : int = 50 ,
456454 max_edge_distance : float = 30 ,
457- iterations_erode : Optional [ int ] = None ,
455+ iterations_erode : int = 0 ,
458456 postprocess_threshold : Optional [float ] = None ,
459457 postprocess_components : Optional [List [int ]] = None ,
460458) -> List [int ]:
@@ -466,7 +464,7 @@ def label_components_sgn(
466464 threshold_erode: Threshold of column value after erosion step with spatial statistics.
467465 min_component_length: Minimal length for filtering out connected components.
468466 max_edge_distance: Maximal distance in micrometer between points to create edges for connected components.
469- iterations_erode: Number of iterations for erosion, normally determined automatically .
467+ iterations_erode: Number of iterations for erosion.
470468 postprocess_threshold: Post-process graph connected components by searching for points closer than threshold.
471469 postprocess_components: Post-process specific graph connected components ([0] for largest component only).
472470
0 commit comments