Skip to content

Commit 3cd40e1

Browse files
author
Oscar Esteban
committed
Merge branch 'master' into enh/ETSConfigTookit
2 parents 4a778c8 + e2ec11c commit 3cd40e1

File tree

8 files changed

+150
-16
lines changed

8 files changed

+150
-16
lines changed

CHANGES

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ Next release
22
============
33

44
* FIX: Prevent crash when tvtk is loaded - ETS_TOOLKIT=null (https://github.com/nipy/nipype/pull/973)
5+
* ENH: Added interfaces of AFNI (https://github.com/nipy/nipype/pull/1360)
56
* ENH: Added support for PETPVC (https://github.com/nipy/nipype/pull/1335)
67
* ENH: Merge S3DataSink into DataSink, added AWS documentation (https://github.com/nipy/nipype/pull/1316)
78
* TST: Cache APT in CircleCI (https://github.com/nipy/nipype/pull/1333)

nipype/interfaces/afni/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,5 +12,5 @@
1212
Fourier, Allineate, Maskave, SkullStrip, TCat, Fim,
1313
BlurInMask, Autobox, TCorrMap, Bandpass, Retroicor,
1414
TCorrelate, TCorr1D, BrickStat, ROIStats, AutoTcorrelate,
15-
AFNItoNIFTI, Eval, Means)
15+
AFNItoNIFTI, Eval, Means, Hist)
1616
from .svm import (SVMTest, SVMTrain)

nipype/interfaces/afni/preprocess.py

Lines changed: 74 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,17 +10,17 @@
1010
"""
1111

1212
import os
13+
import os.path as op
1314
import re
1415
from warnings import warn
1516

16-
from .base import AFNICommand, AFNICommandInputSpec, AFNICommandOutputSpec
17+
from .base import AFNICommand, AFNICommandInputSpec, AFNICommandOutputSpec, Info, no_afni
1718
from ..base import CommandLineInputSpec, CommandLine, OutputMultiPath
1819
from ..base import (Directory, TraitedSpec,
1920
traits, isdefined, File, InputMultiPath, Undefined)
2021
from ...utils.filemanip import (load_json, save_json, split_filename)
2122
from ...utils.filemanip import fname_presuffix
2223

23-
2424
class To3DInputSpec(AFNICommandInputSpec):
2525
out_file = File(name_template="%s", desc='output image file name',
2626
argstr='-prefix %s', name_source=["in_folder"])
@@ -1234,9 +1234,7 @@ class SkullStrip(AFNICommand):
12341234
output_spec = AFNICommandOutputSpec
12351235

12361236
def __init__(self, **inputs):
1237-
from .base import Info, no_afni
12381237
super(SkullStrip, self).__init__(**inputs)
1239-
12401238
if not no_afni():
12411239
v = Info.version()
12421240

@@ -2090,3 +2088,75 @@ class Means(AFNICommand):
20902088
_cmd = '3dMean'
20912089
input_spec = MeansInputSpec
20922090
output_spec = AFNICommandOutputSpec
2091+
2092+
2093+
class HistInputSpec(CommandLineInputSpec):
2094+
in_file = File(
2095+
desc='input file to 3dHist', argstr='-input %s', position=1, mandatory=True,
2096+
exists=True, copyfile=False)
2097+
out_file = File(
2098+
desc='Write histogram to niml file with this prefix', name_template='%s_hist',
2099+
keep_extension=False, argstr='-prefix %s', name_source=['in_file'])
2100+
showhist = traits.Bool(False, usedefault=True, desc='write a text visual histogram',
2101+
argstr='-showhist')
2102+
out_show = File(
2103+
name_template="%s_hist.out", desc='output image file name', keep_extension=False,
2104+
argstr="> %s", name_source="in_file", position=-1)
2105+
mask = File(desc='matrix to align input file', argstr='-mask %s', exists=True)
2106+
nbin = traits.Int(desc='number of bins', argstr='-nbin %d')
2107+
max_value = traits.Float(argstr='-max %f', desc='maximum intensity value')
2108+
min_value = traits.Float(argstr='-min %f', desc='minimum intensity value')
2109+
bin_width = traits.Float(argstr='-binwidth %f', desc='bin width')
2110+
2111+
class HistOutputSpec(TraitedSpec):
2112+
out_file = File(desc='output file', exists=True)
2113+
out_show = File(desc='output visual histogram')
2114+
2115+
2116+
class Hist(CommandLine):
2117+
"""Computes average of all voxels in the input dataset
2118+
which satisfy the criterion in the options list
2119+
2120+
For complete details, see the `3dHist Documentation.
2121+
<http://afni.nimh.nih.gov/pub/dist/doc/program_help/3dHist.html>`_
2122+
2123+
Examples
2124+
========
2125+
2126+
>>> from nipype.interfaces import afni as afni
2127+
>>> hist = afni.Hist()
2128+
>>> hist.inputs.in_file = 'functional.nii'
2129+
>>> hist.cmdline
2130+
'3dHist -input functional.nii -prefix functional_hist'
2131+
>>> res = hist.run() # doctest: +SKIP
2132+
2133+
"""
2134+
2135+
_cmd = '3dHist'
2136+
input_spec = HistInputSpec
2137+
output_spec = HistOutputSpec
2138+
_redirect_x = True
2139+
2140+
def __init__(self, **inputs):
2141+
super(Hist, self).__init__(**inputs)
2142+
if not no_afni():
2143+
version = Info.version()
2144+
2145+
# As of AFNI 16.0.00, redirect_x is not needed
2146+
if isinstance(version[0], int) and version[0] > 15:
2147+
self._redirect_x = False
2148+
2149+
def _parse_inputs(self, skip=None):
2150+
if not self.inputs.showhist:
2151+
if skip is None:
2152+
skip = []
2153+
skip += ['out_show']
2154+
return super(Hist, self)._parse_inputs(skip=skip)
2155+
2156+
2157+
def _list_outputs(self):
2158+
outputs = super(Hist, self)._list_outputs()
2159+
outputs['out_file'] += '.niml.hist'
2160+
if not self.inputs.showhist:
2161+
outputs['out_show'] = Undefined
2162+
return outputs
Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
# AUTO-GENERATED by tools/checkspecs.py - DO NOT EDIT
2+
from ....testing import assert_equal
3+
from ..preprocess import Hist
4+
5+
6+
def test_Hist_inputs():
7+
input_map = dict(args=dict(argstr='%s',
8+
),
9+
bin_width=dict(argstr='-binwidth %f',
10+
),
11+
environ=dict(nohash=True,
12+
usedefault=True,
13+
),
14+
ignore_exception=dict(nohash=True,
15+
usedefault=True,
16+
),
17+
in_file=dict(argstr='-input %s',
18+
copyfile=False,
19+
mandatory=True,
20+
position=1,
21+
),
22+
mask=dict(argstr='-mask %s',
23+
),
24+
max_value=dict(argstr='-max %f',
25+
),
26+
min_value=dict(argstr='-min %f',
27+
),
28+
nbin=dict(argstr='-nbin %d',
29+
),
30+
out_file=dict(argstr='-prefix %s',
31+
keep_extension=False,
32+
name_source=['in_file'],
33+
name_template='%s_hist',
34+
),
35+
out_show=dict(argstr='> %s',
36+
keep_extension=False,
37+
name_source='in_file',
38+
name_template='%s_hist.out',
39+
position=-1,
40+
),
41+
showhist=dict(argstr='-showhist',
42+
usedefault=True,
43+
),
44+
terminal_output=dict(nohash=True,
45+
),
46+
)
47+
inputs = Hist.input_spec()
48+
49+
for key, metadata in list(input_map.items()):
50+
for metakey, value in list(metadata.items()):
51+
yield assert_equal, getattr(inputs.traits()[key], metakey), value
52+
53+
54+
def test_Hist_outputs():
55+
output_map = dict(out_file=dict(),
56+
out_show=dict(),
57+
)
58+
outputs = Hist.output_spec()
59+
60+
for key, metadata in list(output_map.items()):
61+
for metakey, value in list(metadata.items()):
62+
yield assert_equal, getattr(outputs.traits()[key], metakey), value

nipype/interfaces/ants/resampling.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -247,7 +247,7 @@ class ApplyTransformsInputSpec(ANTSCommandInputSpec):
247247
traits.Float())
248248
)
249249
transforms = InputMultiPath(
250-
File(exists=True), argstr='%s', mandatory=True, desc='transform files')
250+
File(exists=True), argstr='%s', mandatory=True, desc='transform files: will be applied in reverse order. For example, the last specified transform will be applied first')
251251
invert_transform_flags = InputMultiPath(traits.Bool())
252252
default_value = traits.Float(0.0, argstr='--default-value %g', usedefault=True)
253253
print_out_composite_warp_file = traits.Bool(False, requires=["output_image"],
@@ -274,12 +274,12 @@ class ApplyTransforms(ANTSCommand):
274274
>>> at.inputs.output_image = 'deformed_moving1.nii'
275275
>>> at.inputs.interpolation = 'Linear'
276276
>>> at.inputs.default_value = 0
277-
>>> at.inputs.transforms = ['trans.mat', 'ants_Warp.nii.gz']
277+
>>> at.inputs.transforms = ['ants_Warp.nii.gz', 'trans.mat']
278278
>>> at.inputs.invert_transform_flags = [False, False]
279279
>>> at.cmdline
280280
'antsApplyTransforms --default-value 0 --dimensionality 3 --input moving1.nii --interpolation Linear \
281-
--output deformed_moving1.nii --reference-image fixed1.nii --transform [ trans.mat, 0 ] \
282-
--transform [ ants_Warp.nii.gz, 0 ]'
281+
--output deformed_moving1.nii --reference-image fixed1.nii --transform [ ants_Warp.nii.gz, 0 ] \
282+
--transform [ trans.mat, 0 ]'
283283
284284
>>> at1 = ApplyTransforms()
285285
>>> at1.inputs.dimension = 3
@@ -289,12 +289,12 @@ class ApplyTransforms(ANTSCommand):
289289
>>> at1.inputs.interpolation = 'BSpline'
290290
>>> at1.inputs.interpolation_parameters = (5,)
291291
>>> at1.inputs.default_value = 0
292-
>>> at1.inputs.transforms = ['trans.mat', 'ants_Warp.nii.gz']
292+
>>> at1.inputs.transforms = ['ants_Warp.nii.gz', 'trans.mat']
293293
>>> at1.inputs.invert_transform_flags = [False, False]
294294
>>> at1.cmdline
295295
'antsApplyTransforms --default-value 0 --dimensionality 3 --input moving1.nii --interpolation BSpline[ 5 ] \
296-
--output deformed_moving1.nii --reference-image fixed1.nii --transform [ trans.mat, 0 ] \
297-
--transform [ ants_Warp.nii.gz, 0 ]'
296+
--output deformed_moving1.nii --reference-image fixed1.nii --transform [ ants_Warp.nii.gz, 0 ] \
297+
--transform [ trans.mat, 0 ]'
298298
299299
300300
"""

nipype/interfaces/fsl/epi.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -589,7 +589,7 @@ class EpiRegInputSpec(FSLCommandInputSpec):
589589
no_fmapreg = traits.Bool(False, argstr='--nofmapreg',
590590
desc='do not perform registration of fmap to T1 \
591591
(use if fmap already registered)')
592-
no_clean = traits.Bool(False, argstr='--noclean',
592+
no_clean = traits.Bool(True, argstr='--noclean', usedefault=True,
593593
desc='do not clean up intermediate files')
594594

595595

@@ -640,8 +640,8 @@ class EpiReg(FSLCommand):
640640
>>> epireg.inputs.pedir='y'
641641
>>> epireg.cmdline #doctest: +ELLIPSIS
642642
'epi_reg --echospacing=0.000670 --fmap=fieldmap_phase_fslprepared.nii \
643-
--fmapmag=fieldmap_mag.nii --fmapmagbrain=fieldmap_mag_brain.nii --pedir=y \
644-
--epi=epi.nii --t1=T1.nii --t1brain=T1_brain.nii --out=epi2struct'
643+
--fmapmag=fieldmap_mag.nii --fmapmagbrain=fieldmap_mag_brain.nii --noclean \
644+
--pedir=y --epi=epi.nii --t1=T1.nii --t1brain=T1_brain.nii --out=epi2struct'
645645
>>> epireg.run() # doctest: +SKIP
646646
647647
"""

nipype/interfaces/fsl/tests/test_auto_EpiReg.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ def test_EpiReg_inputs():
2525
usedefault=True,
2626
),
2727
no_clean=dict(argstr='--noclean',
28+
usedefault=True,
2829
),
2930
no_fmapreg=dict(argstr='--nofmapreg',
3031
),

nipype/pipeline/engine/utils.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1021,7 +1021,7 @@ def export_graph(graph_in, base_dir=None, show=False, use_execgraph=False,
10211021
suffix='.dot',
10221022
use_ext=False,
10231023
newpath=base_dir)
1024-
nx.write_dot(pklgraph, outfname)
1024+
nx.drawing.nx_pydot.write_dot(pklgraph, outfname)
10251025
logger.info('Creating dot file: %s' % outfname)
10261026
cmd = 'dot -T%s -O %s' % (format, outfname)
10271027
res = CommandLine(cmd, terminal_output='allatonce').run()

0 commit comments

Comments
 (0)