Skip to content

Wrong spacing checking logic in DICOM series combination #6630

@function2-llx

Description

@function2-llx

Describe the bug

I found some issues in the following code snip:

first_slice = slices[0]
average_distance = 0.0
first_array = self._get_array_data(first_slice)
shape = first_array.shape
spacing = getattr(first_slice, "PixelSpacing", [1.0, 1.0, 1.0])
pos = getattr(first_slice, "ImagePositionPatient", (0.0, 0.0, 0.0))[2]
stack_array = [first_array]
for idx in range(1, len(slices)):
slc_array = self._get_array_data(slices[idx])
slc_shape = slc_array.shape
slc_spacing = getattr(first_slice, "PixelSpacing", (1.0, 1.0, 1.0))
slc_pos = getattr(first_slice, "ImagePositionPatient", (0.0, 0.0, float(idx)))[2]

  1. In line 520, spacing should be got from slices[idx] instead of first_slice; there's the same issue in line 521;
  2. the default value in line 514 is [1.0, 1.0, 1.0], which is a list instance, while the default value in line 520 is (1.0, 1.0, 1.0), which is a tuple instance, and (1.0, 1.0, 1.0) == [1.0, 1.0, 1.0] will result in False.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions