Skip to content

Commit 48fcf86

Browse files
authored
Merge branch 'master' into master
2 parents 0877483 + 9d63943 commit 48fcf86

File tree

24 files changed

+186
-65
lines changed

24 files changed

+186
-65
lines changed

nipype/algorithms/icc.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
from scipy.linalg import pinv
99
from ..interfaces.base import BaseInterfaceInputSpec, TraitedSpec, \
1010
BaseInterface, traits, File
11-
from nipype.utils import NUMPY_MMAP
11+
from ..utils import NUMPY_MMAP
1212

1313

1414
class ICCInputSpec(BaseInterfaceInputSpec):

nipype/algorithms/metrics.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
from ..interfaces.base import (BaseInterface, traits, TraitedSpec, File,
3131
InputMultiPath,
3232
BaseInterfaceInputSpec, isdefined)
33-
from nipype.utils import NUMPY_MMAP
33+
from ..utils import NUMPY_MMAP
3434

3535
iflogger = logging.getLogger('interface')
3636

nipype/algorithms/misc.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
BaseInterfaceInputSpec, isdefined,
3535
DynamicTraitedSpec, Undefined)
3636
from ..utils.filemanip import fname_presuffix, split_filename
37-
from nipype.utils import NUMPY_MMAP
37+
from ..utils import NUMPY_MMAP
3838

3939
from . import confounds
4040

nipype/interfaces/afni/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,4 +20,4 @@
2020
from .utils import (AFNItoNIFTI, Autobox, BrickStat, Calc, Copy,
2121
Eval, FWHMx,
2222
MaskTool, Merge, Notes, Refit, Resample, TCat, TStat, To3D,
23-
Unifize, ZCutUp,)
23+
Unifize, ZCutUp, GCOR,)
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
# AUTO-GENERATED by tools/checkspecs.py - DO NOT EDIT
2+
from __future__ import unicode_literals
3+
from ..utils import GCOR
4+
5+
6+
def test_GCOR_inputs():
7+
input_map = dict(args=dict(argstr='%s',
8+
),
9+
environ=dict(nohash=True,
10+
usedefault=True,
11+
),
12+
ignore_exception=dict(nohash=True,
13+
usedefault=True,
14+
),
15+
in_file=dict(argstr='-input %s',
16+
copyfile=False,
17+
mandatory=True,
18+
position=-1,
19+
),
20+
mask=dict(argstr='-mask %s',
21+
copyfile=False,
22+
),
23+
nfirst=dict(argstr='-nfirst %d',
24+
),
25+
no_demean=dict(argstr='-no_demean',
26+
),
27+
terminal_output=dict(nohash=True,
28+
),
29+
)
30+
inputs = GCOR.input_spec()
31+
32+
for key, metadata in list(input_map.items()):
33+
for metakey, value in list(metadata.items()):
34+
assert getattr(inputs.traits()[key], metakey) == value
35+
36+
37+
def test_GCOR_outputs():
38+
output_map = dict(out=dict(),
39+
)
40+
outputs = GCOR.output_spec()
41+
42+
for key, metadata in list(output_map.items()):
43+
for metakey, value in list(metadata.items()):
44+
assert getattr(outputs.traits()[key], metakey) == value

nipype/interfaces/afni/utils.py

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1378,3 +1378,66 @@ class ZCutUp(AFNICommand):
13781378
_cmd = '3dZcutup'
13791379
input_spec = ZCutUpInputSpec
13801380
output_spec = AFNICommandOutputSpec
1381+
1382+
1383+
class GCORInputSpec(CommandLineInputSpec):
1384+
in_file = File(
1385+
desc='input dataset to compute the GCOR over',
1386+
argstr='-input %s',
1387+
position=-1,
1388+
mandatory=True,
1389+
exists=True,
1390+
copyfile=False)
1391+
1392+
mask = File(
1393+
desc='mask dataset, for restricting the computation',
1394+
argstr='-mask %s',
1395+
exists=True,
1396+
copyfile=False)
1397+
1398+
nfirst = traits.Int(0, argstr='-nfirst %d',
1399+
desc='specify number of initial TRs to ignore')
1400+
no_demean = traits.Bool(False, argstr='-no_demean',
1401+
desc='do not (need to) demean as first step')
1402+
1403+
1404+
class GCOROutputSpec(TraitedSpec):
1405+
out = traits.Float(desc='global correlation value')
1406+
1407+
1408+
class GCOR(CommandLine):
1409+
"""
1410+
Computes the average correlation between every voxel
1411+
and ever other voxel, over any give mask.
1412+
1413+
1414+
For complete details, see the `@compute_gcor Documentation.
1415+
<https://afni.nimh.nih.gov/pub/dist/doc/program_help/@compute_gcor.html>`_
1416+
1417+
Examples
1418+
========
1419+
1420+
>>> from nipype.interfaces import afni
1421+
>>> gcor = afni.GCOR()
1422+
>>> gcor.inputs.in_file = 'structural.nii'
1423+
>>> gcor.inputs.nfirst = 4
1424+
>>> gcor.cmdline # doctest: +ALLOW_UNICODE
1425+
'@compute_gcor -nfirst 4 -input structural.nii'
1426+
>>> res = gcor.run() # doctest: +SKIP
1427+
1428+
"""
1429+
1430+
_cmd = '@compute_gcor'
1431+
input_spec = GCORInputSpec
1432+
output_spec = GCOROutputSpec
1433+
1434+
def _run_interface(self, runtime):
1435+
runtime = super(GCOR, self)._run_interface(runtime)
1436+
1437+
gcor_line = [line.strip() for line in runtime.stdout.split('\n')
1438+
if line.strip().startswith('GCOR = ')][-1]
1439+
setattr(self, '_gcor', float(gcor_line[len('GCOR = '):]))
1440+
return runtime
1441+
1442+
def _list_outputs(self):
1443+
return {'out': getattr(self, '_gcor')}

nipype/interfaces/ants/registration.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -354,6 +354,16 @@ class RegistrationInputSpec(ANTSCommandInputSpec):
354354
),
355355
)
356356
)
357+
restrict_deformation = traits.List(
358+
traits.List(traits.Enum(0, 1)),
359+
desc=("This option allows the user to restrict the optimization of "
360+
"the displacement field, translation, rigid or affine transform "
361+
"on a per-component basis. For example, if one wants to limit "
362+
"the deformation or rotation of 3-D volume to the first two "
363+
"dimensions, this is possible by specifying a weight vector of "
364+
"'1x1x0' for a deformation field or '1x1x0x1x1x0' for a rigid "
365+
"transformation. Low-dimensional restriction only works if "
366+
"there are no preceding transformations."))
357367
# Convergence flags
358368
number_of_iterations = traits.List(traits.List(traits.Int()))
359369
smoothing_sigmas = traits.List(traits.List(traits.Float()), mandatory=True)
@@ -770,6 +780,9 @@ def _format_registration(self):
770780
else:
771781
histval = self.inputs.use_histogram_matching[ii]
772782
retval.append('--use-histogram-matching %d' % histval)
783+
if isdefined(self.inputs.restrict_deformation):
784+
retval.append('--restrict-deformation %s' %
785+
self._format_xarray(self.inputs.restrict_deformation[ii]))
773786
return " ".join(retval)
774787

775788
def _get_outputfilenames(self, inverse=False):

nipype/interfaces/ants/tests/test_auto_Registration.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,7 @@ def test_Registration_inputs():
7979
),
8080
restore_state=dict(argstr='--restore-state %s',
8181
),
82+
restrict_deformation=dict(),
8283
sampling_percentage=dict(requires=['sampling_strategy'],
8384
),
8485
sampling_percentage_item_trait=dict(),

nipype/interfaces/dipy/preprocess.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@
1313
import nibabel as nb
1414
import numpy as np
1515

16+
from ...utils import NUMPY_MMAP
17+
1618
from ... import logging
1719
from ..base import (traits, TraitedSpec, File, isdefined)
1820
from .base import DipyBaseInterface
@@ -179,7 +181,6 @@ def resample_proxy(in_file, order=3, new_zooms=None, out_file=None):
179181
Performs regridding of an image to set isotropic voxel sizes using dipy.
180182
"""
181183
from dipy.align.reslice import reslice
182-
from nipype.utils import NUMPY_MMAP
183184

184185
if out_file is None:
185186
fname, fext = op.splitext(op.basename(in_file))
@@ -223,7 +224,6 @@ def nlmeans_proxy(in_file, settings,
223224
from dipy.denoise.nlmeans import nlmeans
224225
from scipy.ndimage.morphology import binary_erosion
225226
from scipy import ndimage
226-
from nipype.utils import NUMPY_MMAP
227227

228228
if out_file is None:
229229
fname, fext = op.splitext(op.basename(in_file))

nipype/interfaces/fsl/ICA_AROMA.py

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -10,18 +10,13 @@
1010
... '../../testing/data'))
1111
>>> os.chdir(datadir)
1212
"""
13-
from nipype.interfaces.base import (
14-
TraitedSpec,
15-
CommandLineInputSpec,
16-
CommandLine,
17-
File,
18-
Directory,
19-
traits,
20-
OutputMultiPath,
21-
isdefined
22-
)
13+
14+
from __future__ import print_function, division, unicode_literals, absolute_import
15+
from ..base import (TraitedSpec, CommandLineInputSpec, CommandLine,
16+
File, Directory, traits)
2317
import os
2418

19+
2520
class ICA_AROMAInputSpec(CommandLineInputSpec):
2621
feat_dir = Directory(exists=True, mandatory=True,
2722
argstr='-feat %s',

nipype/interfaces/fsl/fix.py

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
# -*- coding: utf-8 -*-
12
# emacs: -*- mode: python; py-indent-offset: 4; indent-tabs-mode: nil -*-
23
# vi: set ft=python sts=4 ts=4 sw=4 et:
34
"""The fix module provides classes for interfacing with the `FSL FIX
@@ -53,8 +54,9 @@
5354
outgraph = fix_pipeline.run()
5455
5556
"""
57+
from __future__ import print_function, division, unicode_literals, absolute_import
5658

57-
from nipype.interfaces.base import (
59+
from ..base import (
5860
TraitedSpec,
5961
CommandLineInputSpec,
6062
CommandLine,
@@ -64,13 +66,10 @@
6466
BaseInterfaceInputSpec,
6567
traits
6668
)
67-
from nipype.interfaces.traits_extension import (
68-
Directory,
69-
File,
70-
isdefined
71-
)
69+
from ..traits_extension import Directory, File, isdefined
7270
import os
7371

72+
7473
class TrainingSetCreatorInputSpec(BaseInterfaceInputSpec):
7574
mel_icas_in = InputMultiPath(Directory(exists=True), copyfile=False,
7675
desc='Melodic output directories',

nipype/interfaces/niftyseg/base.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
# -*- coding: utf-8 -*-
12
# emacs: -*- mode: python; py-indent-offset: 4; indent-tabs-mode: nil -*-
23
# vi: set ft=python sts=4 ts=4 sw=4 et:
34

@@ -15,9 +16,10 @@
1516
--------
1617
See the docstrings of the individual classes for examples.
1718
"""
19+
from __future__ import print_function, division, unicode_literals, absolute_import
1820

19-
from nipype.interfaces.niftyreg.base import no_nifty_package
20-
from nipype.interfaces.niftyfit.base import NiftyFitCommand
21+
from ..niftyreg.base import no_nifty_package
22+
from ..niftyfit.base import NiftyFitCommand
2123
import subprocess
2224
import warnings
2325

nipype/interfaces/petpvc.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,8 @@
1313
import os
1414

1515
from .base import TraitedSpec, CommandLineInputSpec, CommandLine, File, isdefined, traits
16-
from ..external.due import due, Doi, BibTeX
16+
from ..utils.filemanip import fname_presuffix
17+
from ..external.due import BibTeX
1718

1819
pvc_methods = ['GTM',
1920
'IY',
@@ -200,8 +201,6 @@ def _gen_fname(self, basename, cwd=None, suffix=None, change_ext=True,
200201
New filename based on given parameters.
201202
202203
"""
203-
from nipype.utils.filemanip import fname_presuffix
204-
205204
if basename == '':
206205
msg = 'Unable to generate filename for command %s. ' % self.cmd
207206
msg += 'basename is not set!'

nipype/interfaces/utility/wrappers.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,9 @@
1919

2020
from builtins import str, bytes
2121

22-
from nipype import logging
22+
from ... import logging
2323
from ..base import (traits, DynamicTraitedSpec, Undefined, isdefined, runtime_profile,
24-
BaseInterfaceInputSpec)
24+
BaseInterfaceInputSpec, get_max_resources_used)
2525
from ..io import IOBase, add_traits
2626
from ...utils.filemanip import filename_to_list
2727
from ...utils.misc import getsource, create_function_from_source
@@ -138,7 +138,6 @@ def _add_output_traits(self, base):
138138

139139
def _run_interface(self, runtime):
140140
# Get workflow logger for runtime profile error reporting
141-
from nipype import logging
142141
logger = logging.getLogger('workflow')
143142

144143
# Create function handle
@@ -163,7 +162,6 @@ def _function_handle_wrapper(queue, **kwargs):
163162

164163
# Profile resources if set
165164
if runtime_profile:
166-
from nipype.interfaces.base import get_max_resources_used
167165
import multiprocessing
168166
# Init communication queue and proc objs
169167
queue = multiprocessing.Queue()

nipype/pipeline/engine/utils.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
#!/usr/bin/env python
21
# -*- coding: utf-8 -*-
32
# emacs: -*- mode: python; py-indent-offset: 4; indent-tabs-mode: nil -*-
43
# vi: set ft=python sts=4 ts=4 sw=4 et:
@@ -24,7 +23,7 @@
2423
import pickle
2524
from functools import reduce
2625
import numpy as np
27-
from nipype.utils.misc import package_check
26+
from ...utils.misc import package_check
2827

2928
package_check('networkx', '1.3')
3029

nipype/pipeline/plugins/pbs.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,13 @@ def _is_pending(self, taskid):
4949
environ=dict(os.environ),
5050
terminal_output='allatonce',
5151
ignore_exception=True).run()
52+
stderr = result.runtime.stderr
5253
errmsg = 'Unknown Job Id' # %s' % taskid
53-
return errmsg not in result.runtime.stderr
54+
success = 'Job has finished'
55+
if success in e: # Fix for my PBS
56+
return False
57+
else:
58+
return errmsg not in e
5459

5560
def _submit_batchtask(self, scriptfile, node):
5661
cmd = CommandLine('qsub', environ=dict(os.environ),

nipype/utils/__init__.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# -*- coding: utf-8 -*-
22
from __future__ import absolute_import
33

4-
from nipype.utils.config import NUMPY_MMAP
5-
from nipype.utils.onetime import OneTimeProperty, setattr_on_read
6-
from nipype.utils.tmpdirs import TemporaryDirectory, InTemporaryDirectory
4+
from .config import NUMPY_MMAP
5+
from .onetime import OneTimeProperty, setattr_on_read
6+
from .tmpdirs import TemporaryDirectory, InTemporaryDirectory

0 commit comments

Comments
 (0)