Commit 0317ac288355fd17282735cbe273c753c0bd9f25
1 parent
c06ff6da
Exists in
master
and in
32 other branches
Adapts InVesalius to run with VTK6 (#35)
* Showing the slices * cursor was not displayed correctly * Watershed using vtk6 * generating surface with vtk6 * generating preview in vtk6 * Showing raycasting with vtk6 * Showing measures with vtk6 * saving project * Saving screenshots with vtk6 * Saving meshes with vtk6 * It was not showing surfaces created with greatest region, selected region and all regions filters
Showing
16 changed files
with
190 additions
and
173 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
@@ -55,19 +55,19 @@ def to_vtk(n_array, spacing, slice_number, orientation): | @@ -55,19 +55,19 @@ def to_vtk(n_array, spacing, slice_number, orientation): | ||
55 | image = vtk.vtkImageData() | 55 | image = vtk.vtkImageData() |
56 | image.SetOrigin(0, 0, 0) | 56 | image.SetOrigin(0, 0, 0) |
57 | image.SetSpacing(spacing) | 57 | image.SetSpacing(spacing) |
58 | - image.SetNumberOfScalarComponents(1) | ||
59 | image.SetDimensions(dx, dy, dz) | 58 | image.SetDimensions(dx, dy, dz) |
60 | image.SetExtent(extent) | 59 | image.SetExtent(extent) |
61 | - image.SetScalarType(numpy_support.get_vtk_array_type(n_array.dtype)) | ||
62 | - image.AllocateScalars() | ||
63 | - image.Update() | 60 | + # image.SetNumberOfScalarComponents(1) |
61 | + # image.SetScalarType(numpy_support.get_vtk_array_type(n_array.dtype)) | ||
62 | + image.AllocateScalars(numpy_support.get_vtk_array_type(n_array.dtype), 1) | ||
63 | + # image.Update() | ||
64 | image.GetCellData().SetScalars(v_image) | 64 | image.GetCellData().SetScalars(v_image) |
65 | image.GetPointData().SetScalars(v_image) | 65 | image.GetPointData().SetScalars(v_image) |
66 | - image.Update() | 66 | + # image.Update() |
67 | 67 | ||
68 | image_copy = vtk.vtkImageData() | 68 | image_copy = vtk.vtkImageData() |
69 | image_copy.DeepCopy(image) | 69 | image_copy.DeepCopy(image) |
70 | - image_copy.Update() | 70 | + # image_copy.Update() |
71 | 71 | ||
72 | return image_copy | 72 | return image_copy |
73 | 73 | ||
@@ -224,7 +224,7 @@ class CursorBase(object): | @@ -224,7 +224,7 @@ class CursorBase(object): | ||
224 | img_colours_mask = vtk.vtkImageMapToColors() | 224 | img_colours_mask = vtk.vtkImageMapToColors() |
225 | img_colours_mask.SetLookupTable(lut_mask) | 225 | img_colours_mask.SetLookupTable(lut_mask) |
226 | img_colours_mask.SetOutputFormatToRGBA() | 226 | img_colours_mask.SetOutputFormatToRGBA() |
227 | - img_colours_mask.SetInput(imagedata) | 227 | + img_colours_mask.SetInputData(imagedata) |
228 | img_colours_mask.Update() | 228 | img_colours_mask.Update() |
229 | 229 | ||
230 | return img_colours_mask.GetOutput() | 230 | return img_colours_mask.GetOutput() |
@@ -274,12 +274,12 @@ class CursorCircle(CursorBase): | @@ -274,12 +274,12 @@ class CursorCircle(CursorBase): | ||
274 | circle_ci = self._set_colour(circle_i, self.colour) | 274 | circle_ci = self._set_colour(circle_i, self.colour) |
275 | 275 | ||
276 | if self.mapper is None: | 276 | if self.mapper is None: |
277 | - self.actor.SetInput(circle_ci) | 277 | + self.actor.SetInputData(circle_ci) |
278 | self.actor.InterpolateOff() | 278 | self.actor.InterpolateOff() |
279 | self.actor.PickableOff() | 279 | self.actor.PickableOff() |
280 | self.actor.SetDisplayExtent(circle_ci.GetExtent()) | 280 | self.actor.SetDisplayExtent(circle_ci.GetExtent()) |
281 | else: | 281 | else: |
282 | - self.mapper.SetInput(circle_ci) | 282 | + self.mapper.SetInputData(circle_ci) |
283 | self.mapper.BorderOn() | 283 | self.mapper.BorderOn() |
284 | 284 | ||
285 | self.mapper.SetOrientation(ORIENTATION[self.orientation]) | 285 | self.mapper.SetOrientation(ORIENTATION[self.orientation]) |
@@ -347,12 +347,12 @@ class CursorRectangle(CursorBase): | @@ -347,12 +347,12 @@ class CursorRectangle(CursorBase): | ||
347 | rectangle_ci = self._set_colour(rectangle_i, self.colour) | 347 | rectangle_ci = self._set_colour(rectangle_i, self.colour) |
348 | 348 | ||
349 | if self.mapper is None: | 349 | if self.mapper is None: |
350 | - self.actor.SetInput(rectangle_ci) | 350 | + self.actor.SetInputData(rectangle_ci) |
351 | self.actor.InterpolateOff() | 351 | self.actor.InterpolateOff() |
352 | self.actor.PickableOff() | 352 | self.actor.PickableOff() |
353 | self.actor.SetDisplayExtent(rectangle_ci.GetExtent()) | 353 | self.actor.SetDisplayExtent(rectangle_ci.GetExtent()) |
354 | else: | 354 | else: |
355 | - self.mapper.SetInput(rectangle_ci) | 355 | + self.mapper.SetInputData(rectangle_ci) |
356 | self.mapper.BorderOn() | 356 | self.mapper.BorderOn() |
357 | self.mapper.SetOrientation(ORIENTATION[self.orientation]) | 357 | self.mapper.SetOrientation(ORIENTATION[self.orientation]) |
358 | 358 |
invesalius/data/measures.py
@@ -341,8 +341,8 @@ class CrossPointRepresentation(object): | @@ -341,8 +341,8 @@ class CrossPointRepresentation(object): | ||
341 | sv.SetPoint2(p4) | 341 | sv.SetPoint2(p4) |
342 | 342 | ||
343 | cruz = vtk.vtkAppendPolyData() | 343 | cruz = vtk.vtkAppendPolyData() |
344 | - cruz.AddInput(sv.GetOutput()) | ||
345 | - cruz.AddInput(sh.GetOutput()) | 344 | + cruz.AddInputData(sv.GetOutput()) |
345 | + cruz.AddInputData(sh.GetOutput()) | ||
346 | 346 | ||
347 | c = vtk.vtkCoordinate() | 347 | c = vtk.vtkCoordinate() |
348 | c.SetCoordinateSystemToWorld() | 348 | c.SetCoordinateSystemToWorld() |
@@ -563,9 +563,11 @@ class AngularMeasure(object): | @@ -563,9 +563,11 @@ class AngularMeasure(object): | ||
563 | arc = self.DrawArc() | 563 | arc = self.DrawArc() |
564 | 564 | ||
565 | line = vtk.vtkAppendPolyData() | 565 | line = vtk.vtkAppendPolyData() |
566 | - line.AddInput(line1.GetOutput()) | ||
567 | - line.AddInput(line2.GetOutput()) | ||
568 | - line.AddInput(arc.GetOutput()) | 566 | + line.AddInputConnection(line1.GetOutputPort()) |
567 | + line.AddInputConnection(line2.GetOutputPort()) | ||
568 | + line.AddInputConnection(arc.GetOutputPort()) | ||
569 | + | ||
570 | + print line | ||
569 | 571 | ||
570 | c = vtk.vtkCoordinate() | 572 | c = vtk.vtkCoordinate() |
571 | c.SetCoordinateSystemToWorld() | 573 | c.SetCoordinateSystemToWorld() |
invesalius/data/polydata_utils.py
@@ -36,7 +36,7 @@ def ApplyDecimationFilter(polydata, reduction_factor): | @@ -36,7 +36,7 @@ def ApplyDecimationFilter(polydata, reduction_factor): | ||
36 | # Important: vtkQuadricDecimation presented better results than | 36 | # Important: vtkQuadricDecimation presented better results than |
37 | # vtkDecimatePro | 37 | # vtkDecimatePro |
38 | decimation = vtk.vtkQuadricDecimation() | 38 | decimation = vtk.vtkQuadricDecimation() |
39 | - decimation.SetInput(polydata) | 39 | + decimation.SetInputData(polydata) |
40 | decimation.SetTargetReduction(reduction_factor) | 40 | decimation.SetTargetReduction(reduction_factor) |
41 | decimation.GetOutput().ReleaseDataFlagOn() | 41 | decimation.GetOutput().ReleaseDataFlagOn() |
42 | decimation.AddObserver("ProgressEvent", lambda obj, evt: | 42 | decimation.AddObserver("ProgressEvent", lambda obj, evt: |
@@ -48,7 +48,7 @@ def ApplySmoothFilter(polydata, iterations, relaxation_factor): | @@ -48,7 +48,7 @@ def ApplySmoothFilter(polydata, iterations, relaxation_factor): | ||
48 | Smooth given vtkPolyData surface, based on iteration and relaxation_factor. | 48 | Smooth given vtkPolyData surface, based on iteration and relaxation_factor. |
49 | """ | 49 | """ |
50 | smoother = vtk.vtkSmoothPolyDataFilter() | 50 | smoother = vtk.vtkSmoothPolyDataFilter() |
51 | - smoother.SetInput(polydata) | 51 | + smoother.SetInputData(polydata) |
52 | smoother.SetNumberOfIterations(iterations) | 52 | smoother.SetNumberOfIterations(iterations) |
53 | smoother.SetFeatureAngle(80) | 53 | smoother.SetFeatureAngle(80) |
54 | smoother.SetRelaxationFactor(relaxation_factor) | 54 | smoother.SetRelaxationFactor(relaxation_factor) |
@@ -69,7 +69,7 @@ def FillSurfaceHole(polydata): | @@ -69,7 +69,7 @@ def FillSurfaceHole(polydata): | ||
69 | # Filter used to detect and fill holes. Only fill | 69 | # Filter used to detect and fill holes. Only fill |
70 | print "Filling polydata" | 70 | print "Filling polydata" |
71 | filled_polydata = vtk.vtkFillHolesFilter() | 71 | filled_polydata = vtk.vtkFillHolesFilter() |
72 | - filled_polydata.SetInput(polydata) | 72 | + filled_polydata.SetInputData(polydata) |
73 | filled_polydata.SetHoleSize(500) | 73 | filled_polydata.SetHoleSize(500) |
74 | return filled_polydata.GetOutput() | 74 | return filled_polydata.GetOutput() |
75 | 75 | ||
@@ -79,7 +79,7 @@ def CalculateSurfaceVolume(polydata): | @@ -79,7 +79,7 @@ def CalculateSurfaceVolume(polydata): | ||
79 | """ | 79 | """ |
80 | # Filter used to calculate volume and area from a polydata | 80 | # Filter used to calculate volume and area from a polydata |
81 | measured_polydata = vtk.vtkMassProperties() | 81 | measured_polydata = vtk.vtkMassProperties() |
82 | - measured_polydata.SetInput(polydata) | 82 | + measured_polydata.SetInputData(polydata) |
83 | return measured_polydata.GetVolume() | 83 | return measured_polydata.GetVolume() |
84 | 84 | ||
85 | def CalculateSurfaceArea(polydata): | 85 | def CalculateSurfaceArea(polydata): |
@@ -88,7 +88,7 @@ def CalculateSurfaceArea(polydata): | @@ -88,7 +88,7 @@ def CalculateSurfaceArea(polydata): | ||
88 | """ | 88 | """ |
89 | # Filter used to calculate volume and area from a polydata | 89 | # Filter used to calculate volume and area from a polydata |
90 | measured_polydata = vtk.vtkMassProperties() | 90 | measured_polydata = vtk.vtkMassProperties() |
91 | - measured_polydata.SetInput(polydata) | 91 | + measured_polydata.SetInputData(polydata) |
92 | return measured_polydata.GetSurfaceArea() | 92 | return measured_polydata.GetSurfaceArea() |
93 | 93 | ||
94 | def Merge(polydata_list): | 94 | def Merge(polydata_list): |
@@ -96,11 +96,11 @@ def Merge(polydata_list): | @@ -96,11 +96,11 @@ def Merge(polydata_list): | ||
96 | 96 | ||
97 | for polydata in polydata_list: | 97 | for polydata in polydata_list: |
98 | triangle = vtk.vtkTriangleFilter() | 98 | triangle = vtk.vtkTriangleFilter() |
99 | - triangle.SetInput(polydata) | ||
100 | - append.AddInput(triangle.GetOutput()) | 99 | + triangle.SetInputData(polydata) |
100 | + append.AddInputData(triangle.GetOutput()) | ||
101 | 101 | ||
102 | clean = vtk.vtkCleanPolyData() | 102 | clean = vtk.vtkCleanPolyData() |
103 | - clean.SetInput(append.GetOutput()) | 103 | + clean.SetInputData(append.GetOutput()) |
104 | 104 | ||
105 | return append.GetOutput() | 105 | return append.GetOutput() |
106 | 106 | ||
@@ -112,7 +112,7 @@ def Export(polydata, filename, bin=False): | @@ -112,7 +112,7 @@ def Export(polydata, filename, bin=False): | ||
112 | writer.SetDataModeToBinary() | 112 | writer.SetDataModeToBinary() |
113 | else: | 113 | else: |
114 | writer.SetDataModeToAscii() | 114 | writer.SetDataModeToAscii() |
115 | - writer.SetInput(polydata) | 115 | + writer.SetInputData(polydata) |
116 | writer.Write() | 116 | writer.Write() |
117 | 117 | ||
118 | def Import(filename): | 118 | def Import(filename): |
@@ -130,7 +130,7 @@ def JoinSeedsParts(polydata, point_id_list): | @@ -130,7 +130,7 @@ def JoinSeedsParts(polydata, point_id_list): | ||
130 | from vtkPolyData. | 130 | from vtkPolyData. |
131 | """ | 131 | """ |
132 | conn = vtk.vtkPolyDataConnectivityFilter() | 132 | conn = vtk.vtkPolyDataConnectivityFilter() |
133 | - conn.SetInput(polydata) | 133 | + conn.SetInputData(polydata) |
134 | conn.SetExtractionModeToPointSeededRegions() | 134 | conn.SetExtractionModeToPointSeededRegions() |
135 | UpdateProgress = vu.ShowProgress(1 + len(point_id_list)) | 135 | UpdateProgress = vu.ShowProgress(1 + len(point_id_list)) |
136 | pos = 1 | 136 | pos = 1 |
@@ -145,7 +145,6 @@ def JoinSeedsParts(polydata, point_id_list): | @@ -145,7 +145,6 @@ def JoinSeedsParts(polydata, point_id_list): | ||
145 | 145 | ||
146 | result = vtk.vtkPolyData() | 146 | result = vtk.vtkPolyData() |
147 | result.DeepCopy(conn.GetOutput()) | 147 | result.DeepCopy(conn.GetOutput()) |
148 | - result.Update() | ||
149 | return result | 148 | return result |
150 | 149 | ||
151 | def SelectLargestPart(polydata): | 150 | def SelectLargestPart(polydata): |
@@ -153,7 +152,7 @@ def SelectLargestPart(polydata): | @@ -153,7 +152,7 @@ def SelectLargestPart(polydata): | ||
153 | """ | 152 | """ |
154 | UpdateProgress = vu.ShowProgress(1) | 153 | UpdateProgress = vu.ShowProgress(1) |
155 | conn = vtk.vtkPolyDataConnectivityFilter() | 154 | conn = vtk.vtkPolyDataConnectivityFilter() |
156 | - conn.SetInput(polydata) | 155 | + conn.SetInputData(polydata) |
157 | conn.SetExtractionModeToLargestRegion() | 156 | conn.SetExtractionModeToLargestRegion() |
158 | conn.AddObserver("ProgressEvent", lambda obj, evt: | 157 | conn.AddObserver("ProgressEvent", lambda obj, evt: |
159 | UpdateProgress(conn, "Getting largest part...")) | 158 | UpdateProgress(conn, "Getting largest part...")) |
@@ -161,14 +160,13 @@ def SelectLargestPart(polydata): | @@ -161,14 +160,13 @@ def SelectLargestPart(polydata): | ||
161 | 160 | ||
162 | result = vtk.vtkPolyData() | 161 | result = vtk.vtkPolyData() |
163 | result.DeepCopy(conn.GetOutput()) | 162 | result.DeepCopy(conn.GetOutput()) |
164 | - result.Update() | ||
165 | return result | 163 | return result |
166 | 164 | ||
167 | def SplitDisconectedParts(polydata): | 165 | def SplitDisconectedParts(polydata): |
168 | """ | 166 | """ |
169 | """ | 167 | """ |
170 | conn = vtk.vtkPolyDataConnectivityFilter() | 168 | conn = vtk.vtkPolyDataConnectivityFilter() |
171 | - conn.SetInput(polydata) | 169 | + conn.SetInputData(polydata) |
172 | conn.SetExtractionModeToAllRegions() | 170 | conn.SetExtractionModeToAllRegions() |
173 | conn.Update() | 171 | conn.Update() |
174 | 172 | ||
@@ -191,7 +189,6 @@ def SplitDisconectedParts(polydata): | @@ -191,7 +189,6 @@ def SplitDisconectedParts(polydata): | ||
191 | 189 | ||
192 | p = vtk.vtkPolyData() | 190 | p = vtk.vtkPolyData() |
193 | p.DeepCopy(conn.GetOutput()) | 191 | p.DeepCopy(conn.GetOutput()) |
194 | - p.Update() | ||
195 | 192 | ||
196 | polydata_collection.append(p) | 193 | polydata_collection.append(p) |
197 | if progress: | 194 | if progress: |
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/styles.py
@@ -59,10 +59,14 @@ WATERSHED_OPERATIONS = {_("Erase"): BRUSH_ERASE, | @@ -59,10 +59,14 @@ WATERSHED_OPERATIONS = {_("Erase"): BRUSH_ERASE, | ||
59 | _("Background"): BRUSH_BACKGROUND,} | 59 | _("Background"): BRUSH_BACKGROUND,} |
60 | 60 | ||
61 | def get_LUT_value(data, window, level): | 61 | def get_LUT_value(data, window, level): |
62 | - return np.piecewise(data, | ||
63 | - [data <= (level - 0.5 - (window-1)/2), | ||
64 | - data > (level - 0.5 + (window-1)/2)], | ||
65 | - [0, window, lambda data: ((data - (level - 0.5))/(window-1) + 0.5)*(window)]) | 62 | + shape = data.shape |
63 | + data_ = data.ravel() | ||
64 | + data = np.piecewise(data_, | ||
65 | + [data_ <= (level - 0.5 - (window-1)/2), | ||
66 | + data_ > (level - 0.5 + (window-1)/2)], | ||
67 | + [0, window, lambda data_: ((data_ - (level - 0.5))/(window-1) + 0.5)*(window)]) | ||
68 | + data.shape = shape | ||
69 | + return data | ||
66 | 70 | ||
67 | class BaseImageInteractorStyle(vtk.vtkInteractorStyleImage): | 71 | class BaseImageInteractorStyle(vtk.vtkInteractorStyleImage): |
68 | def __init__(self, viewer): | 72 | def __init__(self, viewer): |
invesalius/data/surface.py
@@ -42,6 +42,8 @@ try: | @@ -42,6 +42,8 @@ try: | ||
42 | except ImportError: | 42 | except ImportError: |
43 | import data.ca_smoothing as ca_smoothing | 43 | import data.ca_smoothing as ca_smoothing |
44 | 44 | ||
45 | +# TODO: Verificar ReleaseDataFlagOn and SetSource | ||
46 | + | ||
45 | class Surface(): | 47 | class Surface(): |
46 | """ | 48 | """ |
47 | Represent both vtkPolyData and associated properties. | 49 | Represent both vtkPolyData and associated properties. |
@@ -240,12 +242,13 @@ class SurfaceManager(): | @@ -240,12 +242,13 @@ class SurfaceManager(): | ||
240 | name=None, colour=None, | 242 | name=None, colour=None, |
241 | transparency=None, volume=None): | 243 | transparency=None, volume=None): |
242 | normals = vtk.vtkPolyDataNormals() | 244 | normals = vtk.vtkPolyDataNormals() |
243 | - normals.SetInput(polydata) | 245 | + normals.SetInputData(polydata) |
244 | normals.SetFeatureAngle(80) | 246 | normals.SetFeatureAngle(80) |
245 | normals.AutoOrientNormalsOn() | 247 | normals.AutoOrientNormalsOn() |
248 | + normals.Update() | ||
246 | 249 | ||
247 | mapper = vtk.vtkPolyDataMapper() | 250 | mapper = vtk.vtkPolyDataMapper() |
248 | - mapper.SetInput(normals.GetOutput()) | 251 | + mapper.SetInputData(normals.GetOutput()) |
249 | mapper.ScalarVisibilityOff() | 252 | mapper.ScalarVisibilityOff() |
250 | mapper.ImmediateModeRenderingOn() # improve performance | 253 | mapper.ImmediateModeRenderingOn() # improve performance |
251 | 254 | ||
@@ -289,11 +292,12 @@ class SurfaceManager(): | @@ -289,11 +292,12 @@ class SurfaceManager(): | ||
289 | # The following lines have to be here, otherwise all volumes disappear | 292 | # The following lines have to be here, otherwise all volumes disappear |
290 | if not volume: | 293 | if not volume: |
291 | triangle_filter = vtk.vtkTriangleFilter() | 294 | triangle_filter = vtk.vtkTriangleFilter() |
292 | - triangle_filter.SetInput(polydata) | 295 | + triangle_filter.SetInputData(polydata) |
293 | triangle_filter.Update() | 296 | triangle_filter.Update() |
294 | 297 | ||
295 | measured_polydata = vtk.vtkMassProperties() | 298 | measured_polydata = vtk.vtkMassProperties() |
296 | - measured_polydata.SetInput(triangle_filter.GetOutput()) | 299 | + measured_polydata.SetInputConnection(triangle_filter.GetOutputPort()) |
300 | + measured_polydata.Update() | ||
297 | volume = measured_polydata.GetVolume() | 301 | volume = measured_polydata.GetVolume() |
298 | surface.volume = volume | 302 | surface.volume = volume |
299 | print ">>>>", surface.volume | 303 | print ">>>>", surface.volume |
@@ -338,19 +342,19 @@ class SurfaceManager(): | @@ -338,19 +342,19 @@ class SurfaceManager(): | ||
338 | surface = surface_dict[key] | 342 | surface = surface_dict[key] |
339 | # Map polygonal data (vtkPolyData) to graphics primitives. | 343 | # Map polygonal data (vtkPolyData) to graphics primitives. |
340 | normals = vtk.vtkPolyDataNormals() | 344 | normals = vtk.vtkPolyDataNormals() |
341 | - normals.SetInput(surface.polydata) | 345 | + normals.SetInputData(surface.polydata) |
342 | normals.SetFeatureAngle(80) | 346 | normals.SetFeatureAngle(80) |
343 | normals.AutoOrientNormalsOn() | 347 | normals.AutoOrientNormalsOn() |
344 | - normals.GetOutput().ReleaseDataFlagOn() | 348 | + # normals.GetOutput().ReleaseDataFlagOn() |
345 | 349 | ||
346 | # Improve performance | 350 | # Improve performance |
347 | stripper = vtk.vtkStripper() | 351 | stripper = vtk.vtkStripper() |
348 | - stripper.SetInput(normals.GetOutput()) | 352 | + stripper.SetInputData(normals.GetOutput()) |
349 | stripper.PassThroughCellIdsOn() | 353 | stripper.PassThroughCellIdsOn() |
350 | stripper.PassThroughPointIdsOn() | 354 | stripper.PassThroughPointIdsOn() |
351 | 355 | ||
352 | mapper = vtk.vtkPolyDataMapper() | 356 | mapper = vtk.vtkPolyDataMapper() |
353 | - mapper.SetInput(stripper.GetOutput()) | 357 | + mapper.SetInputData(stripper.GetOutput()) |
354 | mapper.ScalarVisibilityOff() | 358 | mapper.ScalarVisibilityOff() |
355 | mapper.ImmediateModeRenderingOn() # improve performance | 359 | mapper.ImmediateModeRenderingOn() # improve performance |
356 | 360 | ||
@@ -490,30 +494,30 @@ class SurfaceManager(): | @@ -490,30 +494,30 @@ class SurfaceManager(): | ||
490 | break | 494 | break |
491 | 495 | ||
492 | polydata_append = vtk.vtkAppendPolyData() | 496 | polydata_append = vtk.vtkAppendPolyData() |
493 | - polydata_append.ReleaseDataFlagOn() | 497 | + # polydata_append.ReleaseDataFlagOn() |
494 | t = n_pieces | 498 | t = n_pieces |
495 | while t: | 499 | while t: |
496 | filename_polydata = q_out.get() | 500 | filename_polydata = q_out.get() |
497 | 501 | ||
498 | reader = vtk.vtkXMLPolyDataReader() | 502 | reader = vtk.vtkXMLPolyDataReader() |
499 | reader.SetFileName(filename_polydata) | 503 | reader.SetFileName(filename_polydata) |
500 | - reader.ReleaseDataFlagOn() | 504 | + # reader.ReleaseDataFlagOn() |
501 | reader.Update() | 505 | reader.Update() |
502 | - reader.GetOutput().ReleaseDataFlagOn() | 506 | + # reader.GetOutput().ReleaseDataFlagOn() |
503 | 507 | ||
504 | polydata = reader.GetOutput() | 508 | polydata = reader.GetOutput() |
505 | - polydata.SetSource(None) | 509 | + # polydata.SetSource(None) |
506 | 510 | ||
507 | - polydata_append.AddInput(polydata) | 511 | + polydata_append.AddInputData(polydata) |
508 | del reader | 512 | del reader |
509 | del polydata | 513 | del polydata |
510 | t -= 1 | 514 | t -= 1 |
511 | 515 | ||
512 | polydata_append.Update() | 516 | polydata_append.Update() |
513 | - polydata_append.GetOutput().ReleaseDataFlagOn() | 517 | + # polydata_append.GetOutput().ReleaseDataFlagOn() |
514 | polydata = polydata_append.GetOutput() | 518 | polydata = polydata_append.GetOutput() |
515 | #polydata.Register(None) | 519 | #polydata.Register(None) |
516 | - polydata.SetSource(None) | 520 | + # polydata.SetSource(None) |
517 | del polydata_append | 521 | del polydata_append |
518 | 522 | ||
519 | if algorithm == 'ca_smoothing': | 523 | if algorithm == 'ca_smoothing': |
@@ -521,31 +525,31 @@ class SurfaceManager(): | @@ -521,31 +525,31 @@ class SurfaceManager(): | ||
521 | normals_ref = weakref.ref(normals) | 525 | normals_ref = weakref.ref(normals) |
522 | normals_ref().AddObserver("ProgressEvent", lambda obj,evt: | 526 | normals_ref().AddObserver("ProgressEvent", lambda obj,evt: |
523 | UpdateProgress(normals_ref(), _("Creating 3D surface..."))) | 527 | UpdateProgress(normals_ref(), _("Creating 3D surface..."))) |
524 | - normals.SetInput(polydata) | ||
525 | - normals.ReleaseDataFlagOn() | 528 | + normals.SetInputData(polydata) |
529 | + # normals.ReleaseDataFlagOn() | ||
526 | #normals.SetFeatureAngle(80) | 530 | #normals.SetFeatureAngle(80) |
527 | #normals.AutoOrientNormalsOn() | 531 | #normals.AutoOrientNormalsOn() |
528 | normals.ComputeCellNormalsOn() | 532 | normals.ComputeCellNormalsOn() |
529 | - normals.GetOutput().ReleaseDataFlagOn() | 533 | + # normals.GetOutput().ReleaseDataFlagOn() |
530 | normals.Update() | 534 | normals.Update() |
531 | del polydata | 535 | del polydata |
532 | polydata = normals.GetOutput() | 536 | polydata = normals.GetOutput() |
533 | - polydata.SetSource(None) | 537 | + # polydata.SetSource(None) |
534 | del normals | 538 | del normals |
535 | 539 | ||
536 | clean = vtk.vtkCleanPolyData() | 540 | clean = vtk.vtkCleanPolyData() |
537 | - clean.ReleaseDataFlagOn() | ||
538 | - clean.GetOutput().ReleaseDataFlagOn() | 541 | + # clean.ReleaseDataFlagOn() |
542 | + # clean.GetOutput().ReleaseDataFlagOn() | ||
539 | clean_ref = weakref.ref(clean) | 543 | clean_ref = weakref.ref(clean) |
540 | clean_ref().AddObserver("ProgressEvent", lambda obj,evt: | 544 | clean_ref().AddObserver("ProgressEvent", lambda obj,evt: |
541 | UpdateProgress(clean_ref(), _("Creating 3D surface..."))) | 545 | UpdateProgress(clean_ref(), _("Creating 3D surface..."))) |
542 | - clean.SetInput(polydata) | 546 | + clean.SetInputData(polydata) |
543 | clean.PointMergingOn() | 547 | clean.PointMergingOn() |
544 | clean.Update() | 548 | clean.Update() |
545 | 549 | ||
546 | del polydata | 550 | del polydata |
547 | polydata = clean.GetOutput() | 551 | polydata = clean.GetOutput() |
548 | - polydata.SetSource(None) | 552 | + # polydata.SetSource(None) |
549 | del clean | 553 | del clean |
550 | 554 | ||
551 | try: | 555 | try: |
@@ -556,7 +560,7 @@ class SurfaceManager(): | @@ -556,7 +560,7 @@ class SurfaceManager(): | ||
556 | options['max distance'], | 560 | options['max distance'], |
557 | options['min weight'], | 561 | options['min weight'], |
558 | options['steps']) | 562 | options['steps']) |
559 | - polydata.SetSource(None) | 563 | + # polydata.SetSource(None) |
560 | polydata.DebugOn() | 564 | polydata.DebugOn() |
561 | 565 | ||
562 | else: | 566 | else: |
@@ -565,7 +569,7 @@ class SurfaceManager(): | @@ -565,7 +569,7 @@ class SurfaceManager(): | ||
565 | smoother_ref = weakref.ref(smoother) | 569 | smoother_ref = weakref.ref(smoother) |
566 | smoother_ref().AddObserver("ProgressEvent", lambda obj,evt: | 570 | smoother_ref().AddObserver("ProgressEvent", lambda obj,evt: |
567 | UpdateProgress(smoother_ref(), _("Creating 3D surface..."))) | 571 | UpdateProgress(smoother_ref(), _("Creating 3D surface..."))) |
568 | - smoother.SetInput(polydata) | 572 | + smoother.SetInputData(polydata) |
569 | smoother.SetNumberOfIterations(smooth_iterations) | 573 | smoother.SetNumberOfIterations(smooth_iterations) |
570 | smoother.SetRelaxationFactor(smooth_relaxation_factor) | 574 | smoother.SetRelaxationFactor(smooth_relaxation_factor) |
571 | smoother.SetFeatureAngle(80) | 575 | smoother.SetFeatureAngle(80) |
@@ -575,21 +579,21 @@ class SurfaceManager(): | @@ -575,21 +579,21 @@ class SurfaceManager(): | ||
575 | smoother.FeatureEdgeSmoothingOn() | 579 | smoother.FeatureEdgeSmoothingOn() |
576 | #smoother.NormalizeCoordinatesOn() | 580 | #smoother.NormalizeCoordinatesOn() |
577 | #smoother.NonManifoldSmoothingOn() | 581 | #smoother.NonManifoldSmoothingOn() |
578 | - smoother.ReleaseDataFlagOn() | ||
579 | - smoother.GetOutput().ReleaseDataFlagOn() | 582 | + # smoother.ReleaseDataFlagOn() |
583 | + # smoother.GetOutput().ReleaseDataFlagOn() | ||
580 | smoother.Update() | 584 | smoother.Update() |
581 | del polydata | 585 | del polydata |
582 | polydata = smoother.GetOutput() | 586 | polydata = smoother.GetOutput() |
583 | #polydata.Register(None) | 587 | #polydata.Register(None) |
584 | - polydata.SetSource(None) | 588 | + # polydata.SetSource(None) |
585 | del smoother | 589 | del smoother |
586 | 590 | ||
587 | 591 | ||
588 | if decimate_reduction: | 592 | if decimate_reduction: |
589 | print "Decimating", decimate_reduction | 593 | print "Decimating", decimate_reduction |
590 | decimation = vtk.vtkQuadricDecimation() | 594 | decimation = vtk.vtkQuadricDecimation() |
591 | - decimation.ReleaseDataFlagOn() | ||
592 | - decimation.SetInput(polydata) | 595 | + # decimation.ReleaseDataFlagOn() |
596 | + decimation.SetInputData(polydata) | ||
593 | decimation.SetTargetReduction(decimate_reduction) | 597 | decimation.SetTargetReduction(decimate_reduction) |
594 | decimation_ref = weakref.ref(decimation) | 598 | decimation_ref = weakref.ref(decimation) |
595 | decimation_ref().AddObserver("ProgressEvent", lambda obj,evt: | 599 | decimation_ref().AddObserver("ProgressEvent", lambda obj,evt: |
@@ -597,31 +601,31 @@ class SurfaceManager(): | @@ -597,31 +601,31 @@ class SurfaceManager(): | ||
597 | #decimation.PreserveTopologyOn() | 601 | #decimation.PreserveTopologyOn() |
598 | #decimation.SplittingOff() | 602 | #decimation.SplittingOff() |
599 | #decimation.BoundaryVertexDeletionOff() | 603 | #decimation.BoundaryVertexDeletionOff() |
600 | - decimation.GetOutput().ReleaseDataFlagOn() | 604 | + # decimation.GetOutput().ReleaseDataFlagOn() |
601 | decimation.Update() | 605 | decimation.Update() |
602 | del polydata | 606 | del polydata |
603 | polydata = decimation.GetOutput() | 607 | polydata = decimation.GetOutput() |
604 | #polydata.Register(None) | 608 | #polydata.Register(None) |
605 | - polydata.SetSource(None) | 609 | + # polydata.SetSource(None) |
606 | del decimation | 610 | del decimation |
607 | 611 | ||
608 | to_measure = polydata | 612 | to_measure = polydata |
609 | #to_measure.Register(None) | 613 | #to_measure.Register(None) |
610 | - to_measure.SetSource(None) | 614 | + # to_measure.SetSource(None) |
611 | 615 | ||
612 | if keep_largest: | 616 | if keep_largest: |
613 | conn = vtk.vtkPolyDataConnectivityFilter() | 617 | conn = vtk.vtkPolyDataConnectivityFilter() |
614 | - conn.SetInput(polydata) | 618 | + conn.SetInputData(polydata) |
615 | conn.SetExtractionModeToLargestRegion() | 619 | conn.SetExtractionModeToLargestRegion() |
616 | conn_ref = weakref.ref(conn) | 620 | conn_ref = weakref.ref(conn) |
617 | conn_ref().AddObserver("ProgressEvent", lambda obj,evt: | 621 | conn_ref().AddObserver("ProgressEvent", lambda obj,evt: |
618 | UpdateProgress(conn_ref(), _("Creating 3D surface..."))) | 622 | UpdateProgress(conn_ref(), _("Creating 3D surface..."))) |
619 | conn.Update() | 623 | conn.Update() |
620 | - conn.GetOutput().ReleaseDataFlagOn() | 624 | + # conn.GetOutput().ReleaseDataFlagOn() |
621 | del polydata | 625 | del polydata |
622 | polydata = conn.GetOutput() | 626 | polydata = conn.GetOutput() |
623 | #polydata.Register(None) | 627 | #polydata.Register(None) |
624 | - polydata.SetSource(None) | 628 | + # polydata.SetSource(None) |
625 | del conn | 629 | del conn |
626 | 630 | ||
627 | #Filter used to detect and fill holes. Only fill boundary edges holes. | 631 | #Filter used to detect and fill holes. Only fill boundary edges holes. |
@@ -629,59 +633,59 @@ class SurfaceManager(): | @@ -629,59 +633,59 @@ class SurfaceManager(): | ||
629 | #polydata_utils.FillSurfaceHole, we need to review this. | 633 | #polydata_utils.FillSurfaceHole, we need to review this. |
630 | if fill_holes: | 634 | if fill_holes: |
631 | filled_polydata = vtk.vtkFillHolesFilter() | 635 | filled_polydata = vtk.vtkFillHolesFilter() |
632 | - filled_polydata.ReleaseDataFlagOn() | ||
633 | - filled_polydata.SetInput(polydata) | 636 | + # filled_polydata.ReleaseDataFlagOn() |
637 | + filled_polydata.SetInputData(polydata) | ||
634 | filled_polydata.SetHoleSize(300) | 638 | filled_polydata.SetHoleSize(300) |
635 | filled_polydata_ref = weakref.ref(filled_polydata) | 639 | filled_polydata_ref = weakref.ref(filled_polydata) |
636 | filled_polydata_ref().AddObserver("ProgressEvent", lambda obj,evt: | 640 | filled_polydata_ref().AddObserver("ProgressEvent", lambda obj,evt: |
637 | UpdateProgress(filled_polydata_ref(), _("Creating 3D surface..."))) | 641 | UpdateProgress(filled_polydata_ref(), _("Creating 3D surface..."))) |
638 | filled_polydata.Update() | 642 | filled_polydata.Update() |
639 | - filled_polydata.GetOutput().ReleaseDataFlagOn() | 643 | + # filled_polydata.GetOutput().ReleaseDataFlagOn() |
640 | del polydata | 644 | del polydata |
641 | polydata = filled_polydata.GetOutput() | 645 | polydata = filled_polydata.GetOutput() |
642 | #polydata.Register(None) | 646 | #polydata.Register(None) |
643 | - polydata.SetSource(None) | 647 | + # polydata.SetSource(None) |
644 | polydata.DebugOn() | 648 | polydata.DebugOn() |
645 | del filled_polydata | 649 | del filled_polydata |
646 | 650 | ||
647 | normals = vtk.vtkPolyDataNormals() | 651 | normals = vtk.vtkPolyDataNormals() |
648 | - normals.ReleaseDataFlagOn() | 652 | + # normals.ReleaseDataFlagOn() |
649 | normals_ref = weakref.ref(normals) | 653 | normals_ref = weakref.ref(normals) |
650 | normals_ref().AddObserver("ProgressEvent", lambda obj,evt: | 654 | normals_ref().AddObserver("ProgressEvent", lambda obj,evt: |
651 | UpdateProgress(normals_ref(), _("Creating 3D surface..."))) | 655 | UpdateProgress(normals_ref(), _("Creating 3D surface..."))) |
652 | - normals.SetInput(polydata) | 656 | + normals.SetInputData(polydata) |
653 | normals.SetFeatureAngle(80) | 657 | normals.SetFeatureAngle(80) |
654 | normals.AutoOrientNormalsOn() | 658 | normals.AutoOrientNormalsOn() |
655 | - normals.GetOutput().ReleaseDataFlagOn() | 659 | + # normals.GetOutput().ReleaseDataFlagOn() |
656 | normals.Update() | 660 | normals.Update() |
657 | del polydata | 661 | del polydata |
658 | polydata = normals.GetOutput() | 662 | polydata = normals.GetOutput() |
659 | #polydata.Register(None) | 663 | #polydata.Register(None) |
660 | - polydata.SetSource(None) | 664 | + # polydata.SetSource(None) |
661 | del normals | 665 | del normals |
662 | 666 | ||
663 | # Improve performance | 667 | # Improve performance |
664 | stripper = vtk.vtkStripper() | 668 | stripper = vtk.vtkStripper() |
665 | - stripper.ReleaseDataFlagOn() | 669 | + # stripper.ReleaseDataFlagOn() |
666 | stripper_ref = weakref.ref(stripper) | 670 | stripper_ref = weakref.ref(stripper) |
667 | stripper_ref().AddObserver("ProgressEvent", lambda obj,evt: | 671 | stripper_ref().AddObserver("ProgressEvent", lambda obj,evt: |
668 | UpdateProgress(stripper_ref(), _("Creating 3D surface..."))) | 672 | UpdateProgress(stripper_ref(), _("Creating 3D surface..."))) |
669 | - stripper.SetInput(polydata) | 673 | + stripper.SetInputData(polydata) |
670 | stripper.PassThroughCellIdsOn() | 674 | stripper.PassThroughCellIdsOn() |
671 | stripper.PassThroughPointIdsOn() | 675 | stripper.PassThroughPointIdsOn() |
672 | - stripper.GetOutput().ReleaseDataFlagOn() | 676 | + # stripper.GetOutput().ReleaseDataFlagOn() |
673 | stripper.Update() | 677 | stripper.Update() |
674 | del polydata | 678 | del polydata |
675 | polydata = stripper.GetOutput() | 679 | polydata = stripper.GetOutput() |
676 | #polydata.Register(None) | 680 | #polydata.Register(None) |
677 | - polydata.SetSource(None) | 681 | + # polydata.SetSource(None) |
678 | del stripper | 682 | del stripper |
679 | 683 | ||
680 | # Map polygonal data (vtkPolyData) to graphics primitives. | 684 | # Map polygonal data (vtkPolyData) to graphics primitives. |
681 | mapper = vtk.vtkPolyDataMapper() | 685 | mapper = vtk.vtkPolyDataMapper() |
682 | - mapper.SetInput(polydata) | 686 | + mapper.SetInputData(polydata) |
683 | mapper.ScalarVisibilityOff() | 687 | mapper.ScalarVisibilityOff() |
684 | - mapper.ReleaseDataFlagOn() | 688 | + # mapper.ReleaseDataFlagOn() |
685 | mapper.ImmediateModeRenderingOn() # improve performance | 689 | mapper.ImmediateModeRenderingOn() # improve performance |
686 | 690 | ||
687 | # Represent an object (geometry & properties) in the rendered scene | 691 | # Represent an object (geometry & properties) in the rendered scene |
@@ -720,8 +724,8 @@ class SurfaceManager(): | @@ -720,8 +724,8 @@ class SurfaceManager(): | ||
720 | 724 | ||
721 | # The following lines have to be here, otherwise all volumes disappear | 725 | # The following lines have to be here, otherwise all volumes disappear |
722 | measured_polydata = vtk.vtkMassProperties() | 726 | measured_polydata = vtk.vtkMassProperties() |
723 | - measured_polydata.ReleaseDataFlagOn() | ||
724 | - measured_polydata.SetInput(to_measure) | 727 | + # measured_polydata.ReleaseDataFlagOn() |
728 | + measured_polydata.SetInputData(to_measure) | ||
725 | volume = float(measured_polydata.GetVolume()) | 729 | volume = float(measured_polydata.GetVolume()) |
726 | surface.volume = volume | 730 | surface.volume = volume |
727 | self.last_surface_index = surface.index | 731 | self.last_surface_index = surface.index |
@@ -858,14 +862,15 @@ class SurfaceManager(): | @@ -858,14 +862,15 @@ class SurfaceManager(): | ||
858 | if filetype in (const.FILETYPE_STL, const.FILETYPE_PLY): | 862 | if filetype in (const.FILETYPE_STL, const.FILETYPE_PLY): |
859 | # Invert normals | 863 | # Invert normals |
860 | normals = vtk.vtkPolyDataNormals() | 864 | normals = vtk.vtkPolyDataNormals() |
861 | - normals.SetInput(polydata) | 865 | + normals.SetInputData(polydata) |
862 | normals.SetFeatureAngle(80) | 866 | normals.SetFeatureAngle(80) |
863 | normals.AutoOrientNormalsOn() | 867 | normals.AutoOrientNormalsOn() |
864 | - normals.GetOutput().ReleaseDataFlagOn() | 868 | + # normals.GetOutput().ReleaseDataFlagOn() |
865 | normals.UpdateInformation() | 869 | normals.UpdateInformation() |
870 | + normals.Update() | ||
866 | polydata = normals.GetOutput() | 871 | polydata = normals.GetOutput() |
867 | 872 | ||
868 | filename = filename.encode(wx.GetDefaultPyEncoding()) | 873 | filename = filename.encode(wx.GetDefaultPyEncoding()) |
869 | writer.SetFileName(filename) | 874 | writer.SetFileName(filename) |
870 | - writer.SetInput(polydata) | 875 | + writer.SetInputData(polydata) |
871 | writer.Write() | 876 | writer.Write() |
invesalius/data/surface_process.py
@@ -26,7 +26,7 @@ def ResampleImage3D(imagedata, value): | @@ -26,7 +26,7 @@ def ResampleImage3D(imagedata, value): | ||
26 | resolution = (height/(extent[1]-extent[0])+1)*spacing[1] | 26 | resolution = (height/(extent[1]-extent[0])+1)*spacing[1] |
27 | 27 | ||
28 | resample = vtk.vtkImageResample() | 28 | resample = vtk.vtkImageResample() |
29 | - resample.SetInput(imagedata) | 29 | + resample.SetInputData(imagedata) |
30 | resample.SetAxisMagnificationFactor(0, resolution) | 30 | resample.SetAxisMagnificationFactor(0, resolution) |
31 | resample.SetAxisMagnificationFactor(1, resolution) | 31 | resample.SetAxisMagnificationFactor(1, resolution) |
32 | 32 | ||
@@ -106,7 +106,7 @@ class SurfaceProcess(multiprocessing.Process): | @@ -106,7 +106,7 @@ class SurfaceProcess(multiprocessing.Process): | ||
106 | "AXIAL") | 106 | "AXIAL") |
107 | 107 | ||
108 | gauss = vtk.vtkImageGaussianSmooth() | 108 | gauss = vtk.vtkImageGaussianSmooth() |
109 | - gauss.SetInput(image) | 109 | + gauss.SetInputData(image) |
110 | gauss.SetRadiusFactor(0.3) | 110 | gauss.SetRadiusFactor(0.3) |
111 | gauss.ReleaseDataFlagOn() | 111 | gauss.ReleaseDataFlagOn() |
112 | gauss.Update() | 112 | gauss.Update() |
@@ -125,7 +125,7 @@ class SurfaceProcess(multiprocessing.Process): | @@ -125,7 +125,7 @@ class SurfaceProcess(multiprocessing.Process): | ||
125 | image = ResampleImage3D(image, self.imagedata_resolution) | 125 | image = ResampleImage3D(image, self.imagedata_resolution) |
126 | 126 | ||
127 | flip = vtk.vtkImageFlip() | 127 | flip = vtk.vtkImageFlip() |
128 | - flip.SetInput(image) | 128 | + flip.SetInputData(image) |
129 | flip.SetFilteredAxis(1) | 129 | flip.SetFilteredAxis(1) |
130 | flip.FlipAboutOriginOn() | 130 | flip.FlipAboutOriginOn() |
131 | flip.ReleaseDataFlagOn() | 131 | flip.ReleaseDataFlagOn() |
@@ -148,7 +148,7 @@ class SurfaceProcess(multiprocessing.Process): | @@ -148,7 +148,7 @@ class SurfaceProcess(multiprocessing.Process): | ||
148 | #if self.mode == "CONTOUR": | 148 | #if self.mode == "CONTOUR": |
149 | #print "Contour" | 149 | #print "Contour" |
150 | contour = vtk.vtkContourFilter() | 150 | contour = vtk.vtkContourFilter() |
151 | - contour.SetInput(image) | 151 | + contour.SetInputData(image) |
152 | #contour.SetInput(flip.GetOutput()) | 152 | #contour.SetInput(flip.GetOutput()) |
153 | if self.from_binary: | 153 | if self.from_binary: |
154 | contour.SetValue(0, 127) # initial threshold | 154 | contour.SetValue(0, 127) # initial threshold |
@@ -202,7 +202,7 @@ class SurfaceProcess(multiprocessing.Process): | @@ -202,7 +202,7 @@ class SurfaceProcess(multiprocessing.Process): | ||
202 | 202 | ||
203 | filename = tempfile.mktemp(suffix='_%s.vtp' % (self.pid)) | 203 | filename = tempfile.mktemp(suffix='_%s.vtp' % (self.pid)) |
204 | writer = vtk.vtkXMLPolyDataWriter() | 204 | writer = vtk.vtkXMLPolyDataWriter() |
205 | - writer.SetInput(polydata) | 205 | + writer.SetInputData(polydata) |
206 | writer.SetFileName(filename) | 206 | writer.SetFileName(filename) |
207 | writer.Write() | 207 | writer.Write() |
208 | 208 |
invesalius/data/viewer_slice.py
@@ -753,6 +753,7 @@ class Viewer(wx.Panel): | @@ -753,6 +753,7 @@ class Viewer(wx.Panel): | ||
753 | image = vtk.vtkRenderLargeImage() | 753 | image = vtk.vtkRenderLargeImage() |
754 | image.SetInput(ren) | 754 | image.SetInput(ren) |
755 | image.SetMagnification(1) | 755 | image.SetMagnification(1) |
756 | + image.Update() | ||
756 | 757 | ||
757 | image = image.GetOutput() | 758 | image = image.GetOutput() |
758 | 759 | ||
@@ -769,8 +770,8 @@ class Viewer(wx.Panel): | @@ -769,8 +770,8 @@ class Viewer(wx.Panel): | ||
769 | elif (filetype == const.FILETYPE_TIF): | 770 | elif (filetype == const.FILETYPE_TIF): |
770 | writer = vtk.vtkTIFFWriter() | 771 | writer = vtk.vtkTIFFWriter() |
771 | filename = "%s.tif"%filename.strip(".tif") | 772 | filename = "%s.tif"%filename.strip(".tif") |
772 | - | ||
773 | - writer.SetInput(image) | 773 | + |
774 | + writer.SetInputData(image) | ||
774 | writer.SetFileName(filename) | 775 | writer.SetFileName(filename) |
775 | writer.Write() | 776 | writer.Write() |
776 | 777 | ||
@@ -919,7 +920,7 @@ class Viewer(wx.Panel): | @@ -919,7 +920,7 @@ class Viewer(wx.Panel): | ||
919 | c.SetCoordinateSystemToWorld() | 920 | c.SetCoordinateSystemToWorld() |
920 | 921 | ||
921 | cross_mapper = vtk.vtkPolyDataMapper() | 922 | cross_mapper = vtk.vtkPolyDataMapper() |
922 | - cross_mapper.SetInput(cross.GetOutput()) | 923 | + cross_mapper.SetInputConnection(cross.GetOutputPort()) |
923 | #cross_mapper.SetTransformCoordinate(c) | 924 | #cross_mapper.SetTransformCoordinate(c) |
924 | 925 | ||
925 | p = vtk.vtkProperty() | 926 | p = vtk.vtkProperty() |
@@ -1176,7 +1177,7 @@ class Viewer(wx.Panel): | @@ -1176,7 +1177,7 @@ class Viewer(wx.Panel): | ||
1176 | border_size = self.mip_ctrls.border_spin.GetValue() | 1177 | border_size = self.mip_ctrls.border_spin.GetValue() |
1177 | image = self.slice_.GetSlices(self.orientation, index, | 1178 | image = self.slice_.GetSlices(self.orientation, index, |
1178 | self.number_slices, inverted, border_size) | 1179 | self.number_slices, inverted, border_size) |
1179 | - self.slice_data.actor.SetInput(image) | 1180 | + self.slice_data.actor.SetInputData(image) |
1180 | for actor in self.actors_by_slice_number.get(self.slice_data.number, []): | 1181 | for actor in self.actors_by_slice_number.get(self.slice_data.number, []): |
1181 | self.slice_data.renderer.RemoveActor(actor) | 1182 | self.slice_data.renderer.RemoveActor(actor) |
1182 | for actor in self.actors_by_slice_number.get(index, []): | 1183 | for actor in self.actors_by_slice_number.get(index, []): |
invesalius/data/viewer_volume.py
@@ -318,6 +318,7 @@ class Viewer(wx.Panel): | @@ -318,6 +318,7 @@ class Viewer(wx.Panel): | ||
318 | image = vtk.vtkRenderLargeImage() | 318 | image = vtk.vtkRenderLargeImage() |
319 | image.SetInput(self.ren) | 319 | image.SetInput(self.ren) |
320 | image.SetMagnification(1) | 320 | image.SetMagnification(1) |
321 | + image.Update() | ||
321 | 322 | ||
322 | image = image.GetOutput() | 323 | image = image.GetOutput() |
323 | 324 | ||
@@ -333,12 +334,12 @@ class Viewer(wx.Panel): | @@ -333,12 +334,12 @@ class Viewer(wx.Panel): | ||
333 | elif (filetype == const.FILETYPE_TIF): | 334 | elif (filetype == const.FILETYPE_TIF): |
334 | writer = vtk.vtkTIFFWriter() | 335 | writer = vtk.vtkTIFFWriter() |
335 | filename = "%s.tif"%filename.strip(".tif") | 336 | filename = "%s.tif"%filename.strip(".tif") |
336 | - | ||
337 | - writer.SetInput(image) | 337 | + |
338 | + writer.SetInputData(image) | ||
338 | writer.SetFileName(filename) | 339 | writer.SetFileName(filename) |
339 | writer.Write() | 340 | writer.Write() |
340 | Publisher.sendMessage('End busy cursor') | 341 | Publisher.sendMessage('End busy cursor') |
341 | - | 342 | + |
342 | def OnCloseProject(self, pubsub_evt): | 343 | def OnCloseProject(self, pubsub_evt): |
343 | if self.raycasting_volume: | 344 | if self.raycasting_volume: |
344 | self.raycasting_volume = False | 345 | self.raycasting_volume = False |
invesalius/data/volume.py
@@ -224,7 +224,7 @@ class Volume(): | @@ -224,7 +224,7 @@ class Volume(): | ||
224 | # Update convolution filter | 224 | # Update convolution filter |
225 | original_imagedata = self.imagedata.GetOutput() | 225 | original_imagedata = self.imagedata.GetOutput() |
226 | imagedata = self.ApplyConvolution(original_imagedata) | 226 | imagedata = self.ApplyConvolution(original_imagedata) |
227 | - self.volume_mapper.SetInput(imagedata) | 227 | + self.volume_mapper.SetInputData(imagedata) |
228 | 228 | ||
229 | # Update other information | 229 | # Update other information |
230 | self.SetShading() | 230 | self.SetShading() |
@@ -484,7 +484,7 @@ class Volume(): | @@ -484,7 +484,7 @@ class Volume(): | ||
484 | update_progress = vtk_utils.ShowProgress(number_filters) | 484 | update_progress = vtk_utils.ShowProgress(number_filters) |
485 | for filter in self.config['convolutionFilters']: | 485 | for filter in self.config['convolutionFilters']: |
486 | convolve = vtk.vtkImageConvolve() | 486 | convolve = vtk.vtkImageConvolve() |
487 | - convolve.SetInput(imagedata) | 487 | + convolve.SetInputData(imagedata) |
488 | convolve.SetKernel5x5([i/60.0 for i in Kernels[filter]]) | 488 | convolve.SetKernel5x5([i/60.0 for i in Kernels[filter]]) |
489 | convolve.ReleaseDataFlagOn() | 489 | convolve.ReleaseDataFlagOn() |
490 | 490 | ||
@@ -530,7 +530,7 @@ class Volume(): | @@ -530,7 +530,7 @@ class Volume(): | ||
530 | update_progress= vtk_utils.ShowProgress(2 + number_filters) | 530 | update_progress= vtk_utils.ShowProgress(2 + number_filters) |
531 | # Flip original vtkImageData | 531 | # Flip original vtkImageData |
532 | flip = vtk.vtkImageFlip() | 532 | flip = vtk.vtkImageFlip() |
533 | - flip.SetInput(image) | 533 | + flip.SetInputData(image) |
534 | flip.SetFilteredAxis(1) | 534 | flip.SetFilteredAxis(1) |
535 | flip.FlipAboutOriginOn() | 535 | flip.FlipAboutOriginOn() |
536 | flip.ReleaseDataFlagOn() | 536 | flip.ReleaseDataFlagOn() |
@@ -545,7 +545,7 @@ class Volume(): | @@ -545,7 +545,7 @@ class Volume(): | ||
545 | self.scale = scale | 545 | self.scale = scale |
546 | 546 | ||
547 | cast = vtk.vtkImageShiftScale() | 547 | cast = vtk.vtkImageShiftScale() |
548 | - cast.SetInput(image) | 548 | + cast.SetInputData(image) |
549 | cast.SetShift(abs(scale[0])) | 549 | cast.SetShift(abs(scale[0])) |
550 | cast.SetOutputScalarTypeToUnsignedShort() | 550 | cast.SetOutputScalarTypeToUnsignedShort() |
551 | cast.ReleaseDataFlagOn() | 551 | cast.ReleaseDataFlagOn() |
@@ -589,7 +589,7 @@ class Volume(): | @@ -589,7 +589,7 @@ class Volume(): | ||
589 | self.volume_mapper = volume_mapper | 589 | self.volume_mapper = volume_mapper |
590 | 590 | ||
591 | self.SetTypeRaycasting() | 591 | self.SetTypeRaycasting() |
592 | - volume_mapper.SetInput(image2) | 592 | + volume_mapper.SetInputData(image2) |
593 | 593 | ||
594 | # TODO: Look to this | 594 | # TODO: Look to this |
595 | #volume_mapper_hw = vtk.vtkVolumeTextureMapper3D() | 595 | #volume_mapper_hw = vtk.vtkVolumeTextureMapper3D() |
@@ -657,7 +657,7 @@ class Volume(): | @@ -657,7 +657,7 @@ class Volume(): | ||
657 | image = self.image | 657 | image = self.image |
658 | r = int(image.GetScalarRange()[1] - image.GetScalarRange()[0]) | 658 | r = int(image.GetScalarRange()[1] - image.GetScalarRange()[0]) |
659 | accumulate = vtk.vtkImageAccumulate() | 659 | accumulate = vtk.vtkImageAccumulate() |
660 | - accumulate.SetInput(image) | 660 | + accumulate.SetInputData(image) |
661 | accumulate.SetComponentExtent(0, r -1, 0, 0, 0, 0) | 661 | accumulate.SetComponentExtent(0, r -1, 0, 0, 0, 0) |
662 | accumulate.SetComponentOrigin(image.GetScalarRange()[0], 0, 0) | 662 | accumulate.SetComponentOrigin(image.GetScalarRange()[0], 0, 0) |
663 | accumulate.ReleaseDataFlagOn() | 663 | accumulate.ReleaseDataFlagOn() |
invesalius/data/watershed_process.py
1 | -import numpy as np | ||
2 | -from scipy import ndimage | ||
3 | -from scipy.ndimage import watershed_ift, generate_binary_structure | ||
4 | -from skimage.morphology import watershed | ||
5 | -from skimage import filter | ||
6 | - | ||
7 | - | ||
8 | -def get_LUT_value(data, window, level): | ||
9 | - return np.piecewise(data, | ||
10 | - [data <= (level - 0.5 - (window-1)/2), | ||
11 | - data > (level - 0.5 + (window-1)/2)], | ||
12 | - [0, 255, lambda data: ((data - (level - 0.5))/(window-1) + 0.5)*(255-0)]) | ||
13 | - | ||
14 | - | ||
15 | - | ||
16 | -def do_watershed(image, markers, tfile, shape, bstruct, algorithm, mg_size, use_ww_wl, wl, ww, q): | ||
17 | - mask = np.memmap(tfile, shape=shape, dtype='uint8', mode='r+') | ||
18 | - | ||
19 | - if use_ww_wl: | ||
20 | - if algorithm == 'Watershed': | ||
21 | - tmp_image = ndimage.morphological_gradient( | ||
22 | - get_LUT_value(image, ww, wl).astype('uint16'), | ||
23 | - mg_size) | ||
24 | - tmp_mask = watershed(tmp_image, markers.astype('int16'), bstruct) | ||
25 | - else: | ||
26 | - tmp_image = get_LUT_value(image, ww, wl).astype('uint16') | ||
27 | - #tmp_image = ndimage.gaussian_filter(tmp_image, self.config.mg_size) | ||
28 | - #tmp_image = ndimage.morphological_gradient( | ||
29 | - #get_LUT_value(image, ww, wl).astype('uint16'), | ||
30 | - #self.config.mg_size) | ||
31 | - tmp_mask = watershed_ift(tmp_image, markers.astype('int16'), bstruct) | ||
32 | - else: | ||
33 | - if algorithm == 'Watershed': | ||
34 | - tmp_image = ndimage.morphological_gradient((image - image.min()).astype('uint16'), mg_size) | ||
35 | - tmp_mask = watershed(tmp_image, markers.astype('int16'), bstruct) | ||
36 | - else: | ||
37 | - tmp_image = (image - image.min()).astype('uint16') | ||
38 | - #tmp_image = ndimage.gaussian_filter(tmp_image, self.config.mg_size) | ||
39 | - #tmp_image = ndimage.morphological_gradient((image - image.min()).astype('uint16'), self.config.mg_size) | ||
40 | - tmp_mask = watershed_ift(tmp_image, markers.astype('int8'), bstruct) | ||
41 | - mask[:] = tmp_mask | ||
42 | - mask.flush() | ||
43 | - q.put(1) | 1 | +import numpy as np |
2 | +from scipy import ndimage | ||
3 | +from scipy.ndimage import watershed_ift, generate_binary_structure | ||
4 | +from skimage.morphology import watershed | ||
5 | +from skimage import filter | ||
6 | + | ||
7 | + | ||
8 | +def get_LUT_value(data, window, level): | ||
9 | + shape = data.shape | ||
10 | + data_ = data.ravel() | ||
11 | + data = np.piecewise(data_, | ||
12 | + [data_ <= (level - 0.5 - (window-1)/2), | ||
13 | + data_ > (level - 0.5 + (window-1)/2)], | ||
14 | + [0, window, lambda data_: ((data_ - (level - 0.5))/(window-1) + 0.5)*(window)]) | ||
15 | + data.shape = shape | ||
16 | + return data | ||
17 | + | ||
18 | + | ||
19 | +def do_watershed(image, markers, tfile, shape, bstruct, algorithm, mg_size, use_ww_wl, wl, ww, q): | ||
20 | + mask = np.memmap(tfile, shape=shape, dtype='uint8', mode='r+') | ||
21 | + | ||
22 | + if use_ww_wl: | ||
23 | + if algorithm == 'Watershed': | ||
24 | + tmp_image = ndimage.morphological_gradient( | ||
25 | + get_LUT_value(image, ww, wl).astype('uint16'), | ||
26 | + mg_size) | ||
27 | + tmp_mask = watershed(tmp_image, markers.astype('int16'), bstruct) | ||
28 | + else: | ||
29 | + tmp_image = get_LUT_value(image, ww, wl).astype('uint16') | ||
30 | + #tmp_image = ndimage.gaussian_filter(tmp_image, self.config.mg_size) | ||
31 | + #tmp_image = ndimage.morphological_gradient( | ||
32 | + #get_LUT_value(image, ww, wl).astype('uint16'), | ||
33 | + #self.config.mg_size) | ||
34 | + tmp_mask = watershed_ift(tmp_image, markers.astype('int16'), bstruct) | ||
35 | + else: | ||
36 | + if algorithm == 'Watershed': | ||
37 | + tmp_image = ndimage.morphological_gradient((image - image.min()).astype('uint16'), mg_size) | ||
38 | + tmp_mask = watershed(tmp_image, markers.astype('int16'), bstruct) | ||
39 | + else: | ||
40 | + tmp_image = (image - image.min()).astype('uint16') | ||
41 | + #tmp_image = ndimage.gaussian_filter(tmp_image, self.config.mg_size) | ||
42 | + #tmp_image = ndimage.morphological_gradient((image - image.min()).astype('uint16'), self.config.mg_size) | ||
43 | + tmp_mask = watershed_ift(tmp_image, markers.astype('int8'), bstruct) | ||
44 | + mask[:] = tmp_mask | ||
45 | + mask.flush() | ||
46 | + q.put(1) |
invesalius/gui/dicom_preview_panel.py
@@ -848,12 +848,12 @@ class SingleImagePreview(wx.Panel): | @@ -848,12 +848,12 @@ class SingleImagePreview(wx.Panel): | ||
848 | window_level = dicom.image.level | 848 | window_level = dicom.image.level |
849 | window_width = dicom.image.window | 849 | window_width = dicom.image.window |
850 | colorer = vtk.vtkImageMapToWindowLevelColors() | 850 | colorer = vtk.vtkImageMapToWindowLevelColors() |
851 | - colorer.SetInput(rdicom.GetOutput()) | 851 | + colorer.SetInputConnection(rdicom.GetOutputPort()) |
852 | colorer.SetWindow(float(window_width)) | 852 | colorer.SetWindow(float(window_width)) |
853 | colorer.SetLevel(float(window_level)) | 853 | colorer.SetLevel(float(window_level)) |
854 | 854 | ||
855 | # PLOT IMAGE INTO VIEWER | 855 | # PLOT IMAGE INTO VIEWER |
856 | - self.actor.SetInput(colorer.GetOutput()) | 856 | + self.actor.SetInputData(colorer.GetOutput()) |
857 | self.renderer.ResetCamera() | 857 | self.renderer.ResetCamera() |
858 | self.interactor.Render() | 858 | self.interactor.Render() |
859 | 859 |
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 |