From 5b7747ae79177bf22d730fadf313ea4a0e8b7a04 Mon Sep 17 00:00:00 2001 From: Thiago Franco de Moraes Date: Wed, 6 Apr 2016 16:52:34 -0300 Subject: [PATCH] Showing the slices --- .gitignore | 4 ++++ invesalius/data/converters.py | 10 +++++----- invesalius/data/cursor_actors.py | 15 ++++++++------- invesalius/data/slice_.py | 22 +++++++++++----------- invesalius/data/slice_data.py | 2 +- invesalius/data/viewer_slice.py | 4 ++-- invesalius/reader/dicom_reader.py | 6 +++--- 7 files changed, 34 insertions(+), 29 deletions(-) diff --git a/.gitignore b/.gitignore index 8aa7a97..d1b6ccc 100644 --- a/.gitignore +++ b/.gitignore @@ -20,3 +20,7 @@ invesalius/reader/*.pyc *.so tags *.c + +build +*.patch +*.tgz diff --git a/invesalius/data/converters.py b/invesalius/data/converters.py index c9c6b24..93df985 100644 --- a/invesalius/data/converters.py +++ b/invesalius/data/converters.py @@ -43,16 +43,16 @@ def to_vtk(n_array, spacing, slice_number, orientation): image = vtk.vtkImageData() image.SetOrigin(0, 0, 0) image.SetSpacing(spacing) - image.SetNumberOfScalarComponents(1) image.SetDimensions(dx, dy, dz) + # SetNumberOfScalarComponents and SetScalrType were replaced by + # AllocateScalars + # image.SetNumberOfScalarComponents(1) + # image.SetScalarType(numpy_support.get_vtk_array_type(n_array.dtype)) + image.AllocateScalars(numpy_support.get_vtk_array_type(n_array.dtype), 1) image.SetExtent(extent) - image.SetScalarType(numpy_support.get_vtk_array_type(n_array.dtype)) - image.AllocateScalars() image.GetPointData().SetScalars(v_image) - image.Update() image_copy = vtk.vtkImageData() image_copy.DeepCopy(image) - image_copy.Update() return image_copy diff --git a/invesalius/data/cursor_actors.py b/invesalius/data/cursor_actors.py index 657de4b..7d48422 100644 --- a/invesalius/data/cursor_actors.py +++ b/invesalius/data/cursor_actors.py @@ -24,6 +24,7 @@ import vtk import imagedata_utils from project import Project import constants as const +import converters from vtk.util import numpy_support @@ -224,7 +225,7 @@ class CursorBase(object): img_colours_mask = vtk.vtkImageMapToColors() img_colours_mask.SetLookupTable(lut_mask) img_colours_mask.SetOutputFormatToRGBA() - img_colours_mask.SetInput(imagedata) + img_colours_mask.SetInputData(imagedata) img_colours_mask.Update() return img_colours_mask.GetOutput() @@ -269,17 +270,17 @@ class CursorCircle(CursorBase): z,y,x = numpy.ogrid[zi:zf,yi:yf, xi:xf] circle_m = (z*sz)**2 + (y*sy)**2 + (x*sx)**2 <= r**2 - circle_i = to_vtk(circle_m.astype('uint8'), + circle_i = converters.to_vtk(circle_m.astype('uint8'), self.spacing, 0, self.orientation) circle_ci = self._set_colour(circle_i, self.colour) if self.mapper is None: - self.actor.SetInput(circle_ci) + self.actor.SetInputData(circle_ci) self.actor.InterpolateOff() self.actor.PickableOff() self.actor.SetDisplayExtent(circle_ci.GetExtent()) else: - self.mapper.SetInput(circle_ci) + self.mapper.SetInputData(circle_ci) self.mapper.BorderOn() self.mapper.SetOrientation(ORIENTATION[self.orientation]) @@ -343,16 +344,16 @@ class CursorRectangle(CursorBase): z = math.floor(r/sz) rectangle_m = numpy.ones((z, y, x), dtype='uint8') - rectangle_i = to_vtk(rectangle_m, self.spacing, 0, self.orientation) + rectangle_i = converters.to_vtk(rectangle_m, self.spacing, 0, self.orientation) rectangle_ci = self._set_colour(rectangle_i, self.colour) if self.mapper is None: - self.actor.SetInput(rectangle_ci) + self.actor.SetInputData(rectangle_ci) self.actor.InterpolateOff() self.actor.PickableOff() self.actor.SetDisplayExtent(rectangle_ci.GetExtent()) else: - self.mapper.SetInput(rectangle_ci) + self.mapper.SetInputData(rectangle_ci) self.mapper.BorderOn() self.mapper.SetOrientation(ORIENTATION[self.orientation]) diff --git a/invesalius/data/slice_.py b/invesalius/data/slice_.py index 4101cbb..318de5e 100644 --- a/invesalius/data/slice_.py +++ b/invesalius/data/slice_.py @@ -964,18 +964,18 @@ class Slice(object): img = self.buffer_slices[orientation].vtk_image original_orientation = Project().original_orientation cast = vtk.vtkImageCast() - cast.SetInput(img) + cast.SetInputData(img) cast.SetOutputScalarTypeToDouble() cast.ClampOverflowOn() cast.Update() #if (original_orientation == const.AXIAL): flip = vtk.vtkImageFlip() - flip.SetInput(cast.GetOutput()) + flip.SetInputConnection(cast.GetOutputPort()) flip.SetFilteredAxis(1) flip.FlipAboutOriginOn() flip.Update() - widget.SetInput(flip.GetOutput()) + widget.SetInputConnection(flip.GetOutputPort()) #else: #widget.SetInput(cast.GetOutput()) @@ -1044,7 +1044,7 @@ class Slice(object): i += 1 colorer = vtk.vtkImageMapToColors() - colorer.SetInput(image) + colorer.SetInputData(image) colorer.SetLookupTable(lut) colorer.SetOutputFormatToRGB() colorer.Update() @@ -1059,12 +1059,12 @@ class Slice(object): colorer = vtk.vtkImageMapToColors() colorer.SetLookupTable(lut) - colorer.SetInput(image) + colorer.SetInputData(image) colorer.SetOutputFormatToRGB() colorer.Update() else: colorer = vtk.vtkImageMapToWindowLevelColors() - colorer.SetInput(image) + colorer.SetInputData(image) colorer.SetWindow(self.window_width) colorer.SetLevel(self.window_level) colorer.SetOutputFormatToRGB() @@ -1148,7 +1148,7 @@ class Slice(object): img_colours_bg = vtk.vtkImageMapToColors() img_colours_bg.SetOutputFormatToRGB() img_colours_bg.SetLookupTable(lut_bg) - img_colours_bg.SetInput(imagedata) + img_colours_bg.SetInputData(imagedata) img_colours_bg.Update() return img_colours_bg.GetOutput() @@ -1179,7 +1179,7 @@ class Slice(object): img_colours_mask = vtk.vtkImageMapToColors() img_colours_mask.SetLookupTable(lut_mask) img_colours_mask.SetOutputFormatToRGBA() - img_colours_mask.SetInput(imagedata) + img_colours_mask.SetInputData(imagedata) img_colours_mask.Update() # self.img_colours_mask = img_colours_mask @@ -1211,7 +1211,7 @@ class Slice(object): img_colours_mask = vtk.vtkImageMapToColors() img_colours_mask.SetLookupTable(lut_mask) img_colours_mask.SetOutputFormatToRGBA() - img_colours_mask.SetInput(imagedata) + img_colours_mask.SetInputData(imagedata) img_colours_mask.Update() # self.img_colours_mask = img_colours_mask @@ -1225,8 +1225,8 @@ class Slice(object): blend_imagedata.SetBlendModeToNormal() # blend_imagedata.SetOpacity(0, 1.0) blend_imagedata.SetOpacity(1, 0.8) - blend_imagedata.SetInput(imagedata) - blend_imagedata.AddInput(mask) + blend_imagedata.SetInputData(imagedata) + blend_imagedata.AddInputData(mask) blend_imagedata.Update() return blend_imagedata.GetOutput() diff --git a/invesalius/data/slice_data.py b/invesalius/data/slice_data.py index 55da72b..92d2929 100644 --- a/invesalius/data/slice_data.py +++ b/invesalius/data/slice_data.py @@ -55,7 +55,7 @@ class SliceData(object): def __create_line_actor(self, line): line_mapper = vtk.vtkPolyDataMapper2D() - line_mapper.SetInput(line.GetOutput()) + line_mapper.SetInputConnection(line.GetOutputPort()) line_actor = vtk.vtkActor2D() line_actor.SetMapper(line_mapper) diff --git a/invesalius/data/viewer_slice.py b/invesalius/data/viewer_slice.py index 2952694..9453256 100755 --- a/invesalius/data/viewer_slice.py +++ b/invesalius/data/viewer_slice.py @@ -919,7 +919,7 @@ class Viewer(wx.Panel): c.SetCoordinateSystemToWorld() cross_mapper = vtk.vtkPolyDataMapper() - cross_mapper.SetInput(cross.GetOutput()) + cross_mapper.SetInputConnection(cross.GetOutputPort()) #cross_mapper.SetTransformCoordinate(c) p = vtk.vtkProperty() @@ -1176,7 +1176,7 @@ class Viewer(wx.Panel): border_size = self.mip_ctrls.border_spin.GetValue() image = self.slice_.GetSlices(self.orientation, index, self.number_slices, inverted, border_size) - self.slice_data.actor.SetInput(image) + self.slice_data.actor.SetInputData(image) for actor in self.actors_by_slice_number.get(self.slice_data.number, []): self.slice_data.renderer.RemoveActor(actor) for actor in self.actors_by_slice_number.get(index, []): diff --git a/invesalius/reader/dicom_reader.py b/invesalius/reader/dicom_reader.py index af3292d..c006d0f 100644 --- a/invesalius/reader/dicom_reader.py +++ b/invesalius/reader/dicom_reader.py @@ -195,14 +195,14 @@ class LoadDicom: window = 2000.0 colorer = vtk.vtkImageMapToWindowLevelColors() - colorer.SetInput(rvtk.GetOutput()) + colorer.SetInputConnection(rvtk.GetOutputPort()) colorer.SetWindow(float(window)) colorer.SetLevel(float(level)) colorer.SetOutputFormatToRGB() colorer.Update() resample = vtk.vtkImageResample() - resample.SetInput(colorer.GetOutput()) + resample.SetInputConnection(colorer.GetOutputPort()) resample.SetAxisMagnificationFactor ( 0, 0.25 ) resample.SetAxisMagnificationFactor ( 1, 0.25 ) resample.SetAxisMagnificationFactor ( 2, 1 ) @@ -211,7 +211,7 @@ class LoadDicom: thumbnail_path = tempfile.mktemp() write_png = vtk.vtkPNGWriter() - write_png.SetInput(resample.GetOutput()) + write_png.SetInputConnection(resample.GetOutputPort()) write_png.SetFileName(thumbnail_path) write_png.Write() -- libgit2 0.21.2