@@ -451,11 +451,8 @@ def init_concat_registrations_wf(
451
451
CompositeTransformUtil (process = 'assemble' , out_file = 'anat2std.h5' ),
452
452
name = 'assemble_anat2std' ,
453
453
)
454
- # https://github.com/ANTsX/ANTs/issues/1827
455
- # Until CompositeTransformUtil accepts warps as first transform,
456
- # Use SimpleITK to concatenate
457
454
assemble_std2anat = pe .Node (
458
- niu . Function ( function = _create_inverse_composite , output_names = [ 'out_file' ] ),
455
+ CompositeTransformUtil ( process = 'assemble' , out_file = 'std2anat.h5' ),
459
456
name = 'assemble_std2anat' ,
460
457
)
461
458
@@ -502,42 +499,3 @@ def init_concat_registrations_wf(
502
499
]) # fmt:skip
503
500
504
501
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
0 commit comments