Constructor
new DicomParser()
- Source
Example
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();
Methods
getDefaultCharacterSet() → {string}
Get the default character set.
- Source
Returns:
The default character set.
- Type:
- string
getDicomElements() → {Object.<string, DataElement>}
Get the DICOM data elements.
- Source
Returns:
The data elements.
- Type:
- Object.<string, DataElement>
parse(buffer, untilTagopt)
Parse a DICOM buffer. Fills in the member object 'dataElements'.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
buffer | ArrayBuffer | The input array buffer. | |
untilTag | Tag | <optional> | Optional tag to stop the parsing once reached. |
safeGet(key) → {any|undefined}
Safely get an elements' first value from the parsed elements.
Parameters:
Name | Type | Description |
---|---|---|
key | string | The tag key as for example '00100020'. |
- Source
Returns:
The elements' value or undefined.
- Type:
- any |
undefined
setDecoderCharacterSet(characterSet)
Set the text decoder character set.
Parameters:
Name | Type | Description |
---|---|---|
characterSet | string | The input character set. |
- Source
setDefaultCharacterSet(characterSet)
Set the default character set.
Parameters:
Name | Type | Description |
---|---|---|
characterSet | string | The input character set. |
- Source