Skip to content

Commit 3b88bd4

Browse files
authored
Merge pull request #486 from nipreps/rf/tf-xfms
rf: retrieve transforms with templateflow
2 parents 27a69d6 + 1a128c6 commit 3b88bd4

File tree

6 files changed

+34
-118
lines changed

6 files changed

+34
-118
lines changed

.circleci/config.yml

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -214,8 +214,6 @@ jobs:
214214
- run:
215215
name: Get intermediate transforms
216216
command: |
217-
mkdir -p /tmp/pooch
218-
cd /tmp/pooch
219217
# Caching intermediate templates so no need to constantly fetch
220218
XFM="from-MNI152NLin6Asym_to-MNIInfant+1_xfm.h5"
221219
echo "Downloading $XFM"
@@ -229,7 +227,6 @@ jobs:
229227
paths:
230228
- fslicense
231229
- bcp/nipype.cfg
232-
- pooch/*
233230

234231
test_pytest:
235232
!!merge <<: *machine_defaults
@@ -348,8 +345,7 @@ jobs:
348345
--nthreads 4 -vv --age-months 2 --sloppy \
349346
--surface-recon-method infantfs \
350347
--derivatives precomputed=/tmp/data/${DATASET}/derivatives/bibsnet \
351-
--output-layout bids --anat-only \
352-
--pooch-cache-dir /tmp/pooch
348+
--output-layout bids --anat-only
353349
- run:
354350
name: Checking outputs of anatomical nibabies run
355351
command: |
@@ -378,8 +374,7 @@ jobs:
378374
--nthreads 4 -vv --age-months 2 \
379375
--surface-recon-method infantfs \
380376
--derivatives precomputed=/tmp/data/${DATASET}/derivatives/bibsnet \
381-
--output-layout bids \
382-
--pooch-cache-dir /tmp/pooch
377+
--output-layout bids
383378
- run:
384379
name: Checking outputs of full nibabies run
385380
command: |
@@ -425,8 +420,7 @@ jobs:
425420
--nthreads 4 -vv --age-months 2 \
426421
--surface-recon-method infantfs \
427422
--derivatives precomputed=/tmp/data/${DATASET}-t2only/derivatives/bibsnet \
428-
--output-layout bids --anat-only --cifti-output \
429-
--pooch-cache-dir /tmp/pooch
423+
--output-layout bids --anat-only --cifti-output
430424
- run:
431425
name: Checking outputs of T2-only nibabies anat
432426
command: |

nibabies/interfaces/download.py

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

nibabies/interfaces/tests/test_download.py

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

nibabies/workflows/anatomical/registration.py

Lines changed: 31 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -345,7 +345,6 @@ def init_concat_registrations_wf(
345345
further use in downstream nodes.
346346
347347
"""
348-
from nibabies.interfaces.download import RetrievePoochFiles
349348
from nibabies.interfaces.patches import CompositeTransformUtil
350349

351350
ntpls = len(templates)
@@ -405,9 +404,9 @@ def init_concat_registrations_wf(
405404
]
406405
outputnode = pe.Node(niu.IdentityInterface(fields=out_fields), name='outputnode')
407406

408-
intermed_xfms = pe.MapNode(
409-
RetrievePoochFiles(),
410-
name='retrieve_xfms',
407+
fetch_tf_xfms = pe.MapNode(
408+
niu.Function(function=_get_intermediate_xfms, output_names=['int2tgt_xfm', 'tgt2int_xfm']),
409+
name='fetch_tf_xfms',
411410
iterfield=['target'],
412411
run_without_submitting=True,
413412
)
@@ -460,10 +459,10 @@ def init_concat_registrations_wf(
460459
# Transform concatenation
461460
(inputnode, dis_anat2int, [('anat2int_xfm', 'in_file')]),
462461
(inputnode, dis_int2anat, [('int2anat_xfm', 'in_file')]),
463-
(inputnode, intermed_xfms, [('intermediate', 'intermediate'),
462+
(inputnode, fetch_tf_xfms, [('intermediate', 'intermediate'),
464463
('template', 'target')]),
465-
(intermed_xfms, dis_int2std, [('int2tgt_xfm', 'in_file')]),
466-
(intermed_xfms, dis_std2int, [('tgt2int_xfm', 'in_file')]),
464+
(fetch_tf_xfms, dis_int2std, [('int2tgt_xfm', 'in_file')]),
465+
(fetch_tf_xfms, dis_std2int, [('tgt2int_xfm', 'in_file')]),
467466
(dis_anat2int, order_anat2std, [
468467
('affine_transform', 'in1'),
469468
('displacement_field', 'in2'),
@@ -499,3 +498,28 @@ def init_concat_registrations_wf(
499498
]) # fmt:skip
500499

501500
return workflow
501+
502+
503+
def _get_intermediate_xfms(intermediate, target):
504+
import templateflow.api as tf
505+
506+
# Native -> MNIInfant:cohort-X (int) -> Target (std)
507+
ispace, _, icohort = intermediate.partition(':cohort-')
508+
ispaceid = f'{ispace}+{icohort}' if icohort else ispace
509+
510+
int2std = tf.get(
511+
target,
512+
suffix='xfm',
513+
**{'from': ispaceid},
514+
raise_empty=True,
515+
)
516+
517+
std2int = tf.get(
518+
ispace,
519+
cohort=icohort or None,
520+
suffix='xfm',
521+
**{'from': target},
522+
raise_empty=True,
523+
)
524+
525+
return int2std, std2int

pyproject.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@ dependencies = [
2929
"numpy >= 1.21.0",
3030
"packaging",
3131
"pandas < 3",
32-
"pooch",
3332
"psutil >= 5.4",
3433
"pybids >= 0.15.0",
3534
"requests",

wrapper/src/nibabies_wrapper/__main__.py

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -476,12 +476,6 @@ 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-
)
485479

486480
# Developer patch/shell options
487481
g_dev = parser.add_argument_group(
@@ -649,9 +643,6 @@ def main():
649643
if opts.deriv_filter_file:
650644
container.add_mount(opts.deriv_filter_file, '/opt/derivative_filters.json')
651645
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'))
655646
# Patch derivatives for searching
656647
if opts.derivatives:
657648
deriv_args = ['--derivatives']

0 commit comments

Comments
 (0)