From 95a04f4da8a476f3abf0dc66f260502da9364892 Mon Sep 17 00:00:00 2001 From: Thiago Franco de Moraes Date: Thu, 8 Aug 2013 10:49:16 -0300 Subject: [PATCH] Using the number keyboard to set the mip type --- invesalius/constants.py | 11 +++++++++++ invesalius/data/slice_.py | 49 ++++++++++++++++++++++++++++++++++++++++++++----- invesalius/data/viewer_slice.py | 12 ++++++++++++ 3 files changed, 67 insertions(+), 5 deletions(-) diff --git a/invesalius/constants.py b/invesalius/constants.py index 7e50592..6e1b665 100644 --- a/invesalius/constants.py +++ b/invesalius/constants.py @@ -543,3 +543,14 @@ DICOM_ENCODING_TO_PYTHON = { 'ISO_IR 138': 'iso_ir_138', 'ISO_IR 144': 'iso_ir_144', } + +#-------------------- Projections type ---------------- +PROJECTION_NORMAL=0 +PROJECTION_MaxIP=1 +PROJECTION_MinIP=2 +PROJECTION_MeanIP=3 +PROJECTION_LMIP=4 +PROJECTION_MIDA=5 +PROJECTION_CONTOUR_MIP=6 +PROJECTION_CONTOUR_LMIP=7 +PROJECTION_CONTOUR_MIDA=8 diff --git a/invesalius/data/slice_.py b/invesalius/data/slice_.py index 1182318..73d776b 100644 --- a/invesalius/data/slice_.py +++ b/invesalius/data/slice_.py @@ -85,7 +85,7 @@ class Slice(object): self.histogram = None self._matrix = None - self._type_projection = 'MIDA CONTOUR' + self._type_projection = const.PROJECTION_MIDA self.spacing = (1.0, 1.0, 1.0) @@ -427,7 +427,7 @@ class Slice(object): def GetSlices(self, orientation, slice_number, number_slices): if self.buffer_slices[orientation].index == slice_number and \ - self._type_projection == 'NORMAL': + self._type_projection == const.PROJECTION_NORMAL: if self.buffer_slices[orientation].vtk_image: image = self.buffer_slices[orientation].vtk_image else: @@ -481,8 +481,21 @@ class Slice(object): and self.buffer_slices[orientation].image is not None: n_image = self.buffer_slices[orientation].image else: + if orientation == 'AXIAL': - if self._type_projection == 'MIDA CONTOUR': + if self._type_projection == const.PROJECTION_NORMAL: + n_image = numpy.array(self.matrix[slice_number]) + elif self._type_projection == const.PROJECTION_MaxIP: + n_image = numpy.array(self.matrix[slice_number: + slice_number+number_slices]).max(0) + elif self._type_projection == const.PROJECTION_MIDA: + tmp_array = numpy.array(self.matrix[slice_number: + slice_number + number_slices]) + n_image = numpy.empty(shape=(tmp_array.shape[1], + tmp_array.shape[2]), + dtype=tmp_array.dtype) + mips.mida(tmp_array, 0, self.window_level, self.window_level, n_image) + elif self._type_projection == const.PROJECTION_CONTOUR_MIDA: tmp_array = numpy.array(self.matrix[slice_number: slice_number + number_slices]) n_image = numpy.empty(shape=(tmp_array.shape[1], @@ -492,8 +505,21 @@ class Slice(object): self.window_level, 2, n_image) else: n_image = numpy.array(self.matrix[slice_number]) + elif orientation == 'CORONAL': - if self._type_projection == 'MIDA CONTOUR': + if self._type_projection == const.PROJECTION_NORMAL: + n_image = numpy.array(self.matrix[..., slice_number, ...]) + elif self._type_projection == const.PROJECTION_MaxIP: + n_image = numpy.array(self.matrix[..., slice_number: + slice_number+number_slices, ...]).max(1) + elif self._type_projection == const.PROJECTION_MIDA: + tmp_array = numpy.array(self.matrix[..., slice_number: + slice_number + number_slices, ...]) + n_image = numpy.empty(shape=(tmp_array.shape[0], + tmp_array.shape[2]), + dtype=tmp_array.dtype) + mips.mida(tmp_array, 1, self.window_level, self.window_level, n_image) + elif self._type_projection == const.PROJECTION_CONTOUR_MIDA: tmp_array = numpy.array(self.matrix[..., slice_number: slice_number + number_slices, ...]) n_image = numpy.empty(shape=(tmp_array.shape[0], @@ -504,7 +530,20 @@ class Slice(object): else: n_image = numpy.array(self.matrix[..., slice_number, ...]) elif orientation == 'SAGITAL': - if self._type_projection == 'MIDA CONTOUR': + if self._type_projection == const.PROJECTION_NORMAL: + n_image = numpy.array(self.matrix[..., ..., slice_number]) + elif self._type_projection == const.PROJECTION_MaxIP: + n_image = numpy.array(self.matrix[..., ..., slice_number: + slice_number+number_slices]).max(2) + elif self._type_projection == const.PROJECTION_MIDA: + tmp_array = numpy.array(self.matrix[..., ..., + slice_number: slice_number + number_slices]) + n_image = numpy.empty(shape=(tmp_array.shape[0], + tmp_array.shape[1]), + dtype=tmp_array.dtype) + mips.mida(tmp_array, 2, self.window_level, self.window_level, n_image) + + elif self._type_projection == const.PROJECTION_CONTOUR_MIDA: tmp_array = numpy.array(self.matrix[..., ..., slice_number: slice_number + number_slices]) n_image = numpy.empty(shape=(tmp_array.shape[0], diff --git a/invesalius/data/viewer_slice.py b/invesalius/data/viewer_slice.py index fd47372..acda2b9 100755 --- a/invesalius/data/viewer_slice.py +++ b/invesalius/data/viewer_slice.py @@ -1043,6 +1043,18 @@ class Viewer(wx.Panel): self.number_slices -= 1 print "Subtracting", self.number_slices self.OnScrollBar() + + elif (evt.GetKeyCode() == wx.WXK_NUMPAD0): + self.slice_._type_projection = const.PRJECTION_NORMAL + + elif (evt.GetKeyCode() == wx.WXK_NUMPAD1): + self.slice_._type_projection = const.PROJECTION_MaxIP + + elif (evt.GetKeyCode() == wx.WXK_NUMPAD5): + self.slice_._type_projection = const.PROJECTION_MIDA + + elif (evt.GetKeyCode() == wx.WXK_NUMPAD8): + self.slice_._type_projection = const.PROJECTION_CONTOUR_MIDA self.UpdateSlice3D(pos) self.interactor.Render() -- libgit2 0.21.2