Hi all,
I'm trying to open a CT scan in order to convert the whole volume to houndsfield unit.
In order to do this I manually open each slide and read the slope/intercept and export the whole as a 3D tif image.
But for convenience (and to sustain DICOM metadata) I'm looking for a way to open the list of slides as a sequence and merge common dicom tags (merge a stack of 2D to a single 3D file).
Is there a way to do this (I did not find anything in the doc..) ?
Thanks
If I understand correctly, you want to make an enhanced CT from single slice CTs? In that case I'm afraid you are on your own. If you actually want to create a valid DICOM object, this would be quite a bit of work - and you probably don't really need it. If you just want create a 3D object and save the common tags, this would be less complicated, but you still have to handle and parse the single files separately, e.g. something like
pydicom would only be used to read the files and extract the tags, including the image data, in this scenario,
Is this what you mean to do?
This is exactly what I wanna do.
Secretly hoped pydicom had something to reduce/combine dicom tags
Then I guess I'll juste do something like this :
https://stackoverflow.com/questions/50441027/recursively-merge-dicts-so-that-elements-with-shared-key-are-combined-into-a-lis
Yes, that is a good way to accomplish this!
If you want to share your solution, pydicom-contrib would be a good place for that :)
Closing this as answered.
Sure, I'm working on it but I'll share my code
If you want to share your solution, pydicom-contrib would be a good place for that :)
I implemented it as a 'merge' function (in opposition to Dataset.update) of Dataset objects and port it to Sequence . In your opinion should I go for a pydicom-contrib PR or directly a pydicom PR ?
Here is the code if you wanna make your mind about it.
_I'll also add the ability to ignore/exlude some tags_
I would see that at pydicom-contrib, but would wait for @darcymason to decide.
I'd prefer this to go to contrib for now too... it would be a useful function for many people, I expect, but I'd like to make sure we have the 'API' worked out before putting in mainline pydicom.
Also, implementation detail: I wonder about the recursive merge here. I've had ideas about merging series over the years, but they center around merging all at once rather than two at a time, using all to check for a common data element value across all datasets. That should be much more efficient.
Ok, thanks for the answer, i'll do a pydicom-contrib PR then.
I totally agree with you on the efficiency of the recursive merging, this was just a lazy implementation ;)
Just fixing some minor stuff and looking into the contribution guidelines.