Skip to content

Commit 51585be

Browse files
committed
ading tmpdir; applying pep8 to my changes
1 parent e214b54 commit 51585be

File tree

2 files changed

+24
-17
lines changed

2 files changed

+24
-17
lines changed

nipype/interfaces/ants/registration.py

Lines changed: 18 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,15 @@
11
# -*- coding: utf-8 -*-
2-
"""The ants module provides basic functions for interfacing with ants functions.
2+
"""The ants module provides basic functions for interfacing with ants
3+
functions.
34
45
Change directory to provide relative paths for doctests
56
>>> import os
67
>>> filepath = os.path.dirname( os.path.realpath( __file__ ) )
78
>>> datadir = os.path.realpath(os.path.join(filepath, '../../testing/data'))
89
>>> os.chdir(datadir)
910
"""
10-
from __future__ import print_function, division, unicode_literals, absolute_import
11+
from __future__ import (print_function, division, unicode_literals,
12+
absolute_import)
1113
from builtins import range, str
1214
import os
1315

@@ -20,17 +22,19 @@ class ANTSInputSpec(ANTSCommandInputSpec):
2022
dimension = traits.Enum(3, 2, argstr='%d', usedefault=False,
2123
position=1, desc='image dimension (2 or 3)')
2224
fixed_image = InputMultiPath(File(exists=True), mandatory=True,
23-
desc=('image to which the moving image is warped'))
25+
desc=('image to which the moving image is '
26+
'warped'))
2427
moving_image = InputMultiPath(File(exists=True), argstr='%s',
2528
mandatory=True,
26-
desc=('image to apply transformation to (generally a coregistered '
29+
desc=('image to apply transformation to '
30+
'(generally a coregistered'
2731
'functional)'))
2832

2933
# Not all metrics are appropriate for all modalities. Also, not all metrics
30-
# are efficeint or appropriate at all resolution levels, Some metrics perform
31-
# well for gross global registraiton, but do poorly for small changes (i.e.
32-
# Mattes), and some metrics do well for small changes but don't work well for
33-
# gross level changes (i.e. 'CC').
34+
# are efficeint or appropriate at all resolution levels, Some metrics
35+
# perform well for gross global registraiton, but do poorly for small
36+
# changes (i.e. Mattes), and some metrics do well for small changes but
37+
# don't work well for gross level changes (i.e. 'CC').
3438
#
3539
# This is a two stage registration. in the first stage
3640
# [ 'Mattes', .................]
@@ -54,11 +58,13 @@ class ANTSInputSpec(ANTSCommandInputSpec):
5458
desc='the metric weight(s) for each stage. '
5559
'The weights must sum to 1 per stage.')
5660

57-
radius = traits.List(traits.Int(), requires=['metric'], mandatory=True,
58-
desc='radius of the region (i.e. number of layers around a voxel point)'
59-
' that is used for computing cross correlation')
61+
radius = traits.List(traits.Int(), requires=['metric'], mandatory=True,
62+
desc='radius of the region (i.e. number of layers'
63+
' around a voxel point)'
64+
' that is used for computing cross correlation')
6065

61-
output_transform_prefix = Str('out', usedefault=True, argstr='--output-naming %s',
66+
output_transform_prefix = Str('out', usedefault=True,
67+
argstr='--output-naming %s',
6268
mandatory=True, desc='')
6369
transformation_model = traits.Enum('Diff', 'Elast', 'Exp', 'Greedy Exp',
6470
'SyN', argstr='%s', mandatory=True,

nipype/interfaces/ants/tests/test_registration.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,22 @@
11
# emacs: -*- mode: python; py-indent-offset: 4; indent-tabs-mode: nil -*-
22
# vi: set ft=python sts=4 ts=4 sw=4 et:
33
from __future__ import unicode_literals
4-
from nipype.interfaces.ants import registration
4+
from nipype.interfaces.ants import registration
55
import os
66
import pytest
77

8-
def test_ants_mand():
9-
filepath = os.path.dirname( os.path.realpath( __file__ ) )
8+
9+
def test_ants_mand(tmpdir):
10+
tmpdir.chdir()
11+
filepath = os.path.dirname(os.path.realpath(__file__))
1012
datadir = os.path.realpath(os.path.join(filepath, '../../../testing/data'))
1113

1214
ants = registration.ANTS()
13-
ants.inputs.transformation_model= "SyN"
15+
ants.inputs.transformation_model = "SyN"
1416
ants.inputs.moving_image = [os.path.join(datadir, 'resting.nii')]
1517
ants.inputs.fixed_image = [os.path.join(datadir, 'T1.nii')]
1618
ants.inputs.metric = ['MI']
1719

1820
with pytest.raises(ValueError) as er:
1921
ants.run()
2022
assert "ANTS requires a value for input 'radius'" in str(er.value)
21-

0 commit comments

Comments
 (0)