According to this issue https://github.com/suyashkumar/dicom/issues/161, we have OOM issues and it happens when the DICOM is about 784Mb and server memory is 16Gb, and the DICOM contains multiple frames.
Reason 1: the pixel data is always int (64 bits - 8 bytes), even the bitAllocated can be 16 bit, which means this can takes up to 4 times of memory
Reason 2: the way the DICOM library storing data is [[[sample for sample in pixel] for pixel in frame] for frame in image]. B/c the number of pixel per frame is usually 1M (1000 * 1000 image) and sample per pixel can be 1 => this structure takes 4x of memory.
Anyway to change this issue direcly from the library will make a breaking change to end users.
Solution:
Thanks for contributors, we now have an option to skip processing data and the value of pixel data will be stored in byte array. It is called raw data or unprocessing data.
Instead of loading and manipulating the loaded 3-dimension data, we modify the data directly this unprocessed pixeldata. It can be called in-place read/write
This is an experimental MR. Just let me know what do you think about the interface.
Rationale:
[[[sample for sample in pixel] for pixel in frame] for frame in image]
. B/c the number of pixel per frame is usually 1M (1000 * 1000 image) and sample per pixel can be 1 => this structure takes 4x of memory.Solution: