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

How to use python code to read the pixel data in the segmentation file ? #232

Open
RitchieAlpha opened this issue Jul 30, 2018 · 2 comments

Comments

@RitchieAlpha
Copy link

We find that the data structure of the segmentation is different from the standard dicom file.
We wonder how to read the pixel data in the segmentation by python code?
We use PyDicom module to do this.
I wish you can help us, Thank you very much!

@pieper
Copy link
Member

pieper commented Jul 30, 2018

Hi - the segmentation object will have a PixelData like other objects, but it will be a multiframe with multiple segments concatenated. You need to be able to parse the other header fields to know how the pixels are encoded. I don't think we currently have a pydicom implementation of this, but it's definitely possible to do.

Here's some javascript code that should give you an idea:

https://github.com/pieper/dcmjs/blob/master/examples/displaySegmentation/index.html#L198

If you pursue this and get something working in python it would to post it.

@fedorov
Copy link
Member

fedorov commented Jul 30, 2018

@RitchieAlpha we added the functionality to pydicom to unpack PixelData of the segmentation objects. You can see the details of how it is implemented here: pydicom/pydicom#627. That PR was merged in the end of April, so you should be able to access it from pydicom installed from source, at least.

Note that this functionality just unpacks the individual frames. If you want to reconstruct the volumes of the individual segments, you will need to take a look at the shared and per-frame attributes for image positon, orientation and spacing for the individual frames, and you will also need to look at the segment number corresponding to the individual frames. But hopefully this won't be too hard.

If you have specific questions, or if you have suggestions as to how pydicom functionality could be improved - please let us know!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants