Commit be816908c9bb2c9136e834c9307e37f5894cf264
Exists in
master
and in
46 other branches
Merge pull request #26 from tfmoraes/clean
Clean - This pull request cleans some old and unused codes.
Showing
5 changed files
with
26 additions
and
306 deletions
Show diff stats
invesalius/control.py
invesalius/data/slice_.py
| ... | ... | @@ -16,7 +16,6 @@ |
| 16 | 16 | # PARTICULAR. Consulte a Licenca Publica Geral GNU para obter mais |
| 17 | 17 | # detalhes. |
| 18 | 18 | #-------------------------------------------------------------------------- |
| 19 | -import math | |
| 20 | 19 | import os |
| 21 | 20 | import tempfile |
| 22 | 21 | |
| ... | ... | @@ -79,7 +78,6 @@ class Slice(object): |
| 79 | 78 | # Therefore, we use Singleton design pattern for implementing it. |
| 80 | 79 | |
| 81 | 80 | def __init__(self): |
| 82 | - self.imagedata = None | |
| 83 | 81 | self.current_mask = None |
| 84 | 82 | self.blend_filter = None |
| 85 | 83 | self.histogram = None |
| ... | ... | @@ -159,9 +157,8 @@ class Slice(object): |
| 159 | 157 | |
| 160 | 158 | Publisher.subscribe(self.UpdateColourTableBackgroundWidget,\ |
| 161 | 159 | 'Change colour table from background image from widget') |
| 162 | - Publisher.subscribe(self._set_projection_type, 'Set projection type') | |
| 163 | 160 | |
| 164 | - Publisher.subscribe(self.InputImageWidget, 'Input Image in the widget') | |
| 161 | + Publisher.subscribe(self._set_projection_type, 'Set projection type') | |
| 165 | 162 | |
| 166 | 163 | Publisher.subscribe(self.OnExportMask,'Export mask to file') |
| 167 | 164 | |
| ... | ... | @@ -249,7 +246,6 @@ class Slice(object): |
| 249 | 246 | self.CloseProject() |
| 250 | 247 | |
| 251 | 248 | def CloseProject(self): |
| 252 | - self.imagedata = None | |
| 253 | 249 | f = self._matrix.filename |
| 254 | 250 | self._matrix._mmap.close() |
| 255 | 251 | self._matrix = None |
| ... | ... | @@ -276,10 +272,6 @@ class Slice(object): |
| 276 | 272 | |
| 277 | 273 | Publisher.sendMessage('Select first item from slice menu') |
| 278 | 274 | |
| 279 | - #self.blend_filter = None | |
| 280 | - #self.blend_filter = None | |
| 281 | - #self.num_gradient = 0 | |
| 282 | - | |
| 283 | 275 | def __set_current_mask_threshold_limits(self, pubsub_evt): |
| 284 | 276 | thresh_min = pubsub_evt.data[0] |
| 285 | 277 | thresh_max = pubsub_evt.data[1] |
| ... | ... | @@ -287,10 +279,6 @@ class Slice(object): |
| 287 | 279 | index = self.current_mask.index |
| 288 | 280 | self.SetMaskEditionThreshold(index, (thresh_min, thresh_max)) |
| 289 | 281 | |
| 290 | - #--------------------------------------------------------------------------- | |
| 291 | - # BEGIN PUBSUB_EVT METHODS | |
| 292 | - #--------------------------------------------------------------------------- | |
| 293 | - | |
| 294 | 282 | def __add_mask(self, pubsub_evt): |
| 295 | 283 | mask_name = pubsub_evt.data |
| 296 | 284 | self.CreateMask(name=mask_name) |
| ... | ... | @@ -308,7 +296,7 @@ class Slice(object): |
| 308 | 296 | def __select_current_mask(self, pubsub_evt): |
| 309 | 297 | mask_index = pubsub_evt.data |
| 310 | 298 | self.SelectCurrentMask(mask_index) |
| 311 | - #--------------------------------------------------------------------------- | |
| 299 | + | |
| 312 | 300 | def __set_current_mask_edition_threshold(self, evt_pubsub): |
| 313 | 301 | if self.current_mask: |
| 314 | 302 | threshold_range = evt_pubsub.data |
| ... | ... | @@ -324,7 +312,6 @@ class Slice(object): |
| 324 | 312 | |
| 325 | 313 | to_reload = False |
| 326 | 314 | if threshold_range != self.current_mask.threshold_range: |
| 327 | - print "<<<<<<<<<<<<<<<< DIFERENT >>>>>>>>>>>>>>>>>>>>>>>" | |
| 328 | 315 | to_reload = True |
| 329 | 316 | for orientation in self.buffer_slices: |
| 330 | 317 | self.buffer_slices[orientation].discard_vtk_mask() |
| ... | ... | @@ -836,19 +823,12 @@ class Slice(object): |
| 836 | 823 | |
| 837 | 824 | def SelectCurrentMask(self, index): |
| 838 | 825 | "Insert mask data, based on given index, into pipeline." |
| 839 | - # This condition is not necessary in Linux, only under mac and windows | |
| 840 | - # because combobox event is binded when the same item is selected again. | |
| 841 | - #if index != self.current_mask.index: | |
| 842 | - print "SelectCurrentMask" | |
| 843 | - print "index:", index | |
| 844 | 826 | proj = Project() |
| 845 | 827 | future_mask = proj.GetMask(index) |
| 846 | 828 | future_mask.is_shown = True |
| 847 | 829 | self.current_mask = future_mask |
| 848 | 830 | |
| 849 | 831 | colour = future_mask.colour |
| 850 | - #index = future_mask.index | |
| 851 | - print index | |
| 852 | 832 | self.SetMaskColour(index, colour, update=False) |
| 853 | 833 | |
| 854 | 834 | self.buffer_slices = {"AXIAL": SliceBuffer(), |
| ... | ... | @@ -871,18 +851,9 @@ class Slice(object): |
| 871 | 851 | proj = Project() |
| 872 | 852 | mask = proj.mask_dict[surface_parameters['options']['index']] |
| 873 | 853 | |
| 874 | - # This is very important. Do not use masks' imagedata. It would mess up | |
| 875 | - # surface quality event when using contour | |
| 876 | - #self.SetMaskThreshold(mask.index, threshold) | |
| 877 | - for n in xrange(1, mask.matrix.shape[0]): | |
| 878 | - if mask.matrix[n, 0, 0] == 0: | |
| 879 | - m = mask.matrix[n, 1:, 1:] | |
| 880 | - mask.matrix[n, 1:, 1:] = self.do_threshold_to_a_slice(self.matrix[n-1], m) | |
| 881 | - | |
| 882 | - mask.matrix.flush() | |
| 854 | + self.do_threshold_to_all_slices(mask) | |
| 855 | + Publisher.sendMessage('Create surface', (self, mask, surface_parameters)) | |
| 883 | 856 | |
| 884 | - Publisher.sendMessage('Create surface', (self, mask, | |
| 885 | - surface_parameters)) | |
| 886 | 857 | def GetOutput(self): |
| 887 | 858 | return self.blend_filter.GetOutput() |
| 888 | 859 | |
| ... | ... | @@ -906,59 +877,6 @@ class Slice(object): |
| 906 | 877 | |
| 907 | 878 | Publisher.sendMessage('Check projection menu', tprojection) |
| 908 | 879 | |
| 909 | - def SetInput(self, imagedata, mask_dict): | |
| 910 | - print "SETINPUT!" | |
| 911 | - self.imagedata = imagedata | |
| 912 | - self.extent = imagedata.GetExtent() | |
| 913 | - | |
| 914 | - imagedata_bg = self.__create_background(imagedata) | |
| 915 | - | |
| 916 | - if not mask_dict: | |
| 917 | - imagedata_mask = self.__build_mask(imagedata, create=True) | |
| 918 | - else: | |
| 919 | - self.__load_masks(imagedata, mask_dict) | |
| 920 | - imagedata_mask = self.img_colours_mask.GetOutput() | |
| 921 | - | |
| 922 | - mask_opacity = self.current_mask.opacity | |
| 923 | - | |
| 924 | - # blend both imagedatas, so it can be inserted into viewer | |
| 925 | - blend_filter = vtk.vtkImageBlend() | |
| 926 | - blend_filter.SetBlendModeToNormal() | |
| 927 | - blend_filter.SetOpacity(0, 1) | |
| 928 | - if self.current_mask.is_shown: | |
| 929 | - blend_filter.SetOpacity(1, mask_opacity) | |
| 930 | - else: | |
| 931 | - blend_filter.SetOpacity(1, 0) | |
| 932 | - blend_filter.SetInput(0, imagedata_bg) | |
| 933 | - blend_filter.SetInput(1, imagedata_mask) | |
| 934 | - blend_filter.SetBlendModeToNormal() | |
| 935 | - blend_filter.GetOutput().ReleaseDataFlagOn() | |
| 936 | - self.blend_filter = blend_filter | |
| 937 | - | |
| 938 | - self.window_level = vtk.vtkImageMapToWindowLevelColors() | |
| 939 | - self.window_level.SetInput(self.imagedata) | |
| 940 | - | |
| 941 | - def __create_background(self, imagedata): | |
| 942 | - thresh_min, thresh_max = imagedata.GetScalarRange() | |
| 943 | - Publisher.sendMessage('Update threshold limits list', (thresh_min, | |
| 944 | - thresh_max)) | |
| 945 | - | |
| 946 | - # map scalar values into colors | |
| 947 | - lut_bg = self.lut_bg = vtk.vtkLookupTable() | |
| 948 | - lut_bg.SetTableRange(thresh_min, thresh_max) | |
| 949 | - lut_bg.SetSaturationRange(0, 0) | |
| 950 | - lut_bg.SetHueRange(0, 0) | |
| 951 | - lut_bg.SetValueRange(0, 1) | |
| 952 | - lut_bg.Build() | |
| 953 | - | |
| 954 | - # map the input image through a lookup table | |
| 955 | - img_colours_bg = self.img_colours_bg = vtk.vtkImageMapToColors() | |
| 956 | - img_colours_bg.SetOutputFormatToRGBA() | |
| 957 | - img_colours_bg.SetLookupTable(lut_bg) | |
| 958 | - img_colours_bg.SetInput(imagedata) | |
| 959 | - | |
| 960 | - return img_colours_bg.GetOutput() | |
| 961 | - | |
| 962 | 880 | def UpdateWindowLevelBackground(self, pubsub_evt): |
| 963 | 881 | window, level = pubsub_evt.data |
| 964 | 882 | self.window_width = window |
| ... | ... | @@ -1017,29 +935,6 @@ class Slice(object): |
| 1017 | 935 | |
| 1018 | 936 | Publisher.sendMessage('Reload actual slice') |
| 1019 | 937 | |
| 1020 | - def InputImageWidget(self, pubsub_evt): | |
| 1021 | - widget, orientation = pubsub_evt.data | |
| 1022 | - | |
| 1023 | - original_orientation = Project().original_orientation | |
| 1024 | - | |
| 1025 | - img = self.buffer_slices[orientation].vtk_image | |
| 1026 | - | |
| 1027 | - cast = vtk.vtkImageCast() | |
| 1028 | - cast.SetInput(img) | |
| 1029 | - cast.SetOutputScalarTypeToDouble() | |
| 1030 | - cast.ClampOverflowOn() | |
| 1031 | - cast.Update() | |
| 1032 | - | |
| 1033 | - #if (original_orientation == const.AXIAL): | |
| 1034 | - flip = vtk.vtkImageFlip() | |
| 1035 | - flip.SetInput(cast.GetOutput()) | |
| 1036 | - flip.SetFilteredAxis(1) | |
| 1037 | - flip.FlipAboutOriginOn() | |
| 1038 | - flip.Update() | |
| 1039 | - widget.SetInput(flip.GetOutput()) | |
| 1040 | - #else: | |
| 1041 | - #widget.SetInput(cast.GetOutput()) | |
| 1042 | - | |
| 1043 | 938 | def UpdateSlice3D(self, pubsub_evt): |
| 1044 | 939 | widget, orientation = pubsub_evt.data |
| 1045 | 940 | img = self.buffer_slices[orientation].vtk_image |
| ... | ... | @@ -1111,27 +1006,6 @@ class Slice(object): |
| 1111 | 1006 | Publisher.sendMessage('Change mask selected', mask.index) |
| 1112 | 1007 | Publisher.sendMessage('Update slice viewer') |
| 1113 | 1008 | |
| 1114 | - def __load_masks(self, imagedata, mask_dict): | |
| 1115 | - keys = mask_dict.keys() | |
| 1116 | - keys.sort() | |
| 1117 | - for key in keys: | |
| 1118 | - mask = mask_dict[key] | |
| 1119 | - | |
| 1120 | - # update gui related to mask | |
| 1121 | - utils.debug("__load_masks") | |
| 1122 | - utils.debug('THRESHOLD_RANGE %s'% mask.threshold_range) | |
| 1123 | - Publisher.sendMessage('Add mask', | |
| 1124 | - (mask.index, | |
| 1125 | - mask.name, | |
| 1126 | - mask.threshold_range, | |
| 1127 | - mask.colour)) | |
| 1128 | - | |
| 1129 | - self.current_mask = mask | |
| 1130 | - self.__build_mask(imagedata, False) | |
| 1131 | - | |
| 1132 | - Publisher.sendMessage('Change mask selected', mask.index) | |
| 1133 | - Publisher.sendMessage('Update slice viewer') | |
| 1134 | - | |
| 1135 | 1009 | def do_ww_wl(self, image): |
| 1136 | 1010 | if self.from_ == PLIST: |
| 1137 | 1011 | lut = vtk.vtkWindowLevelLookupTable() |
| ... | ... | @@ -1212,12 +1086,16 @@ class Slice(object): |
| 1212 | 1086 | m[mask == 254] = 254 |
| 1213 | 1087 | return m.astype('uint8') |
| 1214 | 1088 | |
| 1215 | - def do_threshold_to_all_slices(self): | |
| 1216 | - mask = self.current_mask | |
| 1089 | + def do_threshold_to_all_slices(self, mask=None): | |
| 1090 | + """ | |
| 1091 | + Apply threshold to all slices. | |
| 1217 | 1092 | |
| 1218 | - # This is very important. Do not use masks' imagedata. It would mess up | |
| 1219 | - # surface quality event when using contour | |
| 1220 | - #self.SetMaskThreshold(mask.index, threshold) | |
| 1093 | + Params: | |
| 1094 | + - mask: the mask where result of the threshold will be stored.If | |
| 1095 | + None, it'll be the current mask. | |
| 1096 | + """ | |
| 1097 | + if mask is None: | |
| 1098 | + mask = self.current_mask | |
| 1221 | 1099 | for n in xrange(1, mask.matrix.shape[0]): |
| 1222 | 1100 | if mask.matrix[n, 0, 0] == 0: |
| 1223 | 1101 | m = mask.matrix[n, 1:, 1:] |
| ... | ... | @@ -1390,76 +1268,9 @@ class Slice(object): |
| 1390 | 1268 | self.buffer_slices[o].discard_vtk_mask() |
| 1391 | 1269 | Publisher.sendMessage('Reload actual slice') |
| 1392 | 1270 | |
| 1393 | - def __build_mask(self, imagedata, create=True): | |
| 1394 | - # create new mask instance and insert it into project | |
| 1395 | - if create: | |
| 1396 | - self.CreateMask(imagedata=imagedata) | |
| 1397 | - current_mask = self.current_mask | |
| 1398 | - | |
| 1399 | - # properties to be inserted into pipeline | |
| 1400 | - scalar_range = int(imagedata.GetScalarRange()[1]) | |
| 1401 | - r,g,b = current_mask.colour | |
| 1402 | - | |
| 1403 | - # map scalar values into colors | |
| 1404 | - lut_mask = vtk.vtkLookupTable() | |
| 1405 | - lut_mask.SetNumberOfTableValues(1) | |
| 1406 | - lut_mask.SetNumberOfColors(1) | |
| 1407 | - lut_mask.SetHueRange(const.THRESHOLD_HUE_RANGE) | |
| 1408 | - lut_mask.SetSaturationRange(1, 1) | |
| 1409 | - lut_mask.SetValueRange(1, 1) | |
| 1410 | - lut_mask.SetNumberOfTableValues(scalar_range) | |
| 1411 | - lut_mask.SetTableValue(1, r, g, b, 1.0) | |
| 1412 | - lut_mask.SetTableValue(scalar_range - 1, r, g, b, 1.0) | |
| 1413 | - lut_mask.SetRampToLinear() | |
| 1414 | - lut_mask.Build() | |
| 1415 | - self.lut_mask = lut_mask | |
| 1416 | - | |
| 1417 | - mask_thresh_imagedata = self.__create_mask_threshold(imagedata) | |
| 1418 | - | |
| 1419 | - if create: | |
| 1420 | - # threshold pipeline | |
| 1421 | - current_mask.imagedata.DeepCopy(mask_thresh_imagedata) | |
| 1422 | - else: | |
| 1423 | - mask_thresh_imagedata = self.current_mask.imagedata | |
| 1424 | - | |
| 1425 | - # map the input image through a lookup table | |
| 1426 | - img_colours_mask = vtk.vtkImageMapToColors() | |
| 1427 | - img_colours_mask.SetOutputFormatToRGBA() | |
| 1428 | - img_colours_mask.SetLookupTable(lut_mask) | |
| 1429 | - | |
| 1430 | - img_colours_mask.SetInput(mask_thresh_imagedata) | |
| 1431 | - | |
| 1432 | - self.img_colours_mask = img_colours_mask | |
| 1433 | - | |
| 1434 | - return img_colours_mask.GetOutput() | |
| 1435 | - | |
| 1436 | - def __create_mask_threshold(self, imagedata, threshold_range=None): | |
| 1437 | - if not threshold_range: | |
| 1438 | - thresh_min, thresh_max = self.current_mask.threshold_range | |
| 1439 | - else: | |
| 1440 | - thresh_min, thresh_max = threshold_range | |
| 1441 | - | |
| 1442 | - # flexible threshold | |
| 1443 | - img_thresh_mask = vtk.vtkImageThreshold() | |
| 1444 | - img_thresh_mask.SetInValue(const.THRESHOLD_INVALUE) | |
| 1445 | - img_thresh_mask.SetInput(imagedata) | |
| 1446 | - img_thresh_mask.SetOutValue(const.THRESHOLD_OUTVALUE) | |
| 1447 | - img_thresh_mask.ThresholdBetween(float(thresh_min), float(thresh_max)) | |
| 1448 | - img_thresh_mask.Update() | |
| 1449 | - self.img_thresh_mask = img_thresh_mask | |
| 1450 | - | |
| 1451 | - # copy of threshold output | |
| 1452 | - imagedata_mask = vtk.vtkImageData() | |
| 1453 | - imagedata_mask.DeepCopy(img_thresh_mask.GetOutput()) | |
| 1454 | - imagedata_mask.Update() | |
| 1455 | - | |
| 1456 | - return imagedata_mask | |
| 1457 | - | |
| 1458 | 1271 | def _open_image_matrix(self, filename, shape, dtype): |
| 1459 | 1272 | self.matrix_filename = filename |
| 1460 | - print ">>>", filename | |
| 1461 | - self.matrix = numpy.memmap(filename, shape=shape, dtype=dtype, | |
| 1462 | - mode='r+') | |
| 1273 | + self.matrix = numpy.memmap(filename, shape=shape, dtype=dtype, mode='r+') | |
| 1463 | 1274 | |
| 1464 | 1275 | def OnFlipVolume(self, pubsub_evt): |
| 1465 | 1276 | axis = pubsub_evt.data |
| ... | ... | @@ -1489,8 +1300,9 @@ class Slice(object): |
| 1489 | 1300 | print type(self.matrix) |
| 1490 | 1301 | |
| 1491 | 1302 | def OnExportMask(self, pubsub_evt): |
| 1492 | - #imagedata = self.current_mask.imagedata | |
| 1493 | - imagedata = self.imagedata | |
| 1494 | - filename, filetype = pubsub_evt.data | |
| 1495 | - if (filetype == const.FILETYPE_IMAGEDATA): | |
| 1496 | - iu.Export(imagedata, filename) | |
| 1303 | + pass | |
| 1304 | + ##imagedata = self.current_mask.imagedata | |
| 1305 | + #imagedata = self.imagedata | |
| 1306 | + #filename, filetype = pubsub_evt.data | |
| 1307 | + #if (filetype == const.FILETYPE_IMAGEDATA): | |
| 1308 | + #iu.Export(imagedata, filename) | ... | ... |
invesalius/data/styles.py
invesalius/data/viewer_slice.py
| ... | ... | @@ -152,16 +152,10 @@ class Viewer(wx.Panel): |
| 152 | 152 | #self.SetBackgroundColour(colour) |
| 153 | 153 | |
| 154 | 154 | # Interactor additional style |
| 155 | - #self.modes = []#['DEFAULT'] | |
| 156 | - self.left_pressed = 0 | |
| 157 | - self.right_pressed = 0 | |
| 158 | 155 | |
| 159 | 156 | self._number_slices = const.PROJECTION_MIP_SIZE |
| 160 | 157 | self._mip_inverted = False |
| 161 | 158 | |
| 162 | - self.spined_image = False #Use to control to spin | |
| 163 | - self.paned_image = False | |
| 164 | - | |
| 165 | 159 | self.style = None |
| 166 | 160 | self.last_position_mouse_move = () |
| 167 | 161 | self.state = const.STATE_DEFAULT |
| ... | ... | @@ -200,7 +194,6 @@ class Viewer(wx.Panel): |
| 200 | 194 | self.__bind_events() |
| 201 | 195 | self.__bind_events_wx() |
| 202 | 196 | |
| 203 | - self._warped = False | |
| 204 | 197 | self._flush_buffer = False |
| 205 | 198 | |
| 206 | 199 | def __init_gui(self): |
| ... | ... | @@ -230,7 +223,6 @@ class Viewer(wx.Panel): |
| 230 | 223 | self.interactor.SetPicker(self.pick) |
| 231 | 224 | |
| 232 | 225 | def OnContextMenu(self, evt): |
| 233 | - self.right_pressed = 0 | |
| 234 | 226 | if (self.last_position_mouse_move ==\ |
| 235 | 227 | self.interactor.GetLastEventPosition()): |
| 236 | 228 | self.menu.caller = self |
| ... | ... | @@ -826,7 +818,6 @@ class Viewer(wx.Panel): |
| 826 | 818 | for slice_data in self.slice_data_list: |
| 827 | 819 | del slice_data |
| 828 | 820 | |
| 829 | - self.modes = []#['DEFAULT'] | |
| 830 | 821 | self.slice_data_list = [] |
| 831 | 822 | self.layout = (1, 1) |
| 832 | 823 | self.orientation_texts = [] |
| ... | ... | @@ -854,8 +845,8 @@ class Viewer(wx.Panel): |
| 854 | 845 | self.interactor.Bind(wx.EVT_SIZE, self.OnSize) |
| 855 | 846 | |
| 856 | 847 | def LoadImagedata(self, pubsub_evt): |
| 857 | - imagedata, mask_dict = pubsub_evt.data | |
| 858 | - self.SetInput(imagedata, mask_dict) | |
| 848 | + mask_dict = pubsub_evt.data | |
| 849 | + self.SetInput(mask_dict) | |
| 859 | 850 | |
| 860 | 851 | def LoadRenderers(self, imagedata): |
| 861 | 852 | number_renderers = self.layout[0] * self.layout[1] |
| ... | ... | @@ -920,7 +911,7 @@ class Viewer(wx.Panel): |
| 920 | 911 | self.cursor_ = cursor |
| 921 | 912 | return cursor |
| 922 | 913 | |
| 923 | - def SetInput(self, imagedata, mask_dict): | |
| 914 | + def SetInput(self, mask_dict): | |
| 924 | 915 | self.slice_ = sl.Slice() |
| 925 | 916 | |
| 926 | 917 | max_slice_number = sl.Slice().GetNumberOfSlices(self.orientation) |
| ... | ... | @@ -928,11 +919,9 @@ class Viewer(wx.Panel): |
| 928 | 919 | max_slice_number) |
| 929 | 920 | |
| 930 | 921 | self.slice_data = self.create_slice_window() |
| 931 | - #self.slice_data.actor.SetInput(imagedata) | |
| 932 | 922 | self.slice_data.SetCursor(self.__create_cursor()) |
| 933 | 923 | self.cam = self.slice_data.renderer.GetActiveCamera() |
| 934 | - self.__build_cross_lines(imagedata) | |
| 935 | - #self.set_slice_number(0) | |
| 924 | + self.__build_cross_lines() | |
| 936 | 925 | |
| 937 | 926 | # Set the slice number to the last slice to ensure the camera if far |
| 938 | 927 | # enough to show all slices. |
| ... | ... | @@ -940,30 +929,6 @@ class Viewer(wx.Panel): |
| 940 | 929 | self.__update_camera() |
| 941 | 930 | self.slice_data.renderer.ResetCamera() |
| 942 | 931 | self.interactor.GetRenderWindow().AddRenderer(self.slice_data.renderer) |
| 943 | - #if slice_.imagedata is None: | |
| 944 | - #slice_.SetInput(imagedata, mask_dict) | |
| 945 | - | |
| 946 | - ##actor.SetInput(slice_.GetOutput()) | |
| 947 | - #self.LoadRenderers(slice_.GetOutput()) | |
| 948 | - #self.__configure_renderers() | |
| 949 | - #ren = self.slice_data_list[0].renderer | |
| 950 | - #actor = self.slice_data_list[0].actor | |
| 951 | - #actor_bound = actor.GetBounds() | |
| 952 | - #self.cam = ren.GetActiveCamera() | |
| 953 | - | |
| 954 | - #for slice_data in self.slice_data_list: | |
| 955 | - #self.__update_camera(slice_data) | |
| 956 | - #self.Reposition(slice_data) | |
| 957 | - | |
| 958 | - #number_of_slices = self.layout[0] * self.layout[1] | |
| 959 | - #max_slice_number = actor.GetSliceNumberMax() + 1/ \ | |
| 960 | - #number_of_slices | |
| 961 | - | |
| 962 | - #if actor.GetSliceNumberMax() % number_of_slices: | |
| 963 | - #max_slice_number += 1 | |
| 964 | - #self.set_scroll_position(0) | |
| 965 | - | |
| 966 | - #actor_bound = actor.GetBounds() | |
| 967 | 932 | self.interactor.Render() |
| 968 | 933 | |
| 969 | 934 | self.EnableText() |
| ... | ... | @@ -971,7 +936,7 @@ class Viewer(wx.Panel): |
| 971 | 936 | ## Insert cursor |
| 972 | 937 | self.SetInteractorStyle(const.STATE_DEFAULT) |
| 973 | 938 | |
| 974 | - def __build_cross_lines(self, imagedata): | |
| 939 | + def __build_cross_lines(self): | |
| 975 | 940 | renderer = self.slice_data.overlay_renderer |
| 976 | 941 | |
| 977 | 942 | cross = vtk.vtkCursor3D() |
| ... | ... | @@ -1010,28 +975,6 @@ class Viewer(wx.Panel): |
| 1010 | 975 | for slice_data in self.slice_data_list: |
| 1011 | 976 | slice_data.cursor.actor.SetVisibility(visibility) |
| 1012 | 977 | |
| 1013 | - def __update_cursor_position(self, slice_data, position): | |
| 1014 | - x, y, z = position | |
| 1015 | - if (slice_data.cursor): | |
| 1016 | - slice_number = slice_data.number | |
| 1017 | - actor_bound = slice_data.actor.GetBounds() | |
| 1018 | - | |
| 1019 | - yz = [x + abs(x * 0.001), y, z] | |
| 1020 | - xz = [x, y - abs(y * 0.001), z] | |
| 1021 | - xy = [x, y, z + abs(z * 0.001)] | |
| 1022 | - | |
| 1023 | - proj = project.Project() | |
| 1024 | - orig_orien = proj.original_orientation | |
| 1025 | - | |
| 1026 | - if (orig_orien == const.SAGITAL): | |
| 1027 | - coordinates = {"SAGITAL": xy, "CORONAL": yz, "AXIAL": xz} | |
| 1028 | - elif(orig_orien == const.CORONAL): | |
| 1029 | - coordinates = {"SAGITAL": yz, "CORONAL": xy, "AXIAL": xz} | |
| 1030 | - else: | |
| 1031 | - coordinates = {"SAGITAL": yz, "CORONAL": xz, "AXIAL": xy} | |
| 1032 | - | |
| 1033 | - slice_data.cursor.SetPosition(coordinates[self.orientation]) | |
| 1034 | - | |
| 1035 | 978 | def SetOrientation(self, orientation): |
| 1036 | 979 | self.orientation = orientation |
| 1037 | 980 | for slice_data in self.slice_data_list: |
| ... | ... | @@ -1047,7 +990,6 @@ class Viewer(wx.Panel): |
| 1047 | 990 | overlay_renderer.SetActiveCamera(cam) |
| 1048 | 991 | overlay_renderer.SetInteractive(0) |
| 1049 | 992 | |
| 1050 | - | |
| 1051 | 993 | self.interactor.GetRenderWindow().SetNumberOfLayers(2) |
| 1052 | 994 | self.interactor.GetRenderWindow().AddRenderer(overlay_renderer) |
| 1053 | 995 | self.interactor.GetRenderWindow().AddRenderer(renderer) |
| ... | ... | @@ -1286,30 +1228,6 @@ class Viewer(wx.Panel): |
| 1286 | 1228 | self.set_slice_number(pos) |
| 1287 | 1229 | self.interactor.Render() |
| 1288 | 1230 | |
| 1289 | - def test_operation_position(self, coord): | |
| 1290 | - """ | |
| 1291 | - Test if coord is into the imagedata limits. | |
| 1292 | - """ | |
| 1293 | - x, y, z = coord | |
| 1294 | - xi, yi, zi = 0, 0, 0 | |
| 1295 | - xf, yf, zf = self.imagedata.GetDimensions() | |
| 1296 | - if xi <= x <= xf \ | |
| 1297 | - and yi <= y <= yf\ | |
| 1298 | - and zi <= z <= zf: | |
| 1299 | - return True | |
| 1300 | - return False | |
| 1301 | - | |
| 1302 | - def _assert_coord_into_image(self, coord): | |
| 1303 | - extent = self.imagedata.GetWholeExtent() | |
| 1304 | - extent_min = extent[0], extent[2], extent[4] | |
| 1305 | - extent_max = extent[1], extent[3], extent[5] | |
| 1306 | - for index in xrange(3): | |
| 1307 | - if coord[index] > extent_max[index]: | |
| 1308 | - coord[index] = extent_max[index] | |
| 1309 | - elif coord[index] < extent_min[index]: | |
| 1310 | - coord[index] = extent_min[index] | |
| 1311 | - return coord | |
| 1312 | - | |
| 1313 | 1231 | def ReloadActualSlice(self, pubsub_evt=None): |
| 1314 | 1232 | pos = self.scroll.GetThumbPosition() |
| 1315 | 1233 | self.set_slice_number(pos) | ... | ... |
invesalius/project.py
| ... | ... | @@ -22,7 +22,6 @@ import glob |
| 22 | 22 | import os |
| 23 | 23 | import plistlib |
| 24 | 24 | import shutil |
| 25 | -import stat | |
| 26 | 25 | import tarfile |
| 27 | 26 | import tempfile |
| 28 | 27 | |
| ... | ... | @@ -35,7 +34,6 @@ import data.mask as msk |
| 35 | 34 | import data.polydata_utils as pu |
| 36 | 35 | import data.surface as srf |
| 37 | 36 | from presets import Presets |
| 38 | -from reader import dicom | |
| 39 | 37 | from utils import Singleton, debug |
| 40 | 38 | import version |
| 41 | 39 | |
| ... | ... | @@ -47,18 +45,13 @@ class Project(object): |
| 47 | 45 | def __init__(self): |
| 48 | 46 | # Patient/ acquistion information |
| 49 | 47 | self.name = '' |
| 50 | - self.dicom_sample = '' | |
| 51 | 48 | self.modality = '' |
| 52 | 49 | self.original_orientation = '' |
| 53 | 50 | self.window = '' |
| 54 | 51 | self.level = '' |
| 55 | 52 | |
| 56 | - # Original imagedata (shouldn't be changed) | |
| 57 | - self.imagedata = '' | |
| 58 | - | |
| 59 | 53 | # Masks (vtkImageData) |
| 60 | 54 | self.mask_dict = {} |
| 61 | - self.last_mask_index = 0 | |
| 62 | 55 | |
| 63 | 56 | # Surfaces are (vtkPolyData) |
| 64 | 57 | self.surface_dict = {} |
| ... | ... | @@ -107,7 +100,6 @@ class Project(object): |
| 107 | 100 | output |
| 108 | 101 | @ index: index of item that was inserted |
| 109 | 102 | """ |
| 110 | - #self.last_mask_index = mask.index | |
| 111 | 103 | index = len(self.mask_dict) |
| 112 | 104 | self.mask_dict[index] = mask |
| 113 | 105 | return index | ... | ... |