Commit 5eff9593bc0f1624d248583e5342a9da2e98ef35

Authored by tfmoraes
1 parent 8f6722c0

ENH: Dicom_reader is faster again

Showing 1 changed file with 16 additions and 14 deletions   Show diff stats
invesalius/reader/dicom_reader.py
@@ -87,17 +87,19 @@ def LoadImages(dir_): @@ -87,17 +87,19 @@ def LoadImages(dir_):
87 img_app = vtk.vtkImageAppend() 87 img_app = vtk.vtkImageAppend()
88 img_app.SetAppendAxis(2) #Define Stack in Z 88 img_app.SetAppendAxis(2) #Define Stack in Z
89 89
90 - for x in xrange(len(files)):  
91 - if not(const.REDUCE_IMAGEDATA_QUALITY): 90 + if not(const.REDUCE_IMAGEDATA_QUALITY):
  91 + for x in xrange(len(files)):
92 array.InsertValue(x,files[x]) 92 array.InsertValue(x,files[x])
93 - read = vtkgdcm.vtkGDCMImageReader()  
94 - read.SetFileNames(array)  
95 - read.Update() 93 +
  94 + read = vtkgdcm.vtkGDCMImageReader()
  95 + read.SetFileNames(array)
  96 + read.Update()
96 97
97 - img_axial = vtk.vtkImageData()  
98 - img_axial.DeepCopy(read.GetOutput())  
99 - img_axial.SetSpacing(spacing, spacing, spacing_z)  
100 - else: 98 + img_axial = vtk.vtkImageData()
  99 + img_axial.DeepCopy(read.GetOutput())
  100 + img_axial.SetSpacing(spacing, spacing, spacing_z)
  101 + else:
  102 + for x in xrange(len(files)):
101 #SIf the resolution of the 103 #SIf the resolution of the
102 #matrix is very large 104 #matrix is very large
103 read = vtkgdcm.vtkGDCMImageReader() 105 read = vtkgdcm.vtkGDCMImageReader()
@@ -111,11 +113,11 @@ def LoadImages(dir_): @@ -111,11 +113,11 @@ def LoadImages(dir_):
111 img_app.AddInput(img) 113 img_app.AddInput(img)
112 img_app.Update() 114 img_app.Update()
113 115
114 - img_axial = vtk.vtkImageData()  
115 - img_axial.DeepCopy(img_app.GetOutput())  
116 - img_axial.SetSpacing(img_axial.GetSpacing()[0],\  
117 - img_axial.GetSpacing()[1],\  
118 - spacing_z) 116 + img_axial = vtk.vtkImageData()
  117 + img_axial.DeepCopy(img_app.GetOutput())
  118 + img_axial.SetSpacing(img_axial.GetSpacing()[0],\
  119 + img_axial.GetSpacing()[1],\
  120 + spacing_z)
119 121
120 122
121 img_axial.Update() 123 img_axial.Update()