Skip to content

Commit 73bb431

Browse files
committed
PEP8 formatting
1 parent 6a7e2f3 commit 73bb431

File tree

1 file changed

+18
-16
lines changed

1 file changed

+18
-16
lines changed

nipype/algorithms/mesh.py

Lines changed: 18 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -34,10 +34,13 @@ class P2PDistanceInputSpec(BaseInterfaceInputSpec):
3434
'"surface": edge distance is weighted by the '
3535
'corresponding surface area'))
3636

37+
3738
class P2PDistanceOutputSpec(TraitedSpec):
3839
distance = traits.Float(desc="computed distance")
3940

41+
4042
class P2PDistance(BaseInterface):
43+
4144
"""Calculates a point-to-point (p2p) distance between two corresponding
4245
VTK-readable meshes or contours.
4346
@@ -57,10 +60,10 @@ class P2PDistance(BaseInterface):
5760
output_spec = P2PDistanceOutputSpec
5861

5962
def _triangle_area(self, A, B, C):
60-
ABxAC = euclidean(A,B) * euclidean(A,C)
61-
prod = np.dot(np.array(B)-np.array(A),np.array(C)-np.array(A))
62-
angle = np.arccos( prod / ABxAC )
63-
area = 0.5 * ABxAC * np.sin( angle )
63+
ABxAC = euclidean(A, B) * euclidean(A, C)
64+
prod = np.dot(np.array(B) - np.array(A), np.array(C) - np.array(A))
65+
angle = np.arccos(prod / ABxAC)
66+
area = 0.5 * ABxAC * np.sin(angle)
6467
return area
6568

6669
def _run_interface(self, runtime):
@@ -74,33 +77,33 @@ def _run_interface(self, runtime):
7477
except ImportError:
7578
raise ImportError('Interface P2PDistance requires tvtk')
7679

77-
r1 = tvtk.PolyDataReader( file_name=self.inputs.surface1 )
78-
r2 = tvtk.PolyDataReader( file_name=self.inputs.surface2 )
80+
r1 = tvtk.PolyDataReader(file_name=self.inputs.surface1)
81+
r2 = tvtk.PolyDataReader(file_name=self.inputs.surface2)
7982
vtk1 = r1.output
8083
vtk2 = r2.output
8184
r1.update()
8285
r2.update()
83-
assert( len(vtk1.points) == len(vtk2.points) )
86+
assert(len(vtk1.points) == len(vtk2.points))
8487
d = 0.0
8588
totalWeight = 0.0
8689

8790
points = vtk1.points
88-
faces = vtk1.polys.to_array().reshape(-1,4).astype(int)[:,1:]
91+
faces = vtk1.polys.to_array().reshape(-1, 4).astype(int)[:, 1:]
8992

90-
for p1,p2 in zip( points, vtk2.points ):
93+
for p1, p2 in zip(points, vtk2.points):
9194
weight = 1.0
9295
if (self.inputs.weighting == 'surface'):
93-
#compute surfaces, set in weight
96+
# compute surfaces, set in weight
9497
weight = 0.0
95-
point_faces = faces[ (faces[:,:]==0).any(axis=1) ]
98+
point_faces = faces[(faces[:, :] == 0).any(axis=1)]
9699

97100
for idset in point_faces:
98-
p1 = points[ int(idset[0]) ]
99-
p2 = points[ int(idset[1]) ]
100-
p3 = points[ int(idset[2]) ]
101+
p1 = points[int(idset[0])]
102+
p2 = points[int(idset[1])]
103+
p3 = points[int(idset[2])]
101104
weight = weight + self._triangle_area(p1, p2, p3)
102105

103-
d+= weight*euclidean( p1, p2 )
106+
d += weight * euclidean(p1, p2)
104107
totalWeight = totalWeight + weight
105108

106109
self._distance = d / totalWeight
@@ -110,4 +113,3 @@ def _list_outputs(self):
110113
outputs = self._outputs().get()
111114
outputs['distance'] = self._distance
112115
return outputs
113-

0 commit comments

Comments
 (0)