Skip to content

Commit 34195b9

Browse files
committed
fix: use interface implementation
1 parent 0745dc4 commit 34195b9

File tree

1 file changed

+8
-43
lines changed

1 file changed

+8
-43
lines changed

nibabies/workflows/anatomical/registration.py

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

350351
ntpls = len(templates)
@@ -405,11 +406,9 @@ def init_concat_registrations_wf(
405406
outputnode = pe.Node(niu.IdentityInterface(fields=out_fields), name='outputnode')
406407

407408
intermed_xfms = pe.MapNode(
408-
niu.Function(
409-
function=_load_intermediate_xfms, output_names=['int2std_xfm', 'std2int_xfm']
410-
),
411-
name='intermed_xfms',
412-
iterfield=['std'],
409+
RetrievePoochFiles(),
410+
name='retrieve_xfms',
411+
iterfield=['target'],
413412
run_without_submitting=True,
414413
)
415414

@@ -464,10 +463,10 @@ def init_concat_registrations_wf(
464463
# Transform concatenation
465464
(inputnode, dis_anat2int, [('anat2int_xfm', 'in_file')]),
466465
(inputnode, dis_int2anat, [('int2anat_xfm', 'in_file')]),
467-
(inputnode, intermed_xfms, [('intermediate', 'intermediate')]),
468-
(inputnode, intermed_xfms, [('template', 'std')]),
469-
(intermed_xfms, dis_int2std, [('int2std_xfm', 'in_file')]),
470-
(intermed_xfms, dis_std2int, [('std2int_xfm', 'in_file')]),
466+
(inputnode, intermed_xfms, [('intermediate', 'intermediate'),
467+
('template', 'target')]),
468+
(intermed_xfms, dis_int2std, [('int2tgt_xfm', 'in_file')]),
469+
(intermed_xfms, dis_std2int, [('tgt2int_xfm', 'in_file')]),
471470
(dis_anat2int, order_anat2std, [
472471
('affine_transform', 'in1'),
473472
('displacement_field', 'in2'),
@@ -505,40 +504,6 @@ def init_concat_registrations_wf(
505504
return workflow
506505

507506

508-
def _load_intermediate_xfms(intermediate, std):
509-
"""Fetch transforms from the OSF repository (https://osf.io/y763j/)."""
510-
import json
511-
from pathlib import Path
512-
513-
import pooch
514-
515-
from nibabies.data import load
516-
517-
xfms = json.loads(load('xfm_manifest.json').read_text())
518-
# MNIInfant:cohort-1 -> MNIInfant+1
519-
intmed = intermediate.replace(':cohort-', '+')
520-
521-
int2std_name = f'from-{intmed}_to-{std}_xfm.h5'
522-
int2std_meta = xfms[int2std_name]
523-
int2std = pooch.retrieve(
524-
url=int2std_meta['url'],
525-
path=Path.cwd(),
526-
known_hash=int2std_meta['hash'],
527-
fname=int2std_name,
528-
)
529-
530-
std2int_name = f'from-{std}_to-{intmed}_xfm.h5'
531-
std2int_meta = xfms[std2int_name]
532-
std2int = pooch.retrieve(
533-
url=std2int_meta['url'],
534-
path=Path.cwd(),
535-
known_hash=std2int_meta['hash'],
536-
fname=std2int_name,
537-
)
538-
539-
return int2std, std2int
540-
541-
542507
def _create_inverse_composite(in_file, out_file='inverse_composite.h5'):
543508
"""
544509
Build a composite transform with SimpleITK.

0 commit comments

Comments
 (0)