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

Dataset decompress function does not update length of the pixel data #2024

Open
anupbarve opened this issue Mar 11, 2024 · 1 comment
Open

Comments

@anupbarve
Copy link

anupbarve commented Mar 11, 2024

Describe the bug

Pydicom dataset decompress() doesn't update the length of the pixel data automatically. It only gets updated while the dataset is saved to a file. I also tried deepcopy() of the dataset, but that too doesn't work. So have to dump the decompressed dataset on to the disk and reload.

Expected behavior
Length of the pixel data should get updated as part of the dataset decompress()

Steps To Reproduce

  • Read and note pixel data length of a dicom file that has compressed pixel data.
  • Run dataset.decompress()
  • Again read and note the pixel data length and notice that the length has not changed.

Your environment

module       | version
------       | -------
platform     | macOS-13.3.1-arm64-arm-64bit
Python       | 3.11.3 (v3.11.3:f3909b8bc8, Apr  4 2023, 20:12:10) [Clang 13.0.0 (clang-1300.0.29.30)]
pydicom      | 2.4.4
gdcm         | _module not found_
jpeg_ls      | _module not found_
numpy        | 1.26.2
PIL          | _module not found_
pylibjpeg    | 2.0.0
openjpeg     | 2.1.1
libjpeg      | 2.0.2
@scaramallion
Copy link
Member

scaramallion commented Mar 11, 2024

Weirdly, I don't think it's ever worked the way it claims to in the docstring, it only decompresses to the Dataset.pixel_array property, not the dataset's Pixel Data value (even though it changes the transfer syntax). It'll get fixed in the next release.

You should just be able to do ds.PixelData = ds.pixel_array.tobytes() instead of saving/reloading

@scaramallion scaramallion added this to the v3.0 milestone Mar 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants