Commit a1115f2937962f7dd7457edb9b48bd6820e36559
1 parent
91a5b132
Exists in
master
and in
68 other branches
FIX: DICOM (to be attached) reconstruction is flattened. FIX #167
Showing
1 changed file
with
14 additions
and
11 deletions
Show diff stats
invesalius/data/imagedata_utils.py
@@ -75,11 +75,9 @@ def ResampleImage2D(imagedata, px, py, | @@ -75,11 +75,9 @@ def ResampleImage2D(imagedata, px, py, | ||
75 | else: | 75 | else: |
76 | f = extent[1] | 76 | f = extent[1] |
77 | 77 | ||
78 | - | ||
79 | factor_x = px/float(f+1) | 78 | factor_x = px/float(f+1) |
80 | factor_y = py/float(f+1) | 79 | factor_y = py/float(f+1) |
81 | 80 | ||
82 | - | ||
83 | resample = vtk.vtkImageResample() | 81 | resample = vtk.vtkImageResample() |
84 | resample.SetInput(imagedata) | 82 | resample.SetInput(imagedata) |
85 | resample.SetAxisMagnificationFactor(0, factor_x) | 83 | resample.SetAxisMagnificationFactor(0, factor_x) |
@@ -286,24 +284,29 @@ def CreateImageData(filelist, zspacing, xyspacing,size, | @@ -286,24 +284,29 @@ def CreateImageData(filelist, zspacing, xyspacing,size, | ||
286 | update_progress(reader,message)) | 284 | update_progress(reader,message)) |
287 | reader.Update() | 285 | reader.Update() |
288 | 286 | ||
287 | + if (use_dcmspacing): | ||
288 | + spacing = xyspacing | ||
289 | + spacing[2] = zspacing | ||
290 | + else: | ||
291 | + spacing = reader.GetOutput().GetSpacing() | ||
292 | + | ||
293 | + tmp_image = vtk.vtkImageData() | ||
294 | + tmp_image.DeepCopy(reader.GetOutput()) | ||
295 | + tmp_image.SetSpacing(spacing[0], spacing[1], zspacing) | ||
296 | + tmp_image.Update() | ||
297 | + | ||
289 | #Resample image in x,y dimension | 298 | #Resample image in x,y dimension |
290 | - slice_imagedata = ResampleImage2D(reader.GetOutput(), px, py, update_progress) | 299 | + slice_imagedata = ResampleImage2D(tmp_image, px, py, update_progress) |
291 | #Stack images in Z axes | 300 | #Stack images in Z axes |
292 | appender.AddInput(slice_imagedata) | 301 | appender.AddInput(slice_imagedata) |
293 | #appender.AddObserver("ProgressEvent", lambda obj,evt:update_progress(appender)) | 302 | #appender.AddObserver("ProgressEvent", lambda obj,evt:update_progress(appender)) |
294 | appender.Update() | 303 | appender.Update() |
295 | 304 | ||
305 | + spacing = appender.GetOutput().GetSpacing() | ||
306 | + | ||
296 | # The zpacing is a DicomGroup property, so we need to set it | 307 | # The zpacing is a DicomGroup property, so we need to set it |
297 | imagedata = vtk.vtkImageData() | 308 | imagedata = vtk.vtkImageData() |
298 | imagedata.DeepCopy(appender.GetOutput()) | 309 | imagedata.DeepCopy(appender.GetOutput()) |
299 | - imagedata.Update() | ||
300 | - | ||
301 | - if (use_dcmspacing): | ||
302 | - spacing = xyspacing | ||
303 | - spacing[2] = zspacing | ||
304 | - else: | ||
305 | - spacing = imagedata.GetSpacing() | ||
306 | - | ||
307 | imagedata.SetSpacing(spacing[0], spacing[1], zspacing) | 310 | imagedata.SetSpacing(spacing[0], spacing[1], zspacing) |
308 | 311 | ||
309 | imagedata.AddObserver("ProgressEvent", lambda obj,evt: | 312 | imagedata.AddObserver("ProgressEvent", lambda obj,evt: |