diff --git a/invesalius/data/slice_.py b/invesalius/data/slice_.py index 73d776b..fa10bbf 100644 --- a/invesalius/data/slice_.py +++ b/invesalius/data/slice_.py @@ -488,6 +488,19 @@ class Slice(object): 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_MinIP: + n_image = numpy.array(self.matrix[slice_number: + slice_number+number_slices]).min(0) + elif self._type_projection == const.PROJECTION_MeanIP: + n_image = numpy.array(self.matrix[slice_number: + slice_number+number_slices]).mean(0) + elif self._type_projection == const.PROJECTION_LMIP: + 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.lmip(tmp_array, 0, self.window_level, self.window_level, n_image) elif self._type_projection == const.PROJECTION_MIDA: tmp_array = numpy.array(self.matrix[slice_number: slice_number + number_slices]) @@ -495,6 +508,22 @@ class Slice(object): 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_MIP: + 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.fast_countour_mip(tmp_array, 0.2, 0, self.window_level, + self.window_level, 0, n_image) + elif self._type_projection == const.PROJECTION_CONTOUR_LMIP: + 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.fast_countour_mip(tmp_array, 0.2, 0, self.window_level, + self.window_level, 1, n_image) elif self._type_projection == const.PROJECTION_CONTOUR_MIDA: tmp_array = numpy.array(self.matrix[slice_number: slice_number + number_slices]) @@ -512,6 +541,19 @@ class Slice(object): 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_MinIP: + n_image = numpy.array(self.matrix[..., slice_number: + slice_number+number_slices, ...]).min(1) + elif self._type_projection == const.PROJECTION_MeanIP: + n_image = numpy.array(self.matrix[..., slice_number: + slice_number+number_slices, ...]).mean(1) + elif self._type_projection == const.PROJECTION_LMIP: + 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.lmip(tmp_array, 1, self.window_level, self.window_level, n_image) elif self._type_projection == const.PROJECTION_MIDA: tmp_array = numpy.array(self.matrix[..., slice_number: slice_number + number_slices, ...]) @@ -519,6 +561,22 @@ class Slice(object): 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_MIP: + 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.fast_countour_mip(tmp_array, 0.2, 1, self.window_level, + self.window_level, 0, n_image) + elif self._type_projection == const.PROJECTION_CONTOUR_LMIP: + 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.fast_countour_mip(tmp_array, 0.2, 1, self.window_level, + self.window_level, 1, n_image) elif self._type_projection == const.PROJECTION_CONTOUR_MIDA: tmp_array = numpy.array(self.matrix[..., slice_number: slice_number + number_slices, ...]) @@ -535,6 +593,19 @@ class Slice(object): 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_MinIP: + n_image = numpy.array(self.matrix[..., ..., slice_number: + slice_number+number_slices]).min(2) + elif self._type_projection == const.PROJECTION_MeanIP: + n_image = numpy.array(self.matrix[..., ..., slice_number: + slice_number+number_slices]).mean(2) + elif self._type_projection == const.PROJECTION_LMIP: + 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.lmip(tmp_array, 2, self.window_level, self.window_level, n_image) elif self._type_projection == const.PROJECTION_MIDA: tmp_array = numpy.array(self.matrix[..., ..., slice_number: slice_number + number_slices]) @@ -543,6 +614,22 @@ class Slice(object): dtype=tmp_array.dtype) mips.mida(tmp_array, 2, self.window_level, self.window_level, n_image) + elif self._type_projection == const.PROJECTION_CONTOUR_MIP: + 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.fast_countour_mip(tmp_array, 0.2, 2, self.window_level, + self.window_level, 0, n_image) + elif self._type_projection == const.PROJECTION_CONTOUR_LMIP: + 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.fast_countour_mip(tmp_array, 0.2, 2, self.window_level, + self.window_level, 1, n_image) elif self._type_projection == const.PROJECTION_CONTOUR_MIDA: tmp_array = numpy.array(self.matrix[..., ..., slice_number: slice_number + number_slices]) diff --git a/invesalius/data/viewer_slice.py b/invesalius/data/viewer_slice.py index acda2b9..84c3b6c 100755 --- a/invesalius/data/viewer_slice.py +++ b/invesalius/data/viewer_slice.py @@ -1022,6 +1022,16 @@ class Viewer(wx.Panel): min = 0 max = self.slice_.GetMaxSliceNumber(self.orientation) + projections = {wx.WXK_NUMPAD0 : const.PROJECTION_NORMAL, + wx.WXK_NUMPAD1 : const.PROJECTION_MaxIP, + wx.WXK_NUMPAD2 : const.PROJECTION_MinIP, + wx.WXK_NUMPAD3 : const.PROJECTION_MeanIP, + wx.WXK_NUMPAD4 : const.PROJECTION_LMIP, + wx.WXK_NUMPAD5 : const.PROJECTION_MIDA, + wx.WXK_NUMPAD6 : const.PROJECTION_CONTOUR_MIP, + wx.WXK_NUMPAD7 : const.PROJECTION_CONTOUR_LMIP, + wx.WXK_NUMPAD8 : const.PROJECTION_CONTOUR_MIDA,} + if self._flush_buffer: self.slice_.apply_slice_buffer_to_mask(self.orientation) @@ -1044,17 +1054,9 @@ class Viewer(wx.Panel): 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 + elif evt.GetKeyCode() in projections: + print "PROJECTION MANOLO!" + self.slice_._type_projection = projections[evt.GetKeyCode()] self.UpdateSlice3D(pos) self.interactor.Render() -- libgit2 0.21.2