question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

pydicom.read_file() --> _get_pixel_array() no longer exists

See original GitHub issue

Attempting to use the DicomCleaner class to do pixel-level cleaning.

Looks like I keep getting an error in the clean.py file:

<ipython-input-41-aa448e009737> in <module> 5 print(out) 6 if out[‘flagged’]: ----> 7 client.clean()

/opt/conda/lib/python3.6/site-packages/deid-0.1.23-py3.6.egg/deid/dicom/pixels/clean.py in clean(self) 106 107 # We will set original image to image, cleaned to clean –> 108 self.original = dicom._get_pixel_array() 109 self.cleaned = self.original.copy() 110

/opt/conda/lib/python3.6/site-packages/pydicom/dataset.py in getattr(self, name) 530 if tag is None: # name isn’t a DICOM element keyword 531 # Try the base class attribute getter (fix for issue 332) –> 532 return super(Dataset, self).getattribute(name) 533 tag = Tag(tag) 534 if tag not in self.tags: # DICOM DataElement not in the Dataset

AttributeError: ‘FileDataset’ object has no attribute ‘_get_pixel_array’

Tracing this issue back it looks like pydicom’s FileDataset doesn’t actually have a _get_pixel_array() function, as follows:

from pydicom import read_file dicom = read_file(dicom_files[0]) dicom._get_pixel_array()

(dicom_files is a list of local paths to DICOM files). Gives the same error at the same location:

AttributeError Traceback (most recent call last) <ipython-input-51-f7f42af5b358> in <module> 1 from pydicom import read_file 2 dicom = read_file(dicom_files[0]) ----> 3 dicom._get_pixel_array()

/opt/conda/lib/python3.6/site-packages/pydicom/dataset.py in getattr(self, name) 530 if tag is None: # name isn’t a DICOM element keyword 531 # Try the base class attribute getter (fix for issue 332) –> 532 return super(Dataset, self).getattribute(name) 533 tag = Tag(tag) 534 if tag not in self.tags: # DICOM DataElement not in the Dataset

AttributeError: ‘FileDataset’ object has no attribute ‘_get_pixel_array’

On the other hand, I seem to be able to call for the variable directly using dicom.pixel_array or, alternatively, dicom.__getattribute__("pixel_array")

Maybe pydicom changed the Dataset class at some point and broke the clean.py implementation?

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:7 (5 by maintainers)

github_iconTop GitHub Comments

2reactions
vsochcommented, Dec 26, 2018
1reaction
howardpchencommented, Dec 26, 2018

Vanessa thanks for the recommendation! In all honesty I’ve not thought about it till now because it always feels like I might just not be using the package right instead of a bug. Thanks for the encouragement and will recommend pull requests for basic fixes here on out!

Read more comments on GitHub >

github_iconTop Results From Across the Web

Error with exception when reading a file · Issue #331 - GitHub
UPDATE for Python 2.7: I fixed the error after downgrading pydicom and installing an extra dependency, gdcm which when present will be used ......
Read more >
Pydicom.read_file is only working with some Dicom images
You have a dataset that contains compressed Pixel Data. By itself pydicom can only handle Pixel Data that hasn't been compressed, ...
Read more >
Working with Pixel Data — pydicom 2.3.1 documentation
How to work with pixel data in pydicom. Introduction¶. Many DICOM SOP classes contain bulk pixel data, which is usually used to represent...
Read more >
How to read dicom images with pydicom - Google Groups
The data can. be obtained using the get_pixel_array() method, which produces a. 3D numpy array if there a multiple files in the series....
Read more >
dicomparser module — dicompyler-core 0.5.6 documentation
AttributeError – Raised if SOPClassUID is not present in the pydicom Dataset. AttributeError – Raised if the DICOM file or pydicom Dataset cannot...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found