Commit f464a5141e012340ead827101519f114a527e955

Authored by tatiana
1 parent f9191b32

ENC: Imagedata reformat matrix is set in constants, and not simply hardcoded on dicom_reader

invesalius/constants.py
... ... @@ -92,4 +92,5 @@ WINDOW_LEVEL = {"Abdomen":(350,50),
92 92 "Vasculature - Hard":(240,80),
93 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 23 import vtkgdcm
24 24 import gdcm
25 25  
  26 +import constants as const
26 27 import dicom
27 28 import dicom_grouper
28 29 from data.imagedata_utils import ResampleImage2D
29 30  
30   -import constants as const
31 31 def LoadImages(dir_):
32 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 40 dcm_files, acquisition_modality = GetDicomFiles(dir_)
41 41  
... ... @@ -84,15 +84,19 @@ def LoadImages(dir_):
84 84  
85 85 array = vtk.vtkStringArray()
86 86  
87   - #Case Reduce Matrix of the Image
88   - reduce_matrix = 0
89   -
90 87 img_app = vtk.vtkImageAppend()
91 88 img_app.SetAppendAxis(2) #Define Stack in Z
92 89  
93 90 for x in xrange(len(files)):
94   - if not(reduce_matrix):
  91 + if not(const.REDUCE_IMAGEDATA_QUALITY):
95 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 100 else:
97 101 #SIf the resolution of the
98 102 #matrix is very large
... ... @@ -107,27 +111,15 @@ def LoadImages(dir_):
107 111 img_app.AddInput(img)
108 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 117 img_axial.GetSpacing()[1],\
116 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 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 123 return img_axial, acquisition_modality, tilt
132 124  
133 125 def GetDicomFiles(path, recursive = False):
... ...