Commit 6fdc80c1f63c7b10fe9acb844bece8e072ac7162
1 parent
c5ede16c
Exists in
master
and in
6 other branches
ENH: Edited mask to load project
Showing
2 changed files
with
12 additions
and
9 deletions
Show diff stats
invesalius/data/mask.py
@@ -72,11 +72,10 @@ class Mask(): | @@ -72,11 +72,10 @@ class Mask(): | ||
72 | edited_points = {} | 72 | edited_points = {} |
73 | for p in mask[key]: | 73 | for p in mask[key]: |
74 | k = [float(i) for i in p.replace('(', '').replace(')', '').split(',')] | 74 | k = [float(i) for i in p.replace('(', '').replace(')', '').split(',')] |
75 | - print k | ||
76 | edited_points[tuple(k)] = mask[key][p] | 75 | edited_points[tuple(k)] = mask[key][p] |
76 | + | ||
77 | setattr(self, key, edited_points) | 77 | setattr(self, key, edited_points) |
78 | else: | 78 | else: |
79 | setattr(self, key, mask[key]) | 79 | setattr(self, key, mask[key]) |
80 | - print "edited points", self.edited_points | ||
81 | 80 | ||
82 | 81 |
invesalius/data/slice_.py
@@ -333,7 +333,6 @@ class Slice(object): | @@ -333,7 +333,6 @@ class Slice(object): | ||
333 | else: | 333 | else: |
334 | self.__load_masks(imagedata, mask_dict) | 334 | self.__load_masks(imagedata, mask_dict) |
335 | imagedata_mask = self.img_colours_mask.GetOutput() | 335 | imagedata_mask = self.img_colours_mask.GetOutput() |
336 | - | ||
337 | 336 | ||
338 | 337 | ||
339 | mask_opacity = self.current_mask.opacity | 338 | mask_opacity = self.current_mask.opacity |
@@ -526,8 +525,6 @@ class Slice(object): | @@ -526,8 +525,6 @@ class Slice(object): | ||
526 | ps.Publisher().sendMessage('Change mask selected', mask.index) | 525 | ps.Publisher().sendMessage('Change mask selected', mask.index) |
527 | ps.Publisher().sendMessage('Update slice viewer') | 526 | ps.Publisher().sendMessage('Update slice viewer') |
528 | 527 | ||
529 | - | ||
530 | - | ||
531 | def __build_mask(self, imagedata, create=True): | 528 | def __build_mask(self, imagedata, create=True): |
532 | # create new mask instance and insert it into project | 529 | # create new mask instance and insert it into project |
533 | if create: | 530 | if create: |
@@ -551,16 +548,23 @@ class Slice(object): | @@ -551,16 +548,23 @@ class Slice(object): | ||
551 | lut_mask.SetRampToLinear() | 548 | lut_mask.SetRampToLinear() |
552 | lut_mask.Build() | 549 | lut_mask.Build() |
553 | self.lut_mask = lut_mask | 550 | self.lut_mask = lut_mask |
554 | - | ||
555 | - # threshold pipeline | 551 | + |
556 | mask_thresh_imagedata = self.__create_mask_threshold(imagedata) | 552 | mask_thresh_imagedata = self.__create_mask_threshold(imagedata) |
557 | - current_mask.imagedata.DeepCopy(mask_thresh_imagedata) | ||
558 | - | 553 | + |
554 | + if create: | ||
555 | + # threshold pipeline | ||
556 | + current_mask.imagedata.DeepCopy(mask_thresh_imagedata) | ||
557 | + else: | ||
558 | + mask_thresh_imagedata = vtk.vtkImageData() | ||
559 | + mask_thresh_imagedata.DeepCopy(self.current_mask.imagedata) | ||
560 | + | ||
559 | # map the input image through a lookup table | 561 | # map the input image through a lookup table |
560 | img_colours_mask = vtk.vtkImageMapToColors() | 562 | img_colours_mask = vtk.vtkImageMapToColors() |
561 | img_colours_mask.SetOutputFormatToRGBA() | 563 | img_colours_mask.SetOutputFormatToRGBA() |
562 | img_colours_mask.SetLookupTable(lut_mask) | 564 | img_colours_mask.SetLookupTable(lut_mask) |
565 | + | ||
563 | img_colours_mask.SetInput(mask_thresh_imagedata) | 566 | img_colours_mask.SetInput(mask_thresh_imagedata) |
567 | + | ||
564 | self.img_colours_mask = img_colours_mask | 568 | self.img_colours_mask = img_colours_mask |
565 | 569 | ||
566 | return img_colours_mask.GetOutput() | 570 | return img_colours_mask.GetOutput() |