Skip to content

Commit ab87fb9

Browse files
Update val implementation
1 parent 3d4df6e commit ab87fb9

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

flamingo_tools/validation.py

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,9 +74,19 @@ def fetch_data_for_evaluation(
7474
with zarr.open(s3_store, mode="r") as f:
7575
segmentation = f[input_key][roi]
7676

77-
# ...
7877
if components_for_postprocessing is not None:
79-
pass
78+
# Filter the IDs so that only the ones part of 'components_for_postprocessing_remain'.
79+
80+
# First, we download the MoBIE table for this segmentation.
81+
internal_path = os.path.join(BUCKET_NAME, cochlea, "tables", seg_name, "default.tsv")
82+
with fs.open(internal_path, "r") as f:
83+
table = pd.read_csv(f, sep="\t")
84+
85+
# Then we get the ids for the components and us them to filter the segmentation.
86+
component_mask = np.isin(table.component_labels.values, components_for_postprocessing)
87+
keep_label_ids = table.label_id.values[component_mask].astype("int64")
88+
filter_mask = ~np.isin(segmentation, keep_label_ids)
89+
segmentation[filter_mask] = 0
8090

8191
segmentation, _, _ = relabel_sequential(segmentation)
8292

0 commit comments

Comments
 (0)