From f1d4f62b015bc5243adb0f3182dce179a5eeae5d Mon Sep 17 00:00:00 2001 From: paulojamorim Date: Sun, 23 Aug 2009 01:57:25 +0000 Subject: [PATCH] ADD: adding part of the code to change window and level in the 2D --- invesalius/control.py | 16 ++++++++++++---- invesalius/project.py | 31 +++++++++++++++++-------------- 2 files changed, 29 insertions(+), 18 deletions(-) diff --git a/invesalius/control.py b/invesalius/control.py index a7e0190..5699602 100755 --- a/invesalius/control.py +++ b/invesalius/control.py @@ -56,7 +56,7 @@ class Controller(): orientation = const.SAGITAL else: orientation = const.AXIAL - + if (tilt_value): #TODO: Show dialog so user can set not other value tilt_value *= -1 @@ -66,10 +66,10 @@ class Controller(): "No DICOM files were found. Trying to read with ITK..." imagedata = analyze.ReadDirectory(dir_) acquisition_modality = "MRI" - + #TODO: Verify if all Analyse is AXIAL orientation orientation = const.AXIAL - + if not imagedata: print "Sorry, but there are no medical images supported on this dir." else: @@ -79,7 +79,10 @@ class Controller(): proj.SetAcquisitionModality(acquisition_modality) proj.imagedata = imagedata proj.original_orientation = orientation - + proj.window = const.WINDOW_LEVEL['Bone'][0] + proj.level = const.WINDOW_LEVEL['Bone'][1] + + threshold_range = proj.imagedata.GetScalarRange() const.THRESHOLD_OUTVALUE = threshold_range[0] const.THRESHOLD_INVALUE = threshold_range[1] @@ -93,6 +96,11 @@ class Controller(): # Call frame so it shows slice and volume related panels ps.Publisher().sendMessage('Show content panel') + #Initial Window and Level + ps.Publisher().sendMessage('Bright and contrast adjustment image',\ + (proj.window, proj.level)) + + def LoadImagedataInfo(self): proj = prj.Project() diff --git a/invesalius/project.py b/invesalius/project.py index 7949444..2a42b58 100755 --- a/invesalius/project.py +++ b/invesalius/project.py @@ -29,29 +29,32 @@ class Project(object): # Only one project will be initialized per time. Therefore, we use # Singleton design pattern for implementing it __metaclass__= Singleton - + def __init__(self): # TODO: Discuss - # [Tati] Will this type of data be written on project file? What if user + # [Tati] Will this type of data be written on project file? What if user # changes file name and directory? I guess no... But, who knows... #self.name = "Default" #self.dir_ = "C:\\" - + # Original vtkImageData, build based on medical images read. # To be used for general 2D slices rendering both on 2D and 3D # coordinate systems. It might be used, as well, for 3D raycasting. # rendering. # TODO: Discuss when this will be used. self.imagedata = None - + # Masks are related to vtkImageData self.mask_dict = {} # Predefined threshold values self.min_threshold = None self.max_threshold = None + self.window = None + self.level = None + self.presets = Presets() - + self.original_orientation = None # MRI ? CT? self.threshold_modes = self.presets.thresh_ct @@ -60,7 +63,7 @@ class Project(object): # default threshold labels # TODO: Future + # Allow insertion of new threshold modes - + # Surfaces are related to vtkPolyDataa self.surface_dict = {} #self.surface_quality_list = ["Low", "Medium", "High", "Optimal *", @@ -69,18 +72,18 @@ class Project(object): # values set as decimate / smooth # TODO: Future + # Allow insertion of new surface quality modes - + self.measure_dict = {} - + # TODO: Future ++ #self.annotation_dict = {} - + # TODO: Future + # Volume rendering modes related to vtkImageData # this will need to be inserted both in the project and in the user # InVesalius configuration file # self.render_mode = {} - + # The raycasting preset setted in this project self.raycasting_preset = None @@ -91,18 +94,18 @@ class Project(object): def AddMask(self, index, mask): """ Insert new mask (Mask) into project data. - + input @ mask: Mask associated to mask - + output @ index: index of item that was inserted """ self.mask_dict[index] = mask - + def GetMask(self, index): return self.mask_dict[index] - + def SetAcquisitionModality(self, type_): if type_ == "MRI": -- libgit2 0.21.2