Skip to content

Commit be23538

Browse files
committed
mypy
1 parent 54227e6 commit be23538

6 files changed

Lines changed: 31 additions & 30 deletions

File tree

src/rbc/orchestration/all.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ def run(
4242
filters: Filters,
4343
regressors: Sequence[str],
4444
atlas_files: Mapping[str, Path],
45-
fwhm: float,
45+
smooth: float | None = None,
4646
start_tr: int,
4747
tr: float | None = None,
4848
brain_extraction_templates: BrainExtractionTemplates = BRAIN_EXTRACTION_TEMPLATES,
@@ -63,7 +63,7 @@ def run(
6363
filters: Participant/session/task filters.
6464
regressors: Regressor names.
6565
atlas_files: Mapping of atlas labels to resolved NIfTI file paths.
66-
fwhm: Smoothing kernel FWHM in mm.
66+
smooth: Smoothing kernel FWHM in mm.
6767
start_tr: Number of initial TRs discarded during preprocessing.
6868
tr: TR override in seconds, or ``None`` to read from headers.
6969
brain_extraction_templates: Brain extraction template bundle.
@@ -140,14 +140,14 @@ def run(
140140
template_brain_mask=func_outputs.template_brain_mask,
141141
tr=func_metadata.tr,
142142
atlas_files=atlas_files,
143-
fwhm=fwhm,
143+
smooth=smooth,
144144
)
145145
export_metrics(
146146
mni,
147147
metrics_outputs,
148148
regressor=regressor,
149149
atlases=list(atlas_files),
150-
fwhm=fwhm,
150+
smooth=smooth,
151151
)
152152

153153
# QC

src/rbc/workflows/functional.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -375,9 +375,7 @@ def single_session_preprocess(
375375
if smooth is not None:
376376
cleaned_bold_smooth = {}
377377
for regressor in regressor_set:
378-
_logger.info(
379-
"%s smoothing cleaned BOLD (fwhm=%.1f mm)", regressor, smooth
380-
)
378+
_logger.info("%s smoothing cleaned BOLD (fwhm=%.1f mm)", regressor, smooth)
381379
cleaned_bold_smooth[regressor] = apply_smooth(
382380
cleaned[regressor].regressed_bold,
383381
tmpl_brain,

tests/unit/bids/test_exports.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,9 @@ def _make_func_outputs(w: Path, regressors: list[str]) -> FunctionalOutputs:
7373
template_bold=_dummy(w, "template_bold.nii.gz"),
7474
regressed_bold={r: _dummy(w, f"regressed_{r}.nii.gz") for r in regressors},
7575
cleaned_bold={r: _dummy(w, f"cleaned_{r}.nii.gz") for r in regressors},
76+
cleaned_bold_smooth={
77+
r: _dummy(w, f"cleaned_{r}_smooth.nii.gz") for r in regressors
78+
},
7679
regressor_file={r: _dummy(w, f"regressors_{r}.1D") for r in regressors},
7780
template_brain_mask=_dummy(w, "template_mask.nii.gz"),
7881
)
@@ -235,7 +238,7 @@ def test_sanitizes_atlas_labels(
235238
mni = func_bids.derive(space="MNI152NLin6Asym")
236239
outputs = _make_metrics_outputs(workdir, ["schaefer_200"])
237240
export_metrics(
238-
mni, outputs, regressor="36-parameter", atlases=["schaefer_200"], fwhm=6.0
241+
mni, outputs, regressor="36-parameter", atlases=["schaefer_200"], smooth=6.0
239242
)
240243
atlas_files = [
241244
p.name for p in pipe_ctx.output_dir.rglob("*.*") if "atlas-" in p.name
@@ -252,7 +255,7 @@ def test_sanitizes_regressor_labels(
252255
mni = func_bids.derive(space="MNI152NLin6Asym")
253256
outputs = _make_metrics_outputs(workdir, ["aal"])
254257
export_metrics(
255-
mni, outputs, regressor="36-parameter", atlases=["aal"], fwhm=6.0
258+
mni, outputs, regressor="36-parameter", atlases=["aal"], smooth=6.0
256259
)
257260
all_names = [p.name for p in pipe_ctx.output_dir.rglob("*.*")]
258261
reg_files = [n for n in all_names if "reg-" in n]
@@ -267,7 +270,7 @@ def test_file_count_single_atlas(
267270
mni = func_bids.derive(space="MNI152NLin6Asym")
268271
outputs = _make_metrics_outputs(workdir, ["schaefer_200"])
269272
export_metrics(
270-
mni, outputs, regressor="aCompCor", atlases=["schaefer_200"], fwhm=6.0
273+
mni, outputs, regressor="aCompCor", atlases=["schaefer_200"], smooth=6.0
271274
)
272275
saved = list(pipe_ctx.output_dir.rglob("*.*"))
273276
assert len(saved) == 8
@@ -279,7 +282,7 @@ def test_file_count_multiple_atlases(
279282
atlases = ["schaefer_200", "aal"]
280283
mni = func_bids.derive(space="MNI152NLin6Asym")
281284
outputs = _make_metrics_outputs(workdir, atlases)
282-
export_metrics(mni, outputs, regressor="aCompCor", atlases=atlases, fwhm=6.0)
285+
export_metrics(mni, outputs, regressor="aCompCor", atlases=atlases, smooth=6.0)
283286
saved = list(pipe_ctx.output_dir.rglob("*.*"))
284287
assert len(saved) == 10
285288

tests/unit/cli/test_all.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ def test_defaults(self, base_args: argparse.Namespace) -> None:
6464
assert args.regressor == ["36-parameter"]
6565
assert args.task is None
6666
assert "schaefer_200" in args.atlas_files
67-
assert args.fwhm == 6.0
67+
assert args.smooth == 6.0
6868
assert args.start_tr == 2
6969
assert args.participant_label == []
7070
assert args.session_label == []
@@ -94,20 +94,20 @@ def test_invalid_atlas_raises(self, base_args: argparse.Namespace) -> None:
9494
with pytest.raises(FileNotFoundError):
9595
AllArgs.validate_namespace(base_args)
9696

97-
@pytest.mark.parametrize("fwhm", [0.1, 1.0, 6.0, 10.0])
98-
def test_valid_fwhm(self, base_args: argparse.Namespace, fwhm: float) -> None:
97+
@pytest.mark.parametrize("smooth", [0.1, 1.0, 6.0, 10.0])
98+
def test_valid_fwhm(self, base_args: argparse.Namespace, smooth: float) -> None:
9999
"""Positive FWHM values pass validation."""
100-
base_args.fwhm = fwhm
100+
base_args.smooth = smooth
101101
args = AllArgs.validate_namespace(base_args)
102-
assert args.fwhm == fwhm
102+
assert args.smooth == smooth
103103

104-
@pytest.mark.parametrize("fwhm", [0.0, -1.0, -6.0])
104+
@pytest.mark.parametrize("smooth", [0.0, -1.0, -6.0])
105105
def test_invalid_fwhm_raises(
106-
self, base_args: argparse.Namespace, fwhm: float
106+
self, base_args: argparse.Namespace, smooth: float
107107
) -> None:
108108
"""Zero or negative FWHM raises ValueError."""
109-
base_args.fwhm = fwhm
110-
with pytest.raises(ValueError, match="FWHM"):
109+
base_args.smooth = smooth
110+
with pytest.raises(ValueError, match="smooth"):
111111
AllArgs.validate_namespace(base_args)
112112

113113
def test_custom_start_tr(self, base_args: argparse.Namespace) -> None:

tests/unit/cli/test_metrics.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ def test_defaults(self, base_args: argparse.Namespace) -> None:
5555
args = MetricsArgs.validate_namespace(base_args)
5656
assert args.task is None
5757
assert "schaefer_200" in args.atlas_files
58-
assert args.fwhm == 6.0
58+
assert args.smooth == 6.0
5959
assert args.regressor == ["36-parameter"]
6060
assert args.participant_label == []
6161
assert args.session_label == []
@@ -85,20 +85,20 @@ def test_invalid_atlas_raises(self, base_args: argparse.Namespace) -> None:
8585
with pytest.raises(FileNotFoundError):
8686
MetricsArgs.validate_namespace(base_args)
8787

88-
@pytest.mark.parametrize("fwhm", [0.1, 1.0, 6.0, 10.0])
89-
def test_valid_fwhm(self, base_args: argparse.Namespace, fwhm: float) -> None:
88+
@pytest.mark.parametrize("smooth", [0.1, 1.0, 6.0, 10.0])
89+
def test_valid_fwhm(self, base_args: argparse.Namespace, smooth: float) -> None:
9090
"""Positive FWHM values pass validation."""
91-
base_args.fwhm = fwhm
91+
base_args.smooth = smooth
9292
args = MetricsArgs.validate_namespace(base_args)
93-
assert args.fwhm == fwhm
93+
assert args.smooth == smooth
9494

95-
@pytest.mark.parametrize("fwhm", [0.0, -1.0, -6.0])
95+
@pytest.mark.parametrize("smooth", [0.0, -1.0, -6.0])
9696
def test_invalid_fwhm_raises(
97-
self, base_args: argparse.Namespace, fwhm: float
97+
self, base_args: argparse.Namespace, smooth: float
9898
) -> None:
9999
"""Zero or negative FWHM raises ValueError."""
100-
base_args.fwhm = fwhm
101-
with pytest.raises(ValueError, match="FWHM"):
100+
base_args.smooth = smooth
101+
with pytest.raises(ValueError, match="smooth"):
102102
MetricsArgs.validate_namespace(base_args)
103103

104104
@pytest.mark.parametrize(

tests/unit/orchestration/test_functional.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -247,7 +247,7 @@ def test_anat_outputs_forwarded_as_anat_inputs(self, tmp_path: Path) -> None:
247247
filters=Filters(participant_label=["01"]),
248248
regressors=["36-parameter"],
249249
atlas_files={},
250-
fwhm=6.0,
250+
smooth=6.0,
251251
start_tr=2,
252252
)
253253

0 commit comments

Comments
 (0)