Skip to content

Commit

Permalink
Evaluate softmax predictions from command line (#9)
Browse files Browse the repository at this point in the history
  • Loading branch information
joeranbosma authored Sep 30, 2022
1 parent 6afc8ec commit 140b864
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions src/picai_eval/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@
import json
import os

from report_guided_annotation import extract_lesion_candidates

from picai_eval import evaluate_folder

# acquire and parse input and output paths
Expand All @@ -35,6 +37,10 @@
parser.add_argument("--label_extensions", type=str, nargs="+", required=False,
help="List of allowed file formats for annotations." +
"Default: .nii.gz, .nii, .mha, .mhd, .npz and .npy")
parser.add_argument("--y_det_postprocess_func", type=str, required=False,
help="Post-processing function for detection maps. Available: `extract_lesion_candidates`")
parser.add_argument("--y_det_postprocess_kwargs", type=str, required=False,
help='Post-processing arguments for detection maps. E.g.: `{"threshold": "dynamic"}`')
args = parser.parse_args()

if args.labels is None:
Expand All @@ -47,6 +53,16 @@
if isinstance(args.subject_list, dict):
args.subject_list = args.subject_list['subject_list']

if args.y_det_postprocess_func is not None:
if args.y_det_postprocess_func == "extract_lesion_candidates":
if args.y_det_postprocess_kwargs is None:
args.y_det_postprocess_kwargs = {}
else:
args.y_det_postprocess_kwargs = json.loads(args.y_det_postprocess_kwargs)
args.y_det_postprocess_func = lambda pred: extract_lesion_candidates(pred, **args.y_det_postprocess_kwargs)[0]
else:
raise ValueError(f"Received unsupported post-processing function: {args.y_det_postprocess_func}")

print(f"""
PICAI Evaluation
Model predictions path: {args.input}
Expand All @@ -64,6 +80,7 @@
subject_list=args.subject_list,
pred_extensions=args.pred_extensions,
label_extensions=args.label_extensions,
y_det_postprocess_func=args.y_det_postprocess_func,
)

# show metrics
Expand Down

0 comments on commit 140b864

Please sign in to comment.