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',

0 commit comments

Comments
 (0)