dwv. dicom

Classes

DataReader
DataWriter
DicomElementsWrapper
DicomParser
DicomWriter
Tag

Members

(static) dictionary

DICOM tag dictionary 2022a. Generated using xml standard conversion from https://github.com/ivmartel/dcmStdToJs v0.1.0. Conversion changes:

  • (vr) 'See Note' -> 'NONE', 'OB or OW' -> 'ox', 'US or SS' -> 'xs'
  • added 'GenericGroupLength' element to each group Local changes:
  • tag numbers with 'xx' were replaced with '00', 'xxx' with '001' and 'xxxx' with '0004'

(static) requiredDicomSegTags

List of DICOM Seg required tags.

Methods

(static) DefaultTextDecoder()

Default text decoder

(static) DefaultTextEncoder()

Default text encoder.

(static) checkTag(rootElement, tagDefinition)

Check that a DICOM tag definition is present in a parsed element.

Parameters:
NameTypeDescription
rootElementobject

The root dicom element.

tagDefinitionobject

The tag definition as {name, tag, type, enum}.

(static) checkTags(tags, requiredTags, withLog) → {boolean}

Check a list of input tags against a required list.

Parameters:
NameTypeDescription
tagsobject

The tags to check.

requiredTagsArray

Array of tag names.

withLogboolean

Flag to log errors or not.

Returns:

True if all required tags are present in the input.

Type: 
boolean

(static) checkUnknownVR(element)

Fix for broken DICOM elements: Replace "UN" with correct VR if the element exists in dictionary

Parameters:
NameTypeDescription
elementobject

The DICOM element.

(static) cleanString(inputStr) → {string}

Clean string: trim and remove ending.

Parameters:
NameTypeDescription
inputStrstring

The string to clean.

Returns:

The cleaned string.

Type: 
string

(static) equalPosPat(pos1, pos2) → {boolean}

Check two position patients for equality.

Parameters:
NameTypeDescription
pos1*

The first position patient.

pos2*

The second position patient.

Returns:

True is equal.

Type: 
boolean

(static) flattenArrayOfTypedArrays(initialArray) → {object}

Helper method to flatten an array of typed arrays to 2D typed array

Parameters:
NameTypeDescription
initialArrayArray

array of typed arrays

Returns:

a typed array containing all values

Type: 
object

(static) flipArrayEndianness(array)

Flip an array's endianness. Inspired from DataStream.js.

Parameters:
NameTypeDescription
arrayobject

The array to flip (modified).

(static) generatePixelDataFromJSONTags(tags, pixGeneratorName, sliceNumber, images, numberOfSlices) → {object}

Get the DICOM pixel data from a DICOM tags object.

Parameters:
NameTypeDescription
tagsobject

The DICOM tags object.

pixGeneratorNamestring

The name of a pixel generator.

sliceNumbernumber

The slice number.

imagesArray

The images to pass to the generator.

numberOfSlicesnumber

The result number of slices.

Returns:

The DICOM pixel data element.

Type: 
object

(static) getBpeForVrType(vrType) → {number}

Get the number of bytes per element for a given VR type.

Parameters:
NameTypeDescription
vrTypestring

The VR type as defined in the dictionary.

Returns:

The bytes per element.

Type: 
number

(static) getCode(element) → {object}

Get a code object from a dicom element.

Parameters:
NameTypeDescription
elementobject

The dicom element.

Returns:

A code object.

Type: 
object

(static) getComparePosPat(orientation) → {function}

Get a position patient compare function accroding to an input orientation.

Parameters:
NameTypeDescription
orientationdwv.math.Matrix33

The orientation matrix.

Returns:

The position compare function.

Type: 
function

(static) getDataElementPrefixByteSize(vr, isImplicit) → {number}

Get the number of bytes occupied by a data element prefix, i.e. without its value.

Parameters:
NameTypeDescription
vrstring

The Value Representation of the element.

isImplicitboolean

Does the data use implicit VR?

Returns:

The size of the element prefix. WARNING: this is valid for tags with a VR, if not sure use the 'isTagWithVR' function first. Reference:

| Tag | VR | VL | Value | | 4 | 2 | 2 | X | -> regular explicit: 8 + X | 4 | 2+2 | 4 | X | -> 32bit VL: 12 + X

| Tag | VL | Value | | 4 | 4 | X | -> implicit (32bit VL): 8 + X

| Tag | Len | Value | | 4 | 4 | X | -> item: 8 + X

Type: 
number

(static) getDefaultDicomSegJson() → {object}

Get the default DICOM seg tags as an object.

Returns:

The default tags.

Type: 
object

(static) getDicomElement(tagName) → {object}

Get a DICOM element from its tag name (value set separatly).

Parameters:
NameTypeDescription
tagNamestring

The string tag name.

Returns:

The DICOM element.

Type: 
object

(static) getDimensionOrganization(rootElement) → {object}

Check the dimension organization from a dicom element.

Parameters:
NameTypeDescription
rootElementobject

The root dicom element.

Returns:

The dimension organizations and indices.

Type: 
object

(static) getDwvUIDPrefix() → {string}

Get the dwv UID prefix. Issued by Medical Connections Ltd (www.medicalconnections.co.uk) on 25/10/2017.

Returns:

The dwv UID prefix.

Type: 
string

(static) getElementsFromJSONTags(jsonTags) → {object}

Get the DICOM elements from a DICOM json tags object. The json is a simplified version of the oficial DICOM json with tag names instead of keys and direct values (no value property) for simple tags.

Parameters:
NameTypeDescription
jsonTagsobject

The DICOM json tags object.

Returns:

The DICOM elements.

Type: 
object

(static) getFileListFromDicomDir(data) → {Array|undefined}

Get the file list from a DICOMDIR

Parameters:
NameTypeDescription
dataobject

The buffer data of the DICOMDIR

Returns:

The file list as an array ordered by STUDY > SERIES > IMAGES.

Type: 
Array | undefined

(static) getFileMetaInformationGroupLengthTag() → {object}

Get the FileMetaInformationGroupLength Tag.

Returns:

The tag.

Type: 
object

(static) getImageDataData(image) → {object}

Extract the image data from an image.

Parameters:
NameTypeDescription
imageImage

The image to get the data from.

Returns:

The image data buffer.

Type: 
object

(static) getItemDelimitationItemTag() → {dwv.dicom.Tag}

Get the ItemDelimitationItem Tag.

Returns:

The tag.

Type: 
dwv.dicom.Tag

(static) getItemTag() → {dwv.dicom.Tag}

Get the Item Tag.

Returns:

The tag.

Type: 
dwv.dicom.Tag

(static) getOrientationName(orientation) → {string}

Get the name of an image orientation patient.

Parameters:
NameTypeDescription
orientationArray

The image orientation patient.

Returns:

The orientation name: axial, coronal or sagittal.

Type: 
string

(static) getPixelDataTag() → {dwv.dicom.Tag}

Get the PixelData Tag.

Returns:

The tag.

Type: 
dwv.dicom.Tag

(static) getReverseOrientation(ori) → {string}

Get patient orientation label in the reverse direction.

Parameters:
NameTypeDescription
oristring

Patient Orientation value.

Returns:

Reverse Orientation Label.

Type: 
string

(static) getSegment(element) → {object}

Get a segment object from a dicom element.

Parameters:
NameTypeDescription
elementobject

The dicom element.

Returns:

A segment object.

Type: 
object

(static) getSegmentFrameInfo(groupItem) → {object}

Get a frame information object from a dicom element.

Parameters:
NameTypeDescription
groupItemobject

The dicom element.

Returns:

A frame information object.

Type: 
object

(static) getSequenceDelimitationItemTag() → {dwv.dicom.Tag}

Get the SequenceDelimitationItem Tag.

Returns:

The tag.

Type: 
dwv.dicom.Tag

(static) getSpacingFromMeasure(measure) → {dwv.image.Spacing}

Get a spacing object from a dicom measure element.

Parameters:
NameTypeDescription
measureobject

The dicom element.

Returns:

A spacing object.

Type: 
dwv.image.Spacing

(static) getSyntaxDecompressionName(syntax) → {string}

Tell if a given syntax needs decompression.

Parameters:
NameTypeDescription
syntaxstring

The transfer syntax to test.

Returns:

The name of the decompression algorithm.

Type: 
string

(static) getTagFromDictionary(tagName) → {object|null}

Get a tag from the dictionary using a tag string name.

Parameters:
NameTypeDescription
tagNamestring

The tag string name.

Returns:

The tag object or null if not found.

Type: 
object | null

(static) getTagFromKey(key) → {object}

Split a group-element key used to store DICOM elements.

Parameters:
NameTypeDescription
keystring

The key in form "x00280102" as generated by tag::getKey.

Returns:

The DICOM tag.

Type: 
object

(static) getTransferSyntaxName(syntax) → {string}

Get the transfer syntax name. Reference: UID Values.

Parameters:
NameTypeDescription
syntaxstring

The transfer syntax.

Returns:

The name of the transfer syntax.

Type: 
string

(static) getTransferSyntaxUIDTag() → {object}

Get the TransferSyntaxUID Tag.

Returns:

The tag.

Type: 
object

(static) getTypedArray(bitsAllocated, pixelRepresentation, size) → {Array}

Get the appropriate TypedArray in function of arguments.

Parameters:
NameTypeDescription
bitsAllocatednumber

The number of bites used to store the data: [8, 16, 32].

pixelRepresentationnumber

The pixel representation, 0:unsigned;1:signed.

sizedwv.image.Size

The size of the new array.

Returns:

The good typed array.

Type: 
Array

(static) getUID(tagName) → {string}

Get a UID for a DICOM tag. Note: Use https://github.com/uuidjs/uuid?

Parameters:
NameTypeDescription
tagNamestring

The input tag.

Returns:

The corresponding UID.

Type: 
string

(static) getUtfLabel(charSetTerm) → {string}

Get the utfLabel (used by the TextDecoder) from a character set term References:

Parameters:
NameTypeDescription
charSetTermstring

The DICOM character set.

Returns:

The corresponding UTF label.

Type: 
string

(static) getVrPad(vr) → {boolean}

Get the VR specific padding value.

Parameters:
NameTypeDescription
vrstring

The element VR.

Returns:

The value used to pad.

Type: 
boolean

(static) guessTransferSyntax(firstDataElement) → {object}

Guess the transfer syntax from the first data element. See https://github.com/ivmartel/dwv/issues/188 (Allow to load DICOM with no DICM preamble) for more details.

Parameters:
NameTypeDescription
firstDataElementobject

The first data element of the DICOM header.

Returns:

The transfer syntax data element.

Type: 
object

(static) hasDicomPrefix(buffer) → {boolean}

Check that an input buffer includes the DICOM prefix 'DICM' after the 128 bytes preamble. Ref: DICOM File Meta

Parameters:
NameTypeDescription
bufferArrayBuffer

The buffer to check.

Returns:

True if the buffer includes the prefix.

Type: 
boolean

(static) is32bitVLVR(vr) → {boolean}

Does this Value Representation (VR) have a 32bit Value Length (VL). Ref: Data Element explicit.

Parameters:
NameTypeDescription
vrstring

The data Value Representation (VR).

Returns:

True if this VR has a 32-bit VL.

Type: 
boolean

(static) isBigEndianTransferSyntax(syntax) → {boolean}

Tell if a given syntax is a big endian syntax.

Parameters:
NameTypeDescription
syntaxstring

The transfer syntax to test.

Returns:

True if a big endian syntax.

Type: 
boolean

(static) isEqualSegment(seg1, seg2) → {boolean}

Check if two segment objects are equal.

Parameters:
NameTypeDescription
seg1object

The first segment.

seg2object

The second segment.

Returns:

True if both segment are equal.

Type: 
boolean

(static) isEven(number) → {boolean}

Return true if the input number is even.

Parameters:
NameTypeDescription
numbernumber

The number to check.

Returns:

True is the number is even.

Type: 
boolean

(static) isFileMetaInformationGroupLengthTag(tag) → {boolean}

Is the input tag the FileMetaInformationGroupLength Tag.

Parameters:
NameTypeDescription
tagdwv.dicom.Tag

The tag to test.

Returns:

True if the asked tag.

Type: 
boolean

(static) isImplicitTransferSyntax(syntax) → {boolean}

Tell if a given syntax is an implicit one (element with no VR).

Parameters:
NameTypeDescription
syntaxstring

The transfer syntax to test.

Returns:

True if an implicit syntax.

Type: 
boolean

(static) isItemDelimitationItemTag(tag) → {boolean}

Is the input tag the ItemDelimitationItem Tag.

Parameters:
NameTypeDescription
tagdwv.dicom.Tag

The tag to test.

Returns:

True if the asked tag.

Type: 
boolean

(static) isItemTag(tag) → {boolean}

Is the input tag the Item Tag.

Parameters:
NameTypeDescription
tagdwv.dicom.Tag

The tag to test.

Returns:

True if the asked tag.

Type: 
boolean

(static) isJpeg2000TransferSyntax(syntax) → {boolean}

Tell if a given syntax is a JPEG 2000 one.

Parameters:
NameTypeDescription
syntaxstring

The transfer syntax to test.

Returns:

True if a jpeg 2000 syntax.

Type: 
boolean

(static) isJpegBaselineTransferSyntax(syntax) → {boolean}

Tell if a given syntax is a JPEG baseline one.

Parameters:
NameTypeDescription
syntaxstring

The transfer syntax to test.

Returns:

True if a jpeg baseline syntax.

Type: 
boolean

(static) isJpegLosslessTransferSyntax(syntax) → {boolean}

Tell if a given syntax is a JPEG Lossless one.

Parameters:
NameTypeDescription
syntaxstring

The transfer syntax to test.

Returns:

True if a jpeg lossless syntax.

Type: 
boolean

(static) isJpegRetiredTransferSyntax(syntax) → {boolean}

Tell if a given syntax is a retired JPEG one.

Parameters:
NameTypeDescription
syntaxstring

The transfer syntax to test.

Returns:

True if a retired jpeg syntax.

Type: 
boolean

(static) isJpeglsTransferSyntax(syntax) → {boolean}

Tell if a given syntax is a JPEG-LS one.

Parameters:
NameTypeDescription
syntaxstring

The transfer syntax to test.

Returns:

True if a jpeg-ls syntax.

Type: 
boolean

(static) isNativeLittleEndian()

Is the Native endianness Little Endian.

(static) isPixelDataTag(tag) → {boolean}

Is the input tag the PixelData Tag.

Parameters:
NameTypeDescription
tagdwv.dicom.Tag

The tag to test.

Returns:

True if the asked tag.

Type: 
boolean

(static) isReadSupportedTransferSyntax(syntax) → {boolean}

Tell if a given syntax is supported for reading.

Parameters:
NameTypeDescription
syntaxstring

The transfer syntax to test.

Returns:

True if a supported syntax.

Type: 
boolean

(static) isRleTransferSyntax(syntax) → {boolean}

Tell if a given syntax is a RLE (Run-length encoding) one.

Parameters:
NameTypeDescription
syntaxstring

The transfer syntax to test.

Returns:

True if a RLE syntax.

Type: 
boolean

(static) isSequenceDelimitationItemTag(tag) → {boolean}

Is the input tag the SequenceDelimitationItem Tag.

Parameters:
NameTypeDescription
tagdwv.dicom.Tag

The tag to test.

Returns:

True if the asked tag.

Type: 
boolean

(static) isSimilarSegment(seg1, seg2) → {boolean}

Check if two segment objects are similar: either the number or the displayValue are equal.

Parameters:
NameTypeDescription
seg1object

The first segment.

seg2object

The second segment.

Returns:

True if both segment are similar.

Type: 
boolean

(static) isStringVr(vr) → {boolean}

Is the input VR a string VR.

Parameters:
NameTypeDescription
vrstring

The element VR.

Returns:

True if the VR is a string one.

Type: 
boolean

(static) isTypedArrayVr(vr) → {boolean}

Is the input VR a VR that stores data in a typed array. TODO: include ox and xs?

Parameters:
NameTypeDescription
vrstring

The element VR.

Returns:

True if the VR is a typed array one.

Type: 
boolean

(static) isVrToPad(vr) → {boolean}

Is the input VR a VR that could need padding. see http://dicom.nema.org/dicom/2013/output/chtml/part05/sect_6.2.html

Parameters:
NameTypeDescription
vrstring

The element VR.

Returns:

True if the VR needs padding.

Type: 
boolean

(static) padOBValue(value) → {Array|Uint8Array}

Pad an input OB value.

Parameters:
NameTypeDescription
valueArray | Uint8Array

The input value.

Returns:

The padded input.

Type: 
Array | Uint8Array

(static) tagCompareFunction(a, b) → {number}

Tag compare function.

Parameters:
NameTypeDescription
adwv.dicom.Tag

The first tag.

bdwv.dicom.Tag

The second tag.

Returns:

The result of the tag comparison, positive for b before a, negative for a before b and zero to keep same order.

Type: 
number

(static) uint8ArrayPush(arr, value) → {Uint8Array}

Push a value at the end of an input Uint8Array.

Parameters:
NameTypeDescription
arrUint8Array

The input array.

valuenumber

The value to push.

Returns:

The new array.

Type: 
Uint8Array