|
1 | 1 | """Integration test for ``rbc all`` pipeline stage handoff. |
2 | 2 |
|
3 | | -Runs the full pipeline via ``rbc all`` (in-memory handoff) and via the four |
4 | | -individual subcommands in sequence (disk round-trip), then verifies that both |
5 | | -approaches complete without errors, produce key derivative files, and yield |
6 | | -identical outputs. |
| 3 | +Runs the full pipeline via ``rbc all`` (in-memory handoff) and via the |
| 4 | +individual subcommands in sequence (disk round-trip), then verifies that |
| 5 | +both approaches complete without errors, produce key derivative files, |
| 6 | +and yield identical outputs. |
| 7 | +
|
| 8 | +The sequential run reuses anatomical outputs from the ``rbc all`` run to |
| 9 | +avoid running brain extraction and registration twice. |
7 | 10 | """ |
8 | 11 |
|
9 | 12 | from __future__ import annotations |
@@ -92,25 +95,40 @@ def all_output(tmp_path_factory: pytest.TempPathFactory, _runner: str) -> Path: |
92 | 95 |
|
93 | 96 |
|
94 | 97 | @pytest.fixture(scope="session") |
95 | | -def sequential_output(tmp_path_factory: pytest.TempPathFactory, _runner: str) -> Path: |
96 | | - """Run the four individual subcommands in order and return the output dir.""" |
| 98 | +def sequential_output( |
| 99 | + tmp_path_factory: pytest.TempPathFactory, |
| 100 | + _runner: str, |
| 101 | + all_output: Path, |
| 102 | +) -> Path: |
| 103 | + """Run functional/metrics/qc using anat outputs from ``rbc all``. |
| 104 | +
|
| 105 | + Copies the anatomical derivatives produced by the ``all_output`` |
| 106 | + fixture so that only the functional, metrics, and QC stages run, |
| 107 | + saving ~30-40 min of redundant brain extraction and registration. |
| 108 | + """ |
97 | 109 | out = tmp_path_factory.mktemp("sequential") / "derivatives" |
98 | 110 | out.mkdir() |
99 | 111 |
|
| 112 | + # Seed with anatomical outputs + dataset_description from rbc all |
| 113 | + anat_src = all_output / f"sub-{_SUB}" / "anat" |
| 114 | + anat_dst = out / f"sub-{_SUB}" / "anat" |
| 115 | + shutil.copytree(anat_src, anat_dst) |
| 116 | + shutil.copy2( |
| 117 | + all_output / "dataset_description.json", |
| 118 | + out / "dataset_description.json", |
| 119 | + ) |
| 120 | + |
100 | 121 | runner_args = ["--runner", _runner, *_COMMON_ARGS] |
101 | 122 | raw = str(_TEST_DATASET) |
102 | 123 | deriv = str(out) |
103 | 124 |
|
104 | | - # 1. anatomical (raw BIDS only) |
105 | | - _run_rbc(["anatomical", raw, "-o", deriv, *runner_args]) |
106 | | - |
107 | | - # 2. functional (raw BIDS + anat derivatives) |
| 125 | + # functional (raw BIDS + anat derivatives) |
108 | 126 | _run_rbc(["functional", raw, deriv, "-o", deriv, *runner_args]) |
109 | 127 |
|
110 | | - # 3. metrics (raw BIDS + derivatives from previous stages) |
| 128 | + # metrics (derivatives from previous stages) |
111 | 129 | _run_rbc(["metrics", raw, deriv, "-o", deriv, *runner_args]) |
112 | 130 |
|
113 | | - # 4. qc (raw BIDS + derivatives from previous stages) |
| 131 | + # qc (derivatives from previous stages) |
114 | 132 | _run_rbc(["qc", raw, deriv, "-o", deriv, *runner_args]) |
115 | 133 |
|
116 | 134 | return out |
@@ -179,7 +197,7 @@ def test_rbc_all_produces_derivatives(all_output: Path) -> None: |
179 | 197 |
|
180 | 198 | @pytest.mark.slow |
181 | 199 | def test_sequential_produces_derivatives(sequential_output: Path) -> None: |
182 | | - """Running anatomical/functional/metrics/qc individually produces the same files.""" |
| 200 | + """Running functional/metrics/qc individually produces the same files.""" |
183 | 201 | _assert_derivatives_exist(sequential_output) |
184 | 202 |
|
185 | 203 |
|
|
0 commit comments