Skip to content

Commit

Permalink
improve tests
Browse files Browse the repository at this point in the history
  • Loading branch information
mattcieslak committed Dec 6, 2024
1 parent ede492a commit ce3fb25
Showing 1 changed file with 14 additions and 4 deletions.
18 changes: 14 additions & 4 deletions qsirecon/tests/test_interfaces.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@


@pytest.mark.interfaces
def test_shell_selection(data_dir, working_dir):
def test_shell_selection(data_dir):
"""Run reconstruction workflow tests."""
dwi_prefix = "sub-ABCD_acq-10per000_space-T1w_desc-preproc_dwi"
data_dir = "/home/matt/projects/qsirecon/.circleci/data"
Expand Down Expand Up @@ -44,6 +44,9 @@ def test_shell_selection(data_dir, working_dir):
# before those were written in the outputs.
assert not Path(dwi_prefix + "_selected.txt").exists()


@pytest.mark.interfaces
def test_real_shells():
# Check some other sequences we might run into
# ABCD has 4 shells + b=0s
abcd_bval = np.loadtxt(load_data("schemes/ABCD.bval"))
Expand All @@ -57,14 +60,21 @@ def test_shell_selection(data_dir, working_dir):

# DSIQ5 should raise an exception
dsi_bval = np.loadtxt(load_data("schemes/DSIQ5.bval"))
with pytest.raises(Exception):
with pytest.raises(Exception, match="Too many possible shells detected."):
_find_shells(dsi_bval, 100)

# Some other assorted test schemes that should fail
nonshelled_schemes = ["HASC55-1", "HASC55-2", "HASC92", "RAND57", "Q7"]
nonshelled_schemes = ["HASC55-1", "HASC55-2", "HASC92", "RAND57"]
for scheme in nonshelled_schemes:
bval_file = Path(get_test_data_path()) / f"{scheme}.bval"
test_bvals = np.loadtxt(bval_file)

with pytest.raises(Exception):
with pytest.raises(Exception, match="Too many possible shells detected."):
_find_shells(test_bvals, 100)

# DSIQ7 actually _passes_ the mrtrix test, but failes silhouette
bval_file = Path(get_test_data_path()) / "Q7.bval"
test_bvals = np.loadtxt(bval_file)

with pytest.raises(Exception, match="Silhouette score is low. Is this is a DSI scheme?"):
_find_shells(test_bvals, 100)

0 comments on commit ce3fb25

Please sign in to comment.