Use AsyncDicomReader for streaming DICOM parsing
masterThe AsyncDicomReader is an asynchronous, memory-efficient reader designed for large DICOM files. It uses a streaming approach to process data incrementally using async/await patterns, which helps reduce the memory footprint by avoiding loading entire files into memory at once.
Key Features:
- Asynchronous/Streaming: Incremental reading via
async/await. - Memory Efficient: Uses
BufferStreamwith automatic clearing of consumed buffers. - Transfer Syntax Support: Handles Explicit/Implicit Little/Big Endian and compressed syntaxes.
- Sequence Support: Parses DICOM sequences with defined/undefined lengths.
- Pixel Data: Handles both compressed and uncompressed pixel data.
Limitations:
- Files must contain the standard
DICMpreamble. - The interface is preliminary and subject to change.
import { AsyncDicomReader } from 'dcmjs';
async function readDicomFile(arrayBuffer) {
const reader = new AsyncDicomReader();
reader.stream.setData(arrayBuffer);
await reader.readFile();
console.log('Meta information:', reader.meta);
console.log('Dataset:', reader.dict);
return reader;
}