Commit e23f8647c719f144393dbe2ab752893cc64145e3

Authored by Thiago Franco de Moraes
1 parent ec966667

Defined border in a object's variable

Showing 1 changed file with 24 additions and 10 deletions   Show diff stats
invesalius/data/slice_.py
... ... @@ -86,6 +86,7 @@ class Slice(object):
86 86 self._matrix = None
87 87  
88 88 self._type_projection = const.PROJECTION_MIDA
  89 + self.n_border = 3.0
89 90  
90 91 self.spacing = (1.0, 1.0, 1.0)
91 92  
... ... @@ -514,7 +515,7 @@ class Slice(object):
514 515 n_image = numpy.empty(shape=(tmp_array.shape[1],
515 516 tmp_array.shape[2]),
516 517 dtype=tmp_array.dtype)
517   - mips.fast_countour_mip(tmp_array, 0.2, 0, self.window_level,
  518 + mips.fast_countour_mip(tmp_array, self.n_border, 0, self.window_level,
518 519 self.window_level, 0, n_image)
519 520 elif self._type_projection == const.PROJECTION_CONTOUR_LMIP:
520 521 tmp_array = numpy.array(self.matrix[slice_number:
... ... @@ -522,7 +523,7 @@ class Slice(object):
522 523 n_image = numpy.empty(shape=(tmp_array.shape[1],
523 524 tmp_array.shape[2]),
524 525 dtype=tmp_array.dtype)
525   - mips.fast_countour_mip(tmp_array, 0.2, 0, self.window_level,
  526 + mips.fast_countour_mip(tmp_array, self.n_border, 0, self.window_level,
526 527 self.window_level, 1, n_image)
527 528 elif self._type_projection == const.PROJECTION_CONTOUR_MIDA:
528 529 tmp_array = numpy.array(self.matrix[slice_number:
... ... @@ -530,7 +531,7 @@ class Slice(object):
530 531 n_image = numpy.empty(shape=(tmp_array.shape[1],
531 532 tmp_array.shape[2]),
532 533 dtype=tmp_array.dtype)
533   - mips.fast_countour_mip(tmp_array, 0.2, 0, self.window_level,
  534 + mips.fast_countour_mip(tmp_array, self.n_border, 0, self.window_level,
534 535 self.window_level, 2, n_image)
535 536 else:
536 537 n_image = numpy.array(self.matrix[slice_number])
... ... @@ -567,7 +568,7 @@ class Slice(object):
567 568 n_image = numpy.empty(shape=(tmp_array.shape[0],
568 569 tmp_array.shape[2]),
569 570 dtype=tmp_array.dtype)
570   - mips.fast_countour_mip(tmp_array, 0.2, 1, self.window_level,
  571 + mips.fast_countour_mip(tmp_array, self.n_border, 1, self.window_level,
571 572 self.window_level, 0, n_image)
572 573 elif self._type_projection == const.PROJECTION_CONTOUR_LMIP:
573 574 tmp_array = numpy.array(self.matrix[..., slice_number:
... ... @@ -575,7 +576,7 @@ class Slice(object):
575 576 n_image = numpy.empty(shape=(tmp_array.shape[0],
576 577 tmp_array.shape[2]),
577 578 dtype=tmp_array.dtype)
578   - mips.fast_countour_mip(tmp_array, 0.2, 1, self.window_level,
  579 + mips.fast_countour_mip(tmp_array, self.n_border, 1, self.window_level,
579 580 self.window_level, 1, n_image)
580 581 elif self._type_projection == const.PROJECTION_CONTOUR_MIDA:
581 582 tmp_array = numpy.array(self.matrix[..., slice_number:
... ... @@ -583,7 +584,7 @@ class Slice(object):
583 584 n_image = numpy.empty(shape=(tmp_array.shape[0],
584 585 tmp_array.shape[2]),
585 586 dtype=tmp_array.dtype)
586   - mips.fast_countour_mip(tmp_array, 0.2, 1, self.window_level,
  587 + mips.fast_countour_mip(tmp_array, self.n_border, 1, self.window_level,
587 588 self.window_level, 2, n_image)
588 589 else:
589 590 n_image = numpy.array(self.matrix[..., slice_number, ...])
... ... @@ -620,7 +621,7 @@ class Slice(object):
620 621 n_image = numpy.empty(shape=(tmp_array.shape[0],
621 622 tmp_array.shape[1]),
622 623 dtype=tmp_array.dtype)
623   - mips.fast_countour_mip(tmp_array, 0.2, 2, self.window_level,
  624 + mips.fast_countour_mip(tmp_array, self.n_border, 2, self.window_level,
624 625 self.window_level, 0, n_image)
625 626 elif self._type_projection == const.PROJECTION_CONTOUR_LMIP:
626 627 tmp_array = numpy.array(self.matrix[..., ...,
... ... @@ -628,7 +629,7 @@ class Slice(object):
628 629 n_image = numpy.empty(shape=(tmp_array.shape[0],
629 630 tmp_array.shape[1]),
630 631 dtype=tmp_array.dtype)
631   - mips.fast_countour_mip(tmp_array, 0.2, 2, self.window_level,
  632 + mips.fast_countour_mip(tmp_array, self.n_border, 2, self.window_level,
632 633 self.window_level, 1, n_image)
633 634 elif self._type_projection == const.PROJECTION_CONTOUR_MIDA:
634 635 tmp_array = numpy.array(self.matrix[..., ...,
... ... @@ -636,7 +637,7 @@ class Slice(object):
636 637 n_image = numpy.empty(shape=(tmp_array.shape[0],
637 638 tmp_array.shape[1]),
638 639 dtype=tmp_array.dtype)
639   - mips.fast_countour_mip(tmp_array, 0.2, 2, self.window_level,
  640 + mips.fast_countour_mip(tmp_array, self.n_border, 2, self.window_level,
640 641 self.window_level, 2, n_image)
641 642 else:
642 643 n_image = numpy.array(self.matrix[..., ..., slice_number])
... ... @@ -832,6 +833,12 @@ class Slice(object):
832 833 def GetOutput(self):
833 834 return self.blend_filter.GetOutput()
834 835  
  836 + def SetTypeProjection(self, tprojection):
  837 + if self._type_projection != tprojection:
  838 + self._type_projection = tprojection
  839 + for buffer_ in self.buffer_slices.values():
  840 + buffer_.discard_buffer()
  841 +
835 842 def SetInput(self, imagedata, mask_dict):
836 843 print "SETINPUT!"
837 844 self.imagedata = imagedata
... ... @@ -891,7 +898,14 @@ class Slice(object):
891 898 self.window_level = level
892 899  
893 900 for buffer_ in self.buffer_slices.values():
894   - buffer_.discard_vtk_image()
  901 + if self._type_projection in (const.PROJECTION_NORMAL,
  902 + const.PROJECTION_MaxIP,
  903 + const.PROJECTION_MinIP,
  904 + const.PROJECTION_MeanIP,
  905 + const.PROJECTION_LMIP):
  906 + buffer_.discard_vtk_image()
  907 + else:
  908 + buffer_.discard_buffer()
895 909  
896 910 Publisher.sendMessage('Reload actual slice')
897 911  
... ...