DicomParser
Source: dicomParser.js:675
DicomParser class.
Example
CODE
import {DicomParser} from '//esm.sh/dwv';
// XMLHttpRequest onload callback
const onload = function (event) {
// setup the dicom parser
const dicomParser = new DicomParser();
// parse the buffer
dicomParser.parse(event.target.response);
// get the dicom tags
const tags = dicomParser.getDicomElements();
// display the modality
const div = document.getElementById('dwv');
div.appendChild(document.createTextNode(
'Modality: ' + tags['00080060'].value[0]
));
};
// DICOM file request
const request = new XMLHttpRequest();
const url = 'https://raw.githubusercontent.com/ivmartel/dwv/master/tests/data/bbmri-53323851.dcm';
request.open('GET', url);
request.responseType = 'arraybuffer';
request.onload = onload;
request.send();Constructor
new DicomParser(): DicomParserInstance Methods
getDefaultCharacterSet(): string
Get the default character set.
Returns
string— The default character set.
setDefaultCharacterSet(characterSet: string)
Set the default character set.
Parameters
characterSet(string) — The input character set.
setDecoderCharacterSet(characterSet: string)
Set the text decoder character set.
Parameters
characterSet(string) — The input character set.
getDicomElements(): Record.<string, DataElement>
Get the DICOM data elements.
Returns
Record.<string,DataElement>— The data elements.
safeGet(key: string): any | undefined
Safely get an elements' first value from the parsed elements.
Parameters
key(string) — The tag key as for example '00100020'.
Returns
any | undefined— The elements' value or undefined.
parse(buffer: ArrayBuffer, untilTag?: Tag)
Parse a DICOM buffer. Fills in the member object 'dataElements'.
Parameters
buffer(ArrayBuffer) — The input array buffer.untilTag(Tag, optional) — Optional tag to stop the parsing once reached.