Skip to content

Commit a984656

Browse files
committed
Merge branch 'master' of git://github.com/nipy/nipype into rel/1.0
2 parents af57b41 + 1c174df commit a984656

33 files changed

+1948
-41
lines changed

.zenodo.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -530,6 +530,11 @@
530530
{
531531
"name": "Arias, Jaime"
532532
},
533+
{
534+
"affiliation": "Dartmouth College",
535+
"name": "Visconti di Oleggio Castello, Matteo",
536+
"orcid": "0000-0001-7931-5272"
537+
},
533538
{
534539
"affiliation": "CEA",
535540
"name": "Papadopoulos Orfanos, Dimitri",

nipype/interfaces/afni/model.py

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ class DeconvolveInputSpec(AFNICommandInputSpec):
3636
argstr='-input %s',
3737
copyfile=False,
3838
sep=" ",
39-
position=0)
39+
position=1)
4040
sat = traits.Bool(
4141
desc='check the dataset time series for initial saturation transients,'
4242
' which should normally have been excised before data analysis.',
@@ -57,10 +57,11 @@ class DeconvolveInputSpec(AFNICommandInputSpec):
5757
'* If the auto-catenation feature isn\'t used, then this option '
5858
'has no effect, no how, no way.',
5959
argstr='-noblock')
60-
force_TR = traits.Int(
60+
force_TR = traits.Float(
6161
desc='use this value instead of the TR in the \'input\' '
62-
'dataset. (It\'s better to fix the input using Refit.)',
63-
argstr='-force_TR %d')
62+
'dataset. (It\'s better to fix the input using Refit.)',
63+
argstr='-force_TR %f',
64+
position=0)
6465
input1D = File(
6566
desc='filename of single (fMRI) .1D time series where time runs down '
6667
'the column.',
@@ -294,7 +295,11 @@ def _list_outputs(self):
294295

295296
outputs['reml_script'] = self._gen_fname(
296297
suffix='.REML_cmd', **_gen_fname_opts)
297-
outputs['out_file'] = os.path.abspath(self.inputs.out_file)
298+
# remove out_file from outputs if x1d_stop set to True
299+
if self.inputs.x1D_stop:
300+
del outputs['out_file']
301+
else:
302+
outputs['out_file'] = os.path.abspath(self.inputs.out_file)
298303

299304
return outputs
300305

nipype/interfaces/afni/tests/test_auto_Deconvolve.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,10 @@ def test_Deconvolve_inputs():
1818
nohash=True,
1919
usedefault=True,
2020
),
21-
force_TR=dict(argstr='-force_TR %d', ),
21+
force_TR=dict(
22+
argstr='-force_TR %f',
23+
position=0,
24+
),
2225
fout=dict(argstr='-fout', ),
2326
global_times=dict(
2427
argstr='-global_times',
@@ -42,7 +45,7 @@ def test_Deconvolve_inputs():
4245
in_files=dict(
4346
argstr='-input %s',
4447
copyfile=False,
45-
position=0,
48+
position=1,
4649
sep=' ',
4750
),
4851
input1D=dict(argstr='-input1D %s', ),
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
"""Test afni deconvolve"""
2+
3+
from ..model import Deconvolve
4+
5+
def test_x1dstop():
6+
deconv = Deconvolve()
7+
deconv.inputs.out_file = 'file.nii'
8+
assert 'out_file' in deconv._list_outputs()
9+
deconv.inputs.x1D_stop = True
10+
assert not 'out_file' in deconv._list_outputs()

nipype/interfaces/base/core.py

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333

3434
from ... import config, logging, LooseVersion
3535
from ...utils.provenance import write_provenance
36-
from ...utils.misc import trim, str2bool
36+
from ...utils.misc import trim, str2bool, rgetcwd
3737
from ...utils.filemanip import (FileNotFoundError, split_filename, read_stream,
3838
which, get_dependencies, canonicalize_env as
3939
_canonicalize_env)
@@ -438,14 +438,16 @@ def _duecredit_cite(self):
438438
r['path'] = self.__module__
439439
due.cite(**r)
440440

441-
def run(self, **inputs):
441+
def run(self, cwd=None, **inputs):
442442
"""Execute this interface.
443443
444444
This interface will not raise an exception if runtime.returncode is
445445
non-zero.
446446
447447
Parameters
448448
----------
449+
450+
cwd : specify a folder where the interface should be run
449451
inputs : allows the interface settings to be updated
450452
451453
Returns
@@ -455,6 +457,13 @@ def run(self, **inputs):
455457
"""
456458
from ...utils.profiler import ResourceMonitor
457459

460+
# Tear-up: get current and prev directories
461+
syscwd = rgetcwd(error=False) # Recover when wd does not exist
462+
if cwd is None:
463+
cwd = syscwd
464+
465+
os.chdir(cwd) # Change to the interface wd
466+
458467
enable_rm = config.resource_monitor and self.resource_monitor
459468
force_raise = not getattr(self.inputs, 'ignore_exception', False)
460469
self.inputs.trait_set(**inputs)
@@ -471,7 +480,8 @@ def run(self, **inputs):
471480
env['DISPLAY'] = config.get_display()
472481

473482
runtime = Bunch(
474-
cwd=os.getcwd(),
483+
cwd=cwd,
484+
prevcwd=syscwd,
475485
returncode=None,
476486
duration=None,
477487
environ=env,
@@ -556,6 +566,7 @@ def run(self, **inputs):
556566
'rss_GiB': (vals[:, 2] / 1024).tolist(),
557567
'vms_GiB': (vals[:, 3] / 1024).tolist(),
558568
}
569+
os.chdir(syscwd)
559570

560571
return results
561572

nipype/interfaces/dtitk/__init__.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
"""The dtitk module provides classes for interfacing with the `Diffusion
2+
Tensor Imaging Toolkit (DTI-TK)
3+
<http://dti-tk.sourceforge.net/pmwiki/pmwiki.php>`_ command line tools.
4+
5+
Top-level namespace for dti-tk.
6+
"""
7+
8+
# from .base import ()
9+
from .registration import (RigidTask, AffineTask, DiffeoTask,
10+
ComposeXfmTask, diffeoSymTensor3DVolTask,
11+
affSymTensor3DVolTask, affScalarVolTask,
12+
diffeoScalarVolTask)
13+
from .utils import (TVAdjustOriginTask, TVAdjustVoxSpTask,
14+
SVAdjustVoxSpTask, TVResampleTask, SVResampleTask,
15+
TVtoolTask, BinThreshTask)

nipype/interfaces/dtitk/base.py

Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
# -*- coding: utf-8 -*-
2+
# emacs: -*- mode: python; py-indent-offset: 4; indent-tabs-mode: nil -*-
3+
# vi: set ft=python sts=4 ts=4 sw=4 et:
4+
"""The dtitk module provides classes for interfacing with the `DTITK
5+
<http://dti-tk.sourceforge.net/pmwiki/pmwiki.php>`_ command line tools.
6+
7+
These are the base tools for working with DTITK.
8+
Preprocessing tools are found in dtitk/preprocess.py
9+
Registration tools are found in dtitk/registration.py
10+
11+
Currently these tools are supported:
12+
13+
* Rigid Tensor Registration
14+
* Affine Tensor Registration
15+
* Diffeomorphic Tensor Registration
16+
17+
Examples
18+
--------
19+
See the docstrings of the individual classes for examples.
20+
21+
"""
22+
from __future__ import print_function, division, unicode_literals, \
23+
absolute_import
24+
25+
import os
26+
27+
from ... import logging
28+
from ...utils.filemanip import fname_presuffix
29+
from ..base import CommandLine
30+
from nipype.interfaces.fsl.base import Info
31+
32+
LOGGER = logging.getLogger('interface')
33+
34+
35+
class CommandLineDtitk(CommandLine):
36+
37+
def _gen_fname(self, basename, cwd=None, suffix=None, change_ext=True,
38+
ext=None):
39+
"""Generate a filename based on the given parameters.
40+
41+
The filename will take the form: cwd/basename<suffix><ext>.
42+
If change_ext is True, it will use the extentions specified in
43+
<instance>intputs.output_type.
44+
45+
Parameters
46+
----------
47+
basename : str
48+
Filename to base the new filename on.
49+
cwd : str
50+
Path to prefix to the new filename. (default is os.getcwd())
51+
suffix : str
52+
Suffix to add to the `basename`. (defaults is '' )
53+
change_ext : bool
54+
Flag to change the filename extension to the FSL output type.
55+
(default True)
56+
57+
Returns
58+
-------
59+
fname : str
60+
New filename based on given parameters.
61+
62+
"""
63+
64+
if basename == '':
65+
msg = 'Unable to generate filename for command %s. ' % self.cmd
66+
msg += 'basename is not set!'
67+
raise ValueError(msg)
68+
if cwd is None:
69+
cwd = os.getcwd()
70+
if ext is None:
71+
ext = Info.output_type_to_ext(self.inputs.output_type)
72+
if change_ext:
73+
if suffix:
74+
suffix = ''.join((suffix, ext))
75+
else:
76+
suffix = ext
77+
if suffix is None:
78+
suffix = ''
79+
fname = fname_presuffix(basename, suffix=suffix,
80+
use_ext=False, newpath=cwd)
81+
return fname

0 commit comments

Comments
 (0)