Commit 1d21c8fcd975794acd327c94af6b3370393020ba

Authored by tatiana
1 parent d1fe1aa7

FIX: Last mask threshold when project is opened

invesalius/control.py
... ... @@ -86,7 +86,6 @@ class Controller():
86 86 self.progress_dialog = dialog.ProgressDialog(
87 87 maximum = data[1])
88 88 else:
89   - print data[0]
90 89 if not(self.progress_dialog.Update(data[0],message)):
91 90 self.progress_dialog.Close()
92 91 self.progress_dialog = None
... ... @@ -120,9 +119,7 @@ class Controller():
120 119  
121 120 if len(patients_groups):
122 121 group = dcm.SelectLargerDicomGroup(patients_groups)
123   - print "Group", group.GetHandSortedList()
124 122 imagedata, dicom = self.OpenDicomGroup(group, gui=False)
125   - print "imagedata", imagedata
126 123 self.CreateDicomProject(imagedata, dicom)
127 124 # OPTION 2: ANALYZE?
128 125 else:
... ... @@ -204,7 +201,6 @@ class Controller():
204 201  
205 202 # Create imagedata
206 203 filelist = dicom_group.GetFilenameList()
207   - print "filelist", filelist
208 204 zspacing = dicom_group.zspacing
209 205 imagedata = utils.CreateImageData(filelist, zspacing)
210 206  
... ... @@ -227,14 +223,13 @@ class Controller():
227 223  
228 224 thresh_modes = proj.threshold_modes.keys()
229 225 thresh_modes.sort()
230   - ps.Publisher().sendMessage('Set threshold modes',
231   - (thresh_modes,const.THRESHOLD_PRESETS_INDEX))
232 226  
233   - # Set default value into slices' default mask
234   - key= thresh_modes[const.THRESHOLD_PRESETS_INDEX]
235   - #value = proj.threshold_modes.get_value(key)
236   - value = proj.threshold_modes[key]
237   - (min_thresh, max_thresh) = value
  227 + default_threshold = const.THRESHOLD_PRESETS_INDEX
  228 + if proj.mask_dict:
  229 + last = max(proj.mask_dict.keys())
  230 + default_threshold = proj.mask_dict[last].threshold_range
  231 + ps.Publisher().sendMessage('Set threshold modes',
  232 + (thresh_modes,default_threshold))
238 233  
239 234 def LoadRaycastingPreset(self, pubsub_evt):
240 235 label = pubsub_evt.data
... ...
invesalius/data/slice_.py
... ... @@ -216,6 +216,10 @@ class Slice(object):
216 216 else:
217 217 proj = Project()
218 218 proj.mask_dict[index].threshold_range = threshold_range
  219 +
  220 + proj = Project()
  221 + proj.mask_dict[self.current_mask.index ].threshold_range = threshold_range
  222 +
219 223  
220 224 def ShowMask(self, index, value):
221 225 "Show a mask given its index and 'show' value (0: hide, other: show)"
... ... @@ -508,6 +512,8 @@ class Slice(object):
508 512 mask = mask_dict[key]
509 513  
510 514 # update gui related to mask
  515 + print "__load_masks"
  516 + print 'THRESHOLD_RANGE', mask.threshold_range
511 517 ps.Publisher().sendMessage('Add mask',
512 518 (mask.index,
513 519 mask.name,
... ...
invesalius/data/surface.py
... ... @@ -334,7 +334,7 @@ class SurfaceManager():
334 334  
335 335 def OnShowSurface(self, pubsub_evt):
336 336 index, value = pubsub_evt.data
337   - print "OnShowSurface", index, value
  337 + #print "OnShowSurface", index, value
338 338 self.ShowActor(index, value)
339 339  
340 340 def ShowActor(self, index, value):
... ...
invesalius/data/viewer_slice.py
... ... @@ -215,7 +215,7 @@ class Viewer(wx.Panel):
215 215 self.interactor.SetCursor(wx.StockCursor(wx.CURSOR_SIZING))
216 216  
217 217 def __set_mode_zoom(self, pubsub_evt):
218   - print "Zoom"
  218 + #print "Zoom"
219 219 self.append_mode('ZOOM')
220 220 self.mouse_pressed = 0
221 221 ICON_IMAGE = wx.Image(os.path.join(const.ICON_DIR,
... ... @@ -735,7 +735,7 @@ class Viewer(wx.Panel):
735 735 'Set slice viewer layout')
736 736  
737 737 def ChangeBrushOperation(self, pubsub_evt):
738   - print pubsub_evt.data
  738 + #print pubsub_evt.data
739 739 self._brush_cursor_op = pubsub_evt.data
740 740  
741 741 def __bind_events_wx(self):
... ... @@ -912,10 +912,10 @@ class Viewer(wx.Panel):
912 912 extent = slice_data.actor.GetDisplayExtent()
913 913 cam = slice_data.renderer.GetActiveCamera()
914 914  
915   - print
916   - print self.orientation
917   - print x, y, z
918   - print actor_bound
  915 + #print
  916 + #print self.orientation
  917 + #print x, y, z
  918 + #print actor_bound
919 919 #print "ViewUp", cam.GetViewUp()
920 920 #print "Position", cam.GetPosition()
921 921 #print "Orientation", cam.GetOrientation()
... ... @@ -923,10 +923,10 @@ class Viewer(wx.Panel):
923 923  
924 924 vCamera = numpy.array(cam.GetPosition()) - numpy.array(cam.GetFocalPoint())
925 925 n_vCamera = vCamera / numpy.linalg.norm(vCamera)
926   - print "Normalized", n_vCamera
  926 + #print "Normalized", n_vCamera
927 927  
928 928 pos = [j + 0.01 * i for i,j in zip(n_vCamera, (x, y, z))]
929   - print "posicao", pos
  929 + #print "posicao", pos
930 930  
931 931 #yz = [x + abs(x * 0.001), y, z]
932 932 #xz = [x, y - abs(y * 0.001), z]
... ... @@ -988,10 +988,10 @@ class Viewer(wx.Panel):
988 988 slice_number = slice_data.number
989 989 actor_bound = slice_data.actor.GetBounds()
990 990  
991   - print
992   - print self.orientation
993   - print x, y, z
994   - print actor_bound
  991 + #print
  992 + #print self.orientation
  993 + #print x, y, z
  994 + #print actor_bound
995 995  
996 996 yz = [x + abs(x * 0.001), y, z]
997 997 xz = [x, y - abs(y * 0.001), z]
... ... @@ -1107,7 +1107,7 @@ class Viewer(wx.Panel):
1107 1107 evt.Skip()
1108 1108  
1109 1109 def OnScrollBarRelease(self, evt):
1110   - print "OnScrollBarRelease"
  1110 + #print "OnScrollBarRelease"
1111 1111 self.UpdateSlice3D(self.pos)
1112 1112 evt.Skip()
1113 1113  
... ...
invesalius/gui/data_notebook.py
... ... @@ -172,6 +172,7 @@ class MasksListCtrlPanel(wx.ListCtrl, listmix.TextEditMixin):
172 172  
173 173 def EditMaskThreshold(self, pubsub_evt):
174 174 index, threshold_range = pubsub_evt.data
  175 + print "EditMaskThreshold", threshold_range
175 176 self.SetStringItem(index, 2, str(threshold_range))
176 177  
177 178 def EditMaskColour(self, pubsub_evt):
... ...
invesalius/gui/task_slice.py
... ... @@ -325,8 +325,14 @@ class MaskProperties(wx.Panel):
325 325 def SetThresholdModes(self, pubsub_evt):
326 326 (thresh_modes_names, default_thresh) = pubsub_evt.data
327 327 self.combo_thresh.SetItems(thresh_modes_names)
328   - self.combo_thresh.SetSelection(default_thresh)
329   - (thresh_min, thresh_max) = self.threshold_modes[thresh_modes_names[default_thresh]]
  328 + if isinstance(default_thresh, int):
  329 + self.combo_thresh.SetSelection(default_thresh)
  330 + (thresh_min, thresh_max) =\
  331 + self.threshold_modes[thresh_modes_names[default_thresh]]
  332 + else:
  333 + self.combo_thresh.SetSelection(3)
  334 + thresh_min, thresh_max = default_thresh
  335 +
330 336 self.gradient.SetMinValue(thresh_min)
331 337 self.gradient.SetMaxValue(thresh_max)
332 338  
... ... @@ -349,6 +355,7 @@ class MaskProperties(wx.Panel):
349 355 def OnSlideChanged(self, evt):
350 356 thresh_min = self.gradient.GetMinValue()
351 357 thresh_max = self.gradient.GetMaxValue()
  358 + print "OnSlideChanged", thresh_min, thresh_max
352 359 if self.bind_evt_gradient:
353 360 ps.Publisher().sendMessage('Set threshold values',
354 361 (thresh_min, thresh_max))
... ...
invesalius/project.py
... ... @@ -181,14 +181,14 @@ class Project(object):
181 181 def OpenPlistProject(self, filename):
182 182 filelist = Extract(filename, tempfile.gettempdir())
183 183 main_plist = min(filelist, key=lambda x: len(x))
184   - print main_plist
  184 + #print main_plist
185 185 project = plistlib.readPlist(main_plist)
186 186  
187   - print "antes", self.__dict__
  187 + #print "antes", self.__dict__
188 188  
189 189 # Path were extracted project is
190 190 dirpath = os.path.split(filelist[0])[0]
191   - print "* dirpath", dirpath
  191 + #print "* dirpath", dirpath
192 192  
193 193 for key in project:
194 194 if key == 'imagedata':
... ... @@ -220,7 +220,7 @@ class Project(object):
220 220 self.surface_dict[s.index] = s
221 221 else:
222 222 setattr(self, key, project[key])
223   - print "depois", self.__dict__
  223 + #print "depois", self.__dict__
224 224  
225 225  
226 226  
... ... @@ -233,7 +233,7 @@ def Compress(folder, filename):
233 233  
234 234 def Extract(filename, folder):
235 235 tar = tarfile.open(filename, "r:gz")
236   - tar.list(verbose=True)
  236 + #tar.list(verbose=True)
237 237 tar.extractall(folder)
238 238 filelist = [os.path.join(folder, i) for i in tar.getnames()]
239 239 tar.close()
... ...
invesalius/reader/dicom_reader.py
... ... @@ -85,13 +85,11 @@ def yGetDicomGroups(directory, recursive=True, gui=True):
85 85 dirpath, dirnames, filenames = os.walk(directory)
86 86 nfiles = len(filenames)
87 87  
88   - print "TOTAL FILES:", nfiles
89 88 counter = 0
90 89 grouper = dicom_grouper.DicomPatientGrouper()
91 90 # Retrieve only DICOM files, splited into groups
92 91 if recursive:
93 92 for dirpath, dirnames, filenames in os.walk(directory):
94   - print "@: ",dirpath
95 93 for name in filenames:
96 94 filepath = str(os.path.join(dirpath, name))
97 95 parser = dicom.Parser()
... ... @@ -104,7 +102,6 @@ def yGetDicomGroups(directory, recursive=True, gui=True):
104 102 grouper.AddFile(dcm)
105 103 else:
106 104 dirpath, dirnames, filenames = os.walk(directory)
107   - print "@: ",dirpath
108 105 for name in filenames:
109 106 filepath = str(os.path.join(dirpath, name))
110 107 parser = dicom.Parser()
... ...