@@ -1511,6 +1511,81 @@ def _list_outputs(self):
1511
1511
return outputs
1512
1512
1513
1513
1514
+ class NwarpAdjustInputSpec (AFNICommandInputSpec ):
1515
+ warps = InputMultiPath (
1516
+ File (exists = True ),
1517
+ minlen = 5 ,
1518
+ mandatory = True ,
1519
+ argstr = '-nwarp %s' ,
1520
+ desc = 'List of input 3D warp datasets' )
1521
+ in_files = InputMultiPath (
1522
+ File (exists = True ),
1523
+ minlen = 5 ,
1524
+ argstr = '-source %s' ,
1525
+ desc = 'List of input 3D datasets to be warped by the adjusted warp '
1526
+ 'datasets. There must be exactly as many of these datasets as '
1527
+ 'there are input warps.' )
1528
+ out_file = File (
1529
+ desc = 'Output mean dataset, only needed if in_files are also given. '
1530
+ 'The output dataset will be on the common grid shared by the '
1531
+ 'source datasets.' ,
1532
+ argstr = '-prefix %s' ,
1533
+ name_source = 'in_files' ,
1534
+ name_template = '%s_NwarpAdjust' ,
1535
+ keep_extension = True ,
1536
+ requires = ['in_files' ])
1537
+
1538
+
1539
+ class NwarpAdjust (AFNICommandBase ):
1540
+ """This program takes as input a bunch of 3D warps, averages them,
1541
+ and computes the inverse of this average warp. It then composes
1542
+ each input warp with this inverse average to 'adjust' the set of
1543
+ warps. Optionally, it can also read in a set of 1-brick datasets
1544
+ corresponding to the input warps, and warp each of them, and average
1545
+ those.
1546
+
1547
+ For complete details, see the `3dNwarpAdjust Documentation.
1548
+ <https://afni.nimh.nih.gov/pub/dist/doc/program_help/3dNwarpAdjust.html>`_
1549
+
1550
+ Examples
1551
+ ========
1552
+
1553
+ >>> from nipype.interfaces import afni
1554
+ >>> adjust = afni.NwarpAdjust()
1555
+ >>> adjust.inputs.warps = ['func2anat_InverseWarp.nii.gz', 'func2anat_InverseWarp.nii.gz', 'func2anat_InverseWarp.nii.gz', 'func2anat_InverseWarp.nii.gz', 'func2anat_InverseWarp.nii.gz']
1556
+ >>> adjust.cmdline
1557
+ '3dNwarpAdjust -nwarp func2anat_InverseWarp.nii.gz func2anat_InverseWarp.nii.gz func2anat_InverseWarp.nii.gz func2anat_InverseWarp.nii.gz func2anat_InverseWarp.nii.gz'
1558
+ >>> res = adjust.run() # doctest: +SKIP
1559
+
1560
+ """
1561
+ _cmd = '3dNwarpAdjust'
1562
+ input_spec = NwarpAdjustInputSpec
1563
+ output_spec = AFNICommandOutputSpec
1564
+
1565
+ def _parse_inputs (self , skip = None ):
1566
+ if not self .inputs .in_files :
1567
+ if skip is None :
1568
+ skip = []
1569
+ skip += ['out_file' ]
1570
+ return super (NwarpAdjust , self )._parse_inputs (skip = skip )
1571
+
1572
+ def _list_outputs (self ):
1573
+ outputs = self .output_spec ().get ()
1574
+
1575
+ if self .inputs .in_files :
1576
+ if self .inputs .out_file :
1577
+ outputs ['out_file' ] = os .path .abspath (self .inputs .out_file )
1578
+ else :
1579
+ basename = os .path .basename (self .inputs .in_files [0 ])
1580
+ basename_noext , ext = op .splitext (basename )
1581
+ if '.gz' in ext :
1582
+ basename_noext , ext2 = op .splitext (basename_noext )
1583
+ ext = ext2 + ext
1584
+ outputs ['out_file' ] = os .path .abspath (
1585
+ basename_noext + '_NwarpAdjust' + ext )
1586
+ return outputs
1587
+
1588
+
1514
1589
class NwarpApplyInputSpec (CommandLineInputSpec ):
1515
1590
in_file = traits .Either (
1516
1591
File (exists = True ),
0 commit comments