Skip to content

Commit ff28f7b

Browse files
authored
Merge pull request #16 from tclose/unitests
Added NIfTI unittest
2 parents b2f1830 + 69a3f38 commit ff28f7b

File tree

4 files changed

+67
-9
lines changed

4 files changed

+67
-9
lines changed

.github/workflows/pythonpackage.yml

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,9 +52,20 @@ jobs:
5252
strategy:
5353
matrix:
5454
python-version: [3.7, 3.8, 3.9]
55-
55+
defaults:
56+
run:
57+
shell: bash -l {0}
5658
steps:
5759
- uses: actions/checkout@v2
60+
- name: Install Minconda
61+
uses: conda-incubator/setup-miniconda@v2
62+
with:
63+
auto-activate-base: true
64+
activate-environment: ""
65+
- name: Install MRtrix via Conda
66+
run: |
67+
conda install -c mrtrix3 mrtrix3
68+
mrconvert --version
5869
- name: Set up Python ${{ matrix.python-version }}
5970
uses: actions/setup-python@v2
6071
with:

conftest.py

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
import os
2+
import tempfile
3+
from pathlib import Path
4+
import pytest
5+
6+
7+
@pytest.fixture
8+
def work_dir():
9+
return Path(tempfile.mkdtemp())
10+
11+
12+
# For debugging in IDE's don't catch raised exceptions and let the IDE
13+
# break at it
14+
if os.getenv("_PYTEST_RAISE", "0") != "0":
15+
16+
@pytest.hookimpl(tryfirst=True)
17+
def pytest_exception_interact(call):
18+
raise call.excinfo.value
19+
20+
@pytest.hookimpl(tryfirst=True)
21+
def pytest_internalerror(excinfo):
22+
raise excinfo.value
Lines changed: 31 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,42 @@
1+
from pathlib import Path
12
import pytest
23
from pydra.tasks.mrtrix3.utils import MRConvert
3-
from medimages4tests.dicom.mri.dwi.siemens.skyra.syngo_d13c import sample_image
4+
from medimages4tests.dicom.mri.dwi.siemens.skyra.syngo_d13c import (
5+
sample_image as sample_dwi_dicom,
6+
)
7+
from medimages4tests.nifti import sample_image as sample_nifti
48

59

610
@pytest.fixture
7-
def dicom_dataset():
8-
return sample_image()
11+
def dwi_dicom_dataset():
12+
return sample_dwi_dicom()
913

1014

11-
def test_mrconvert(dicom_dataset):
15+
@pytest.fixture
16+
def nifti_dataset(work_dir):
17+
return sample_nifti(work_dir / "nifti", compressed=True)
18+
19+
20+
def test_mrconvert_default_out_file(nifti_dataset):
21+
22+
task = MRConvert(in_file=nifti_dataset, axes=[0, 1, 2, -1])
23+
24+
result = task()
25+
26+
assert Path(result.output.out_file).exists()
27+
28+
29+
@pytest.mark.xfail(
30+
reason=(
31+
"Cannot pass input to input field with 'output_file_template' "
32+
"https://github.com/nipype/pydra/pull/585 (or equivalent) is merged "
33+
"into main branch"
34+
)
35+
)
36+
def test_mrconvert_explicit_out_file(dwi_dicom_dataset):
1237

13-
task = MRConvert(in_file=dicom_dataset, out_file="test.nii.gz")
38+
task = MRConvert(in_file=dwi_dicom_dataset, out_file="test.nii.gz")
1439

1540
result = task()
1641

17-
assert result.output.out_file.exists()
42+
assert Path(result.output.out_file).exists()

setup.cfg

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ classifiers =
2020
[options]
2121
python_requires = >=3.7
2222
install_requires =
23-
pydra >= 0.6.2
23+
pydra >= 0.19
2424
packages = find_namespace:
2525

2626
[options.packages.find]
@@ -44,7 +44,7 @@ test =
4444
pytest-env
4545
pytest-xdist
4646
pytest-rerunfailures
47-
medimages4tests
47+
medimages4tests >= 0.2
4848
codecov
4949
tests =
5050
%(test)s

0 commit comments

Comments
 (0)