Skip to content

Commit 09c00b7

Browse files
committed
Merge pull request nipy#322 from satra/fix/cleanup
Fix/cleanup
2 parents 845d809 + e028db0 commit 09c00b7

17 files changed

+280
-211
lines changed

examples/dmri_group_connectivity_camino.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@
5454
import os.path as op # system functions
5555
import cmp
5656
from nipype.workflows.dmri.camino.group_connectivity import create_group_connectivity_pipeline
57-
from nipype.workflows.dmri.connectivity.group_connectivity import (create_merge_networks_by_group_workflow,
57+
from nipype.workflows.dmri.connectivity.group_connectivity import (create_merge_networks_by_group_workflow,
5858
create_merge_group_networks_workflow, create_average_networks_by_group_workflow)
5959

6060
"""

nipype/interfaces/ants/__init__.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# emacs: -*- mode: python; py-indent-offset: 4; indent-tabs-mode: nil -*-
22
# vi: set ft=python sts=4 ts=4 sw=4 et:
3+
34
"""Top-level namespace for ants."""
4-
from nipype.interfaces.ants.base import ANTSCommand
5-
from nipype.interfaces.ants.normalize import (BuildTemplate,
6-
WarpImageMultiTransform, GenWarpFields)
5+
6+
from .normalize import (BuildTemplate, WarpImageMultiTransform, GenWarpFields)
77

nipype/interfaces/ants/base.py

Lines changed: 41 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -2,24 +2,50 @@
22
# vi: set ft=python sts=4 ts=4 sw=4 et:
33
"""The ants module provides basic functions for interfacing with ANTS tools."""
44

5-
__docformat__ = 'restructuredtext'
6-
7-
# Standard library imports
8-
import os
9-
from copy import deepcopy
10-
11-
# Third-party imports
12-
import numpy as np
13-
145
# Local imports
15-
from nipype.interfaces.base import (TraitedSpec, File, traits,
16-
Directory, InputMultiPath,
17-
OutputMultiPath, CommandLine,
18-
CommandLineInputSpec, isdefined)
6+
from nipype.interfaces.base import (CommandLine, CommandLineInputSpec, traits,
7+
isdefined)
8+
199
import logging
2010
logger = logging.getLogger('iflogger')
2111

12+
13+
class ANTSCommandInputSpec(CommandLineInputSpec):
14+
"""Base Input Specification for all ANTS Commands
15+
"""
16+
17+
num_threads = traits.Int(1, usedefault=True,
18+
desc="Number of ITK threads to use")
19+
20+
2221
class ANTSCommand(CommandLine):
22+
"""Base class for ANTS interfaces
23+
"""
24+
25+
input_spec = ANTSCommandInputSpec
26+
_num_threads = 1
27+
2328
def __init__(self, **inputs):
24-
self.inputs.environ['ITK_GLOBAL_DEFAULT_NUMBER_OF_THREADS']='1'
25-
return super(ANTSCommand, self).__init__(**inputs)
29+
super(ANTSCommand, self).__init__(**inputs)
30+
self.inputs.on_trait_change(self._num_threads_update, 'num_threads')
31+
32+
if not isdefined(self.inputs.num_threads):
33+
self.inputs.num_threads = self._num_threads
34+
else:
35+
self._num_threads_update()
36+
37+
def _num_threads_update(self):
38+
self._num_threads = self.inputs.num_threads
39+
self.inputs.environ.update({'ITK_GLOBAL_DEFAULT_NUMBER_OF_THREADS':
40+
'%s' % self.inputs.num_threads})
41+
42+
@classmethod
43+
def set_default_num_threads(cls, num_threads):
44+
"""Set the default number of threads for ITK calls
45+
46+
This method is used to set the default number of ITK threads for all
47+
the ANTS interfaces. However, setting this will not update the output
48+
type for any existing instances. For these, assign the
49+
<instance>.inputs.num_threads
50+
"""
51+
cls._num_threads = num_threads

nipype/interfaces/ants/normalize.py

Lines changed: 204 additions & 171 deletions
Large diffs are not rendered by default.

nipype/interfaces/cmtk/nx.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -505,7 +505,7 @@ class AverageNetworks(BaseInterface):
505505
"""
506506
Calculates and outputs the average network given a set of input NetworkX gpickle files
507507
508-
This interface will only keep an edge in the averaged network if that edge is present in
508+
This interface will only keep an edge in the averaged network if that edge is present in
509509
at least half of the input networks.
510510
511511
Example

nipype/interfaces/setup.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,14 @@
11
# emacs: -*- mode: python; py-indent-offset: 4; indent-tabs-mode: nil -*-
22
# vi: set ft=python sts=4 ts=4 sw=4 et:
3-
def configuration(parent_package='',top_path=None):
3+
4+
5+
def configuration(parent_package='', top_path=None):
46
from numpy.distutils.misc_util import Configuration
57

68
config = Configuration('interfaces', parent_package, top_path)
79

810
config.add_subpackage('afni')
11+
config.add_subpackage('ants')
912
config.add_subpackage('camino')
1013
config.add_subpackage('camino2trackvis')
1114
config.add_subpackage('cmtk')

nipype/interfaces/spm/preprocess.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1056,7 +1056,7 @@ class ApplyDeformationFieldInputSpec(SPMCommandInputSpec):
10561056
reference_volume = File(exists=True, mandatory=True, field='comp{2}.id.space')
10571057
interp = traits.Range(low=0, high=7, field='interp',
10581058
desc='degree of b-spline used for interpolation')
1059-
1059+
10601060

10611061
class ApplyDeformationFieldOutputSpec(TraitedSpec):
10621062
out_files = OutputMultiPath(File(exists=True))

nipype/testing/data/ants_Affine.txt

Whitespace-only changes.

nipype/testing/data/ants_Warp.nii.gz

Whitespace-only changes.

nipype/testing/data/ants_deformed.nii.gz

Whitespace-only changes.

0 commit comments

Comments
 (0)