Skip to content

Commit 70b1890

Browse files
authored
Merge pull request #469 from nipreps/rf/drop-simpleitk
RF: Use `CompositeTransform` when assembling inverse composite transforms
2 parents 630786a + 64710ff commit 70b1890

File tree

2 files changed

+1
-44
lines changed

2 files changed

+1
-44
lines changed

nibabies/workflows/anatomical/registration.py

Lines changed: 1 addition & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -451,11 +451,8 @@ def init_concat_registrations_wf(
451451
CompositeTransformUtil(process='assemble', out_file='anat2std.h5'),
452452
name='assemble_anat2std',
453453
)
454-
# https://github.com/ANTsX/ANTs/issues/1827
455-
# Until CompositeTransformUtil accepts warps as first transform,
456-
# Use SimpleITK to concatenate
457454
assemble_std2anat = pe.Node(
458-
niu.Function(function=_create_inverse_composite, output_names=['out_file']),
455+
CompositeTransformUtil(process='assemble', out_file='std2anat.h5'),
459456
name='assemble_std2anat',
460457
)
461458

@@ -502,42 +499,3 @@ def init_concat_registrations_wf(
502499
]) # fmt:skip
503500

504501
return workflow
505-
506-
507-
def _create_inverse_composite(in_file, out_file='inverse_composite.h5'):
508-
"""
509-
Build a composite transform with SimpleITK.
510-
511-
This serves as a workaround for a bug in ANTs's CompositeTransformUtil
512-
https://github.com/ANTsX/ANTs/issues/1827
513-
where composite transforms cannot be created with a displacement field placed first.
514-
515-
Parameters
516-
----------
517-
in_file : list of str
518-
List of input transforms to concatenate into a composite transform.
519-
out_file : str, optional
520-
File to write the composite transform to.
521-
522-
Returns
523-
-------
524-
out_file : str
525-
Absolute path to the composite transform.
526-
"""
527-
528-
from pathlib import Path
529-
530-
import SimpleITK as sitk
531-
532-
composite = sitk.CompositeTransform(3)
533-
for xfm_file in in_file:
534-
if xfm_file.endswith('mat'):
535-
xfm = sitk.ReadTransform(xfm_file)
536-
else:
537-
xfm = sitk.DisplacementFieldTransform(sitk.ReadImage(xfm_file))
538-
539-
composite.AddTransform(xfm)
540-
541-
out_file = str(Path(out_file).absolute())
542-
sitk.WriteTransform(composite, out_file)
543-
return out_file

pyproject.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@ dependencies = [
3333
"psutil >= 5.4",
3434
"pybids >= 0.15.0",
3535
"requests",
36-
"SimpleITK",
3736
"sdcflows >= 2.13.0",
3837
"smriprep >= 0.17.0",
3938
"tedana >= 23.0.2",

0 commit comments

Comments
 (0)