44individual subcommands in sequence (disk round-trip), then verifies that both
55approaches complete without errors, produce key derivative files, and yield
66identical outputs.
7-
8- The BOLD timeseries is truncated to a small number of volumes so that
9- functional processing finishes in minutes rather than tens of minutes.
107"""
118
129from __future__ import annotations
1613from pathlib import Path
1714from typing import TYPE_CHECKING
1815
19- import nibabel as nib
20- import numpy as np
2116import pytest
2217
2318if TYPE_CHECKING :
2419 from collections .abc import Sequence
2520
26- _ORIG_DATASET = Path (__file__ ).parents [1 ] / "data" / "ds000001"
21+ _TEST_DATASET = Path (__file__ ).parents [1 ] / "data" / "ds000001"
2722
2823# Subject with no session in ds000001.
2924_SUB = "01"
3025_TASK = "balloonanalogrisktask"
3126_RUN = "01"
3227
33- # Number of BOLD volumes to keep. The 36-parameter regressor model needs
34- # more timepoints than regressors (~36 columns + derivatives). After
35- # discarding --start-tr 2, we need at least ~45 usable volumes.
36- _BOLD_VOLUMES = 50
37-
3828
3929# ---------------------------------------------------------------------------
4030# Helpers
@@ -83,36 +73,14 @@ def _runner(request: pytest.FixtureRequest) -> str:
8373
8474
8575@pytest .fixture (scope = "session" )
86- def truncated_dataset (tmp_path_factory : pytest .TempPathFactory ) -> Path :
87- """Copy ds000001 and truncate the BOLD to *_BOLD_VOLUMES* volumes."""
88- dest = tmp_path_factory .mktemp ("ds" ) / "ds000001"
89- shutil .copytree (_ORIG_DATASET , dest )
90-
91- bold = (
92- dest
93- / f"sub-{ _SUB } "
94- / "func"
95- / f"sub-{ _SUB } _task-{ _TASK } _run-{ _RUN } _bold.nii.gz"
96- )
97- img = nib .nifti1 .load (bold )
98- data = np .asarray (img .dataobj [:, :, :, :_BOLD_VOLUMES ])
99- nib .nifti1 .save (nib .Nifti1Image (data , img .affine , img .header ), bold )
100- return dest
101-
102-
103- @pytest .fixture (scope = "session" )
104- def all_output (
105- tmp_path_factory : pytest .TempPathFactory ,
106- _runner : str ,
107- truncated_dataset : Path ,
108- ) -> Path :
76+ def all_output (tmp_path_factory : pytest .TempPathFactory , _runner : str ) -> Path :
10977 """Run ``rbc all`` once and return the output directory."""
11078 out = tmp_path_factory .mktemp ("all" ) / "derivatives"
11179 out .mkdir ()
11280 _run_rbc (
11381 [
11482 "all" ,
115- str (truncated_dataset ),
83+ str (_TEST_DATASET ),
11684 "-o" ,
11785 str (out ),
11886 "--runner" ,
@@ -124,17 +92,13 @@ def all_output(
12492
12593
12694@pytest .fixture (scope = "session" )
127- def sequential_output (
128- tmp_path_factory : pytest .TempPathFactory ,
129- _runner : str ,
130- truncated_dataset : Path ,
131- ) -> Path :
95+ def sequential_output (tmp_path_factory : pytest .TempPathFactory , _runner : str ) -> Path :
13296 """Run the four individual subcommands in order and return the output dir."""
13397 out = tmp_path_factory .mktemp ("sequential" ) / "derivatives"
13498 out .mkdir ()
13599
136100 runner_args = ["--runner" , _runner , * _COMMON_ARGS ]
137- raw = str (truncated_dataset )
101+ raw = str (_TEST_DATASET )
138102 deriv = str (out )
139103
140104 # 1. anatomical (raw BIDS only)
0 commit comments