Skip to content

Commit 98c6d11

Browse files
committed
sty: using yapf to clean pep8 issues
1 parent 501e65f commit 98c6d11

File tree

347 files changed

+42800
-25450
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

347 files changed

+42800
-25450
lines changed

nipype/__init__.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,8 @@
77
import os
88
from distutils.version import LooseVersion
99

10-
from .info import (LONG_DESCRIPTION as __doc__,
11-
URL as __url__,
12-
STATUS as __status__,
13-
__version__)
10+
from .info import (LONG_DESCRIPTION as __doc__, URL as __url__, STATUS as
11+
__status__, __version__)
1412
from .utils.config import NipypeConfig
1513
from .utils.logger import Logging
1614
from .refs import due
@@ -41,13 +39,15 @@ def __call__(self, doctests=True):
4139
['-x', '--ignore={}/external'.format(nipype_path), nipype_path])
4240
pytest.main(**params)
4341

42+
4443
test = NipypeTester()
4544

4645

4746
def get_info():
4847
"""Returns package information"""
4948
return _get_pkg_info(os.path.dirname(__file__))
5049

50+
5151
from .pipeline import Node, MapNode, JoinNode, Workflow
52-
from .interfaces import (DataGrabber, DataSink, SelectFiles,
53-
IdentityInterface, Rename, Function, Select, Merge)
52+
from .interfaces import (DataGrabber, DataSink, SelectFiles, IdentityInterface,
53+
Rename, Function, Select, Merge)

nipype/algorithms/confounds.py

Lines changed: 322 additions & 196 deletions
Large diffs are not rendered by default.

nipype/algorithms/icc.py

Lines changed: 19 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,10 @@
1313

1414

1515
class ICCInputSpec(BaseInterfaceInputSpec):
16-
subjects_sessions = traits.List(traits.List(File(exists=True)),
17-
desc="n subjects m sessions 3D stat files",
18-
mandatory=True)
16+
subjects_sessions = traits.List(
17+
traits.List(File(exists=True)),
18+
desc="n subjects m sessions 3D stat files",
19+
mandatory=True)
1920
mask = File(exists=True, mandatory=True)
2021

2122

@@ -40,11 +41,13 @@ def _run_interface(self, runtime):
4041
maskdata = np.logical_not(
4142
np.logical_or(maskdata == 0, np.isnan(maskdata)))
4243

43-
session_datas = [[nb.load(fname, mmap=NUMPY_MMAP).get_data()[
44-
maskdata].reshape(-1, 1) for fname in sessions]
45-
for sessions in self.inputs.subjects_sessions]
46-
list_of_sessions = [np.dstack(session_data)
47-
for session_data in session_datas]
44+
session_datas = [[
45+
nb.load(fname, mmap=NUMPY_MMAP).get_data()[maskdata].reshape(
46+
-1, 1) for fname in sessions
47+
] for sessions in self.inputs.subjects_sessions]
48+
list_of_sessions = [
49+
np.dstack(session_data) for session_data in session_datas
50+
]
4851
all_data = np.hstack(list_of_sessions)
4952
icc = np.zeros(session_datas[0][0].shape)
5053
session_F = np.zeros(session_datas[0][0].shape)
@@ -53,21 +56,22 @@ def _run_interface(self, runtime):
5356

5457
for x in range(icc.shape[0]):
5558
Y = all_data[x, :, :]
56-
icc[x], subject_var[x], session_var[x], session_F[x], _, _ = ICC_rep_anova(Y)
59+
icc[x], subject_var[x], session_var[x], session_F[
60+
x], _, _ = ICC_rep_anova(Y)
5761

5862
nim = nb.load(self.inputs.subjects_sessions[0][0])
5963
new_data = np.zeros(nim.shape)
60-
new_data[maskdata] = icc.reshape(-1,)
64+
new_data[maskdata] = icc.reshape(-1, )
6165
new_img = nb.Nifti1Image(new_data, nim.affine, nim.header)
6266
nb.save(new_img, 'icc_map.nii')
6367

6468
new_data = np.zeros(nim.shape)
65-
new_data[maskdata] = session_var.reshape(-1,)
69+
new_data[maskdata] = session_var.reshape(-1, )
6670
new_img = nb.Nifti1Image(new_data, nim.affine, nim.header)
6771
nb.save(new_img, 'session_var_map.nii')
6872

6973
new_data = np.zeros(nim.shape)
70-
new_data[maskdata] = subject_var.reshape(-1,)
74+
new_data[maskdata] = subject_var.reshape(-1, )
7175
new_img = nb.Nifti1Image(new_data, nim.affine, nim.header)
7276
nb.save(new_img, 'subject_var_map.nii')
7377

@@ -102,7 +106,7 @@ def ICC_rep_anova(Y):
102106

103107
# Sum Square Total
104108
mean_Y = mean(Y)
105-
SST = ((Y - mean_Y) ** 2).sum()
109+
SST = ((Y - mean_Y)**2).sum()
106110

107111
# create the design matrix for the different levels
108112
x = kron(eye(nb_conditions), ones((nb_subjects, 1))) # sessions
@@ -112,14 +116,14 @@ def ICC_rep_anova(Y):
112116
# Sum Square Error
113117
predicted_Y = dot(dot(dot(X, pinv(dot(X.T, X))), X.T), Y.flatten('F'))
114118
residuals = Y.flatten('F') - predicted_Y
115-
SSE = (residuals ** 2).sum()
119+
SSE = (residuals**2).sum()
116120

117121
residuals.shape = Y.shape
118122

119123
MSE = SSE / dfe
120124

121125
# Sum square session effect - between colums/sessions
122-
SSC = ((mean(Y, 0) - mean_Y) ** 2).sum() * nb_subjects
126+
SSC = ((mean(Y, 0) - mean_Y)**2).sum() * nb_subjects
123127
MSC = SSC / dfc / nb_subjects
124128

125129
session_effect_F = MSC / MSE

nipype/algorithms/mesh.py

Lines changed: 90 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -40,15 +40,25 @@ def __init__(self, **inputs):
4040

4141

4242
class WarpPointsInputSpec(BaseInterfaceInputSpec):
43-
points = File(exists=True, mandatory=True,
44-
desc='file containing the point set')
45-
warp = File(exists=True, mandatory=True,
46-
desc='dense deformation field to be applied')
47-
interp = traits.Enum('cubic', 'nearest', 'linear', usedefault=True,
48-
mandatory=True, desc='interpolation')
49-
out_points = File(name_source='points', name_template='%s_warped',
50-
output_name='out_points', keep_extension=True,
51-
desc='the warped point set')
43+
points = File(
44+
exists=True, mandatory=True, desc='file containing the point set')
45+
warp = File(
46+
exists=True,
47+
mandatory=True,
48+
desc='dense deformation field to be applied')
49+
interp = traits.Enum(
50+
'cubic',
51+
'nearest',
52+
'linear',
53+
usedefault=True,
54+
mandatory=True,
55+
desc='interpolation')
56+
out_points = File(
57+
name_source='points',
58+
name_template='%s_warped',
59+
output_name='out_points',
60+
keep_extension=True,
61+
desc='the warped point set')
5262

5363

5464
class WarpPointsOutputSpec(TraitedSpec):
@@ -111,10 +121,9 @@ def _run_interface(self, runtime):
111121
wdata = axis.get_data()
112122
if np.any(wdata != 0):
113123

114-
warp = ndimage.map_coordinates(wdata,
115-
voxpoints.transpose())
124+
warp = ndimage.map_coordinates(wdata, voxpoints.transpose())
116125
else:
117-
warp = np.zeros((points.shape[0],))
126+
warp = np.zeros((points.shape[0], ))
118127

119128
warps.append(warp)
120129

@@ -130,39 +139,52 @@ def _run_interface(self, runtime):
130139

131140
def _list_outputs(self):
132141
outputs = self._outputs().get()
133-
outputs['out_points'] = self._gen_fname(self.inputs.points,
134-
suffix='warped',
135-
ext='.vtk')
142+
outputs['out_points'] = self._gen_fname(
143+
self.inputs.points, suffix='warped', ext='.vtk')
136144
return outputs
137145

138146

139147
class ComputeMeshWarpInputSpec(BaseInterfaceInputSpec):
140-
surface1 = File(exists=True, mandatory=True,
141-
desc=('Reference surface (vtk format) to which compute '
142-
'distance.'))
143-
surface2 = File(exists=True, mandatory=True,
144-
145-
desc=('Test surface (vtk format) from which compute '
146-
'distance.'))
147-
metric = traits.Enum('euclidean', 'sqeuclidean', usedefault=True,
148-
desc='norm used to report distance')
148+
surface1 = File(
149+
exists=True,
150+
mandatory=True,
151+
desc=('Reference surface (vtk format) to which compute '
152+
'distance.'))
153+
surface2 = File(
154+
exists=True,
155+
mandatory=True,
156+
desc=('Test surface (vtk format) from which compute '
157+
'distance.'))
158+
metric = traits.Enum(
159+
'euclidean',
160+
'sqeuclidean',
161+
usedefault=True,
162+
desc='norm used to report distance')
149163
weighting = traits.Enum(
150-
'none', 'area', usedefault=True,
164+
'none',
165+
'area',
166+
usedefault=True,
151167
desc=('"none": no weighting is performed, surface": edge distance is '
152168
'weighted by the corresponding surface area'))
153-
out_warp = File('surfwarp.vtk', usedefault=True,
154-
desc='vtk file based on surface1 and warpings mapping it '
155-
'to surface2')
156-
out_file = File('distance.npy', usedefault=True,
157-
desc='numpy file keeping computed distances and weights')
169+
out_warp = File(
170+
'surfwarp.vtk',
171+
usedefault=True,
172+
desc='vtk file based on surface1 and warpings mapping it '
173+
'to surface2')
174+
out_file = File(
175+
'distance.npy',
176+
usedefault=True,
177+
desc='numpy file keeping computed distances and weights')
158178

159179

160180
class ComputeMeshWarpOutputSpec(TraitedSpec):
161181
distance = traits.Float(desc="computed distance")
162-
out_warp = File(exists=True, desc=('vtk file with the vertex-wise '
163-
'mapping of surface1 to surface2'))
164-
out_file = File(exists=True,
165-
desc='numpy file keeping computed distances and weights')
182+
out_warp = File(
183+
exists=True,
184+
desc=('vtk file with the vertex-wise '
185+
'mapping of surface1 to surface2'))
186+
out_file = File(
187+
exists=True, desc='numpy file keeping computed distances and weights')
166188

167189

168190
class ComputeMeshWarp(TVTKBaseInterface):
@@ -206,7 +228,7 @@ def _run_interface(self, runtime):
206228
vtk2 = VTKInfo.vtk_output(r2)
207229
r1.update()
208230
r2.update()
209-
assert(len(vtk1.points) == len(vtk2.points))
231+
assert (len(vtk1.points) == len(vtk2.points))
210232

211233
points1 = np.array(vtk1.points)
212234
points2 = np.array(vtk2.points)
@@ -262,31 +284,45 @@ def _list_outputs(self):
262284

263285

264286
class MeshWarpMathsInputSpec(BaseInterfaceInputSpec):
265-
in_surf = File(exists=True, mandatory=True,
266-
desc=('Input surface in vtk format, with associated warp '
267-
'field as point data (ie. from ComputeMeshWarp'))
268-
float_trait = traits.Either(traits.Float(1.0), traits.Tuple(
269-
traits.Float(1.0), traits.Float(1.0), traits.Float(1.0)))
287+
in_surf = File(
288+
exists=True,
289+
mandatory=True,
290+
desc=('Input surface in vtk format, with associated warp '
291+
'field as point data (ie. from ComputeMeshWarp'))
292+
float_trait = traits.Either(
293+
traits.Float(1.0),
294+
traits.Tuple(traits.Float(1.0), traits.Float(1.0), traits.Float(1.0)))
270295

271296
operator = traits.Either(
272-
float_trait, File(exists=True), default=1.0, mandatory=True,
297+
float_trait,
298+
File(exists=True),
299+
default=1.0,
300+
mandatory=True,
273301
desc='image, float or tuple of floats to act as operator')
274302

275-
operation = traits.Enum('sum', 'sub', 'mul', 'div', usedefault=True,
276-
desc='operation to be performed')
303+
operation = traits.Enum(
304+
'sum',
305+
'sub',
306+
'mul',
307+
'div',
308+
usedefault=True,
309+
desc='operation to be performed')
277310

278-
out_warp = File('warp_maths.vtk', usedefault=True,
279-
desc='vtk file based on in_surf and warpings mapping it '
280-
'to out_file')
281-
out_file = File('warped_surf.vtk', usedefault=True,
282-
desc='vtk with surface warped')
311+
out_warp = File(
312+
'warp_maths.vtk',
313+
usedefault=True,
314+
desc='vtk file based on in_surf and warpings mapping it '
315+
'to out_file')
316+
out_file = File(
317+
'warped_surf.vtk', usedefault=True, desc='vtk with surface warped')
283318

284319

285320
class MeshWarpMathsOutputSpec(TraitedSpec):
286-
out_warp = File(exists=True, desc=('vtk file with the vertex-wise '
287-
'mapping of surface1 to surface2'))
288-
out_file = File(exists=True,
289-
desc='vtk with surface warped')
321+
out_warp = File(
322+
exists=True,
323+
desc=('vtk file with the vertex-wise '
324+
'mapping of surface1 to surface2'))
325+
out_file = File(exists=True, desc='vtk with surface warped')
290326

291327

292328
class MeshWarpMaths(TVTKBaseInterface):
@@ -330,16 +366,15 @@ def _run_interface(self, runtime):
330366
r2 = tvtk.PolyDataReader(file_name=self.inputs.surface2)
331367
vtk2 = VTKInfo.vtk_output(r2)
332368
r2.update()
333-
assert(len(points1) == len(vtk2.points))
369+
assert (len(points1) == len(vtk2.points))
334370

335371
opfield = vtk2.point_data.vectors
336372

337373
if opfield is None:
338374
opfield = vtk2.point_data.scalars
339375

340376
if opfield is None:
341-
raise RuntimeError(
342-
'No operator values found in operator file')
377+
raise RuntimeError('No operator values found in operator file')
343378

344379
opfield = np.array(opfield)
345380

0 commit comments

Comments
 (0)