-
-
Notifications
You must be signed in to change notification settings - Fork 471
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
Write PixelData to DICOM Dataset on disk without loading the PixelData into memory #1913
Comments
No, that is beyond the scope of pydicom directly. Because DICOM doesn't have "records" of fixed size, the only way to know where a data element begins in file is to write out all the previous ones. Here are some thoughts (untested) on a workaround: Create a new One caution for the generator, is that DICOM, IIUC, would require encapsulation for the data -- if you search you will find some previous issues/discussions about that topic; pydicom has some support for encapsulation. I think that could work. If someone wrote something like that, I think we could incorporate it into pydicom. |
A couple of other thoughts:
I'm also musing about a completely different path -- add a callable (generator) to the |
Thanks for the quick reply!
This is what I'm attempting currently! We know the length of bytes ahead of time because we can look at the filesize of the pixel data on disk. So far I've made a class that implements
It seems this function would need to change a bit as you said to see if there is a value_generator |
Here is the hacked function I came up with:
Do you think there is a way to support this kind of use case or would this be out of scope? Open to API suggestions too! |
I think that looks pretty good, and I wouldn't mind incorporating that in pydicom, but perhaps without necessarily knowing the length. I wondered about doing it for any element but practically it should only be OB so I'm okay with that. There would have to be checks in other places in code, like in |
This is the approach I'm going to go with. I'm thinking we can also make it completely compatible with all existing code by making the getter for Then code can opt-in to the iterator interface by checking DataElement for Thanks for being open to the change and for the guidance! |
I have a Python program that creates a .dcm file. It uses pydicom to write the appropriate tags and save the file. I have long mp4 videos that when uncompressed uses about 10gb memory. I'm trying to avoid loading the entire video into memory.
Does Pydicom support setting the PixelData property to a file pointer or stream?
The text was updated successfully, but these errors were encountered: