Pydicom is a commonly used Python DICOM parser. However, an example of parsing a multi frame graph is not provided. In this paper, a simple explanation is made by combining the correlation function and DICOM knowledge.
DICOM multi frame data storage
The most important part of DICOM standard about multi frame data storage is ps3.5 annex a.4 a.4 transfer syntax for encapsulation of encoded pixel data.
Pixel data is stored in pixel data (7fe00010) at any time. It may be stored directly (native) or packaged (encapsulated). Common multi frame images are usually stored in package, especially when the data is stored in compressed format.
When packing and storing, the data is divided into many data stream fragments, and each segment is saved as a DICOM item with the tag of (fffe, e000). The first item saves the basic offset table and the starting offset of each frame. Then, the following data segment holds the real data.
**Theoretically, a frame can be saved in multiple data segments. **However, one data segment does not hold two frames of data. In practical application, it is rarely seen that frames cross data segments, but a good DICOM parser should support this situation. That’s why the interfaces of some DICOM libraries look a little odd.
Take pydicom 1.2 as an example, pydicom.encaps It encapsulates the functions related to multiple frames. Analysis of the most likely functions
Multi frame usage pydicom.encaps To deal with it
pydicom.encaps.decode_ data_ Sequence returns the item of each (fffe, e000) in the form of a list of byte strings. If you get all the fragment data at one time, it may consume a lot of memory. Notice that in theory you don’t get a frame
pydicom.encaps.generate_ pixel_ Data generates a generator. Each iteration, the return is made into a fragments tuple, each fragment is a byte, and each tuple is a frame. If a fame is saved in a frame. Tuple has only one element.
pydicom.encaps.generate_ pixel_ data_ The frame iteration returns one byte at a time, which represents all the data of the frame. This should be the most commonly used function. Code implementation is to generate_ pixel_ The tuples generated by data are spliced together.
The input of these methods is pixel_ array。 The corresponding pydicom provides a method of using FP as a parameter.
The above detailed explanation of Python parsing multi frame DICOM data is the whole content shared by Xiaobian. I hope it can give you a reference, and I hope you can support developer more.