Skip to content

Commit

Permalink
Added LNK, BIO and OP scores. Made code fresh such that pylint stops …
Browse files Browse the repository at this point in the history
…barking
  • Loading branch information
TimoK93 committed Apr 18, 2024
1 parent 65f41f1 commit ed0acba
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 13 deletions.
4 changes: 2 additions & 2 deletions ctc_metrics/metrics/biological/bio.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,5 +35,5 @@ def bio(
total_metrics += 1
else:
cca = 0
bio = (ct + tf + bc + cca) / total_metrics
return bio
metric = (ct + tf + bc + cca) / total_metrics
return metric
16 changes: 7 additions & 9 deletions ctc_metrics/scripts/evaluate.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import argparse
import numpy as np
from os.path import join, basename, exists
from os.path import join, basename
from multiprocessing import Pool, cpu_count
import numpy as np

from ctc_metrics.metrics import (
valid, det, seg, tra, ct, tf, bc, cca, op_ctb, op_csb, bio, op_clb, lnk
Expand Down Expand Up @@ -73,7 +73,7 @@ def load_data(

# Match golden truth tracking masks to result masks
traj = {}
is_valid = True
is_valid = 0
if trajectory_data:
traj = match_computed_to_reference_masks(
ref_tra_masks, comp_masks, threads=threads)
Expand All @@ -99,7 +99,6 @@ def calculate_metrics(
ref_tracks: np.ndarray,
traj: dict,
segm: dict,
comp_masks: list,
metrics: list = None,
is_valid: bool = None,
): # pylint: disable=too-complex
Expand All @@ -111,7 +110,6 @@ def calculate_metrics(
ref_tracks: The reference tracks result file.
traj: The frame-wise trajectory match data.
segm: The frame-wise segmentation match data.
comp_masks: The computed masks.
metrics: The metrics to evaluate.
is_valid: A Flag if the results are valid
Expand Down Expand Up @@ -186,7 +184,7 @@ def calculate_metrics(
if "BIO(0)" in results and "LNK" in results:
for i in range(4):
results[f"OP_CLB({i})"] = op_clb(
results[f"LNK"], results[f"BIO({i})"])
results[f"LNK({i})"], results[f"BIO({i})"])

return results

Expand Down Expand Up @@ -219,17 +217,17 @@ def evaluate_sequence(
trajectory_data = True
segmentation_data = True

if metrics == ["SEG"] or metrics == ["CCA"]:
if metrics in (["SEG"], ["CCA"]):
trajectory_data = False

if "SEG" not in metrics:
segmentation_data = False

comp_tracks, ref_tracks, traj, segm, comp_masks, is_valid = load_data(
comp_tracks, ref_tracks, traj, segm, _, is_valid = load_data(
res, gt, trajectory_data, segmentation_data, threads)

results = calculate_metrics(
comp_tracks, ref_tracks, traj, segm, comp_masks, metrics, is_valid)
comp_tracks, ref_tracks, traj, segm, metrics, is_valid)

print("with results: ", results, " done!")

Expand Down
4 changes: 2 additions & 2 deletions ctc_metrics/scripts/validate.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,8 @@ def validate_all(
"""
results = []
ret = parse_directories(res_root, None)
for res, gt, name in zip(*ret):
results.append([name, validate_sequence(res, gt)])
for res, _, name in zip(*ret):
results.append([name, validate_sequence(res, threads)])
return results


Expand Down

0 comments on commit ed0acba

Please sign in to comment.