Skip to content

Commit

Permalink
fix: Switch to test_data_package universally
Browse files Browse the repository at this point in the history
  • Loading branch information
effigies committed Oct 4, 2024
1 parent 70bfd85 commit dcff97d
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 16 deletions.
26 changes: 13 additions & 13 deletions nireports/tests/test_dwi.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,15 +38,15 @@
from nireports.tests.utils import _generate_raincloud_random_data


def test_plot_dwi(tmp_path, testdata_path, outdir):
def test_plot_dwi(tmp_path, test_data_package, outdir):
"""Check the plot of DWI data."""

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

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

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

Expand All @@ -65,11 +65,11 @@ def test_plot_dwi(tmp_path, testdata_path, outdir):
"dwi_btable",
["ds000114_singleshell", "hcph_multishell", "ds004737_dsi"],
)
def test_plot_gradients(tmp_path, testdata_path, dwi_btable, outdir):
def test_plot_gradients(tmp_path, test_data_package, dwi_btable, outdir):
"""Check the plot of DWI gradients."""

bvecs = np.loadtxt(testdata_path / f"{dwi_btable}.bvec").T
bvals = np.loadtxt(testdata_path / f"{dwi_btable}.bval")
bvecs = np.loadtxt(test_data_package / f"{dwi_btable}.bvec").T
bvals = np.loadtxt(test_data_package / f"{dwi_btable}.bval")

b0s_mask = bvals < 50

Expand Down Expand Up @@ -120,19 +120,19 @@ def test_plot_tissue_values(tmp_path):
)


def test_nii_to_carpetplot_data(tmp_path, testdata_path, outdir):
def test_nii_to_carpetplot_data(tmp_path, test_data_package, outdir):
"""Check the nii to carpet plot data function"""

testdata_name = "ds000114_sub-01_ses-test_desc-trunc_dwi"

nii = nb.load(testdata_path / f"{testdata_name}.nii.gz")
bvals = np.loadtxt(testdata_path / f"{testdata_name}.bval")
nii = nb.load(test_data_package / f"{testdata_name}.nii.gz")
bvals = np.loadtxt(test_data_package / f"{testdata_name}.bval")

mask_data = np.round(82 * np.random.rand(nii.shape[0], nii.shape[1], nii.shape[2]))

mask_nii = nb.Nifti1Image(mask_data, np.eye(4))

filepath = testdata_path / "aseg.auto_noCCseg.label_intensities.txt"
filepath = test_data_package / "aseg.auto_noCCseg.label_intensities.txt"
keywords = ["Cerebral_White_Matter", "Cerebral_Cortex", "Ventricle"]

segment_labels = get_segment_labels(filepath, keywords)
Expand All @@ -149,12 +149,12 @@ def test_nii_to_carpetplot_data(tmp_path, testdata_path, outdir):
plot_carpet(data, segments, output_file=image_path)


def test_get_segment_labels(tmp_path, testdata_path):
def test_get_segment_labels(tmp_path, test_data_package):
"""Check the segment label function"""

testdata_name = "aseg.auto_noCCseg.label_intensities.txt"

filepath = testdata_path / testdata_name
filepath = test_data_package / testdata_name
keywords = ["Cerebral_White_Matter", "Cerebral_Cortex", "Ventricle"]

segment_labels = get_segment_labels(filepath, keywords)
Expand Down
6 changes: 3 additions & 3 deletions nireports/tests/test_interfaces.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,11 +101,11 @@ def test_RaincloudPlot(orient, density, tmp_path):
_smoke_test_report(rc_rpt, f"raincloud_orient-{orient}_density-{density}.svg")


def test_FMRISummary(testdata_path, tmp_path, outdir):
def test_FMRISummary(test_data_package, tmp_path, outdir):
"""Exercise the FMRISummary interface."""
rng = np.random.default_rng(2010)

in_func = testdata_path / "sub-ds205s03_task-functionallocalizer_run-01_bold_volreg.nii.gz"
in_func = test_data_package / "sub-ds205s03_task-functionallocalizer_run-01_bold_volreg.nii.gz"
ntimepoints = nb.load(in_func).shape[-1]

np.savetxt(
Expand All @@ -126,7 +126,7 @@ def test_FMRISummary(testdata_path, tmp_path, outdir):
interface = FMRISummary(
in_func=str(in_func),
in_segm=str(
testdata_path / "sub-ds205s03_task-functionallocalizer_run-01_bold_parc.nii.gz"
test_data_package / "sub-ds205s03_task-functionallocalizer_run-01_bold_parc.nii.gz"
),
fd=str(tmp_path / "fd.txt"),
outliers=str(tmp_path / "outliers.txt"),
Expand Down

0 comments on commit dcff97d

Please sign in to comment.