Commit f1d4f62b015bc5243adb0f3182dce179a5eeae5d

Authored by Paulo Henrique Junqueira Amorim
1 parent 1642e140

ADD: adding part of the code to change window and level in the 2D

Showing 2 changed files with 29 additions and 18 deletions   Show diff stats
invesalius/control.py
@@ -56,7 +56,7 @@ class Controller(): @@ -56,7 +56,7 @@ class Controller():
56 orientation = const.SAGITAL 56 orientation = const.SAGITAL
57 else: 57 else:
58 orientation = const.AXIAL 58 orientation = const.AXIAL
59 - 59 +
60 if (tilt_value): 60 if (tilt_value):
61 #TODO: Show dialog so user can set not other value 61 #TODO: Show dialog so user can set not other value
62 tilt_value *= -1 62 tilt_value *= -1
@@ -66,10 +66,10 @@ class Controller(): @@ -66,10 +66,10 @@ class Controller():
66 "No DICOM files were found. Trying to read with ITK..." 66 "No DICOM files were found. Trying to read with ITK..."
67 imagedata = analyze.ReadDirectory(dir_) 67 imagedata = analyze.ReadDirectory(dir_)
68 acquisition_modality = "MRI" 68 acquisition_modality = "MRI"
69 - 69 +
70 #TODO: Verify if all Analyse is AXIAL orientation 70 #TODO: Verify if all Analyse is AXIAL orientation
71 orientation = const.AXIAL 71 orientation = const.AXIAL
72 - 72 +
73 if not imagedata: 73 if not imagedata:
74 print "Sorry, but there are no medical images supported on this dir." 74 print "Sorry, but there are no medical images supported on this dir."
75 else: 75 else:
@@ -79,7 +79,10 @@ class Controller(): @@ -79,7 +79,10 @@ class Controller():
79 proj.SetAcquisitionModality(acquisition_modality) 79 proj.SetAcquisitionModality(acquisition_modality)
80 proj.imagedata = imagedata 80 proj.imagedata = imagedata
81 proj.original_orientation = orientation 81 proj.original_orientation = orientation
82 - 82 + proj.window = const.WINDOW_LEVEL['Bone'][0]
  83 + proj.level = const.WINDOW_LEVEL['Bone'][1]
  84 +
  85 +
83 threshold_range = proj.imagedata.GetScalarRange() 86 threshold_range = proj.imagedata.GetScalarRange()
84 const.THRESHOLD_OUTVALUE = threshold_range[0] 87 const.THRESHOLD_OUTVALUE = threshold_range[0]
85 const.THRESHOLD_INVALUE = threshold_range[1] 88 const.THRESHOLD_INVALUE = threshold_range[1]
@@ -93,6 +96,11 @@ class Controller(): @@ -93,6 +96,11 @@ class Controller():
93 # Call frame so it shows slice and volume related panels 96 # Call frame so it shows slice and volume related panels
94 ps.Publisher().sendMessage('Show content panel') 97 ps.Publisher().sendMessage('Show content panel')
95 98
  99 + #Initial Window and Level
  100 + ps.Publisher().sendMessage('Bright and contrast adjustment image',\
  101 + (proj.window, proj.level))
  102 +
  103 +
96 def LoadImagedataInfo(self): 104 def LoadImagedataInfo(self):
97 proj = prj.Project() 105 proj = prj.Project()
98 106
invesalius/project.py
@@ -29,29 +29,32 @@ class Project(object): @@ -29,29 +29,32 @@ class Project(object):
29 # Only one project will be initialized per time. Therefore, we use 29 # Only one project will be initialized per time. Therefore, we use
30 # Singleton design pattern for implementing it 30 # Singleton design pattern for implementing it
31 __metaclass__= Singleton 31 __metaclass__= Singleton
32 - 32 +
33 def __init__(self): 33 def __init__(self):
34 # TODO: Discuss 34 # TODO: Discuss
35 - # [Tati] Will this type of data be written on project file? What if user 35 + # [Tati] Will this type of data be written on project file? What if user
36 # changes file name and directory? I guess no... But, who knows... 36 # changes file name and directory? I guess no... But, who knows...
37 #self.name = "Default" 37 #self.name = "Default"
38 #self.dir_ = "C:\\" 38 #self.dir_ = "C:\\"
39 - 39 +
40 # Original vtkImageData, build based on medical images read. 40 # Original vtkImageData, build based on medical images read.
41 # To be used for general 2D slices rendering both on 2D and 3D 41 # To be used for general 2D slices rendering both on 2D and 3D
42 # coordinate systems. It might be used, as well, for 3D raycasting. 42 # coordinate systems. It might be used, as well, for 3D raycasting.
43 # rendering. 43 # rendering.
44 # TODO: Discuss when this will be used. 44 # TODO: Discuss when this will be used.
45 self.imagedata = None 45 self.imagedata = None
46 - 46 +
47 # Masks are related to vtkImageData 47 # Masks are related to vtkImageData
48 self.mask_dict = {} 48 self.mask_dict = {}
49 # Predefined threshold values 49 # Predefined threshold values
50 self.min_threshold = None 50 self.min_threshold = None
51 self.max_threshold = None 51 self.max_threshold = None
52 52
  53 + self.window = None
  54 + self.level = None
  55 +
53 self.presets = Presets() 56 self.presets = Presets()
54 - 57 +
55 self.original_orientation = None 58 self.original_orientation = None
56 # MRI ? CT? 59 # MRI ? CT?
57 self.threshold_modes = self.presets.thresh_ct 60 self.threshold_modes = self.presets.thresh_ct
@@ -60,7 +63,7 @@ class Project(object): @@ -60,7 +63,7 @@ class Project(object):
60 # default threshold labels 63 # default threshold labels
61 # TODO: Future + 64 # TODO: Future +
62 # Allow insertion of new threshold modes 65 # Allow insertion of new threshold modes
63 - 66 +
64 # Surfaces are related to vtkPolyDataa 67 # Surfaces are related to vtkPolyDataa
65 self.surface_dict = {} 68 self.surface_dict = {}
66 #self.surface_quality_list = ["Low", "Medium", "High", "Optimal *", 69 #self.surface_quality_list = ["Low", "Medium", "High", "Optimal *",
@@ -69,18 +72,18 @@ class Project(object): @@ -69,18 +72,18 @@ class Project(object):
69 # values set as decimate / smooth 72 # values set as decimate / smooth
70 # TODO: Future + 73 # TODO: Future +
71 # Allow insertion of new surface quality modes 74 # Allow insertion of new surface quality modes
72 - 75 +
73 self.measure_dict = {} 76 self.measure_dict = {}
74 - 77 +
75 # TODO: Future ++ 78 # TODO: Future ++
76 #self.annotation_dict = {} 79 #self.annotation_dict = {}
77 - 80 +
78 # TODO: Future + 81 # TODO: Future +
79 # Volume rendering modes related to vtkImageData 82 # Volume rendering modes related to vtkImageData
80 # this will need to be inserted both in the project and in the user 83 # this will need to be inserted both in the project and in the user
81 # InVesalius configuration file 84 # InVesalius configuration file
82 # self.render_mode = {} 85 # self.render_mode = {}
83 - 86 +
84 # The raycasting preset setted in this project 87 # The raycasting preset setted in this project
85 self.raycasting_preset = None 88 self.raycasting_preset = None
86 89
@@ -91,18 +94,18 @@ class Project(object): @@ -91,18 +94,18 @@ class Project(object):
91 def AddMask(self, index, mask): 94 def AddMask(self, index, mask):
92 """ 95 """
93 Insert new mask (Mask) into project data. 96 Insert new mask (Mask) into project data.
94 - 97 +
95 input 98 input
96 @ mask: Mask associated to mask 99 @ mask: Mask associated to mask
97 - 100 +
98 output 101 output
99 @ index: index of item that was inserted 102 @ index: index of item that was inserted
100 """ 103 """
101 self.mask_dict[index] = mask 104 self.mask_dict[index] = mask
102 - 105 +
103 def GetMask(self, index): 106 def GetMask(self, index):
104 return self.mask_dict[index] 107 return self.mask_dict[index]
105 - 108 +
106 109
107 def SetAcquisitionModality(self, type_): 110 def SetAcquisitionModality(self, type_):
108 if type_ == "MRI": 111 if type_ == "MRI":