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