Skip to content

Commit a3e7707

Browse files
committed
Remove redundant regressor_set, replace fake tests with real ds000114 integration
- Drop regressor_set param from longitudinal_process; iterate regressor_files.keys() instead. The resolve layer already filters to the requested strategies, so the dict keys ARE the set. Eliminates the caller sync burden. - Delete tests/full_pipeline/longitudinal/ -- the conftest hacked the cross-sectional anat brain as a "longitudinal template", which exercises the code path but not the actual transform chain. - Rewrite tests/integration/longitudinal/test_regression_reuse.py as a proper end-to-end CLI test: rbc functional -> rbc longitudinal functional on ds000114 sub-01 ses-test via subprocess. Asserts expected BIDS tree, non-degenerate variance, and binary mask. - Add ds000114_func_derivatives and longitudinal_func_output fixtures to the integration conftest so the full cross-sectional -> longitudinal chain runs on real multi-session data with docker.
1 parent b487e35 commit a3e7707

7 files changed

Lines changed: 148 additions & 299 deletions

File tree

src/rbc/orchestration/longitudinal/functional.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -60,10 +60,7 @@ def process_func(
6060
ses=pipe_ctx.ses, # type: ignore[arg-type]
6161
regressors=regressors,
6262
)
63-
func_outputs = functional_longitudinal(
64-
**resolved, # type: ignore[arg-type]
65-
regressor_set=regressors,
66-
)
63+
func_outputs = functional_longitudinal(**resolved) # type: ignore[arg-type]
6764
fex = func_q.derive(space="longitudinal")
6865
export_longitudinal_func(fex, func_outputs, regressors=regressors)
6966

src/rbc/workflows/longitudinal/functional.py

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,7 @@
1919
)
2020

2121
if TYPE_CHECKING:
22-
from collections.abc import Sequence
2322
from pathlib import Path
24-
from typing import Literal
2523

2624
_logger = logging.getLogger("rbc")
2725

@@ -57,7 +55,6 @@ def longitudinal_process(
5755
bold: Path,
5856
bold_mask: Path,
5957
regressor_files: dict[str, Path],
60-
regressor_set: Sequence[Literal["36-parameter", "aCompCor"]] = ("36-parameter",),
6158
) -> FunctionalLongOutputs:
6259
"""Transform preprocessed functional outputs to longitudinal template space.
6360
@@ -66,6 +63,10 @@ def longitudinal_process(
6663
No regressor recomputation is performed: the same regressor matrix is
6764
applied in the new target space.
6865
66+
Regression is applied for every strategy present in *regressor_files*.
67+
The caller controls which strategies to run by passing only the desired
68+
keys (the resolve layer filters to the requested ``--regressor`` set).
69+
6970
Args:
7071
template: Longitudinal template image.
7172
anat_to_template_xfm: T1w-to-longitudinal-template composite warp.
@@ -74,9 +75,8 @@ def longitudinal_process(
7475
bold: Preprocessed bold image.
7576
bold_mask: Bold brain mask.
7677
regressor_files: Raw (unfiltered) regressor ``.1D`` files from
77-
the cross-sectional run, keyed by strategy name.
78-
regressor_set: Which regressor strategies to apply. Must be a
79-
subset of the keys in *regressor_files*.
78+
the cross-sectional run, keyed by strategy name. Regression
79+
is applied for every key in this dict.
8080
8181
Returns:
8282
:class:`FunctionalLongOutputs` with all inputs transformed to
@@ -98,8 +98,7 @@ def longitudinal_process(
9898

9999
regressed: dict[str, Path] = {}
100100
cleaned: dict[str, Path] = {}
101-
for reg in regressor_set:
102-
reg_file = regressor_files[reg]
101+
for reg, reg_file in regressor_files.items():
103102
_logger.info("Longitudinal %s nuisance regression (no bandpass)", reg)
104103
regressed[reg] = apply_regression(
105104
bold_file=long_bold,

tests/full_pipeline/longitudinal/__init__.py

Lines changed: 0 additions & 1 deletion
This file was deleted.

tests/full_pipeline/longitudinal/conftest.py

Lines changed: 0 additions & 110 deletions
This file was deleted.

tests/full_pipeline/longitudinal/test_functional.py

Lines changed: 0 additions & 64 deletions
This file was deleted.

tests/integration/longitudinal/conftest.py

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
)
2626

2727
_SUB = "01"
28+
_TASK = "fingerfootlips"
2829

2930

3031
def _rbc_exe() -> str:
@@ -143,3 +144,70 @@ def longitudinal_template_output(
143144
],
144145
)
145146
return ds000114_anat_derivatives
147+
148+
149+
@pytest.fixture(scope="session")
150+
def ds000114_func_derivatives(
151+
ds000114_dataset: Path,
152+
longitudinal_template_output: Path,
153+
_runner: str,
154+
) -> Path:
155+
"""Run ``rbc functional`` on ds000114 sub-01 ses-test.
156+
157+
Produces cross-sectional functional derivatives (including raw
158+
regressor ``.1D`` files) that the longitudinal functional stage
159+
consumes. Writes into the same derivatives tree as the template
160+
stage so all outputs are visible to downstream fixtures.
161+
162+
Only ses-test is processed (one session is sufficient to exercise
163+
the longitudinal functional chain).
164+
"""
165+
_run_rbc(
166+
[
167+
"functional",
168+
str(ds000114_dataset),
169+
str(longitudinal_template_output),
170+
"-o",
171+
str(longitudinal_template_output),
172+
"--runner",
173+
_runner,
174+
"--participant-label",
175+
_SUB,
176+
"--session-label",
177+
"test",
178+
"--task",
179+
_TASK,
180+
],
181+
)
182+
return longitudinal_template_output
183+
184+
185+
@pytest.fixture(scope="session")
186+
def longitudinal_func_output(
187+
ds000114_func_derivatives: Path,
188+
_runner: str,
189+
) -> Path:
190+
"""Run ``rbc longitudinal functional`` on ds000114 sub-01 ses-test.
191+
192+
Produces longitudinal functional derivatives (warped BOLD,
193+
per-regressor regressed/cleaned BOLD) by consuming the
194+
cross-sectional functional outputs and the longitudinal template.
195+
"""
196+
_run_rbc(
197+
[
198+
"longitudinal",
199+
"functional",
200+
str(ds000114_func_derivatives),
201+
"-o",
202+
str(ds000114_func_derivatives),
203+
"--runner",
204+
_runner,
205+
"--participant-label",
206+
_SUB,
207+
"--session-label",
208+
"test",
209+
"--task",
210+
_TASK,
211+
],
212+
)
213+
return ds000114_func_derivatives

0 commit comments

Comments
 (0)