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 | 75 | else: |
76 | 76 | f = extent[1] |
77 | 77 | |
78 | - | |
79 | 78 | factor_x = px/float(f+1) |
80 | 79 | factor_y = py/float(f+1) |
81 | 80 | |
82 | - | |
83 | 81 | resample = vtk.vtkImageResample() |
84 | 82 | resample.SetInput(imagedata) |
85 | 83 | resample.SetAxisMagnificationFactor(0, factor_x) |
... | ... | @@ -286,24 +284,29 @@ def CreateImageData(filelist, zspacing, xyspacing,size, |
286 | 284 | update_progress(reader,message)) |
287 | 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 | 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 | 300 | #Stack images in Z axes |
292 | 301 | appender.AddInput(slice_imagedata) |
293 | 302 | #appender.AddObserver("ProgressEvent", lambda obj,evt:update_progress(appender)) |
294 | 303 | appender.Update() |
295 | 304 | |
305 | + spacing = appender.GetOutput().GetSpacing() | |
306 | + | |
296 | 307 | # The zpacing is a DicomGroup property, so we need to set it |
297 | 308 | imagedata = vtk.vtkImageData() |
298 | 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 | 310 | imagedata.SetSpacing(spacing[0], spacing[1], zspacing) |
308 | 311 | |
309 | 312 | imagedata.AddObserver("ProgressEvent", lambda obj,evt: | ... | ... |