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 543 'ISO_IR 138': 'iso_ir_138',
544 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 85 self.histogram = None
86 86 self._matrix = None
87 87  
88   - self._type_projection = 'MIDA CONTOUR'
  88 + self._type_projection = const.PROJECTION_MIDA
89 89  
90 90 self.spacing = (1.0, 1.0, 1.0)
91 91  
... ... @@ -427,7 +427,7 @@ class Slice(object):
427 427  
428 428 def GetSlices(self, orientation, slice_number, number_slices):
429 429 if self.buffer_slices[orientation].index == slice_number and \
430   - self._type_projection == 'NORMAL':
  430 + self._type_projection == const.PROJECTION_NORMAL:
431 431 if self.buffer_slices[orientation].vtk_image:
432 432 image = self.buffer_slices[orientation].vtk_image
433 433 else:
... ... @@ -481,8 +481,21 @@ class Slice(object):
481 481 and self.buffer_slices[orientation].image is not None:
482 482 n_image = self.buffer_slices[orientation].image
483 483 else:
  484 +
484 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 499 tmp_array = numpy.array(self.matrix[slice_number:
487 500 slice_number + number_slices])
488 501 n_image = numpy.empty(shape=(tmp_array.shape[1],
... ... @@ -492,8 +505,21 @@ class Slice(object):
492 505 self.window_level, 2, n_image)
493 506 else:
494 507 n_image = numpy.array(self.matrix[slice_number])
  508 +
495 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 523 tmp_array = numpy.array(self.matrix[..., slice_number:
498 524 slice_number + number_slices, ...])
499 525 n_image = numpy.empty(shape=(tmp_array.shape[0],
... ... @@ -504,7 +530,20 @@ class Slice(object):
504 530 else:
505 531 n_image = numpy.array(self.matrix[..., slice_number, ...])
506 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 547 tmp_array = numpy.array(self.matrix[..., ...,
509 548 slice_number: slice_number + number_slices])
510 549 n_image = numpy.empty(shape=(tmp_array.shape[0],
... ...
invesalius/data/viewer_slice.py
... ... @@ -1043,6 +1043,18 @@ class Viewer(wx.Panel):
1043 1043 self.number_slices -= 1
1044 1044 print "Subtracting", self.number_slices
1045 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 1059 self.UpdateSlice3D(pos)
1048 1060 self.interactor.Render()
... ...