Skip to content

Commit

Permalink
add test to make sure passing empty anat metrics works
Browse files Browse the repository at this point in the history
  • Loading branch information
htwangtw committed Apr 2, 2024
1 parent 7f70d4e commit adf5437
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
6 changes: 6 additions & 0 deletions giga_auto_qc/assessments.py
Original file line number Diff line number Diff line change
Expand Up @@ -403,6 +403,12 @@ def quality_accessments(
> qulaity_control_standards["functional_dice"]
)
functional_metrics["pass_func_qc"] = keep_fd * keep_proportion * keep_func
if anatomical_metrics.empty:
functional_metrics["pass_anat_qc"] = np.nan
functional_metrics["pass_all_qc"] = functional_metrics[
"pass_func_qc"
].copy()
return functional_metrics

# get the anatomical pass / fail
pass_anat_qc = {}
Expand Down
11 changes: 11 additions & 0 deletions giga_auto_qc/tests/test_assessments.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,17 @@ def test_quality_accessments():
)
assert metrics["pass_all_qc"].astype(int).sum() == 1

metrics = assessments.quality_accessments(
functional_metrics=functional_metrics,
anatomical_metrics=pd.DataFrame(),
qulaity_control_standards=qc,
)
assert (
metrics["pass_all_qc"].astype(int).sum()
== metrics["pass_func_qc"].astype(int).sum()
)
assert metrics["pass_anat_qc"].isnull().all() == True


def test_dice_coefficient():
"""Check the dice coefficient is calculated correctly."""
Expand Down

0 comments on commit adf5437

Please sign in to comment.