Commit 95a04f4da8a476f3abf0dc66f260502da9364892

Authored by Thiago Franco de Moraes
1 parent c36746ee

Using the number keyboard to set the mip type

invesalius/constants.py
@@ -543,3 +543,14 @@ DICOM_ENCODING_TO_PYTHON = { @@ -543,3 +543,14 @@ DICOM_ENCODING_TO_PYTHON = {
543 'ISO_IR 138': 'iso_ir_138', 543 'ISO_IR 138': 'iso_ir_138',
544 'ISO_IR 144': 'iso_ir_144', 544 'ISO_IR 144': 'iso_ir_144',
545 } 545 }
  546 +
  547 +#-------------------- Projections type ----------------
  548 +PROJECTION_NORMAL=0
  549 +PROJECTION_MaxIP=1
  550 +PROJECTION_MinIP=2
  551 +PROJECTION_MeanIP=3
  552 +PROJECTION_LMIP=4
  553 +PROJECTION_MIDA=5
  554 +PROJECTION_CONTOUR_MIP=6
  555 +PROJECTION_CONTOUR_LMIP=7
  556 +PROJECTION_CONTOUR_MIDA=8
invesalius/data/slice_.py
@@ -85,7 +85,7 @@ class Slice(object): @@ -85,7 +85,7 @@ class Slice(object):
85 self.histogram = None 85 self.histogram = None
86 self._matrix = None 86 self._matrix = None
87 87
88 - self._type_projection = 'MIDA CONTOUR' 88 + self._type_projection = const.PROJECTION_MIDA
89 89
90 self.spacing = (1.0, 1.0, 1.0) 90 self.spacing = (1.0, 1.0, 1.0)
91 91
@@ -427,7 +427,7 @@ class Slice(object): @@ -427,7 +427,7 @@ class Slice(object):
427 427
428 def GetSlices(self, orientation, slice_number, number_slices): 428 def GetSlices(self, orientation, slice_number, number_slices):
429 if self.buffer_slices[orientation].index == slice_number and \ 429 if self.buffer_slices[orientation].index == slice_number and \
430 - self._type_projection == 'NORMAL': 430 + self._type_projection == const.PROJECTION_NORMAL:
431 if self.buffer_slices[orientation].vtk_image: 431 if self.buffer_slices[orientation].vtk_image:
432 image = self.buffer_slices[orientation].vtk_image 432 image = self.buffer_slices[orientation].vtk_image
433 else: 433 else:
@@ -481,8 +481,21 @@ class Slice(object): @@ -481,8 +481,21 @@ class Slice(object):
481 and self.buffer_slices[orientation].image is not None: 481 and self.buffer_slices[orientation].image is not None:
482 n_image = self.buffer_slices[orientation].image 482 n_image = self.buffer_slices[orientation].image
483 else: 483 else:
  484 +
484 if orientation == 'AXIAL': 485 if orientation == 'AXIAL':
485 - if self._type_projection == 'MIDA CONTOUR': 486 + if self._type_projection == const.PROJECTION_NORMAL:
  487 + n_image = numpy.array(self.matrix[slice_number])
  488 + elif self._type_projection == const.PROJECTION_MaxIP:
  489 + n_image = numpy.array(self.matrix[slice_number:
  490 + slice_number+number_slices]).max(0)
  491 + elif self._type_projection == const.PROJECTION_MIDA:
  492 + tmp_array = numpy.array(self.matrix[slice_number:
  493 + slice_number + number_slices])
  494 + n_image = numpy.empty(shape=(tmp_array.shape[1],
  495 + tmp_array.shape[2]),
  496 + dtype=tmp_array.dtype)
  497 + mips.mida(tmp_array, 0, self.window_level, self.window_level, n_image)
  498 + elif self._type_projection == const.PROJECTION_CONTOUR_MIDA:
486 tmp_array = numpy.array(self.matrix[slice_number: 499 tmp_array = numpy.array(self.matrix[slice_number:
487 slice_number + number_slices]) 500 slice_number + number_slices])
488 n_image = numpy.empty(shape=(tmp_array.shape[1], 501 n_image = numpy.empty(shape=(tmp_array.shape[1],
@@ -492,8 +505,21 @@ class Slice(object): @@ -492,8 +505,21 @@ class Slice(object):
492 self.window_level, 2, n_image) 505 self.window_level, 2, n_image)
493 else: 506 else:
494 n_image = numpy.array(self.matrix[slice_number]) 507 n_image = numpy.array(self.matrix[slice_number])
  508 +
495 elif orientation == 'CORONAL': 509 elif orientation == 'CORONAL':
496 - if self._type_projection == 'MIDA CONTOUR': 510 + if self._type_projection == const.PROJECTION_NORMAL:
  511 + n_image = numpy.array(self.matrix[..., slice_number, ...])
  512 + elif self._type_projection == const.PROJECTION_MaxIP:
  513 + n_image = numpy.array(self.matrix[..., slice_number:
  514 + slice_number+number_slices, ...]).max(1)
  515 + elif self._type_projection == const.PROJECTION_MIDA:
  516 + tmp_array = numpy.array(self.matrix[..., slice_number:
  517 + slice_number + number_slices, ...])
  518 + n_image = numpy.empty(shape=(tmp_array.shape[0],
  519 + tmp_array.shape[2]),
  520 + dtype=tmp_array.dtype)
  521 + mips.mida(tmp_array, 1, self.window_level, self.window_level, n_image)
  522 + elif self._type_projection == const.PROJECTION_CONTOUR_MIDA:
497 tmp_array = numpy.array(self.matrix[..., slice_number: 523 tmp_array = numpy.array(self.matrix[..., slice_number:
498 slice_number + number_slices, ...]) 524 slice_number + number_slices, ...])
499 n_image = numpy.empty(shape=(tmp_array.shape[0], 525 n_image = numpy.empty(shape=(tmp_array.shape[0],
@@ -504,7 +530,20 @@ class Slice(object): @@ -504,7 +530,20 @@ class Slice(object):
504 else: 530 else:
505 n_image = numpy.array(self.matrix[..., slice_number, ...]) 531 n_image = numpy.array(self.matrix[..., slice_number, ...])
506 elif orientation == 'SAGITAL': 532 elif orientation == 'SAGITAL':
507 - if self._type_projection == 'MIDA CONTOUR': 533 + if self._type_projection == const.PROJECTION_NORMAL:
  534 + n_image = numpy.array(self.matrix[..., ..., slice_number])
  535 + elif self._type_projection == const.PROJECTION_MaxIP:
  536 + n_image = numpy.array(self.matrix[..., ..., slice_number:
  537 + slice_number+number_slices]).max(2)
  538 + elif self._type_projection == const.PROJECTION_MIDA:
  539 + tmp_array = numpy.array(self.matrix[..., ...,
  540 + slice_number: slice_number + number_slices])
  541 + n_image = numpy.empty(shape=(tmp_array.shape[0],
  542 + tmp_array.shape[1]),
  543 + dtype=tmp_array.dtype)
  544 + mips.mida(tmp_array, 2, self.window_level, self.window_level, n_image)
  545 +
  546 + elif self._type_projection == const.PROJECTION_CONTOUR_MIDA:
508 tmp_array = numpy.array(self.matrix[..., ..., 547 tmp_array = numpy.array(self.matrix[..., ...,
509 slice_number: slice_number + number_slices]) 548 slice_number: slice_number + number_slices])
510 n_image = numpy.empty(shape=(tmp_array.shape[0], 549 n_image = numpy.empty(shape=(tmp_array.shape[0],
invesalius/data/viewer_slice.py
@@ -1043,6 +1043,18 @@ class Viewer(wx.Panel): @@ -1043,6 +1043,18 @@ class Viewer(wx.Panel):
1043 self.number_slices -= 1 1043 self.number_slices -= 1
1044 print "Subtracting", self.number_slices 1044 print "Subtracting", self.number_slices
1045 self.OnScrollBar() 1045 self.OnScrollBar()
  1046 +
  1047 + elif (evt.GetKeyCode() == wx.WXK_NUMPAD0):
  1048 + self.slice_._type_projection = const.PRJECTION_NORMAL
  1049 +
  1050 + elif (evt.GetKeyCode() == wx.WXK_NUMPAD1):
  1051 + self.slice_._type_projection = const.PROJECTION_MaxIP
  1052 +
  1053 + elif (evt.GetKeyCode() == wx.WXK_NUMPAD5):
  1054 + self.slice_._type_projection = const.PROJECTION_MIDA
  1055 +
  1056 + elif (evt.GetKeyCode() == wx.WXK_NUMPAD8):
  1057 + self.slice_._type_projection = const.PROJECTION_CONTOUR_MIDA
1046 1058
1047 self.UpdateSlice3D(pos) 1059 self.UpdateSlice3D(pos)
1048 self.interactor.Render() 1060 self.interactor.Render()