dcmjs-org / dcmjs

Javascript implementation of DICOM manipulation
https://dcmjs.netlify.com/
MIT License
296 stars 112 forks source link

Reading a big sized DICOM: RangeError: Offset is outside the bounds of the DataView #290

Closed z-nino closed 2 years ago

z-nino commented 2 years ago

When I try to read a ArrayBuffer of a big Dicom (1.13 GB), I get this error:

dcmjs.es.js?b347:897 Uncaught (in promise) RangeError: Offset is outside the bounds of the DataView
    at DataView.getUint16 (<anonymous>)
    at ReadBufferStream.readUint16 (dcmjs.es.js?b347:897:1)
    at SequenceOfItems.readBytes (dcmjs.es.js?b347:2125:1)
    at SequenceOfItems.read (dcmjs.es.js?b347:1166:1)
    at Function.readTag (dcmjs.es.js?b347:3287:1)
    at Function.read (dcmjs.es.js?b347:3129:1)
    at Function.readFile (dcmjs.es.js?b347:3193:1)
    at _callee$ (dicom.js?583f:5:1)
    at tryCatch (runtime.js?96cf:63:1)
    at Generator.invoke [as _invoke] (runtime.js?96cf:293:1)

Code: let DicomDict = dcmjs.data.DicomMessage.readFile(dicom.content);

Dicoms which are smaller in size, are read without any problems.

pieper commented 2 years ago

Are you using node or a specific browser? Can you share a dataset to replicate the issue? It may be that you are hitting a system resource limit on the size of instance that can be handled.

z-nino commented 2 years ago

We are using the Chrome browser. Here is the dicom in question: https://drive.google.com/file/d/1nrrrfbHFySYVwWb_NtkzVr8WRFCuTe7I/view?usp=sharing

pieper commented 2 years ago

I was going to have a look at this but the link is dead. I guess the issue is resolved or you determined this was a browser limitation, but reopen this issue if you think there's something wrong in the library.

ledinhthi commented 2 years ago

Dataset.file_meta ------------------------------- (0002, 0002) Media Storage SOP Class UID UI: Encapsulated PDF Storage (0002, 0003) Media Storage SOP Instance UID UI: 2.16.840.1.114430.287196081618142314176776725491661159509.60.1 (0002, 0010) Transfer Syntax UID UI: Explicit VR Little Endian (0002, 0012) Implementation Class UID UI: 1.3.46.670589.50.1.8.0

(0008, 0005) Specific Character Set CS: 'ISO_IR 192' (0008, 0016) SOP Class UID UI: Encapsulated PDF Storage (0008, 0018) SOP Instance UID UI: 1.9.9.01003197320704082022 (0008, 0023) Content Date DA: '20220804' (0008, 0033) Content Time TM: '010031.964232' (0008, 0060) Modality CS: 'DOC' (0008, 0064) Conversion Type CS: 'WSD' (0010, 0010) Patient's Name PN: 'John Doe' (0010, 0020) Patient ID LO: '12345' (0010, 0040) Patient's Sex CS: 'M' (0020, 000d) Study Instance UID UI: 1.9.9.01003196523004082022 (0020, 000e) Series Instance UID UI: 1.9.9.01003197320704082022 (0042, 0011) Encapsulated Document OB: Array of 27714 elements (0042, 0012) MIME Type of Encapsulated Document LO: 'application/pdf'