Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Incorrect spacing is recorded when reading single pydicom dataset object with pydicom #6944

Closed
KumoLiu opened this issue Sep 5, 2023 · 0 comments · Fixed by #6943
Closed
Assignees
Labels
bug Something isn't working

Comments

@KumoLiu
Copy link
Contributor

KumoLiu commented Sep 5, 2023

Describe the bug
When reading the dicom series with LoadImage(pydicom backend) in MONAI transforms, the spacing is recorded incorrectly.

updated when reading dicom series:

stack_metadata["spacing"] = np.asarray(spacing)

didn't updated when reading a single pydicom dataset object:

for key in ["00200037", "00200032", "52009229", "52009230"]:

dr, dc = metadata.get("spacing", (1.0, 1.0))[:2]

To Reproduce
Steps to reproduce the behavior:

  1. Install the MONAI dev branch.
  2. Download the attachment dcm file whose md5 is f511acb750076c56ad2d9647dcfe521d, put it in a folder.
  3. Run
from monai.transforms import LoadImage
loader = LoadImage(reader='pydicomreader')
pydicom_result = loader('./test_data')
print(pydicom_result.affine)

loader = LoadImage(reader='itkreader')
itk_result = loader('./test_data')
print(itk_result.affine)

Expected behavior
pydicom can record spacing correctly when reading a single pydicom dataset object

@KumoLiu KumoLiu self-assigned this Sep 5, 2023
@KumoLiu KumoLiu added the bug Something isn't working label Sep 5, 2023
KumoLiu added a commit to KumoLiu/MONAI that referenced this issue Sep 5, 2023
@wyli wyli closed this as completed in #6943 Sep 5, 2023
wyli pushed a commit that referenced this issue Sep 5, 2023
Fixes #6942
fixes #6944.

### Description
When using itk backend reading dicom series and there is only one file
in the folder, return the first name since itk assuming that there must
be more than one file in the tuple.

https://github.com/InsightSoftwareConsortium/ITK/blob/452cb3f9716e95532200de3196d51cd705a0ec5e/Wrapping/Generators/Python/itk/support/extras.py#L1275-L1284

### Types of changes
<!--- Put an `x` in all the boxes that apply, and remove the not
applicable items -->
- [x] Non-breaking change (fix or new feature that would not break
existing functionality).
- [ ] Breaking change (fix or new feature that would cause existing
functionality to change).
- [ ] New tests added to cover the changes.
- [ ] Integration tests passed locally by running `./runtests.sh -f -u
--net --coverage`.
- [ ] Quick tests passed locally by running `./runtests.sh --quick
--unittests --disttests`.
- [ ] In-line docstrings updated.
- [ ] Documentation updated, tested `make html` command in the `docs/`
folder.

---------

Signed-off-by: KumoLiu <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant