Skip to content

Commit

Permalink
TEST: Use consistent naming, truncated bvals/bvecs
Browse files Browse the repository at this point in the history
  • Loading branch information
effigies committed May 9, 2024
1 parent ab285cc commit ba1f12a
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 5 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
0 0 0 0 0 0 0 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
0 0 0 0 0 0 0 -1 -0.002 0.026 -0.591 0.236 0.893 -0.796 -0.234 -0.936 -0.506 -0.346 -0.457 0.487
0 0 0 0 0 0 0 0 1 0.649 -0.766 -0.524 -0.259 0.129 0.93 0.14 -0.845 -0.847 -0.631 -0.389
0 0 0 0 0 0 0 0 0 0.76 0.252 0.818 0.368 0.591 0.284 0.324 -0.175 -0.402 -0.627 0.782
10 changes: 5 additions & 5 deletions nireports/tests/test_dwi.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,23 +35,23 @@
def test_plot_dwi(tmp_path, testdata_path, outdir):
"""Check the plot of DWI data."""

dwi_img = nb.load(testdata_path / 'ds000114_sub-01_ses-test_dwi.nii.gz')
stem = 'ds000114_sub-01_ses-test_desc-trunc_dwi'
dwi_img = nb.load(testdata_path / f'{stem}.nii.gz')
affine = dwi_img.affine

bvecs = np.loadtxt(testdata_path / 'ds000114_singleshell.bvec').T
bvals = np.loadtxt(testdata_path / 'ds000114_singleshell.bval')
bvecs = np.loadtxt(testdata_path / f'{stem}.bvec').T
bvals = np.loadtxt(testdata_path / f'{stem}.bval')

gradients = np.hstack([bvecs, bvals[:, None]])

# Pick a random volume to show
rng = np.random.default_rng(1234)
# The image is truncated, so limit the range by volumes, not gradients
idx = rng.integers(low=0, high=dwi_img.shape[-1], size=1).item()

_ = plot_dwi(dwi_img.get_fdata()[..., idx], affine, gradient=gradients[idx])

if outdir is not None:
plt.savefig(outdir / 'ds000114_dwi.svg', bbox_inches='tight')
plt.savefig(outdir / f'{stem}.svg', bbox_inches='tight')


@pytest.mark.parametrize(
Expand Down

0 comments on commit ba1f12a

Please sign in to comment.