From 1d21c8fcd975794acd327c94af6b3370393020ba Mon Sep 17 00:00:00 2001 From: tatiana Date: Mon, 16 Nov 2009 18:04:07 +0000 Subject: [PATCH] FIX: Last mask threshold when project is opened --- invesalius/control.py | 17 ++++++----------- invesalius/data/slice_.py | 6 ++++++ invesalius/data/surface.py | 2 +- invesalius/data/viewer_slice.py | 26 +++++++++++++------------- invesalius/gui/data_notebook.py | 1 + invesalius/gui/task_slice.py | 11 +++++++++-- invesalius/project.py | 10 +++++----- invesalius/reader/dicom_reader.py | 3 --- 8 files changed, 41 insertions(+), 35 deletions(-) diff --git a/invesalius/control.py b/invesalius/control.py index ffc6611..911b8ae 100755 --- a/invesalius/control.py +++ b/invesalius/control.py @@ -86,7 +86,6 @@ class Controller(): self.progress_dialog = dialog.ProgressDialog( maximum = data[1]) else: - print data[0] if not(self.progress_dialog.Update(data[0],message)): self.progress_dialog.Close() self.progress_dialog = None @@ -120,9 +119,7 @@ class Controller(): if len(patients_groups): group = dcm.SelectLargerDicomGroup(patients_groups) - print "Group", group.GetHandSortedList() imagedata, dicom = self.OpenDicomGroup(group, gui=False) - print "imagedata", imagedata self.CreateDicomProject(imagedata, dicom) # OPTION 2: ANALYZE? else: @@ -204,7 +201,6 @@ class Controller(): # Create imagedata filelist = dicom_group.GetFilenameList() - print "filelist", filelist zspacing = dicom_group.zspacing imagedata = utils.CreateImageData(filelist, zspacing) @@ -227,14 +223,13 @@ class Controller(): thresh_modes = proj.threshold_modes.keys() thresh_modes.sort() - ps.Publisher().sendMessage('Set threshold modes', - (thresh_modes,const.THRESHOLD_PRESETS_INDEX)) - # Set default value into slices' default mask - key= thresh_modes[const.THRESHOLD_PRESETS_INDEX] - #value = proj.threshold_modes.get_value(key) - value = proj.threshold_modes[key] - (min_thresh, max_thresh) = value + default_threshold = const.THRESHOLD_PRESETS_INDEX + if proj.mask_dict: + last = max(proj.mask_dict.keys()) + default_threshold = proj.mask_dict[last].threshold_range + ps.Publisher().sendMessage('Set threshold modes', + (thresh_modes,default_threshold)) def LoadRaycastingPreset(self, pubsub_evt): label = pubsub_evt.data diff --git a/invesalius/data/slice_.py b/invesalius/data/slice_.py index 60f1c73..6f284d8 100644 --- a/invesalius/data/slice_.py +++ b/invesalius/data/slice_.py @@ -216,6 +216,10 @@ class Slice(object): else: proj = Project() proj.mask_dict[index].threshold_range = threshold_range + + proj = Project() + proj.mask_dict[self.current_mask.index ].threshold_range = threshold_range + def ShowMask(self, index, value): "Show a mask given its index and 'show' value (0: hide, other: show)" @@ -508,6 +512,8 @@ class Slice(object): mask = mask_dict[key] # update gui related to mask + print "__load_masks" + print 'THRESHOLD_RANGE', mask.threshold_range ps.Publisher().sendMessage('Add mask', (mask.index, mask.name, diff --git a/invesalius/data/surface.py b/invesalius/data/surface.py index 451dd86..a21e266 100644 --- a/invesalius/data/surface.py +++ b/invesalius/data/surface.py @@ -334,7 +334,7 @@ class SurfaceManager(): def OnShowSurface(self, pubsub_evt): index, value = pubsub_evt.data - print "OnShowSurface", index, value + #print "OnShowSurface", index, value self.ShowActor(index, value) def ShowActor(self, index, value): diff --git a/invesalius/data/viewer_slice.py b/invesalius/data/viewer_slice.py index 00ce3b2..a52bbe0 100755 --- a/invesalius/data/viewer_slice.py +++ b/invesalius/data/viewer_slice.py @@ -215,7 +215,7 @@ class Viewer(wx.Panel): self.interactor.SetCursor(wx.StockCursor(wx.CURSOR_SIZING)) def __set_mode_zoom(self, pubsub_evt): - print "Zoom" + #print "Zoom" self.append_mode('ZOOM') self.mouse_pressed = 0 ICON_IMAGE = wx.Image(os.path.join(const.ICON_DIR, @@ -735,7 +735,7 @@ class Viewer(wx.Panel): 'Set slice viewer layout') def ChangeBrushOperation(self, pubsub_evt): - print pubsub_evt.data + #print pubsub_evt.data self._brush_cursor_op = pubsub_evt.data def __bind_events_wx(self): @@ -912,10 +912,10 @@ class Viewer(wx.Panel): extent = slice_data.actor.GetDisplayExtent() cam = slice_data.renderer.GetActiveCamera() - print - print self.orientation - print x, y, z - print actor_bound + #print + #print self.orientation + #print x, y, z + #print actor_bound #print "ViewUp", cam.GetViewUp() #print "Position", cam.GetPosition() #print "Orientation", cam.GetOrientation() @@ -923,10 +923,10 @@ class Viewer(wx.Panel): vCamera = numpy.array(cam.GetPosition()) - numpy.array(cam.GetFocalPoint()) n_vCamera = vCamera / numpy.linalg.norm(vCamera) - print "Normalized", n_vCamera + #print "Normalized", n_vCamera pos = [j + 0.01 * i for i,j in zip(n_vCamera, (x, y, z))] - print "posicao", pos + #print "posicao", pos #yz = [x + abs(x * 0.001), y, z] #xz = [x, y - abs(y * 0.001), z] @@ -988,10 +988,10 @@ class Viewer(wx.Panel): slice_number = slice_data.number actor_bound = slice_data.actor.GetBounds() - print - print self.orientation - print x, y, z - print actor_bound + #print + #print self.orientation + #print x, y, z + #print actor_bound yz = [x + abs(x * 0.001), y, z] xz = [x, y - abs(y * 0.001), z] @@ -1107,7 +1107,7 @@ class Viewer(wx.Panel): evt.Skip() def OnScrollBarRelease(self, evt): - print "OnScrollBarRelease" + #print "OnScrollBarRelease" self.UpdateSlice3D(self.pos) evt.Skip() diff --git a/invesalius/gui/data_notebook.py b/invesalius/gui/data_notebook.py index f89d7f6..07b9992 100644 --- a/invesalius/gui/data_notebook.py +++ b/invesalius/gui/data_notebook.py @@ -172,6 +172,7 @@ class MasksListCtrlPanel(wx.ListCtrl, listmix.TextEditMixin): def EditMaskThreshold(self, pubsub_evt): index, threshold_range = pubsub_evt.data + print "EditMaskThreshold", threshold_range self.SetStringItem(index, 2, str(threshold_range)) def EditMaskColour(self, pubsub_evt): diff --git a/invesalius/gui/task_slice.py b/invesalius/gui/task_slice.py index 7d72285..3f1ca57 100644 --- a/invesalius/gui/task_slice.py +++ b/invesalius/gui/task_slice.py @@ -325,8 +325,14 @@ class MaskProperties(wx.Panel): def SetThresholdModes(self, pubsub_evt): (thresh_modes_names, default_thresh) = pubsub_evt.data self.combo_thresh.SetItems(thresh_modes_names) - self.combo_thresh.SetSelection(default_thresh) - (thresh_min, thresh_max) = self.threshold_modes[thresh_modes_names[default_thresh]] + if isinstance(default_thresh, int): + self.combo_thresh.SetSelection(default_thresh) + (thresh_min, thresh_max) =\ + self.threshold_modes[thresh_modes_names[default_thresh]] + else: + self.combo_thresh.SetSelection(3) + thresh_min, thresh_max = default_thresh + self.gradient.SetMinValue(thresh_min) self.gradient.SetMaxValue(thresh_max) @@ -349,6 +355,7 @@ class MaskProperties(wx.Panel): def OnSlideChanged(self, evt): thresh_min = self.gradient.GetMinValue() thresh_max = self.gradient.GetMaxValue() + print "OnSlideChanged", thresh_min, thresh_max if self.bind_evt_gradient: ps.Publisher().sendMessage('Set threshold values', (thresh_min, thresh_max)) diff --git a/invesalius/project.py b/invesalius/project.py index 09f6ea6..23d8053 100755 --- a/invesalius/project.py +++ b/invesalius/project.py @@ -181,14 +181,14 @@ class Project(object): def OpenPlistProject(self, filename): filelist = Extract(filename, tempfile.gettempdir()) main_plist = min(filelist, key=lambda x: len(x)) - print main_plist + #print main_plist project = plistlib.readPlist(main_plist) - print "antes", self.__dict__ + #print "antes", self.__dict__ # Path were extracted project is dirpath = os.path.split(filelist[0])[0] - print "* dirpath", dirpath + #print "* dirpath", dirpath for key in project: if key == 'imagedata': @@ -220,7 +220,7 @@ class Project(object): self.surface_dict[s.index] = s else: setattr(self, key, project[key]) - print "depois", self.__dict__ + #print "depois", self.__dict__ @@ -233,7 +233,7 @@ def Compress(folder, filename): def Extract(filename, folder): tar = tarfile.open(filename, "r:gz") - tar.list(verbose=True) + #tar.list(verbose=True) tar.extractall(folder) filelist = [os.path.join(folder, i) for i in tar.getnames()] tar.close() diff --git a/invesalius/reader/dicom_reader.py b/invesalius/reader/dicom_reader.py index fe467ab..3ef99f6 100644 --- a/invesalius/reader/dicom_reader.py +++ b/invesalius/reader/dicom_reader.py @@ -85,13 +85,11 @@ def yGetDicomGroups(directory, recursive=True, gui=True): dirpath, dirnames, filenames = os.walk(directory) nfiles = len(filenames) - print "TOTAL FILES:", nfiles counter = 0 grouper = dicom_grouper.DicomPatientGrouper() # Retrieve only DICOM files, splited into groups if recursive: for dirpath, dirnames, filenames in os.walk(directory): - print "@: ",dirpath for name in filenames: filepath = str(os.path.join(dirpath, name)) parser = dicom.Parser() @@ -104,7 +102,6 @@ def yGetDicomGroups(directory, recursive=True, gui=True): grouper.AddFile(dcm) else: dirpath, dirnames, filenames = os.walk(directory) - print "@: ",dirpath for name in filenames: filepath = str(os.path.join(dirpath, name)) parser = dicom.Parser() -- libgit2 0.21.2