dwv.dicom. DicomWriter

new DicomWriter()

DICOM writer.

Example usage: var parser = new dwv.dicom.DicomParser(); parser.parse(this.response);

var writer = new dwv.dicom.DicomWriter(parser.getRawDicomElements()); var blob = new Blob([writer.getBuffer()], {type: 'application/dicom'});

var element = document.getElementById("download"); element.href = URL.createObjectURL(blob); element.download = "anonym.dcm";

Members

anonymisationRules

Example anonymisation rules.

rules

Public (modifiable) rules. Set of objects as: name : { action: 'actionName', value: 'optionalValue } The names are either 'default', tagName or groupName. Each DICOM element will be checked to see if a rule is applicable. First checked by tagName and then by groupName, if nothing is found the default rule is applied.

Methods

encodeSpecialString(str) → {Uint8Array}

Encode data as a UTF-8.

Parameters:
NameTypeDescription
strnumber

The string to write.

Returns:

The encoded string.

Type: 
Uint8Array

encodeString(str) → {Uint8Array}

Encode string data.

Parameters:
NameTypeDescription
strnumber

The string to encode.

Returns:

The encoded string.

Type: 
Uint8Array

getBuffer(dicomElements) → {ArrayBuffer}

Get the ArrayBuffer corresponding to input DICOM elements.

Parameters:
NameTypeDescription
dicomElementsArray

The wrapped elements to write.

Returns:

The elements as a buffer.

Type: 
ArrayBuffer

getElementToWrite(element) → {object}

Get the element to write according to the class rules. Priority order: tagName, groupName, default.

Parameters:
NameTypeDescription
elementobject

The element to check

Returns:

The element to write, can be null.

Type: 
object

setElementValue(element, value, isImplicit, bitsAllocated) → {number}

Set a DICOM element value according to its VR (Value Representation).

Parameters:
NameTypeDescription
elementobject

The DICOM element to set the value.

valueobject

The value to set.

isImplicitboolean

Does the data use implicit VR?

bitsAllocatednumber

Bits allocated used for pixel data.

Returns:

The total element size.

Type: 
number

useSpecialTextEncoder()

Use a TextEncoder instead of the default text decoder.

writeDataElement(writer, element, byteOffset, isImplicit) → {number}

Write a data element.

Parameters:
NameTypeDescription
writerdwv.dicom.DataWriter

The raw data writer.

elementobject

The DICOM data element to write.

byteOffsetnumber

The offset to start writing from.

isImplicitboolean

Is the DICOM VR implicit?

Returns:

The new offset position.

Type: 
number

writeDataElementItems(writer, byteOffset, items, isImplicit) → {number}

Write a list of items.

Parameters:
NameTypeDescription
writerdwv.dicom.DataWriter

The raw data writer.

byteOffsetnumber

The offset to start writing from.

itemsArray

The list of items to write.

isImplicitboolean

Is the DICOM VR implicit?

Returns:

The new offset position.

Type: 
number

writeDataElementValue(writer, element, byteOffset, value, isImplicit) → {number}

Write data with a specific Value Representation (VR).

Parameters:
NameTypeDescription
writerdwv.dicom.DataWriter

The raw data writer.

elementobject

The element to write.

byteOffsetnumber

The offset to start writing from.

valueArray

The array to write.

isImplicitboolean

Is the DICOM VR implicit?

Returns:

The new offset position.

Type: 
number

writePixelDataElementValue(writer, element, byteOffset, value, isImplicit) → {number}

Write a pixel data element.

Parameters:
NameTypeDescription
writerdwv.dicom.DataWriter

The raw data writer.

elementobject

The element to write.

byteOffsetnumber

The offset to start writing from.

valueArray

The array to write.

isImplicitboolean

Is the DICOM VR implicit?

Returns:

The new offset position.

Type: 
number