Commit 5b7747ae79177bf22d730fadf313ea4a0e8b7a04
1 parent
c06ff6da
Exists in
vtk6
Showing the slices
Showing
7 changed files
with
34 additions
and
29 deletions
Show diff stats
.gitignore
invesalius/data/converters.py
@@ -43,16 +43,16 @@ def to_vtk(n_array, spacing, slice_number, orientation): | @@ -43,16 +43,16 @@ def to_vtk(n_array, spacing, slice_number, orientation): | ||
43 | image = vtk.vtkImageData() | 43 | image = vtk.vtkImageData() |
44 | image.SetOrigin(0, 0, 0) | 44 | image.SetOrigin(0, 0, 0) |
45 | image.SetSpacing(spacing) | 45 | image.SetSpacing(spacing) |
46 | - image.SetNumberOfScalarComponents(1) | ||
47 | image.SetDimensions(dx, dy, dz) | 46 | image.SetDimensions(dx, dy, dz) |
47 | + # SetNumberOfScalarComponents and SetScalrType were replaced by | ||
48 | + # AllocateScalars | ||
49 | + # image.SetNumberOfScalarComponents(1) | ||
50 | + # image.SetScalarType(numpy_support.get_vtk_array_type(n_array.dtype)) | ||
51 | + image.AllocateScalars(numpy_support.get_vtk_array_type(n_array.dtype), 1) | ||
48 | image.SetExtent(extent) | 52 | image.SetExtent(extent) |
49 | - image.SetScalarType(numpy_support.get_vtk_array_type(n_array.dtype)) | ||
50 | - image.AllocateScalars() | ||
51 | image.GetPointData().SetScalars(v_image) | 53 | image.GetPointData().SetScalars(v_image) |
52 | - image.Update() | ||
53 | 54 | ||
54 | image_copy = vtk.vtkImageData() | 55 | image_copy = vtk.vtkImageData() |
55 | image_copy.DeepCopy(image) | 56 | image_copy.DeepCopy(image) |
56 | - image_copy.Update() | ||
57 | 57 | ||
58 | return image_copy | 58 | return image_copy |
invesalius/data/cursor_actors.py
@@ -24,6 +24,7 @@ import vtk | @@ -24,6 +24,7 @@ import vtk | ||
24 | import imagedata_utils | 24 | import imagedata_utils |
25 | from project import Project | 25 | from project import Project |
26 | import constants as const | 26 | import constants as const |
27 | +import converters | ||
27 | 28 | ||
28 | from vtk.util import numpy_support | 29 | from vtk.util import numpy_support |
29 | 30 | ||
@@ -224,7 +225,7 @@ class CursorBase(object): | @@ -224,7 +225,7 @@ class CursorBase(object): | ||
224 | img_colours_mask = vtk.vtkImageMapToColors() | 225 | img_colours_mask = vtk.vtkImageMapToColors() |
225 | img_colours_mask.SetLookupTable(lut_mask) | 226 | img_colours_mask.SetLookupTable(lut_mask) |
226 | img_colours_mask.SetOutputFormatToRGBA() | 227 | img_colours_mask.SetOutputFormatToRGBA() |
227 | - img_colours_mask.SetInput(imagedata) | 228 | + img_colours_mask.SetInputData(imagedata) |
228 | img_colours_mask.Update() | 229 | img_colours_mask.Update() |
229 | 230 | ||
230 | return img_colours_mask.GetOutput() | 231 | return img_colours_mask.GetOutput() |
@@ -269,17 +270,17 @@ class CursorCircle(CursorBase): | @@ -269,17 +270,17 @@ class CursorCircle(CursorBase): | ||
269 | z,y,x = numpy.ogrid[zi:zf,yi:yf, xi:xf] | 270 | z,y,x = numpy.ogrid[zi:zf,yi:yf, xi:xf] |
270 | 271 | ||
271 | circle_m = (z*sz)**2 + (y*sy)**2 + (x*sx)**2 <= r**2 | 272 | circle_m = (z*sz)**2 + (y*sy)**2 + (x*sx)**2 <= r**2 |
272 | - circle_i = to_vtk(circle_m.astype('uint8'), | 273 | + circle_i = converters.to_vtk(circle_m.astype('uint8'), |
273 | self.spacing, 0, self.orientation) | 274 | self.spacing, 0, self.orientation) |
274 | circle_ci = self._set_colour(circle_i, self.colour) | 275 | circle_ci = self._set_colour(circle_i, self.colour) |
275 | 276 | ||
276 | if self.mapper is None: | 277 | if self.mapper is None: |
277 | - self.actor.SetInput(circle_ci) | 278 | + self.actor.SetInputData(circle_ci) |
278 | self.actor.InterpolateOff() | 279 | self.actor.InterpolateOff() |
279 | self.actor.PickableOff() | 280 | self.actor.PickableOff() |
280 | self.actor.SetDisplayExtent(circle_ci.GetExtent()) | 281 | self.actor.SetDisplayExtent(circle_ci.GetExtent()) |
281 | else: | 282 | else: |
282 | - self.mapper.SetInput(circle_ci) | 283 | + self.mapper.SetInputData(circle_ci) |
283 | self.mapper.BorderOn() | 284 | self.mapper.BorderOn() |
284 | 285 | ||
285 | self.mapper.SetOrientation(ORIENTATION[self.orientation]) | 286 | self.mapper.SetOrientation(ORIENTATION[self.orientation]) |
@@ -343,16 +344,16 @@ class CursorRectangle(CursorBase): | @@ -343,16 +344,16 @@ class CursorRectangle(CursorBase): | ||
343 | z = math.floor(r/sz) | 344 | z = math.floor(r/sz) |
344 | 345 | ||
345 | rectangle_m = numpy.ones((z, y, x), dtype='uint8') | 346 | rectangle_m = numpy.ones((z, y, x), dtype='uint8') |
346 | - rectangle_i = to_vtk(rectangle_m, self.spacing, 0, self.orientation) | 347 | + rectangle_i = converters.to_vtk(rectangle_m, self.spacing, 0, self.orientation) |
347 | rectangle_ci = self._set_colour(rectangle_i, self.colour) | 348 | rectangle_ci = self._set_colour(rectangle_i, self.colour) |
348 | 349 | ||
349 | if self.mapper is None: | 350 | if self.mapper is None: |
350 | - self.actor.SetInput(rectangle_ci) | 351 | + self.actor.SetInputData(rectangle_ci) |
351 | self.actor.InterpolateOff() | 352 | self.actor.InterpolateOff() |
352 | self.actor.PickableOff() | 353 | self.actor.PickableOff() |
353 | self.actor.SetDisplayExtent(rectangle_ci.GetExtent()) | 354 | self.actor.SetDisplayExtent(rectangle_ci.GetExtent()) |
354 | else: | 355 | else: |
355 | - self.mapper.SetInput(rectangle_ci) | 356 | + self.mapper.SetInputData(rectangle_ci) |
356 | self.mapper.BorderOn() | 357 | self.mapper.BorderOn() |
357 | self.mapper.SetOrientation(ORIENTATION[self.orientation]) | 358 | self.mapper.SetOrientation(ORIENTATION[self.orientation]) |
358 | 359 |
invesalius/data/slice_.py
@@ -964,18 +964,18 @@ class Slice(object): | @@ -964,18 +964,18 @@ class Slice(object): | ||
964 | img = self.buffer_slices[orientation].vtk_image | 964 | img = self.buffer_slices[orientation].vtk_image |
965 | original_orientation = Project().original_orientation | 965 | original_orientation = Project().original_orientation |
966 | cast = vtk.vtkImageCast() | 966 | cast = vtk.vtkImageCast() |
967 | - cast.SetInput(img) | 967 | + cast.SetInputData(img) |
968 | cast.SetOutputScalarTypeToDouble() | 968 | cast.SetOutputScalarTypeToDouble() |
969 | cast.ClampOverflowOn() | 969 | cast.ClampOverflowOn() |
970 | cast.Update() | 970 | cast.Update() |
971 | 971 | ||
972 | #if (original_orientation == const.AXIAL): | 972 | #if (original_orientation == const.AXIAL): |
973 | flip = vtk.vtkImageFlip() | 973 | flip = vtk.vtkImageFlip() |
974 | - flip.SetInput(cast.GetOutput()) | 974 | + flip.SetInputConnection(cast.GetOutputPort()) |
975 | flip.SetFilteredAxis(1) | 975 | flip.SetFilteredAxis(1) |
976 | flip.FlipAboutOriginOn() | 976 | flip.FlipAboutOriginOn() |
977 | flip.Update() | 977 | flip.Update() |
978 | - widget.SetInput(flip.GetOutput()) | 978 | + widget.SetInputConnection(flip.GetOutputPort()) |
979 | #else: | 979 | #else: |
980 | #widget.SetInput(cast.GetOutput()) | 980 | #widget.SetInput(cast.GetOutput()) |
981 | 981 | ||
@@ -1044,7 +1044,7 @@ class Slice(object): | @@ -1044,7 +1044,7 @@ class Slice(object): | ||
1044 | i += 1 | 1044 | i += 1 |
1045 | 1045 | ||
1046 | colorer = vtk.vtkImageMapToColors() | 1046 | colorer = vtk.vtkImageMapToColors() |
1047 | - colorer.SetInput(image) | 1047 | + colorer.SetInputData(image) |
1048 | colorer.SetLookupTable(lut) | 1048 | colorer.SetLookupTable(lut) |
1049 | colorer.SetOutputFormatToRGB() | 1049 | colorer.SetOutputFormatToRGB() |
1050 | colorer.Update() | 1050 | colorer.Update() |
@@ -1059,12 +1059,12 @@ class Slice(object): | @@ -1059,12 +1059,12 @@ class Slice(object): | ||
1059 | 1059 | ||
1060 | colorer = vtk.vtkImageMapToColors() | 1060 | colorer = vtk.vtkImageMapToColors() |
1061 | colorer.SetLookupTable(lut) | 1061 | colorer.SetLookupTable(lut) |
1062 | - colorer.SetInput(image) | 1062 | + colorer.SetInputData(image) |
1063 | colorer.SetOutputFormatToRGB() | 1063 | colorer.SetOutputFormatToRGB() |
1064 | colorer.Update() | 1064 | colorer.Update() |
1065 | else: | 1065 | else: |
1066 | colorer = vtk.vtkImageMapToWindowLevelColors() | 1066 | colorer = vtk.vtkImageMapToWindowLevelColors() |
1067 | - colorer.SetInput(image) | 1067 | + colorer.SetInputData(image) |
1068 | colorer.SetWindow(self.window_width) | 1068 | colorer.SetWindow(self.window_width) |
1069 | colorer.SetLevel(self.window_level) | 1069 | colorer.SetLevel(self.window_level) |
1070 | colorer.SetOutputFormatToRGB() | 1070 | colorer.SetOutputFormatToRGB() |
@@ -1148,7 +1148,7 @@ class Slice(object): | @@ -1148,7 +1148,7 @@ class Slice(object): | ||
1148 | img_colours_bg = vtk.vtkImageMapToColors() | 1148 | img_colours_bg = vtk.vtkImageMapToColors() |
1149 | img_colours_bg.SetOutputFormatToRGB() | 1149 | img_colours_bg.SetOutputFormatToRGB() |
1150 | img_colours_bg.SetLookupTable(lut_bg) | 1150 | img_colours_bg.SetLookupTable(lut_bg) |
1151 | - img_colours_bg.SetInput(imagedata) | 1151 | + img_colours_bg.SetInputData(imagedata) |
1152 | img_colours_bg.Update() | 1152 | img_colours_bg.Update() |
1153 | 1153 | ||
1154 | return img_colours_bg.GetOutput() | 1154 | return img_colours_bg.GetOutput() |
@@ -1179,7 +1179,7 @@ class Slice(object): | @@ -1179,7 +1179,7 @@ class Slice(object): | ||
1179 | img_colours_mask = vtk.vtkImageMapToColors() | 1179 | img_colours_mask = vtk.vtkImageMapToColors() |
1180 | img_colours_mask.SetLookupTable(lut_mask) | 1180 | img_colours_mask.SetLookupTable(lut_mask) |
1181 | img_colours_mask.SetOutputFormatToRGBA() | 1181 | img_colours_mask.SetOutputFormatToRGBA() |
1182 | - img_colours_mask.SetInput(imagedata) | 1182 | + img_colours_mask.SetInputData(imagedata) |
1183 | img_colours_mask.Update() | 1183 | img_colours_mask.Update() |
1184 | # self.img_colours_mask = img_colours_mask | 1184 | # self.img_colours_mask = img_colours_mask |
1185 | 1185 | ||
@@ -1211,7 +1211,7 @@ class Slice(object): | @@ -1211,7 +1211,7 @@ class Slice(object): | ||
1211 | img_colours_mask = vtk.vtkImageMapToColors() | 1211 | img_colours_mask = vtk.vtkImageMapToColors() |
1212 | img_colours_mask.SetLookupTable(lut_mask) | 1212 | img_colours_mask.SetLookupTable(lut_mask) |
1213 | img_colours_mask.SetOutputFormatToRGBA() | 1213 | img_colours_mask.SetOutputFormatToRGBA() |
1214 | - img_colours_mask.SetInput(imagedata) | 1214 | + img_colours_mask.SetInputData(imagedata) |
1215 | img_colours_mask.Update() | 1215 | img_colours_mask.Update() |
1216 | # self.img_colours_mask = img_colours_mask | 1216 | # self.img_colours_mask = img_colours_mask |
1217 | 1217 | ||
@@ -1225,8 +1225,8 @@ class Slice(object): | @@ -1225,8 +1225,8 @@ class Slice(object): | ||
1225 | blend_imagedata.SetBlendModeToNormal() | 1225 | blend_imagedata.SetBlendModeToNormal() |
1226 | # blend_imagedata.SetOpacity(0, 1.0) | 1226 | # blend_imagedata.SetOpacity(0, 1.0) |
1227 | blend_imagedata.SetOpacity(1, 0.8) | 1227 | blend_imagedata.SetOpacity(1, 0.8) |
1228 | - blend_imagedata.SetInput(imagedata) | ||
1229 | - blend_imagedata.AddInput(mask) | 1228 | + blend_imagedata.SetInputData(imagedata) |
1229 | + blend_imagedata.AddInputData(mask) | ||
1230 | blend_imagedata.Update() | 1230 | blend_imagedata.Update() |
1231 | 1231 | ||
1232 | return blend_imagedata.GetOutput() | 1232 | return blend_imagedata.GetOutput() |
invesalius/data/slice_data.py
@@ -55,7 +55,7 @@ class SliceData(object): | @@ -55,7 +55,7 @@ class SliceData(object): | ||
55 | 55 | ||
56 | def __create_line_actor(self, line): | 56 | def __create_line_actor(self, line): |
57 | line_mapper = vtk.vtkPolyDataMapper2D() | 57 | line_mapper = vtk.vtkPolyDataMapper2D() |
58 | - line_mapper.SetInput(line.GetOutput()) | 58 | + line_mapper.SetInputConnection(line.GetOutputPort()) |
59 | 59 | ||
60 | line_actor = vtk.vtkActor2D() | 60 | line_actor = vtk.vtkActor2D() |
61 | line_actor.SetMapper(line_mapper) | 61 | line_actor.SetMapper(line_mapper) |
invesalius/data/viewer_slice.py
@@ -919,7 +919,7 @@ class Viewer(wx.Panel): | @@ -919,7 +919,7 @@ class Viewer(wx.Panel): | ||
919 | c.SetCoordinateSystemToWorld() | 919 | c.SetCoordinateSystemToWorld() |
920 | 920 | ||
921 | cross_mapper = vtk.vtkPolyDataMapper() | 921 | cross_mapper = vtk.vtkPolyDataMapper() |
922 | - cross_mapper.SetInput(cross.GetOutput()) | 922 | + cross_mapper.SetInputConnection(cross.GetOutputPort()) |
923 | #cross_mapper.SetTransformCoordinate(c) | 923 | #cross_mapper.SetTransformCoordinate(c) |
924 | 924 | ||
925 | p = vtk.vtkProperty() | 925 | p = vtk.vtkProperty() |
@@ -1176,7 +1176,7 @@ class Viewer(wx.Panel): | @@ -1176,7 +1176,7 @@ class Viewer(wx.Panel): | ||
1176 | border_size = self.mip_ctrls.border_spin.GetValue() | 1176 | border_size = self.mip_ctrls.border_spin.GetValue() |
1177 | image = self.slice_.GetSlices(self.orientation, index, | 1177 | image = self.slice_.GetSlices(self.orientation, index, |
1178 | self.number_slices, inverted, border_size) | 1178 | self.number_slices, inverted, border_size) |
1179 | - self.slice_data.actor.SetInput(image) | 1179 | + self.slice_data.actor.SetInputData(image) |
1180 | for actor in self.actors_by_slice_number.get(self.slice_data.number, []): | 1180 | for actor in self.actors_by_slice_number.get(self.slice_data.number, []): |
1181 | self.slice_data.renderer.RemoveActor(actor) | 1181 | self.slice_data.renderer.RemoveActor(actor) |
1182 | for actor in self.actors_by_slice_number.get(index, []): | 1182 | for actor in self.actors_by_slice_number.get(index, []): |
invesalius/reader/dicom_reader.py
@@ -195,14 +195,14 @@ class LoadDicom: | @@ -195,14 +195,14 @@ class LoadDicom: | ||
195 | window = 2000.0 | 195 | window = 2000.0 |
196 | 196 | ||
197 | colorer = vtk.vtkImageMapToWindowLevelColors() | 197 | colorer = vtk.vtkImageMapToWindowLevelColors() |
198 | - colorer.SetInput(rvtk.GetOutput()) | 198 | + colorer.SetInputConnection(rvtk.GetOutputPort()) |
199 | colorer.SetWindow(float(window)) | 199 | colorer.SetWindow(float(window)) |
200 | colorer.SetLevel(float(level)) | 200 | colorer.SetLevel(float(level)) |
201 | colorer.SetOutputFormatToRGB() | 201 | colorer.SetOutputFormatToRGB() |
202 | colorer.Update() | 202 | colorer.Update() |
203 | 203 | ||
204 | resample = vtk.vtkImageResample() | 204 | resample = vtk.vtkImageResample() |
205 | - resample.SetInput(colorer.GetOutput()) | 205 | + resample.SetInputConnection(colorer.GetOutputPort()) |
206 | resample.SetAxisMagnificationFactor ( 0, 0.25 ) | 206 | resample.SetAxisMagnificationFactor ( 0, 0.25 ) |
207 | resample.SetAxisMagnificationFactor ( 1, 0.25 ) | 207 | resample.SetAxisMagnificationFactor ( 1, 0.25 ) |
208 | resample.SetAxisMagnificationFactor ( 2, 1 ) | 208 | resample.SetAxisMagnificationFactor ( 2, 1 ) |
@@ -211,7 +211,7 @@ class LoadDicom: | @@ -211,7 +211,7 @@ class LoadDicom: | ||
211 | thumbnail_path = tempfile.mktemp() | 211 | thumbnail_path = tempfile.mktemp() |
212 | 212 | ||
213 | write_png = vtk.vtkPNGWriter() | 213 | write_png = vtk.vtkPNGWriter() |
214 | - write_png.SetInput(resample.GetOutput()) | 214 | + write_png.SetInputConnection(resample.GetOutputPort()) |
215 | write_png.SetFileName(thumbnail_path) | 215 | write_png.SetFileName(thumbnail_path) |
216 | write_png.Write() | 216 | write_png.Write() |
217 | 217 |