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] |
- In line 520, spacing should be got from
slices[idx] instead of first_slice; there's the same issue in line 521;
- 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.
Describe the bug
I found some issues in the following code snip:
MONAI/monai/data/image_reader.py
Lines 510 to 521 in 2cbed6c
slices[idx]instead offirst_slice; there's the same issue in line 521;[1.0, 1.0, 1.0], which is alistinstance, while the default value in line 520 is(1.0, 1.0, 1.0), which is atupleinstance, and(1.0, 1.0, 1.0) == [1.0, 1.0, 1.0]will result inFalse.