Closed bisol closed 9 years ago
I have tried and failed to commit a new branch. Anyhow, this worked for me:
// handle nested sequences of explicit length
if (dataElement.vr == "SQ" && sequences.length > 1 ) {
sequences[sequences.length - 2].vlCount -= 4; // offsets the +12 below
}
// end of sequence with explicit length
if ( dataElement.vr !== "SQ" && sequences.length !== 0 ) {
var last = sequences.length - 1;
sequences[last].vlCount += tagOffset;
// check if we have reached the sequence vl
while ( sequences.length > 0 && sequences[last].vlCount === sequences[last].vl ) {
// last count + size of a sequence
var lastVlCount = sequences[last].vlCount + 12;
// remove last sequence
sequences = sequences.slice(0, -1);
// add nested sequence vl
if ( sequences.length !== 0 ) {
last = sequences.length - 1;
sequences[last].vlCount += lastVlCount;
}
}
}
there are so many problems with current dicomParser.js
you need to update dicomParser.js with new one that is
Thanks for your code @bisol!
Your comment is not really helping the issue @pervez8ktt... Feel free to contribute to the dcmbench project to prove your point!
@ivmartel
I should mention that I don't fully understand the magic numbers (+12 and -4). I tested this with a handful of DICOM images, but that's far from thorough. Maybe it will break with a triple nested sequence...
Ok, got it, the problem is implicit/explicit transfer syntax. The 4 bytes are used to store the VR in the explicit case (see DICOM sect_7.5.html#table_7.5-1) which was what I tested against. Yours is implicit so no need for those 4 bytes.
I'm using DWV 0.11.1, and got this error while trying to display an image:
I've traced it to these tests on dwv.dicom.DicomParser.prototype.parse
Seems like it can't handle a sequence with another sequence as it's last item.
This site limits attachments by file extension, so I uploaded the DICOM file renamed to png :p