Skip to content

Commit 8a8348f

Browse files
committed
Option to specify components for identifying central path
1 parent 533f8e4 commit 8a8348f

File tree

2 files changed

+10
-3
lines changed

2 files changed

+10
-3
lines changed

flamingo_tools/segmentation/cochlea_mapping.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -583,6 +583,7 @@ def equidistant_centers(
583583
def tonotopic_mapping(
584584
table: pd.DataFrame,
585585
component_label: List[int] = [1],
586+
component_mapping: Optional[List[int]] = None,
586587
cell_type: str = "ihc",
587588
animal: str = "mouse",
588589
) -> pd.DataFrame:
@@ -592,6 +593,7 @@ def tonotopic_mapping(
592593
Args:
593594
table: Dataframe of segmentation table.
594595
component_label: List of component labels to evaluate.
596+
components_mapping: Components to use for tonotopic mapping. Ignore components torn parallel to main canal.
595597
cell_type: Cell type of segmentation.
596598
597599
Returns:
@@ -602,16 +604,19 @@ def tonotopic_mapping(
602604
centroids = list(zip(new_subset["anchor_x"], new_subset["anchor_y"], new_subset["anchor_z"]))
603605
label_ids = [int(i) for i in list(new_subset["label_id"])]
604606

607+
if component_mapping is None:
608+
component_mapping = component_label
609+
605610
if cell_type == "ihc":
606611
total_distance, _, path_dict = measure_run_length_ihcs(centroids, component_label=component_label)
607612

608613
else:
609-
if len(component_label) == 1:
614+
if len(component_mapping) == 1:
610615
total_distance, _, path_dict = measure_run_length_sgns(centroids)
611616

612617
else:
613618
centroids_components = []
614-
for label in component_label:
619+
for label in component_mapping:
615620
subset = table[table["component_labels"] == label]
616621
subset_centroids = list(zip(subset["anchor_x"], subset["anchor_y"], subset["anchor_z"]))
617622
centroids_components.append(subset_centroids)

reproducibility/tonotopic_mapping/repro_tonotopic_mapping.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,13 +54,15 @@ def repro_tonotopic_mapping(
5454

5555
cell_type = dic["type"] if "type" in dic else default_cell_type
5656
component_list = dic["component_list"] if "component_list" in dic else default_component_list
57+
component_mapping = dic["component_mapping"] if "component_mapping" in dic else component_list
5758

5859
for column in remove_columns:
5960
if column in list(table.columns):
6061
table = table.drop(column, axis=1)
6162

6263
if not os.path.isfile(output_table_path) or force_overwrite:
63-
table = tonotopic_mapping(table, component_label=component_list, animal=animal, cell_type=cell_type)
64+
table = tonotopic_mapping(table, component_label=component_list, animal=animal,
65+
cell_type=cell_type, component_mapping=component_mapping)
6466

6567
table.to_csv(output_table_path, sep="\t", index=False)
6668

0 commit comments

Comments
 (0)