Skip to content

Commit 49eb727

Browse files
committed
Address review feedback
- 4-D atlas is now an error, not a warning (ambiguous volumes) - "timeseries extraction" -> "connectome extraction" in atlas help text - Use _or_default in _build_brain_extraction_templates - Remove hard-coded resolution from help text and docstrings
1 parent 599f243 commit 49eb727

15 files changed

Lines changed: 43 additions & 47 deletions

File tree

src/rbc/cli/all.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ def register_command(
137137
default=["schaefer_200"],
138138
metavar="ATLAS",
139139
help=(
140-
"Atlas(es) for timeseries extraction. Accepts registry names "
140+
"Atlas(es) for connectome extraction. Accepts registry names "
141141
f"({', '.join(sorted(ATLAS_REGISTRY))}) or paths to custom NIfTI "
142142
"atlas files."
143143
),
@@ -166,7 +166,7 @@ def register_command(
166166
"--anat-template",
167167
type=_validate_nifti_path,
168168
default=None,
169-
help="Custom 1 mm brain template for anatomical registration.",
169+
help="Custom brain template for anatomical registration.",
170170
)
171171
templates.add_argument(
172172
"--brain-extraction-template",
@@ -190,13 +190,13 @@ def register_command(
190190
"--func-template",
191191
type=_validate_nifti_path,
192192
default=None,
193-
help="Custom 2 mm brain template for functional resampling.",
193+
help="Custom brain template for functional resampling (default: MNI152 2 mm).",
194194
)
195195
templates.add_argument(
196196
"--func-template-mask",
197197
type=_validate_nifti_path,
198198
default=None,
199-
help="Custom 2 mm brain mask for functional masking.",
199+
help="Custom brain mask for functional masking (default: MNI152 2 mm).",
200200
)
201201
templates.add_argument(
202202
"--func-template-ref",

src/rbc/cli/anatomical.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ def register_command(
7979
"--anat-template",
8080
type=_validate_nifti_path,
8181
default=None,
82-
help="Custom 1 mm brain template for anatomical registration.",
82+
help="Custom brain template for anatomical registration.",
8383
)
8484
templates.add_argument(
8585
"--brain-extraction-template",

src/rbc/cli/base.py

Lines changed: 15 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -98,10 +98,13 @@ def _validate_positive(value: float | int | None, name: str) -> None:
9898

9999

100100
def _validate_atlas_nifti(path: Path) -> None:
101-
"""Warn if a custom atlas NIfTI has a non-integer dtype or is 4-D.
101+
"""Validate a custom atlas NIfTI has integer labels and is 3-D.
102102
103103
Args:
104104
path: Path to a NIfTI atlas file.
105+
106+
Raises:
107+
ValueError: If the atlas is not a 3-D volume.
105108
"""
106109
try:
107110
hdr = nib.nifti1.load(path).header
@@ -112,17 +115,16 @@ def _validate_atlas_nifti(path: Path) -> None:
112115
if dtype.kind not in ("i", "u"): # integer or unsigned integer
113116
_logger.warning(
114117
"Atlas %s has dtype %s (expected integer labels). "
115-
"Timeseries extraction may produce unexpected results.",
118+
"Parcellation-based extraction may produce unexpected results.",
116119
path.name,
117120
dtype,
118121
)
119122
shape = hdr.get_data_shape()
120123
if len(shape) > 3:
121-
_logger.warning(
122-
"Atlas %s is %d-D (expected 3-D parcellation). "
123-
"Only the first volume will be used.",
124-
path.name,
125-
len(shape),
124+
raise ValueError(
125+
f"Atlas {path.name} is {len(shape)}-D (expected a 3-D "
126+
f"parcellation). Multi-volume atlases are ambiguous; extract "
127+
f"the desired volume first."
126128
)
127129

128130

@@ -150,20 +152,14 @@ def _build_brain_extraction_templates(
150152
n_custom,
151153
)
152154
return BrainExtractionTemplates(
153-
template=(
154-
ns.brain_extraction_template
155-
if ns.brain_extraction_template is not None
156-
else BRAIN_EXTRACTION_TEMPLATES.template
155+
template=_or_default(
156+
ns.brain_extraction_template, BRAIN_EXTRACTION_TEMPLATES.template
157157
),
158-
probability_mask=(
159-
ns.brain_extraction_prob_mask
160-
if ns.brain_extraction_prob_mask is not None
161-
else BRAIN_EXTRACTION_TEMPLATES.probability_mask
158+
probability_mask=_or_default(
159+
ns.brain_extraction_prob_mask, BRAIN_EXTRACTION_TEMPLATES.probability_mask
162160
),
163-
registration_mask=(
164-
ns.brain_extraction_reg_mask
165-
if ns.brain_extraction_reg_mask is not None
166-
else BRAIN_EXTRACTION_TEMPLATES.registration_mask
161+
registration_mask=_or_default(
162+
ns.brain_extraction_reg_mask, BRAIN_EXTRACTION_TEMPLATES.registration_mask
167163
),
168164
)
169165

src/rbc/cli/functional.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -121,13 +121,13 @@ def register_command(
121121
"--func-template",
122122
type=_validate_nifti_path,
123123
default=None,
124-
help="Custom 2 mm brain template for functional resampling.",
124+
help="Custom brain template for functional resampling (default: MNI152 2 mm).",
125125
)
126126
templates.add_argument(
127127
"--func-template-mask",
128128
type=_validate_nifti_path,
129129
default=None,
130-
help="Custom 2 mm brain mask for functional masking.",
130+
help="Custom brain mask for functional masking (default: MNI152 2 mm).",
131131
)
132132
templates.add_argument(
133133
"--func-template-ref",

src/rbc/cli/longitudinal.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ def register_command(
9191
"--anat-template",
9292
type=_validate_nifti_path,
9393
default=None,
94-
help="Custom 1 mm brain template for anatomical registration.",
94+
help="Custom brain template for anatomical registration.",
9595
)
9696

9797
parser.set_defaults(

src/rbc/cli/metrics.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ def register_command(
111111
default=["schaefer_200"],
112112
metavar="ATLAS",
113113
help=(
114-
"Atlas(es) for timeseries extraction. Accepts registry names "
114+
"Atlas(es) for connectome extraction. Accepts registry names "
115115
f"({', '.join(sorted(ATLAS_REGISTRY))}) or paths to custom NIfTI "
116116
"atlas files."
117117
),

src/rbc/core/anatomical/registration.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,8 @@ def ants_registration(
4242
Args:
4343
in_file: Skull-stripped T1w brain image (output of brain extraction).
4444
seed: Random seed for ANTs reproducibility.
45-
registration_template: 1 mm brain template used as the fixed image.
46-
Defaults to the bundled MNI152 1 mm template.
45+
registration_template: Brain template used as the fixed image
46+
(default: MNI152 1 mm).
4747
4848
Returns:
4949
Forward (T1w -> template) and inverse (template -> T1w) composite

src/rbc/orchestration/all.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -67,9 +67,9 @@ def run(
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.
70-
registration_template: 1 mm brain template for ANTs registration.
71-
func_template: 2 mm brain template for functional resampling.
72-
func_template_mask: 2 mm brain mask for functional masking.
70+
registration_template: Brain template for ANTs registration.
71+
func_template: Brain template for functional resampling (default: MNI152 2 mm).
72+
func_template_mask: Brain mask for functional masking (default: MNI152 2 mm).
7373
func_template_ref: BOLD reference image for functional masking.
7474
runner_config: Execution backend configuration.
7575
"""

src/rbc/orchestration/anatomical.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ def process_session(
4040
session: Session tables for a single subject/session.
4141
pipe_ctx: RunContext bound to this subject/session.
4242
brain_extraction_templates: Brain extraction template bundle.
43-
registration_template: 1 mm brain template for ANTs registration.
43+
registration_template: Brain template for ANTs registration.
4444
4545
Returns:
4646
The last :class:`AnatomicalOutputs` (for use by downstream workflows).
@@ -78,7 +78,7 @@ def run(
7878
output_dir: Output directory for derivatives.
7979
filters: Participant/session/task filters.
8080
brain_extraction_templates: Brain extraction template bundle.
81-
registration_template: 1 mm brain template for ANTs registration.
81+
registration_template: Brain template for ANTs registration.
8282
runner_config: Execution backend configuration.
8383
"""
8484
config = runner_config or RunnerConfig()

src/rbc/orchestration/functional.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,8 @@ def process_session(
4949
pipe_ctx: RunContext bound to this subject/session.
5050
regressors: Regressor names.
5151
tr: TR override in seconds, or ``None`` to read from headers.
52-
func_template: 2 mm brain template for functional resampling.
53-
func_template_mask: 2 mm brain mask for functional masking.
52+
func_template: Brain template for functional resampling (default: MNI152 2 mm).
53+
func_template_mask: Brain mask for functional masking (default: MNI152 2 mm).
5454
func_template_ref: BOLD reference image for functional masking.
5555
5656
Returns:
@@ -108,8 +108,8 @@ def run(
108108
filters: Participant/session/task filters.
109109
regressors: Regressor names.
110110
tr: TR override in seconds.
111-
func_template: 2 mm brain template for functional resampling.
112-
func_template_mask: 2 mm brain mask for functional masking.
111+
func_template: Brain template for functional resampling (default: MNI152 2 mm).
112+
func_template_mask: Brain mask for functional masking (default: MNI152 2 mm).
113113
func_template_ref: BOLD reference image for functional masking.
114114
runner_config: Execution backend configuration.
115115
"""

0 commit comments

Comments
 (0)