Skip to content

Commit

Permalink
TEST add unit test to check test_calculate_anat_metrics (#20)
Browse files Browse the repository at this point in the history
* Always run full test on merge

* ADD test for anatomical dice score
  • Loading branch information
htwangtw authored Aug 29, 2023
1 parent c3e772a commit 2db8eeb
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 1 deletion.
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ jobs:
pytest -m "not smoke" --cov=giga_auto_qc --cov-report=xml --doctest-modules -v --pyargs giga_auto_qc
- name: Full test - run all the test to generate accurate coverage report.
if: ${{ contains(needs.check_skip_flags.outputs.head-commit-message, 'full_test') }}
if: ${{ contains(needs.check_skip_flags.outputs.head-commit-message, 'full_test') }} || ${{ github.event.pull_request.merged }}
run: pytest --cov=giga_auto_qc --cov-report=xml --doctest-modules -v --pyargs giga_auto_qc

- uses: codecov/codecov-action@v3
Expand Down
31 changes: 31 additions & 0 deletions giga_auto_qc/tests/test_assessments.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@
import pandas as pd
from nibabel import Nifti1Image
from giga_auto_qc import assessments
from bids import BIDSLayout
from pkg_resources import resource_filename
import pytest
import templateflow


def test_quality_accessments():
Expand Down Expand Up @@ -85,3 +89,30 @@ def test_get_consistent_masks():
) = assessments._get_consistent_masks(mask_imgs, exclude)
assert len(cleaned_func_masks) == 7
assert len(weird_mask_identifiers) == 3


@pytest.mark.smoke
def test_calculate_anat_metrics():
bids_dir = resource_filename(
"giga_auto_qc",
"data/test_data/ds000017-fmriprep22.0.1-downsampled-nosurface",
)
fmriprep_bids_layout = BIDSLayout(
root=bids_dir,
database_path=bids_dir,
validate=False,
derivatives=True,
reset_database=True,
)
template_mask = templateflow.api.get(
["MNI152NLin2009cAsym"], desc="brain", suffix="mask", resolution="01"
)
df = assessments.calculate_anat_metrics(
["1", "2"],
fmriprep_bids_layout,
{"anat": template_mask},
{"anatomical_dice": 0.97},
)
print(df)

assert df.shape == (2, 2)

0 comments on commit 2db8eeb

Please sign in to comment.