Commit ec966667098bcc53f58a96910d310c6a89ed29d7
1 parent
95a04f4d
Exists in
master
and in
3 other branches
Added the min, mean, lmip and contours
Showing
2 changed files
with
100 additions
and
11 deletions
Show diff stats
invesalius/data/slice_.py
@@ -488,6 +488,19 @@ class Slice(object): | @@ -488,6 +488,19 @@ class Slice(object): | ||
488 | elif self._type_projection == const.PROJECTION_MaxIP: | 488 | elif self._type_projection == const.PROJECTION_MaxIP: |
489 | n_image = numpy.array(self.matrix[slice_number: | 489 | n_image = numpy.array(self.matrix[slice_number: |
490 | slice_number+number_slices]).max(0) | 490 | slice_number+number_slices]).max(0) |
491 | + elif self._type_projection == const.PROJECTION_MinIP: | ||
492 | + n_image = numpy.array(self.matrix[slice_number: | ||
493 | + slice_number+number_slices]).min(0) | ||
494 | + elif self._type_projection == const.PROJECTION_MeanIP: | ||
495 | + n_image = numpy.array(self.matrix[slice_number: | ||
496 | + slice_number+number_slices]).mean(0) | ||
497 | + elif self._type_projection == const.PROJECTION_LMIP: | ||
498 | + tmp_array = numpy.array(self.matrix[slice_number: | ||
499 | + slice_number + number_slices]) | ||
500 | + n_image = numpy.empty(shape=(tmp_array.shape[1], | ||
501 | + tmp_array.shape[2]), | ||
502 | + dtype=tmp_array.dtype) | ||
503 | + mips.lmip(tmp_array, 0, self.window_level, self.window_level, n_image) | ||
491 | elif self._type_projection == const.PROJECTION_MIDA: | 504 | elif self._type_projection == const.PROJECTION_MIDA: |
492 | tmp_array = numpy.array(self.matrix[slice_number: | 505 | tmp_array = numpy.array(self.matrix[slice_number: |
493 | slice_number + number_slices]) | 506 | slice_number + number_slices]) |
@@ -495,6 +508,22 @@ class Slice(object): | @@ -495,6 +508,22 @@ class Slice(object): | ||
495 | tmp_array.shape[2]), | 508 | tmp_array.shape[2]), |
496 | dtype=tmp_array.dtype) | 509 | dtype=tmp_array.dtype) |
497 | mips.mida(tmp_array, 0, self.window_level, self.window_level, n_image) | 510 | mips.mida(tmp_array, 0, self.window_level, self.window_level, n_image) |
511 | + elif self._type_projection == const.PROJECTION_CONTOUR_MIP: | ||
512 | + tmp_array = numpy.array(self.matrix[slice_number: | ||
513 | + slice_number + number_slices]) | ||
514 | + n_image = numpy.empty(shape=(tmp_array.shape[1], | ||
515 | + tmp_array.shape[2]), | ||
516 | + dtype=tmp_array.dtype) | ||
517 | + mips.fast_countour_mip(tmp_array, 0.2, 0, self.window_level, | ||
518 | + self.window_level, 0, n_image) | ||
519 | + elif self._type_projection == const.PROJECTION_CONTOUR_LMIP: | ||
520 | + tmp_array = numpy.array(self.matrix[slice_number: | ||
521 | + slice_number + number_slices]) | ||
522 | + n_image = numpy.empty(shape=(tmp_array.shape[1], | ||
523 | + tmp_array.shape[2]), | ||
524 | + dtype=tmp_array.dtype) | ||
525 | + mips.fast_countour_mip(tmp_array, 0.2, 0, self.window_level, | ||
526 | + self.window_level, 1, n_image) | ||
498 | elif self._type_projection == const.PROJECTION_CONTOUR_MIDA: | 527 | elif self._type_projection == const.PROJECTION_CONTOUR_MIDA: |
499 | tmp_array = numpy.array(self.matrix[slice_number: | 528 | tmp_array = numpy.array(self.matrix[slice_number: |
500 | slice_number + number_slices]) | 529 | slice_number + number_slices]) |
@@ -512,6 +541,19 @@ class Slice(object): | @@ -512,6 +541,19 @@ class Slice(object): | ||
512 | elif self._type_projection == const.PROJECTION_MaxIP: | 541 | elif self._type_projection == const.PROJECTION_MaxIP: |
513 | n_image = numpy.array(self.matrix[..., slice_number: | 542 | n_image = numpy.array(self.matrix[..., slice_number: |
514 | slice_number+number_slices, ...]).max(1) | 543 | slice_number+number_slices, ...]).max(1) |
544 | + elif self._type_projection == const.PROJECTION_MinIP: | ||
545 | + n_image = numpy.array(self.matrix[..., slice_number: | ||
546 | + slice_number+number_slices, ...]).min(1) | ||
547 | + elif self._type_projection == const.PROJECTION_MeanIP: | ||
548 | + n_image = numpy.array(self.matrix[..., slice_number: | ||
549 | + slice_number+number_slices, ...]).mean(1) | ||
550 | + elif self._type_projection == const.PROJECTION_LMIP: | ||
551 | + tmp_array = numpy.array(self.matrix[..., slice_number: | ||
552 | + slice_number + number_slices, ...]) | ||
553 | + n_image = numpy.empty(shape=(tmp_array.shape[0], | ||
554 | + tmp_array.shape[2]), | ||
555 | + dtype=tmp_array.dtype) | ||
556 | + mips.lmip(tmp_array, 1, self.window_level, self.window_level, n_image) | ||
515 | elif self._type_projection == const.PROJECTION_MIDA: | 557 | elif self._type_projection == const.PROJECTION_MIDA: |
516 | tmp_array = numpy.array(self.matrix[..., slice_number: | 558 | tmp_array = numpy.array(self.matrix[..., slice_number: |
517 | slice_number + number_slices, ...]) | 559 | slice_number + number_slices, ...]) |
@@ -519,6 +561,22 @@ class Slice(object): | @@ -519,6 +561,22 @@ class Slice(object): | ||
519 | tmp_array.shape[2]), | 561 | tmp_array.shape[2]), |
520 | dtype=tmp_array.dtype) | 562 | dtype=tmp_array.dtype) |
521 | mips.mida(tmp_array, 1, self.window_level, self.window_level, n_image) | 563 | mips.mida(tmp_array, 1, self.window_level, self.window_level, n_image) |
564 | + elif self._type_projection == const.PROJECTION_CONTOUR_MIP: | ||
565 | + tmp_array = numpy.array(self.matrix[..., slice_number: | ||
566 | + slice_number + number_slices, ...]) | ||
567 | + n_image = numpy.empty(shape=(tmp_array.shape[0], | ||
568 | + tmp_array.shape[2]), | ||
569 | + dtype=tmp_array.dtype) | ||
570 | + mips.fast_countour_mip(tmp_array, 0.2, 1, self.window_level, | ||
571 | + self.window_level, 0, n_image) | ||
572 | + elif self._type_projection == const.PROJECTION_CONTOUR_LMIP: | ||
573 | + tmp_array = numpy.array(self.matrix[..., slice_number: | ||
574 | + slice_number + number_slices, ...]) | ||
575 | + n_image = numpy.empty(shape=(tmp_array.shape[0], | ||
576 | + tmp_array.shape[2]), | ||
577 | + dtype=tmp_array.dtype) | ||
578 | + mips.fast_countour_mip(tmp_array, 0.2, 1, self.window_level, | ||
579 | + self.window_level, 1, n_image) | ||
522 | elif self._type_projection == const.PROJECTION_CONTOUR_MIDA: | 580 | elif self._type_projection == const.PROJECTION_CONTOUR_MIDA: |
523 | tmp_array = numpy.array(self.matrix[..., slice_number: | 581 | tmp_array = numpy.array(self.matrix[..., slice_number: |
524 | slice_number + number_slices, ...]) | 582 | slice_number + number_slices, ...]) |
@@ -535,6 +593,19 @@ class Slice(object): | @@ -535,6 +593,19 @@ class Slice(object): | ||
535 | elif self._type_projection == const.PROJECTION_MaxIP: | 593 | elif self._type_projection == const.PROJECTION_MaxIP: |
536 | n_image = numpy.array(self.matrix[..., ..., slice_number: | 594 | n_image = numpy.array(self.matrix[..., ..., slice_number: |
537 | slice_number+number_slices]).max(2) | 595 | slice_number+number_slices]).max(2) |
596 | + elif self._type_projection == const.PROJECTION_MinIP: | ||
597 | + n_image = numpy.array(self.matrix[..., ..., slice_number: | ||
598 | + slice_number+number_slices]).min(2) | ||
599 | + elif self._type_projection == const.PROJECTION_MeanIP: | ||
600 | + n_image = numpy.array(self.matrix[..., ..., slice_number: | ||
601 | + slice_number+number_slices]).mean(2) | ||
602 | + elif self._type_projection == const.PROJECTION_LMIP: | ||
603 | + tmp_array = numpy.array(self.matrix[..., ..., | ||
604 | + slice_number: slice_number + number_slices]) | ||
605 | + n_image = numpy.empty(shape=(tmp_array.shape[0], | ||
606 | + tmp_array.shape[1]), | ||
607 | + dtype=tmp_array.dtype) | ||
608 | + mips.lmip(tmp_array, 2, self.window_level, self.window_level, n_image) | ||
538 | elif self._type_projection == const.PROJECTION_MIDA: | 609 | elif self._type_projection == const.PROJECTION_MIDA: |
539 | tmp_array = numpy.array(self.matrix[..., ..., | 610 | tmp_array = numpy.array(self.matrix[..., ..., |
540 | slice_number: slice_number + number_slices]) | 611 | slice_number: slice_number + number_slices]) |
@@ -543,6 +614,22 @@ class Slice(object): | @@ -543,6 +614,22 @@ class Slice(object): | ||
543 | dtype=tmp_array.dtype) | 614 | dtype=tmp_array.dtype) |
544 | mips.mida(tmp_array, 2, self.window_level, self.window_level, n_image) | 615 | mips.mida(tmp_array, 2, self.window_level, self.window_level, n_image) |
545 | 616 | ||
617 | + elif self._type_projection == const.PROJECTION_CONTOUR_MIP: | ||
618 | + tmp_array = numpy.array(self.matrix[..., ..., | ||
619 | + slice_number: slice_number + number_slices]) | ||
620 | + n_image = numpy.empty(shape=(tmp_array.shape[0], | ||
621 | + tmp_array.shape[1]), | ||
622 | + dtype=tmp_array.dtype) | ||
623 | + mips.fast_countour_mip(tmp_array, 0.2, 2, self.window_level, | ||
624 | + self.window_level, 0, n_image) | ||
625 | + elif self._type_projection == const.PROJECTION_CONTOUR_LMIP: | ||
626 | + tmp_array = numpy.array(self.matrix[..., ..., | ||
627 | + slice_number: slice_number + number_slices]) | ||
628 | + n_image = numpy.empty(shape=(tmp_array.shape[0], | ||
629 | + tmp_array.shape[1]), | ||
630 | + dtype=tmp_array.dtype) | ||
631 | + mips.fast_countour_mip(tmp_array, 0.2, 2, self.window_level, | ||
632 | + self.window_level, 1, n_image) | ||
546 | elif self._type_projection == const.PROJECTION_CONTOUR_MIDA: | 633 | elif self._type_projection == const.PROJECTION_CONTOUR_MIDA: |
547 | tmp_array = numpy.array(self.matrix[..., ..., | 634 | tmp_array = numpy.array(self.matrix[..., ..., |
548 | slice_number: slice_number + number_slices]) | 635 | slice_number: slice_number + number_slices]) |
invesalius/data/viewer_slice.py
@@ -1022,6 +1022,16 @@ class Viewer(wx.Panel): | @@ -1022,6 +1022,16 @@ class Viewer(wx.Panel): | ||
1022 | min = 0 | 1022 | min = 0 |
1023 | max = self.slice_.GetMaxSliceNumber(self.orientation) | 1023 | max = self.slice_.GetMaxSliceNumber(self.orientation) |
1024 | 1024 | ||
1025 | + projections = {wx.WXK_NUMPAD0 : const.PROJECTION_NORMAL, | ||
1026 | + wx.WXK_NUMPAD1 : const.PROJECTION_MaxIP, | ||
1027 | + wx.WXK_NUMPAD2 : const.PROJECTION_MinIP, | ||
1028 | + wx.WXK_NUMPAD3 : const.PROJECTION_MeanIP, | ||
1029 | + wx.WXK_NUMPAD4 : const.PROJECTION_LMIP, | ||
1030 | + wx.WXK_NUMPAD5 : const.PROJECTION_MIDA, | ||
1031 | + wx.WXK_NUMPAD6 : const.PROJECTION_CONTOUR_MIP, | ||
1032 | + wx.WXK_NUMPAD7 : const.PROJECTION_CONTOUR_LMIP, | ||
1033 | + wx.WXK_NUMPAD8 : const.PROJECTION_CONTOUR_MIDA,} | ||
1034 | + | ||
1025 | if self._flush_buffer: | 1035 | if self._flush_buffer: |
1026 | self.slice_.apply_slice_buffer_to_mask(self.orientation) | 1036 | self.slice_.apply_slice_buffer_to_mask(self.orientation) |
1027 | 1037 | ||
@@ -1044,17 +1054,9 @@ class Viewer(wx.Panel): | @@ -1044,17 +1054,9 @@ class Viewer(wx.Panel): | ||
1044 | print "Subtracting", self.number_slices | 1054 | print "Subtracting", self.number_slices |
1045 | self.OnScrollBar() | 1055 | self.OnScrollBar() |
1046 | 1056 | ||
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 | 1057 | + elif evt.GetKeyCode() in projections: |
1058 | + print "PROJECTION MANOLO!" | ||
1059 | + self.slice_._type_projection = projections[evt.GetKeyCode()] | ||
1058 | 1060 | ||
1059 | self.UpdateSlice3D(pos) | 1061 | self.UpdateSlice3D(pos) |
1060 | self.interactor.Render() | 1062 | self.interactor.Render() |