Skip to content

Commit d17cdf7

Browse files
committed
ENH: add test for PET confounds workflow
1 parent 31e3adf commit d17cdf7

File tree

1 file changed

+34
-0
lines changed

1 file changed

+34
-0
lines changed
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
import nibabel as nb
2+
import numpy as np
3+
4+
from ..confounds import init_pet_confs_wf
5+
6+
7+
def test_dvars_connects_pet_mask(tmp_path):
8+
"""Check dvars node connection and execution."""
9+
wf = init_pet_confs_wf(
10+
mem_gb=0.01,
11+
metadata={},
12+
regressors_all_comps=False,
13+
regressors_dvars_th=1.5,
14+
regressors_fd_th=0.5,
15+
)
16+
17+
edge = wf._graph.get_edge_data(wf.get_node('inputnode'), wf.get_node('dvars'))
18+
assert ('pet_mask', 'in_mask') in edge['connect']
19+
20+
img = nb.Nifti1Image(np.random.rand(2, 2, 2, 5), np.eye(4))
21+
mask = nb.Nifti1Image(np.ones((2, 2, 2), dtype=np.uint8), np.eye(4))
22+
pet_file = tmp_path / 'pet.nii.gz'
23+
mask_file = tmp_path / 'mask.nii.gz'
24+
img.to_filename(pet_file)
25+
mask.to_filename(mask_file)
26+
27+
node = wf.get_node('dvars')
28+
node.base_dir = tmp_path
29+
node.inputs.in_file = str(pet_file)
30+
node.inputs.in_mask = str(mask_file)
31+
result = node.run()
32+
33+
assert result.outputs.out_nstd
34+
assert result.outputs.out_std

0 commit comments

Comments
 (0)