Skip to content

Commit 25478a7

Browse files
Updates to IHC evaluation
1 parent 1803292 commit 25478a7

File tree

2 files changed

+12
-9
lines changed

2 files changed

+12
-9
lines changed

scripts/measurements/evaluate_sgn_therapy.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,7 @@ def check_project(save=False):
1515
project_info = json.loads(content.read())
1616

1717
cochleae = [
18-
"M_LR_000144_L", "M_LR_000145_L",
19-
"M_LR_000151_R", "M_LR_000155_L",
18+
"M_LR_000144_L", "M_LR_000145_L", "M_LR_000151_R", "M_LR_000155_L",
2019
]
2120

2221
sgn_name = "SGN_resized_v2"
@@ -32,8 +31,8 @@ def check_project(save=False):
3231
continue
3332

3433
# Get the ihc table folder.
35-
ihc = sources[sgn_name]["segmentation"]
36-
table_folder = os.path.join(BUCKET_NAME, cochlea, ihc["tableData"]["tsv"]["relativePath"])
34+
sgn = sources[sgn_name]["segmentation"]
35+
table_folder = os.path.join(BUCKET_NAME, cochlea, sgn["tableData"]["tsv"]["relativePath"])
3736

3837
# For debugging.
3938
x = s3.ls(table_folder)
@@ -42,11 +41,14 @@ def check_project(save=False):
4241

4342
default_table = s3.open(os.path.join(table_folder, "default.tsv"), mode="rb")
4443
default_table = pd.read_csv(default_table, sep="\t")
44+
main_ids = default_table[default_table.component_labels == 1].label_id
4545

4646
measurement_table = s3.open(
4747
os.path.join(table_folder, "GFP-resized_SGN-resized-v2_object-measures.tsv"), mode="rb"
4848
)
4949
measurement_table = pd.read_csv(measurement_table, sep="\t")
50+
measurement_table = measurement_table[measurement_table.label_id.isin(main_ids)]
51+
assert len(measurement_table) == len(main_ids)
5052

5153
if save:
5254
os.makedirs(OUTPUT_FOLDER, exist_ok=True)

scripts/validation/IHCs/run_evaluation.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
ANNOTATION_FOLDERS = ["consensus_annotation"]
1313

1414

15-
def run_evaluation(root, annotation_folders, result_file, cache_folder):
15+
def run_evaluation(root, annotation_folders, result_file, cache_folder, segmentation_name):
1616
results = {
1717
"annotator": [],
1818
"cochlea": [],
@@ -32,12 +32,12 @@ def run_evaluation(root, annotation_folders, result_file, cache_folder):
3232
print(annotation_path)
3333
cochlea, slice_id = _parse_annotation_path(annotation_path)
3434

35-
# For the cochlea M_LR_000226_R the actual component is 2, not 1
36-
component = 2 if "226_R" in cochlea else 1
35+
# For the cochlea M_LR_000226_R the actual component is 2, not 1. (Only for IHC_v2).
36+
component = 2 if ("226_R" in cochlea and segmentation_name == "IHC_v2") else 1
3737
print("Run evaluation for", annotator, cochlea, "z=", slice_id)
3838
segmentation, annotations = fetch_data_for_evaluation(
3939
annotation_path, components_for_postprocessing=[component],
40-
seg_name="IHC_v2",
40+
seg_name=segmentation_name,
4141
cache_path=None if cache_folder is None else os.path.join(cache_folder, f"{cochlea}_{slice_id}.tif")
4242
)
4343
scores = compute_scores_for_annotated_slice(segmentation, annotations, matching_tolerance=5)
@@ -59,9 +59,10 @@ def main():
5959
parser.add_argument("-i", "--input", default=ROOT)
6060
parser.add_argument("--folders", default=ANNOTATION_FOLDERS)
6161
parser.add_argument("--result_file", default="results.csv")
62+
parser.add_argument("--segmentation_name", default="IHC_v2")
6263
parser.add_argument("--cache_folder")
6364
args = parser.parse_args()
64-
run_evaluation(args.input, args.folders, args.result_file, args.cache_folder)
65+
run_evaluation(args.input, args.folders, args.result_file, args.cache_folder, args.segmentation_name)
6566

6667

6768
if __name__ == "__main__":

0 commit comments

Comments
 (0)