@@ -40,15 +40,25 @@ def __init__(self, **inputs):
4040
4141
4242class 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
5464class 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
139147class 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
160180class 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
168190class 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
264286class 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
285320class 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
292328class 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