Skip to content

Commit 9b07a69

Browse files
author
bpinsard
committed
fixing for new gen_filename autopep8
1 parent f318486 commit 9b07a69

File tree

2 files changed

+120
-66
lines changed

2 files changed

+120
-66
lines changed

nipype/interfaces/afni/__init__.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,5 @@
1111
from .preprocess import (To3D, Refit, Resample, TStat, Automask, Volreg, Merge,
1212
ZCutUp, Calc, TShift, Warp, Detrend, Despike, Copy,
1313
Fourier, Allineate, Maskave, SkullStrip, TCat, Fim,
14-
TCorrelate, BrickStat, ROIStats, AutoTcorrelate)
14+
TCorrelate, BrickStat, ROIStats, AutoTcorrelate,
15+
BlurInMask, Autobox, TCorrMap)

nipype/interfaces/afni/preprocess.py

Lines changed: 118 additions & 65 deletions
Original file line numberDiff line numberDiff line change
@@ -1302,18 +1302,18 @@ class TCorrelateInputSpec(AFNIBaseCommandInputSpec):
13021302
mandatory=True,
13031303
exists=True)
13041304
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)
13091309
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)
13111311
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)
13151315
polort = traits.Int(desc='Remove polynomical trend of order m',
1316-
argstr='-polort %d', position=2)
1316+
argstr='-polort %d', position=2)
13171317

13181318

13191319
class TCorrelate(AFNIBaseCommand):
@@ -1344,19 +1344,19 @@ class TCorrelate(AFNIBaseCommand):
13441344

13451345
class BrickStatInputSpec(AFNIBaseCommandInputSpec):
13461346
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)
13511351

13521352
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)
13561356

13571357
min = traits.Bool(desc='print the minimum value in dataset',
1358-
argstr='-min',
1359-
position=1)
1358+
argstr='-min',
1359+
position=1)
13601360

13611361

13621362
class BrickStatOutputSpec(TraitedSpec):
@@ -1415,25 +1415,25 @@ def aggregate_outputs(self, runtime=None, needed_outputs=None):
14151415

14161416
class ROIStatsInputSpec(AFNIBaseCommandInputSpec):
14171417
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)
14221422

14231423
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)
14271427

14281428
mask_f2short = traits.Bool(
14291429
desc='Tells the program to convert a float mask ' +
1430-
'to short integers, by simple rounding.',
1430+
'to short integers, by simple rounding.',
14311431
argstr='-mask_f2short',
14321432
position=2)
14331433

14341434
quiet = traits.Bool(desc='execute quietly',
1435-
argstr='-quiet',
1436-
position=1)
1435+
argstr='-quiet',
1436+
position=1)
14371437

14381438

14391439
class ROIStatsOutputSpec(TraitedSpec):
@@ -1507,17 +1507,17 @@ def aggregate_outputs(self, runtime=None, needed_outputs=None):
15071507

15081508
class CalcInputSpec(AFNICommandInputSpec):
15091509
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)
15111511
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)
15131513
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)
15151515
expr = traits.Str(desc='expr', argstr='-expr "%s"', position=2,
1516-
mandatory=True)
1516+
mandatory=True)
15171517
start_idx = traits.Int(desc='start index for in_file_a',
1518-
requires=['stop_idx'])
1518+
requires=['stop_idx'])
15191519
stop_idx = traits.Int(desc='stop index for in_file_a',
1520-
requires=['start_idx'])
1520+
requires=['start_idx'])
15211521
single_idx = traits.Int(desc='volume index for in_file_a')
15221522
other = File(desc='other options', argstr='')
15231523
suffix = traits.Str('_calc', desc="out_file suffix", usedefault=True)
@@ -1553,7 +1553,7 @@ def _format_arg(self, name, trait_spec, value):
15531553
arg = trait_spec.argstr % value
15541554
if isdefined(self.inputs.start_idx):
15551555
arg += '[%d..%d]' % (self.inputs.start_idx,
1556-
self.inputs.stop_idx)
1556+
self.inputs.stop_idx)
15571557
if isdefined(self.inputs.single_idx):
15581558
arg += '[%d]' % (self.inputs.single_idx)
15591559
return arg
@@ -1603,20 +1603,33 @@ class BlurInMaskInputSpec(AFNICommandInputSpec):
16031603
suffix = traits.Str('_blurmask', desc="out_file suffix", usedefault=True)
16041604

16051605

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.
16081608
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+
"""
16091623

1610-
class BlurInMask(AFNICommand):
16111624
_cmd = '3dBlurInMask'
16121625
input_spec = BlurInMaskInputSpec
1613-
output_spec = BlurInMaskOutputSpec
1626+
output_spec = AFNICommandOutputSpec
16141627

16151628
def _list_outputs(self):
16161629
outputs = self.output_spec().get()
16171630
if not isdefined(self.inputs.out_file):
16181631
outputs['out_file'] = self._gen_fname(self.inputs.in_file,
1619-
suffix=self.inputs.suffix)
1632+
suffix=self.inputs.suffix)
16201633
else:
16211634
outputs['out_file'] = os.path.abspath(self.inputs.out_file)
16221635
return outputs
@@ -1626,68 +1639,62 @@ def _gen_filename(self, name):
16261639
return self._list_outputs()[name]
16271640

16281641

1629-
class TCorrMapInputSpec(AFNICommandInputSpec):
1642+
class TCorrMapInputSpec(AFNIBaseCommandInputSpec):
16301643
in_file = File(exists=True, argstr='-input %s', mandatory=True)
16311644
seeds = File(exists=True, argstr='-seed %s', xor=('seeds_width'))
16321645
mask = File(exists=True, argstr='-mask %s')
16331646
automask = traits.Bool(argstr='-automask')
16341647
polort = traits.Int(argstr='-polort %d')
16351648
bandpass = traits.Tuple((traits.Float(), traits.Float()),
1636-
argstr='-bpass %f %f')
1649+
argstr='-bpass %f %f')
16371650
regress_out_timeseries = traits.File(exists=True, argstr='-ort %s')
16381651
blur_fwhm = traits.Float(argstr='-Gblur %f')
16391652
seeds_width = traits.Float(argstr='-Mseed %f', xor=('seeds'))
16401653

16411654
# 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")
16461659

16471660
_thresh_opts = ('absolute_threshold',
1648-
'var_absolute_threshold', 'var_absolute_threshold_normalize')
1661+
'var_absolute_threshold',
1662+
'var_absolute_threshold_normalize')
16491663
thresholds = traits.List(traits.Int())
16501664
absolute_threshold = File(
1651-
genfile=True,
16521665
argstr='-Thresh %f %s', suffix='_thresh',
1653-
xor=_thresh_opts)
1666+
name_source="in_file", xor=_thresh_opts)
16541667
var_absolute_threshold = File(
1655-
genfile=True,
16561668
argstr='-VarThresh %f %f %f %s', suffix='_varthresh',
1657-
xor=_thresh_opts)
1669+
name_source="in_file", xor=_thresh_opts)
16581670
var_absolute_threshold_normalize = File(
1659-
genfile=True,
16601671
argstr='-VarThreshN %f %f %f %s', suffix='_varthreshn',
1661-
xor=_thresh_opts)
1672+
name_source="in_file", xor=_thresh_opts)
16621673

16631674
correlation_maps = File(
1664-
genfile=True, argstr='-CorrMap %s', suffix='_corrmap')
1675+
argstr='-CorrMap %s', name_source="in_file")
16651676
correlation_maps_masked = File(
1666-
genfile=True, argstr='-CorrMask %s', suffix='_corrmask')
1677+
argstr='-CorrMask %s', name_source="in_file")
16671678

16681679
_expr_opts = ('average_expr', 'average_expr_nonzero', 'sum_expr')
16691680
expr = traits.Str()
16701681
average_expr = File(
1671-
genfile=True,
16721682
argstr='-Aexpr %s %s', suffix='_aexpr',
16731683
xor=_expr_opts)
16741684
average_expr_nonzero = File(
1675-
genfile=True,
16761685
argstr='-Cexpr %s %s', suffix='_cexpr',
16771686
xor=_expr_opts)
16781687
sum_expr = File(
1679-
genfile=True,
16801688
argstr='-Sexpr %s %s', suffix='_sexpr',
16811689
xor=_expr_opts)
16821690
histogram_bin_numbers = traits.Int()
16831691
histogram = File(
1684-
genfile=True,
16851692
argstr='-Hist %d %s', suffix='_hist')
16861693

16871694

16881695
class TCorrMapOutputSpec(TraitedSpec):
16891696

1690-
mean_file = File(genfile=True)
1697+
mean_file = File()
16911698
zmean = File()
16921699
qmean = File()
16931700
pmean = File()
@@ -1703,6 +1710,25 @@ class TCorrMapOutputSpec(TraitedSpec):
17031710

17041711

17051712
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+
17061732
_cmd = '3dTcorrMap'
17071733
input_spec = TCorrMapInputSpec
17081734
output_spec = TCorrMapOutputSpec
@@ -1735,15 +1761,25 @@ def _parse_inputs(self, skip=None):
17351761
return super(TCorrMap, self)._parse_inputs(skip=skip)
17361762

17371763
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)
17401768

17411769

17421770
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')
17451776
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.""")
17471783

17481784

17491785
class AutoboxOuputSpec(TraitedSpec): # out_file not mandatory
@@ -1758,6 +1794,23 @@ class AutoboxOuputSpec(TraitedSpec): # out_file not mandatory
17581794

17591795

17601796
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+
17611814
_cmd = '3dAutobox'
17621815
input_spec = AutoboxInputSpec
17631816
output_spec = AutoboxOuputSpec

0 commit comments

Comments
 (0)