Skip to content

Commit d008a41

Browse files
authored
Merge pull request #470 from nipreps/enh/enable-multi-step-reg
ENH: Make `--multi-step-reg` a boolean action, enable by default
2 parents 279dabc + b0c4c46 commit d008a41

File tree

9 files changed

+60
-22
lines changed

9 files changed

+60
-22
lines changed

.circleci/config.yml

Lines changed: 23 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -211,11 +211,25 @@ jobs:
211211
printf "[execution]\nstop_on_first_crash = true\n" > /tmp/bcp/nipype.cfg
212212
echo "poll_sleep_duration = 0.01" >> /tmp/bcp/nipype.cfg
213213
echo "hash_method = content" >> /tmp/bcp/nipype.cfg
214+
- run:
215+
name: Get intermediate transforms
216+
command: |
217+
mkdir -p /tmp/pooch
218+
cd /tmp/pooch
219+
# Caching intermediate templates so no need to constantly fetch
220+
XFM="from-MNI152NLin6Asym_to-MNIInfant+1_xfm.h5"
221+
echo "Downloading $XFM"
222+
curl -Lo "$XFM" https://osf.io/download/kx7ny
223+
XFM="from-MNIInfant+1_to-MNI152NLin6Asym_xfm.h5"
224+
echo "Downloading $XFM"
225+
curl -Lo "$XFM" https://osf.io/download/7ge2b
226+
214227
- persist_to_workspace:
215228
root: /tmp
216229
paths:
217230
- fslicense
218231
- bcp/nipype.cfg
232+
- pooch/*
219233

220234
test_pytest:
221235
!!merge <<: *machine_defaults
@@ -334,7 +348,8 @@ jobs:
334348
--nthreads 4 -vv --age-months 2 --sloppy \
335349
--surface-recon-method infantfs \
336350
--derivatives precomputed=/tmp/data/${DATASET}/derivatives/bibsnet \
337-
--output-layout bids --anat-only
351+
--output-layout bids --anat-only \
352+
--pooch-cache-dir /tmp/pooch
338353
- run:
339354
name: Checking outputs of anatomical nibabies run
340355
command: |
@@ -360,10 +375,11 @@ jobs:
360375
--skull-strip-template UNCInfant:cohort-1 \
361376
--output-spaces MNIInfant:cohort-1 func \
362377
--sloppy --write-graph --mem-mb 14000 \
363-
--nthreads 4 -vv --age-months 2 --sloppy \
378+
--nthreads 4 -vv --age-months 2 \
364379
--surface-recon-method infantfs \
365380
--derivatives precomputed=/tmp/data/${DATASET}/derivatives/bibsnet \
366-
--output-layout bids
381+
--output-layout bids \
382+
--pooch-cache-dir /tmp/pooch
367383
- run:
368384
name: Checking outputs of full nibabies run
369385
command: |
@@ -393,7 +409,7 @@ jobs:
393409
cp -r /tmp/data/${DATASET}/derivatives/bibsnet /tmp/data/${DATASET}-t2only/derivatives
394410
395411
- run:
396-
name: Run nibabies single anatomical workflow
412+
name: Run nibabies single anatomical workflow (T2w only)
397413
no_output_timeout: 1h
398414
command: |
399415
mkdir -p /tmp/data/${DATASET}-t2only /tmp/${DATASET}/derivatives/nibabies-t2only /tmp/${DATASET}/work-t2only
@@ -406,10 +422,11 @@ jobs:
406422
--skull-strip-template UNCInfant:cohort-1 \
407423
--output-spaces MNIInfant:cohort-1 func \
408424
--sloppy --write-graph --mem-mb 14000 \
409-
--nthreads 4 -vv --age-months 2 --sloppy \
425+
--nthreads 4 -vv --age-months 2 \
410426
--surface-recon-method infantfs \
411427
--derivatives precomputed=/tmp/data/${DATASET}-t2only/derivatives/bibsnet \
412-
--output-layout bids --anat-only --cifti-output
428+
--output-layout bids --anat-only --cifti-output \
429+
--pooch-cache-dir /tmp/pooch
413430
- run:
414431
name: Checking outputs of T2-only nibabies anat
415432
command: |

.github/workflows/pytest.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ jobs:
3131
dependencies: [ 'latest', 'pre' ]
3232
include:
3333
- os: ubuntu-latest
34-
python-version: '3.13'
34+
python-version: '3.12'
3535
dependencies: 'min'
3636

3737
env:

env.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ channels:
44
- conda-forge
55
# Update this ~yearly; last updated June 12 2025
66
dependencies:
7-
- python=3.13
7+
- python=3.12
88
# Needed for svgo and bids-validator; consider moving to deno
99
- nodejs=20
1010
# Intel Math Kernel Library for numpy

nibabies/cli/parser.py

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,12 @@
1515

1616
def _build_parser():
1717
"""Build parser object."""
18-
from argparse import Action, ArgumentDefaultsHelpFormatter, ArgumentParser
18+
from argparse import (
19+
Action,
20+
ArgumentDefaultsHelpFormatter,
21+
ArgumentParser,
22+
BooleanOptionalAction,
23+
)
1924
from functools import partial
2025
from pathlib import Path
2126

@@ -759,7 +764,8 @@ def _str_none(val):
759764
)
760765
g_baby.add_argument(
761766
'--multi-step-reg',
762-
action='store_true',
767+
action=BooleanOptionalAction,
768+
default=True,
763769
help='For certain adult templates (MNI152NLin6Asym), perform two step '
764770
'registrations (native -> MNIInfant -> template) and concatenate into a single xfm',
765771
)
@@ -773,6 +779,11 @@ def parse_args(args=None, namespace=None):
773779
parser = _build_parser()
774780
opts = parser.parse_args(args, namespace)
775781

782+
if opts.sloppy:
783+
config.loggers.cli.warning('Sloppy mode enabled: expect low-quality results')
784+
# disable multi-step registration as it expects a warp
785+
opts.multi_step_reg = False
786+
776787
if opts.config_file:
777788
skip = {} if opts.reports_only else {'execution': ('run_uuid',)}
778789
config.load(opts.config_file, skip=skip)

nibabies/config.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -578,7 +578,7 @@ class workflow(_Config):
578578
"""Run FreeSurfer ``recon-all`` with the ``-logitudinal`` flag."""
579579
medial_surface_nan = None
580580
"""Fill medial surface with :abbr:`NaNs (not-a-number)` when sampling."""
581-
multi_step_reg = False
581+
multi_step_reg = True
582582
"""Perform multiple registrations (native -> MNIInfant -> template) and concatenate into a
583583
single transform"""
584584
norm_csf = False

nibabies/utils/tests/test_bids.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,5 +78,5 @@ def test_get_age_from_tsv_warning(tmp_path):
7878
dual_participants = {'participant_id': ['sub-1', 'sub-2', 'sub-2']}
7979
create_tsv({**dual_participants, **age_months}, tsv_file)
8080

81-
with pytest.warns(UserWarning):
81+
with pytest.warns(UserWarning, match='Multiple matches for participant_id:sub-2'):
8282
_get_age_from_tsv(tsv_file, 'participant_id', 'sub-2')

nibabies/workflows/tests/test_base.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ def _make_params(
138138
ignore: list[str] = None,
139139
bids_filters: dict = None,
140140
norm_csf: bool = False,
141-
multi_step_reg: bool = False,
141+
multi_step_reg: bool = True,
142142
):
143143
if ignore is None:
144144
ignore = []
@@ -219,6 +219,7 @@ def _make_params(
219219
_make_params(bids_filters={'sbref': {'suffix': 'sbref'}}),
220220
_make_params(norm_csf=True),
221221
_make_params(multi_step_reg=True),
222+
_make_params(multi_step_reg=False),
222223
],
223224
)
224225
def test_init_nibabies_wf(

requirements.txt

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -28,13 +28,13 @@ bidsschematools==1.0.10
2828
# via bids-validator
2929
bokeh==3.6.3
3030
# via tedana
31-
boto3==1.38.35
31+
boto3==1.38.36
3232
# via datalad
33-
botocore==1.38.35
33+
botocore==1.38.36
3434
# via
3535
# boto3
3636
# s3transfer
37-
certifi==2025.4.26
37+
certifi==2025.6.15
3838
# via requests
3939
chardet==5.2.0
4040
# via datalad
@@ -74,7 +74,7 @@ fasteners==0.19
7474
# via datalad
7575
filelock==3.18.0
7676
# via nipype
77-
fonttools==4.58.2
77+
fonttools==4.58.4
7878
# via matplotlib
7979
formulaic==1.1.1
8080
# via pybids
@@ -165,7 +165,7 @@ more-itertools==10.7.0
165165
# datalad-next
166166
# jaraco-classes
167167
# jaraco-functools
168-
msgpack==1.1.0
168+
msgpack==1.1.1
169169
# via datalad
170170
networkx==3.5
171171
# via
@@ -385,7 +385,7 @@ seaborn==0.13.2
385385
# nireports
386386
# niworkflows
387387
# tedana
388-
simpleitk==2.5.0
388+
simpleitk==2.5.2
389389
# via nibabies (pyproject.toml)
390390
simplejson==3.20.1
391391
# via nipype

wrapper/src/nibabies_wrapper/__main__.py

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
MISSING = """
3030
Image '{}' is missing
3131
Would you like to download? [Y/n] """
32-
PKG_PATH = '/opt/conda/envs/nibabies/lib/python3.13/site-packages'
32+
PKG_PATH = '/opt/conda/envs/nibabies/lib/python3.12/site-packages'
3333
TF_TEMPLATES = (
3434
'MNI152Lin',
3535
'MNI152NLin2009cAsym',
@@ -187,7 +187,7 @@ def set_version(self):
187187
self.add_envvar((version_env, version))
188188

189189
def add_envvar(self, envtuple):
190-
"""Set an environmental variable
190+
"""Set an environment variable
191191
192192
Inputs
193193
------
@@ -197,7 +197,7 @@ def add_envvar(self, envtuple):
197197
env = '='.join(envtuple)
198198
self.add_cmd(['-e', env])
199199
elif self.service == 'singularity':
200-
# singularity will transfer over environmental variables
200+
# singularity will transfer over environment variables
201201
# with the prefix: SINGULARITYENV_
202202
envvar, value = envtuple
203203
envvar = 'SINGULARITYENV_' + envvar
@@ -476,6 +476,12 @@ def _is_file(path, parser):
476476
type=os.path.abspath,
477477
help='Filter file',
478478
)
479+
g_wrap.add_argument(
480+
'--pooch-cache-dir',
481+
metavar='DIR',
482+
type=os.path.abspath,
483+
help='Directory to serve as cache for pooch files'
484+
)
479485

480486
# Developer patch/shell options
481487
g_dev = parser.add_argument_group(
@@ -643,6 +649,9 @@ def main():
643649
if opts.deriv_filter_file:
644650
container.add_mount(opts.deriv_filter_file, '/opt/derivative_filters.json')
645651
unknown_args.extend(['--deriv-filter-file', '/opt/derivative_filters.json'])
652+
if opts.pooch_cache_dir:
653+
container.add_mount(opts.pooch_cache_dir, '/tmp/pooch_cache', read_only=False)
654+
container.add_envvar(('NIBABIES_POOCH_DIR', '/tmp/pooch_cache'))
646655
# Patch derivatives for searching
647656
if opts.derivatives:
648657
deriv_args = ['--derivatives']

0 commit comments

Comments
 (0)