@@ -144,10 +144,12 @@ def _run_interface(self, runtime):
144
144
import nibabel as nb
145
145
import numpy as np
146
146
from scipy import ndimage
147
+ from tvtk .common import configure_input_data
148
+ from tvtk .common import is_old_pipeline as vtk_old
147
149
148
150
r = tvtk .PolyDataReader (file_name = self .inputs .points )
149
151
r .update ()
150
- mesh = r .output
152
+ mesh = r .output if vtk_old () else r . get_output ()
151
153
points = np .array (mesh .points )
152
154
warp_dims = nb .funcs .four_to_three (nb .load (self .inputs .warp ))
153
155
@@ -174,21 +176,14 @@ def _run_interface(self, runtime):
174
176
newpoints = [p + d for p , d in zip (points , disps )]
175
177
mesh .points = newpoints
176
178
w = tvtk .PolyDataWriter ()
177
- if self .vtk_version ()[0 ] < 6 :
178
- w .input = mesh
179
- else :
180
- w .set_input_data_object (mesh )
181
-
182
- w .file_name = self ._gen_fname (self .inputs .points ,
183
- suffix = 'warped' ,
184
- ext = '.vtk' )
179
+ configure_input_data (w , mesh )
180
+ w .file_name = self ._gen_fname (self .inputs .points , suffix = 'warped' , ext = '.vtk' )
185
181
w .write ()
186
182
return runtime
187
183
188
184
def _list_outputs (self ):
189
185
outputs = self ._outputs ().get ()
190
- outputs ['out_points' ] = self ._gen_fname (self .inputs .points ,
191
- suffix = 'warped' ,
186
+ outputs ['out_points' ] = self ._gen_fname (self .inputs .points , suffix = 'warped' ,
192
187
ext = '.vtk' )
193
188
return outputs
194
189
@@ -258,10 +253,13 @@ def _triangle_area(self, A, B, C):
258
253
return area
259
254
260
255
def _run_interface (self , runtime ):
256
+ from tvtk .common import configure_input_data
257
+ from tvtk .common import is_old_pipeline as vtk_old
258
+
261
259
r1 = tvtk .PolyDataReader (file_name = self .inputs .surface1 )
262
260
r2 = tvtk .PolyDataReader (file_name = self .inputs .surface2 )
263
- vtk1 = r1 .output
264
- vtk2 = r2 .output
261
+ vtk1 = r1 .output if vtk_old () else r1 . get_output ()
262
+ vtk2 = r2 .output if vtk_old () else r2 . get_output ()
265
263
r1 .update ()
266
264
r2 .update ()
267
265
assert (len (vtk1 .points ) == len (vtk2 .points ))
@@ -305,12 +303,7 @@ def _run_interface(self, runtime):
305
303
out_mesh .point_data .vectors .name = 'warpings'
306
304
writer = tvtk .PolyDataWriter (
307
305
file_name = op .abspath (self .inputs .out_warp ))
308
-
309
- if self .vtk_version ()[0 ] < 6 :
310
- writer .input = out_mesh
311
- else :
312
- writer .set_input_data_object (out_mesh )
313
-
306
+ configure_input_data (writer , out_mesh )
314
307
writer .write ()
315
308
316
309
self ._distance = np .average (errvector , weights = weights )
@@ -379,8 +372,11 @@ class MeshWarpMaths(TVTKBaseInterface):
379
372
output_spec = MeshWarpMathsOutputSpec
380
373
381
374
def _run_interface (self , runtime ):
375
+ from tvtk .common import configure_input_data
376
+ from tvtk .common import is_old_pipeline as vtk_old
377
+
382
378
r1 = tvtk .PolyDataReader (file_name = self .inputs .in_surf )
383
- vtk1 = r1 .output
379
+ vtk1 = r1 .output if vtk_old () else r1 . get_output ()
384
380
r1 .update ()
385
381
points1 = np .array (vtk1 .points )
386
382
@@ -392,7 +388,7 @@ def _run_interface(self, runtime):
392
388
393
389
if isinstance (operator , string_types ):
394
390
r2 = tvtk .PolyDataReader (file_name = self .inputs .surface2 )
395
- vtk2 = r2 .output
391
+ vtk2 = r2 .output if vtk_old () else r2 . get_output ()
396
392
r2 .update ()
397
393
assert (len (points1 ) == len (vtk2 .points ))
398
394
@@ -425,25 +421,15 @@ def _run_interface(self, runtime):
425
421
warping /= opfield
426
422
427
423
vtk1 .point_data .vectors = warping
428
- writer = tvtk .PolyDataWriter (
429
- file_name = op .abspath (self .inputs .out_warp ))
430
- if self .vtk_version ()[0 ] < 6 :
431
- writer .input = vtk1
432
- else :
433
- writer .set_input_data_object (vtk1 )
424
+ writer = tvtk .PolyDataWriter (file_name = op .abspath (self .inputs .out_warp ))
425
+ configure_input_data (writer , vtk1 )
434
426
writer .write ()
435
427
436
428
vtk1 .point_data .vectors = None
437
429
vtk1 .points = points1 + warping
438
- writer = tvtk .PolyDataWriter (
439
- file_name = op .abspath (self .inputs .out_file ))
440
-
441
- if self .vtk_version ()[0 ] < 6 :
442
- writer .input = vtk1
443
- else :
444
- writer .set_input_data_object (vtk1 )
430
+ writer = tvtk .PolyDataWriter (file_name = op .abspath (self .inputs .out_file ))
431
+ configure_input_data (writer , vtk1 )
445
432
writer .write ()
446
-
447
433
return runtime
448
434
449
435
def _list_outputs (self ):
0 commit comments