Commit f464a5141e012340ead827101519f114a527e955
1 parent
f9191b32
Exists in
master
and in
68 other branches
ENC: Imagedata reformat matrix is set in constants, and not simply hardcoded on dicom_reader
Showing
2 changed files
with
18 additions
and
25 deletions
Show diff stats
invesalius/constants.py
@@ -92,4 +92,5 @@ WINDOW_LEVEL = {"Abdomen":(350,50), | @@ -92,4 +92,5 @@ WINDOW_LEVEL = {"Abdomen":(350,50), | ||
92 | "Vasculature - Hard":(240,80), | 92 | "Vasculature - Hard":(240,80), |
93 | "Vasculature - Soft":(650,160)} | 93 | "Vasculature - Soft":(650,160)} |
94 | 94 | ||
95 | +REDUCE_IMAGEDATA_QUALITY = 1 | ||
95 | 96 |
invesalius/reader/dicom_reader.py
@@ -23,19 +23,19 @@ import vtk | @@ -23,19 +23,19 @@ import vtk | ||
23 | import vtkgdcm | 23 | import vtkgdcm |
24 | import gdcm | 24 | import gdcm |
25 | 25 | ||
26 | +import constants as const | ||
26 | import dicom | 27 | import dicom |
27 | import dicom_grouper | 28 | import dicom_grouper |
28 | from data.imagedata_utils import ResampleImage2D | 29 | from data.imagedata_utils import ResampleImage2D |
29 | 30 | ||
30 | -import constants as const | ||
31 | def LoadImages(dir_): | 31 | def LoadImages(dir_): |
32 | # TODO!!! SUPER GAMBIARRA!!! DO THIS BETTER | 32 | # TODO!!! SUPER GAMBIARRA!!! DO THIS BETTER |
33 | 33 | ||
34 | - #if 0: | ||
35 | - fow = vtk.vtkFileOutputWindow() | ||
36 | - fow.SetFileName('vtk_output.txt') | ||
37 | - ow = vtk.vtkOutputWindow () | ||
38 | - ow.SetInstance (fow) | 34 | + if 0: |
35 | + fow = vtk.vtkFileOutputWindow() | ||
36 | + fow.SetFileName('vtk_output.txt') | ||
37 | + ow = vtk.vtkOutputWindow () | ||
38 | + ow.SetInstance (fow) | ||
39 | 39 | ||
40 | dcm_files, acquisition_modality = GetDicomFiles(dir_) | 40 | dcm_files, acquisition_modality = GetDicomFiles(dir_) |
41 | 41 | ||
@@ -84,15 +84,19 @@ def LoadImages(dir_): | @@ -84,15 +84,19 @@ def LoadImages(dir_): | ||
84 | 84 | ||
85 | array = vtk.vtkStringArray() | 85 | array = vtk.vtkStringArray() |
86 | 86 | ||
87 | - #Case Reduce Matrix of the Image | ||
88 | - reduce_matrix = 0 | ||
89 | - | ||
90 | img_app = vtk.vtkImageAppend() | 87 | img_app = vtk.vtkImageAppend() |
91 | img_app.SetAppendAxis(2) #Define Stack in Z | 88 | img_app.SetAppendAxis(2) #Define Stack in Z |
92 | 89 | ||
93 | for x in xrange(len(files)): | 90 | for x in xrange(len(files)): |
94 | - if not(reduce_matrix): | 91 | + if not(const.REDUCE_IMAGEDATA_QUALITY): |
95 | array.InsertValue(x,files[x]) | 92 | array.InsertValue(x,files[x]) |
93 | + read = vtkgdcm.vtkGDCMImageReader() | ||
94 | + read.SetFileNames(array) | ||
95 | + read.Update() | ||
96 | + | ||
97 | + img_axial = vtk.vtkImageData() | ||
98 | + img_axial.DeepCopy(read.GetOutput()) | ||
99 | + img_axial.SetSpacing(spacing, spacing, spacing_z) | ||
96 | else: | 100 | else: |
97 | #SIf the resolution of the | 101 | #SIf the resolution of the |
98 | #matrix is very large | 102 | #matrix is very large |
@@ -107,27 +111,15 @@ def LoadImages(dir_): | @@ -107,27 +111,15 @@ def LoadImages(dir_): | ||
107 | img_app.AddInput(img) | 111 | img_app.AddInput(img) |
108 | img_app.Update() | 112 | img_app.Update() |
109 | 113 | ||
110 | - img_axial = vtk.vtkImageData() | ||
111 | - | ||
112 | - if (reduce_matrix): | ||
113 | - img_axial.DeepCopy(img_app.GetOutput()) | ||
114 | - img_axial.SetSpacing(img_axial.GetSpacing()[0],\ | 114 | + img_axial = vtk.vtkImageData() |
115 | + img_axial.DeepCopy(img_app.GetOutput()) | ||
116 | + img_axial.SetSpacing(img_axial.GetSpacing()[0],\ | ||
115 | img_axial.GetSpacing()[1],\ | 117 | img_axial.GetSpacing()[1],\ |
116 | spacing_z) | 118 | spacing_z) |
117 | - else: | ||
118 | - read = vtkgdcm.vtkGDCMImageReader() | ||
119 | - read.SetFileNames(array) | ||
120 | - read.Update() | ||
121 | 119 | ||
122 | - img_axial.DeepCopy(read.GetOutput()) | ||
123 | - img_axial.SetSpacing(spacing, spacing, spacing_z) | ||
124 | 120 | ||
125 | img_axial.Update() | 121 | img_axial.Update() |
126 | 122 | ||
127 | - thresh_min, thresh_max = img_axial.GetScalarRange() | ||
128 | - const.THRESHOLD_INVALUE = thresh_max | ||
129 | - const.THRESHOLD_OUTVALUE = thresh_min | ||
130 | - | ||
131 | return img_axial, acquisition_modality, tilt | 123 | return img_axial, acquisition_modality, tilt |
132 | 124 | ||
133 | def GetDicomFiles(path, recursive = False): | 125 | def GetDicomFiles(path, recursive = False): |