Constructor
new DicomWriter()
- Source
// add link to html
const link = document.createElement("a");
link.appendChild(document.createTextNode("download"));
const div = document.getElementById("dwv");
div.appendChild(link);
// XMLHttpRequest onload callback
const onload = function (event) {
const parser = new dwv.DicomParser();
parser.parse(event.target.response);
// create writer
const writer = new dwv.DicomWriter();
// get buffer using default rules
const dicomBuffer = writer.getBuffer(parser.getDicomElements());
// create blob
const blob = new Blob([dicomBuffer], {type: 'application/dicom'});
// add blob to download link
link.href = URL.createObjectURL(blob);
link.download = "anonym.dcm";
};
// 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
getBuffer(dataElements) → {ArrayBuffer}
Get the ArrayBuffer corresponding to input DICOM elements.
Name | Type | Description |
---|---|---|
dataElements | Object.<string, DataElement> | The elements to write. |
- Source
The elements as a buffer.
- Type:
- ArrayBuffer
getElementToWrite(element) → {DataElement|null}
Get the element to write according to the class rules. Priority order: tagName, groupName, default.
Name | Type | Description |
---|---|---|
element | DataElement | The element to check. |
- Source
The element to write, can be null.
- Type:
- DataElement |
null
setFixUnknownVR(flag)
Set the vr=UN check and fix flag.
Name | Type | Description |
---|---|---|
flag | boolean | True to activate the check and fix. |
- Source
setRules(rules, addMissingTagsopt)
Set the writing rules. List of writer rules indexed by either default
, tagKey, tagName or groupName. Each DICOM element will be checked to see if a rule is applicable. First checked by tagKey, tagName and then by groupName, if nothing is found the default rule is applied.
Name | Type | Attributes | Description |
---|---|---|---|
rules | Object.<string, WriterRule> | The input rules. | |
addMissingTags | boolean | <optional> | If true, explicit tags that have replace rule and a value will be added if missing. Defaults to false. |
- Source
setUseUnVrForPrivateSq(flag)
Set the use UN VR for private sequence flag.
Name | Type | Description |
---|---|---|
flag | boolean | True to use UN VR. |
- Source
useSpecialTextEncoder()
Use a TextEncoder instead of the default text decoder.
- Source