Skip to content

Commit 4bdd241

Browse files
committed
Merge branch 'master' into enh/FSLstd2imgcoords
2 parents ba97ef1 + beec4be commit 4bdd241

File tree

7 files changed

+281
-6
lines changed

7 files changed

+281
-6
lines changed

CHANGES

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ Next release
55
* ENH: New interfaces in dipy: RESTORE, EstimateResponseSH, CSD and StreamlineTractography
66
(https://github.com/nipy/nipype/pull/1090)
77
* ENH: Added interfaces of AFNI (https://github.com/nipy/nipype/pull/1360,
8-
https://github.com/nipy/nipype/pull/1361)
8+
https://github.com/nipy/nipype/pull/1361, https://github.com/nipy/nipype/pull/1382)
99
* ENH: Provides a Nipype wrapper for antsJointFusion (https://github.com/nipy/nipype/pull/1351)
1010
* ENH: Added support for PETPVC (https://github.com/nipy/nipype/pull/1335)
1111
* ENH: Merge S3DataSink into DataSink, added AWS documentation (https://github.com/nipy/nipype/pull/1316)

doc/users/plugins.rst

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -298,10 +298,11 @@ a custom template::
298298
In addition to overall workflow configuration, you can use node level
299299
configuration for OAR::
300300

301-
node.plugin_args = {'oarsub_args': '-l "nodes=1/cores=3"'}
301+
node.plugin_args = {'overwrite': True, 'oarsub_args': '-l "nodes=1/cores=3"'}
302302

303303
this would apply only to the node and is useful in situations, where a
304304
particular node might use more resources than other nodes in a workflow.
305+
You need to set the 'overwrite' flag to bypass the general settings-template you defined for the other nodes.
305306

306307

307308
``qsub`` emulation

nipype/interfaces/afni/__init__.py

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

nipype/interfaces/afni/preprocess.py

Lines changed: 131 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,7 @@
1616

1717
from .base import (AFNICommandBase, AFNICommand, AFNICommandInputSpec, AFNICommandOutputSpec,
1818
Info, no_afni)
19-
from ..base import CommandLineInputSpec
20-
from ..base import (Directory, TraitedSpec,
19+
from ..base import (CommandLineInputSpec, CommandLine, Directory, TraitedSpec,
2120
traits, isdefined, File, InputMultiPath, Undefined)
2221
from ...external.six import string_types
2322
from ...utils.filemanip import (load_json, save_json, split_filename)
@@ -2372,3 +2371,133 @@ def _list_outputs(self):
23722371

23732372
outputs['fwhm'] = tuple(sout)
23742373
return outputs
2374+
2375+
2376+
class OutlierCountInputSpec(CommandLineInputSpec):
2377+
in_file = File(argstr='%s', mandatory=True, exists=True, position=-2, desc='input dataset')
2378+
mask = File(exists=True, argstr='-mask %s', xor=['autoclip', 'automask'],
2379+
desc='only count voxels within the given mask')
2380+
qthr = traits.Range(value=1e-3, low=0.0, high=1.0, argstr='-qthr %.5f',
2381+
desc='indicate a value for q to compute alpha')
2382+
2383+
autoclip = traits.Bool(False, usedefault=True, argstr='-autoclip', xor=['in_file'],
2384+
desc='clip off small voxels')
2385+
automask = traits.Bool(False, usedefault=True, argstr='-automask', xor=['in_file'],
2386+
desc='clip off small voxels')
2387+
2388+
fraction = traits.Bool(False, usedefault=True, argstr='-fraction',
2389+
desc='write out the fraction of masked voxels'
2390+
' which are outliers at each timepoint')
2391+
interval = traits.Bool(False, usedefault=True, argstr='-range',
2392+
desc='write out the median + 3.5 MAD of outlier'
2393+
' count with each timepoint')
2394+
save_outliers = traits.Bool(False, usedefault=True, desc='enables out_file option')
2395+
outliers_file = File(
2396+
name_template="%s_outliers", argstr='-save %s', name_source=["in_file"],
2397+
output_name='out_outliers', keep_extension=True, desc='output image file name')
2398+
2399+
polort = traits.Int(argstr='-polort %d',
2400+
desc='detrend each voxel timeseries with polynomials')
2401+
legendre = traits.Bool(False, usedefault=True, argstr='-legendre',
2402+
desc='use Legendre polynomials')
2403+
out_file = File(
2404+
name_template='%s_outliers', name_source=['in_file'], argstr='> %s',
2405+
keep_extension=False, position=-1, desc='capture standard output')
2406+
2407+
2408+
class OutlierCountOutputSpec(TraitedSpec):
2409+
out_outliers = File(exists=True, desc='output image file name')
2410+
out_file = File(
2411+
name_template='%s_tqual', name_source=['in_file'], argstr='> %s',
2412+
keep_extension=False, position=-1, desc='capture standard output')
2413+
2414+
2415+
class OutlierCount(CommandLine):
2416+
"""Create a 3D dataset from 2D image files using AFNI to3d command
2417+
2418+
For complete details, see the `to3d Documentation
2419+
<http://afni.nimh.nih.gov/pub/dist/doc/program_help/to3d.html>`_
2420+
2421+
Examples
2422+
========
2423+
2424+
>>> from nipype.interfaces import afni
2425+
>>> toutcount = afni.OutlierCount()
2426+
>>> toutcount.inputs.in_file = 'functional.nii'
2427+
>>> toutcount.cmdline #doctest: +ELLIPSIS
2428+
'3dToutcount functional.nii > functional_outliers'
2429+
>>> res = toutcount.run() #doctest: +SKIP
2430+
2431+
"""
2432+
2433+
_cmd = '3dToutcount'
2434+
input_spec = OutlierCountInputSpec
2435+
output_spec = OutlierCountOutputSpec
2436+
2437+
def _parse_inputs(self, skip=None):
2438+
if skip is None:
2439+
skip = []
2440+
2441+
if not self.inputs.save_outliers:
2442+
skip += ['outliers_file']
2443+
return super(OutlierCount, self)._parse_inputs(skip)
2444+
2445+
def _list_outputs(self):
2446+
outputs = self.output_spec().get()
2447+
if self.inputs.save_outliers:
2448+
outputs['out_outliers'] = op.abspath(self.inputs.outliers_file)
2449+
outputs['out_file'] = op.abspath(self.inputs.out_file)
2450+
return outputs
2451+
2452+
2453+
class QualityIndexInputSpec(CommandLineInputSpec):
2454+
in_file = File(argstr='%s', mandatory=True, exists=True, position=-2, desc='input dataset')
2455+
mask = File(exists=True, argstr='-mask %s', xor=['autoclip', 'automask'],
2456+
desc='compute correlation only across masked voxels')
2457+
spearman = traits.Bool(False, usedefault=True, argstr='-spearman',
2458+
desc='Quality index is 1 minus the Spearman (rank) '
2459+
'correlation coefficient of each sub-brick '
2460+
'with the median sub-brick. (default)')
2461+
quadrant = traits.Bool(False, usedefault=True, argstr='-quadrant',
2462+
desc='Similar to -spearman, but using 1 minus the '
2463+
'quadrant correlation coefficient as the '
2464+
'quality index.')
2465+
autoclip = traits.Bool(False, usedefault=True, argstr='-autoclip', xor=['mask'],
2466+
desc='clip off small voxels')
2467+
automask = traits.Bool(False, usedefault=True, argstr='-automask', xor=['mask'],
2468+
desc='clip off small voxels')
2469+
clip = traits.Float(argstr='-clip %f', desc='clip off values below')
2470+
2471+
interval = traits.Bool(False, usedefault=True, argstr='-range',
2472+
desc='write out the median + 3.5 MAD of outlier'
2473+
' count with each timepoint')
2474+
out_file = File(
2475+
name_template='%s_tqual', name_source=['in_file'], argstr='> %s',
2476+
keep_extension=False, position=-1, desc='capture standard output')
2477+
2478+
2479+
class QualityIndexOutputSpec(TraitedSpec):
2480+
out_file = File(desc='file containing the caputured standard output')
2481+
2482+
2483+
class QualityIndex(CommandLine):
2484+
"""Create a 3D dataset from 2D image files using AFNI to3d command
2485+
2486+
For complete details, see the `to3d Documentation
2487+
<http://afni.nimh.nih.gov/pub/dist/doc/program_help/to3d.html>`_
2488+
2489+
Examples
2490+
========
2491+
2492+
>>> from nipype.interfaces import afni
2493+
>>> tqual = afni.QualityIndex()
2494+
>>> tqual.inputs.in_file = 'functional.nii'
2495+
>>> tqual.cmdline #doctest: +ELLIPSIS
2496+
'3dTqual functional.nii > functional_tqual'
2497+
>>> res = tqual.run() #doctest: +SKIP
2498+
2499+
"""
2500+
2501+
_cmd = '3dTqual'
2502+
input_spec = QualityIndexInputSpec
2503+
output_spec = QualityIndexOutputSpec
Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
# AUTO-GENERATED by tools/checkspecs.py - DO NOT EDIT
2+
from ....testing import assert_equal
3+
from ..preprocess import OutlierCount
4+
5+
6+
def test_OutlierCount_inputs():
7+
input_map = dict(args=dict(argstr='%s',
8+
),
9+
autoclip=dict(argstr='-autoclip',
10+
usedefault=True,
11+
xor=['in_file'],
12+
),
13+
automask=dict(argstr='-automask',
14+
usedefault=True,
15+
xor=['in_file'],
16+
),
17+
environ=dict(nohash=True,
18+
usedefault=True,
19+
),
20+
fraction=dict(argstr='-fraction',
21+
usedefault=True,
22+
),
23+
ignore_exception=dict(nohash=True,
24+
usedefault=True,
25+
),
26+
in_file=dict(argstr='%s',
27+
mandatory=True,
28+
position=-2,
29+
),
30+
interval=dict(argstr='-range',
31+
usedefault=True,
32+
),
33+
legendre=dict(argstr='-legendre',
34+
usedefault=True,
35+
),
36+
mask=dict(argstr='-mask %s',
37+
xor=['autoclip', 'automask'],
38+
),
39+
out_file=dict(argstr='> %s',
40+
keep_extension=False,
41+
name_source=['in_file'],
42+
name_template='%s_outliers',
43+
position=-1,
44+
),
45+
outliers_file=dict(argstr='-save %s',
46+
keep_extension=True,
47+
name_source=['in_file'],
48+
name_template='%s_outliers',
49+
output_name='out_outliers',
50+
),
51+
polort=dict(argstr='-polort %d',
52+
),
53+
qthr=dict(argstr='-qthr %.5f',
54+
),
55+
save_outliers=dict(usedefault=True,
56+
),
57+
terminal_output=dict(nohash=True,
58+
),
59+
)
60+
inputs = OutlierCount.input_spec()
61+
62+
for key, metadata in list(input_map.items()):
63+
for metakey, value in list(metadata.items()):
64+
yield assert_equal, getattr(inputs.traits()[key], metakey), value
65+
66+
67+
def test_OutlierCount_outputs():
68+
output_map = dict(out_file=dict(argstr='> %s',
69+
keep_extension=False,
70+
name_source=['in_file'],
71+
name_template='%s_tqual',
72+
position=-1,
73+
),
74+
out_outliers=dict(),
75+
)
76+
outputs = OutlierCount.output_spec()
77+
78+
for key, metadata in list(output_map.items()):
79+
for metakey, value in list(metadata.items()):
80+
yield assert_equal, getattr(outputs.traits()[key], metakey), value
Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
# AUTO-GENERATED by tools/checkspecs.py - DO NOT EDIT
2+
from ....testing import assert_equal
3+
from ..preprocess import QualityIndex
4+
5+
6+
def test_QualityIndex_inputs():
7+
input_map = dict(args=dict(argstr='%s',
8+
),
9+
autoclip=dict(argstr='-autoclip',
10+
usedefault=True,
11+
xor=['mask'],
12+
),
13+
automask=dict(argstr='-automask',
14+
usedefault=True,
15+
xor=['mask'],
16+
),
17+
clip=dict(argstr='-clip %f',
18+
),
19+
environ=dict(nohash=True,
20+
usedefault=True,
21+
),
22+
ignore_exception=dict(nohash=True,
23+
usedefault=True,
24+
),
25+
in_file=dict(argstr='%s',
26+
mandatory=True,
27+
position=-2,
28+
),
29+
interval=dict(argstr='-range',
30+
usedefault=True,
31+
),
32+
mask=dict(argstr='-mask %s',
33+
xor=['autoclip', 'automask'],
34+
),
35+
out_file=dict(argstr='> %s',
36+
keep_extension=False,
37+
name_source=['in_file'],
38+
name_template='%s_tqual',
39+
position=-1,
40+
),
41+
quadrant=dict(argstr='-quadrant',
42+
usedefault=True,
43+
),
44+
spearman=dict(argstr='-spearman',
45+
usedefault=True,
46+
),
47+
terminal_output=dict(nohash=True,
48+
),
49+
)
50+
inputs = QualityIndex.input_spec()
51+
52+
for key, metadata in list(input_map.items()):
53+
for metakey, value in list(metadata.items()):
54+
yield assert_equal, getattr(inputs.traits()[key], metakey), value
55+
56+
57+
def test_QualityIndex_outputs():
58+
output_map = dict(out_file=dict(),
59+
)
60+
outputs = QualityIndex.output_spec()
61+
62+
for key, metadata in list(output_map.items()):
63+
for metakey, value in list(metadata.items()):
64+
yield assert_equal, getattr(outputs.traits()[key], metakey), value

nipype/interfaces/freesurfer/utils.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -852,7 +852,7 @@ def _format_arg(self, name, spec, value):
852852
if name == "out_file" and not os.path.isabs(value):
853853
value = os.path.abspath(value)
854854
return super(MRIsConvert, self)._format_arg(name, spec, value)
855-
855+
856856
def _list_outputs(self):
857857
outputs = self.output_spec().get()
858858
outputs["converted"] = os.path.abspath(self._gen_outfilename())

0 commit comments

Comments
 (0)