@@ -1302,18 +1302,18 @@ class TCorrelateInputSpec(AFNIBaseCommandInputSpec):
1302
1302
mandatory = True ,
1303
1303
exists = True )
1304
1304
yset = File (desc = 'input yset' ,
1305
- argstr = ' %s' ,
1306
- position = - 1 ,
1307
- mandatory = True ,
1308
- exists = True )
1305
+ argstr = ' %s' ,
1306
+ position = - 1 ,
1307
+ mandatory = True ,
1308
+ exists = True )
1309
1309
out_file = File ("%s_tcorr" , desc = 'output image file name' ,
1310
- argstr = '-prefix %s' , name_source = "xset" , usedefault = True )
1310
+ argstr = '-prefix %s' , name_source = "xset" , usedefault = True )
1311
1311
pearson = traits .Bool (desc = 'Correlation is the normal' +
1312
- ' Pearson correlation coefficient' ,
1313
- argstr = '-pearson' ,
1314
- position = 1 )
1312
+ ' Pearson correlation coefficient' ,
1313
+ argstr = '-pearson' ,
1314
+ position = 1 )
1315
1315
polort = traits .Int (desc = 'Remove polynomical trend of order m' ,
1316
- argstr = '-polort %d' , position = 2 )
1316
+ argstr = '-polort %d' , position = 2 )
1317
1317
1318
1318
1319
1319
class TCorrelate (AFNIBaseCommand ):
@@ -1344,19 +1344,19 @@ class TCorrelate(AFNIBaseCommand):
1344
1344
1345
1345
class BrickStatInputSpec (AFNIBaseCommandInputSpec ):
1346
1346
in_file = File (desc = 'input file to 3dmaskave' ,
1347
- argstr = '%s' ,
1348
- position = - 1 ,
1349
- mandatory = True ,
1350
- exists = True )
1347
+ argstr = '%s' ,
1348
+ position = - 1 ,
1349
+ mandatory = True ,
1350
+ exists = True )
1351
1351
1352
1352
mask = File (desc = '-mask dset = use dset as mask to include/exclude voxels' ,
1353
- argstr = '-mask %s' ,
1354
- position = 2 ,
1355
- exists = True )
1353
+ argstr = '-mask %s' ,
1354
+ position = 2 ,
1355
+ exists = True )
1356
1356
1357
1357
min = traits .Bool (desc = 'print the minimum value in dataset' ,
1358
- argstr = '-min' ,
1359
- position = 1 )
1358
+ argstr = '-min' ,
1359
+ position = 1 )
1360
1360
1361
1361
1362
1362
class BrickStatOutputSpec (TraitedSpec ):
@@ -1415,25 +1415,25 @@ def aggregate_outputs(self, runtime=None, needed_outputs=None):
1415
1415
1416
1416
class ROIStatsInputSpec (AFNIBaseCommandInputSpec ):
1417
1417
in_file = File (desc = 'input file to 3dROIstats' ,
1418
- argstr = '%s' ,
1419
- position = - 1 ,
1420
- mandatory = True ,
1421
- exists = True )
1418
+ argstr = '%s' ,
1419
+ position = - 1 ,
1420
+ mandatory = True ,
1421
+ exists = True )
1422
1422
1423
1423
mask = File (desc = 'input mask' ,
1424
- argstr = '-mask %s' ,
1425
- position = 3 ,
1426
- exists = True )
1424
+ argstr = '-mask %s' ,
1425
+ position = 3 ,
1426
+ exists = True )
1427
1427
1428
1428
mask_f2short = traits .Bool (
1429
1429
desc = 'Tells the program to convert a float mask ' +
1430
- 'to short integers, by simple rounding.' ,
1430
+ 'to short integers, by simple rounding.' ,
1431
1431
argstr = '-mask_f2short' ,
1432
1432
position = 2 )
1433
1433
1434
1434
quiet = traits .Bool (desc = 'execute quietly' ,
1435
- argstr = '-quiet' ,
1436
- position = 1 )
1435
+ argstr = '-quiet' ,
1436
+ position = 1 )
1437
1437
1438
1438
1439
1439
class ROIStatsOutputSpec (TraitedSpec ):
@@ -1507,17 +1507,17 @@ def aggregate_outputs(self, runtime=None, needed_outputs=None):
1507
1507
1508
1508
class CalcInputSpec (AFNICommandInputSpec ):
1509
1509
in_file_a = File (desc = 'input file to 3dcalc' ,
1510
- argstr = '-a %s' , position = 0 , mandatory = True , exists = True )
1510
+ argstr = '-a %s' , position = 0 , mandatory = True , exists = True )
1511
1511
in_file_b = File (desc = 'operand file to 3dcalc' ,
1512
- argstr = ' -b %s' , position = 1 , exists = True )
1512
+ argstr = ' -b %s' , position = 1 , exists = True )
1513
1513
out_file = File ("%s_calc" , desc = 'output image file name' ,
1514
- argstr = '-prefix %s' , name_source = "in_file_a" , usedefault = True )
1514
+ argstr = '-prefix %s' , name_source = "in_file_a" , usedefault = True )
1515
1515
expr = traits .Str (desc = 'expr' , argstr = '-expr "%s"' , position = 2 ,
1516
- mandatory = True )
1516
+ mandatory = True )
1517
1517
start_idx = traits .Int (desc = 'start index for in_file_a' ,
1518
- requires = ['stop_idx' ])
1518
+ requires = ['stop_idx' ])
1519
1519
stop_idx = traits .Int (desc = 'stop index for in_file_a' ,
1520
- requires = ['start_idx' ])
1520
+ requires = ['start_idx' ])
1521
1521
single_idx = traits .Int (desc = 'volume index for in_file_a' )
1522
1522
other = File (desc = 'other options' , argstr = '' )
1523
1523
suffix = traits .Str ('_calc' , desc = "out_file suffix" , usedefault = True )
@@ -1553,7 +1553,7 @@ def _format_arg(self, name, trait_spec, value):
1553
1553
arg = trait_spec .argstr % value
1554
1554
if isdefined (self .inputs .start_idx ):
1555
1555
arg += '[%d..%d]' % (self .inputs .start_idx ,
1556
- self .inputs .stop_idx )
1556
+ self .inputs .stop_idx )
1557
1557
if isdefined (self .inputs .single_idx ):
1558
1558
arg += '[%d]' % (self .inputs .single_idx )
1559
1559
return arg
@@ -1603,20 +1603,33 @@ class BlurInMaskInputSpec(AFNICommandInputSpec):
1603
1603
suffix = traits .Str ('_blurmask' , desc = "out_file suffix" , usedefault = True )
1604
1604
1605
1605
1606
- class BlurInMaskOutputSpec ( TraitedSpec ):
1607
- out_file = File ( exists = True )
1606
+ class BlurInMask ( AFNICommand ):
1607
+ """ Blurs a dataset spatially inside a mask. That's all. Experimental.
1608
1608
1609
+ For complete details, see the `3dBlurInMask Documentation.
1610
+ <http://afni.nimh.nih.gov/pub/dist/doc/program_help/3dBlurInMask.html>
1611
+
1612
+ Examples
1613
+ ========
1614
+
1615
+ >>> from nipype.interfaces import afni as afni
1616
+ >>> bim = afni.BlurInMask()
1617
+ >>> bim.inputs.in_file = 'functional.nii'
1618
+ >>> bim.inputs.mask = 'mask.nii'
1619
+ >>> bim.inputs.fwhm = 5.0
1620
+ >>> res = bim.run() # doctest: +SKIP
1621
+
1622
+ """
1609
1623
1610
- class BlurInMask (AFNICommand ):
1611
1624
_cmd = '3dBlurInMask'
1612
1625
input_spec = BlurInMaskInputSpec
1613
- output_spec = BlurInMaskOutputSpec
1626
+ output_spec = AFNICommandOutputSpec
1614
1627
1615
1628
def _list_outputs (self ):
1616
1629
outputs = self .output_spec ().get ()
1617
1630
if not isdefined (self .inputs .out_file ):
1618
1631
outputs ['out_file' ] = self ._gen_fname (self .inputs .in_file ,
1619
- suffix = self .inputs .suffix )
1632
+ suffix = self .inputs .suffix )
1620
1633
else :
1621
1634
outputs ['out_file' ] = os .path .abspath (self .inputs .out_file )
1622
1635
return outputs
@@ -1626,68 +1639,62 @@ def _gen_filename(self, name):
1626
1639
return self ._list_outputs ()[name ]
1627
1640
1628
1641
1629
- class TCorrMapInputSpec (AFNICommandInputSpec ):
1642
+ class TCorrMapInputSpec (AFNIBaseCommandInputSpec ):
1630
1643
in_file = File (exists = True , argstr = '-input %s' , mandatory = True )
1631
1644
seeds = File (exists = True , argstr = '-seed %s' , xor = ('seeds_width' ))
1632
1645
mask = File (exists = True , argstr = '-mask %s' )
1633
1646
automask = traits .Bool (argstr = '-automask' )
1634
1647
polort = traits .Int (argstr = '-polort %d' )
1635
1648
bandpass = traits .Tuple ((traits .Float (), traits .Float ()),
1636
- argstr = '-bpass %f %f' )
1649
+ argstr = '-bpass %f %f' )
1637
1650
regress_out_timeseries = traits .File (exists = True , argstr = '-ort %s' )
1638
1651
blur_fwhm = traits .Float (argstr = '-Gblur %f' )
1639
1652
seeds_width = traits .Float (argstr = '-Mseed %f' , xor = ('seeds' ))
1640
1653
1641
1654
# outputs
1642
- mean_file = File (genfile = True , argstr = '-Mean %s' , suffix = '_mean' )
1643
- zmean = File (genfile = True , argstr = '-Zmean %s' , suffix = '_zmean' )
1644
- qmean = File (genfile = True , argstr = '-Qmean %s' , suffix = '_qmean' )
1645
- pmean = File (genfile = True , argstr = '-Pmean %s' , suffix = '_pmean' )
1655
+ mean_file = File (argstr = '-Mean %s' , suffix = '_mean' , name_source = "in_file" )
1656
+ zmean = File (argstr = '-Zmean %s' , suffix = '_zmean' , name_source = "in_file" )
1657
+ qmean = File (argstr = '-Qmean %s' , suffix = '_qmean' , name_source = "in_file" )
1658
+ pmean = File (argstr = '-Pmean %s' , suffix = '_pmean' , name_source = "in_file" )
1646
1659
1647
1660
_thresh_opts = ('absolute_threshold' ,
1648
- 'var_absolute_threshold' , 'var_absolute_threshold_normalize' )
1661
+ 'var_absolute_threshold' ,
1662
+ 'var_absolute_threshold_normalize' )
1649
1663
thresholds = traits .List (traits .Int ())
1650
1664
absolute_threshold = File (
1651
- genfile = True ,
1652
1665
argstr = '-Thresh %f %s' , suffix = '_thresh' ,
1653
- xor = _thresh_opts )
1666
+ name_source = "in_file" , xor = _thresh_opts )
1654
1667
var_absolute_threshold = File (
1655
- genfile = True ,
1656
1668
argstr = '-VarThresh %f %f %f %s' , suffix = '_varthresh' ,
1657
- xor = _thresh_opts )
1669
+ name_source = "in_file" , xor = _thresh_opts )
1658
1670
var_absolute_threshold_normalize = File (
1659
- genfile = True ,
1660
1671
argstr = '-VarThreshN %f %f %f %s' , suffix = '_varthreshn' ,
1661
- xor = _thresh_opts )
1672
+ name_source = "in_file" , xor = _thresh_opts )
1662
1673
1663
1674
correlation_maps = File (
1664
- genfile = True , argstr = '-CorrMap %s' , suffix = '_corrmap' )
1675
+ argstr = '-CorrMap %s' , name_source = "in_file" )
1665
1676
correlation_maps_masked = File (
1666
- genfile = True , argstr = '-CorrMask %s' , suffix = '_corrmask' )
1677
+ argstr = '-CorrMask %s' , name_source = "in_file" )
1667
1678
1668
1679
_expr_opts = ('average_expr' , 'average_expr_nonzero' , 'sum_expr' )
1669
1680
expr = traits .Str ()
1670
1681
average_expr = File (
1671
- genfile = True ,
1672
1682
argstr = '-Aexpr %s %s' , suffix = '_aexpr' ,
1673
1683
xor = _expr_opts )
1674
1684
average_expr_nonzero = File (
1675
- genfile = True ,
1676
1685
argstr = '-Cexpr %s %s' , suffix = '_cexpr' ,
1677
1686
xor = _expr_opts )
1678
1687
sum_expr = File (
1679
- genfile = True ,
1680
1688
argstr = '-Sexpr %s %s' , suffix = '_sexpr' ,
1681
1689
xor = _expr_opts )
1682
1690
histogram_bin_numbers = traits .Int ()
1683
1691
histogram = File (
1684
- genfile = True ,
1685
1692
argstr = '-Hist %d %s' , suffix = '_hist' )
1686
1693
1687
1694
1688
1695
class TCorrMapOutputSpec (TraitedSpec ):
1689
1696
1690
- mean_file = File (genfile = True )
1697
+ mean_file = File ()
1691
1698
zmean = File ()
1692
1699
qmean = File ()
1693
1700
pmean = File ()
@@ -1703,6 +1710,25 @@ class TCorrMapOutputSpec(TraitedSpec):
1703
1710
1704
1711
1705
1712
class TCorrMap (AFNICommand ):
1713
+ """ For each voxel time series, computes the correlation between it
1714
+ and all other voxels, and combines this set of values into the
1715
+ output dataset(s) in some way.
1716
+
1717
+ For complete details, see the `3dTcorrMap Documentation.
1718
+ <http://afni.nimh.nih.gov/pub/dist/doc/program_help/3dTcorrMap.html>
1719
+
1720
+ Examples
1721
+ ========
1722
+
1723
+ >>> from nipype.interfaces import afni as afni
1724
+ >>> tcm = afni.TcorrMap()
1725
+ >>> tcm.inputs.in_file = 'functional.nii'
1726
+ >>> tcm.inputs.mask = 'mask.nii'
1727
+ >>> tcm.mean_file = '%s_meancorr.nii'
1728
+ >>> res = tcm.run() # doctest: +SKIP
1729
+
1730
+ """
1731
+
1706
1732
_cmd = '3dTcorrMap'
1707
1733
input_spec = TCorrMapInputSpec
1708
1734
output_spec = TCorrMapOutputSpec
@@ -1735,15 +1761,25 @@ def _parse_inputs(self, skip=None):
1735
1761
return super (TCorrMap , self )._parse_inputs (skip = skip )
1736
1762
1737
1763
def _gen_filename (self , name ):
1738
- if name in self ._outputs ().get ().keys ():
1739
- return self ._list_outputs ()[name ]
1764
+ if hasattr (self .inputs , name ) and \
1765
+ not isdefined (getattr (self .inputs , name )):
1766
+ return Undefined
1767
+ return super (TCorrMap , self )._gen_filename (name )
1740
1768
1741
1769
1742
1770
class AutoboxInputSpec (AFNICommandInputSpec ):
1743
- in_file = File (exists = True , mandatory = True , argstr = '-input %s' )
1744
- padding = traits .Int (argstr = '-npad %d' )
1771
+ in_file = File (exists = True , mandatory = True , argstr = '-input %s' ,
1772
+ desc = 'input file' )
1773
+ padding = traits .Int (
1774
+ argstr = '-npad %d' ,
1775
+ desc = 'Number of extra voxels to pad on each side of box' )
1745
1776
out_file = File (argstr = "-prefix %s" , name_source = "in_file" )
1746
- no_clustering = traits .Bool (argstr = '-noclust' )
1777
+ no_clustering = traits .Bool (
1778
+ argstr = '-noclust' ,
1779
+ desc = """Don't do any clustering to find box. Any non-zero
1780
+ voxel will be preserved in the cropped volume.
1781
+ The default method uses some clustering to find the
1782
+ cropping box, and will clip off small isolated blobs.""" )
1747
1783
1748
1784
1749
1785
class AutoboxOuputSpec (TraitedSpec ): # out_file not mandatory
@@ -1758,6 +1794,23 @@ class AutoboxOuputSpec(TraitedSpec): # out_file not mandatory
1758
1794
1759
1795
1760
1796
class Autobox (AFNICommand ):
1797
+ """ Computes size of a box that fits around the volume.
1798
+ Also can be used to crop the volume to that box.
1799
+
1800
+ For complete details, see the `3dAutobox Documentation.
1801
+ <http://afni.nimh.nih.gov/pub/dist/doc/program_help/3dAutobox.html>
1802
+
1803
+ Examples
1804
+ ========
1805
+
1806
+ >>> from nipype.interfaces import afni as afni
1807
+ >>> abox = afni.Autobox()
1808
+ >>> abox.inputs.in_file = 'structural.nii'
1809
+ >>> abox.inputs.padding = 5
1810
+ >>> res = abox.run() # doctest: +SKIP
1811
+
1812
+ """
1813
+
1761
1814
_cmd = '3dAutobox'
1762
1815
input_spec = AutoboxInputSpec
1763
1816
output_spec = AutoboxOuputSpec
0 commit comments