Cannot obtain pixel spacing from dicom #1686
Replies: 10 comments
-
That radiant information makes it look like PixelSpacing is buried under a sequence item, which may also be nested, judging by the leading spaces. You would have to specify the overlying data elements for pydicom to get to that element. You could perhaps try ds.PixelMeasuresSequence[0].PixelSpacing but it doesn't look from the radiant output that that would work either. Is it possible to provide a de-identified version of the file? From that output it looks like it might be corrupted somehow. |
Beta Was this translation helpful? Give feedback.
-
Actually, I can not find the How to upload the file to github? |
Beta Was this translation helpful? Give feedback.
-
I have upload the file in: https://github.com/zhang-qiang-github/dicomfile |
Beta Was this translation helpful? Give feedback.
-
The sequence is inside the ds.SharedFunctionalGroupsSequence[0].PixelMeasuresSequence[0].PixelSpacing |
Beta Was this translation helpful? Give feedback.
-
But, after read dicom, how can I know which method is used to obtain pixel spacing? |
Beta Was this translation helpful? Give feedback.
-
This depends on the SOP class of the image. For single-frame SOP classes (MR, CT, ...) it is always in the root, for multi-frame enhanced SOP classes (Enhanced CT, Enhanced MR, ...) it can be found in the Shared Functional Groups Sequence. if "PixelSpacing" in ds:
pixel_spacing = ds.PixelSpacing
elif "SharedFunctionalGroupsSequence" in ds:
pixel_spacing = ds.SharedFunctionalGroupsSequence[0].PixelMeasuresSequence[0].PixelSpacing
else:
# handle no pixel spacing |
Beta Was this translation helpful? Give feedback.
-
@mrbean-bremen Thank you for your kindly reply. Is it possible the |
Beta Was this translation helpful? Give feedback.
-
You probably mean in other sequences - as far as I know, no. |
Beta Was this translation helpful? Give feedback.
-
I find a dicom, where I have upload this dynamic dicom image in: https://github.com/zhang-qiang-github/dicomfile In this image, the Is there any general method to obtian |
Beta Was this translation helpful? Give feedback.
-
You are right, any tag may appear in In theory, you would have to check the value in each of the sequence items in this case, but I think in the case of I'm converting this to a discussion item, as it maybe of interest for someone else. |
Beta Was this translation helpful? Give feedback.
-
Describe the bug
I can not obtain pixel spacing using
pydicom
.Steps To Reproduce
The code is:
And it reports:
'FileDataset' object has no attribute 'PixelSpacing'
Your environment
Other information
I am not sure whether this issue is relatived with my dicom file. If I open it with radiant, it looks like:
which is different with the normal dicom file.
Beta Was this translation helpful? Give feedback.
All reactions