Dicom.VR (Dicom v0.9.1)

Copy Markdown View Source

DICOM Value Representations (VR).

Defines the data types used in DICOM attributes: Person Name (PN), Date (DA), Unique Identifier (UI), Other Byte (OB), etc.

Reference: DICOM PS3.5 Section 6.2.

Summary

Functions

Returns a sorted list of all 34 VR atoms.

Returns true if the VR represents binary/pixel data.

Returns the list of binary VR atoms.

Returns the human-readable description for a VR per PS3.5 Table 6.2-1.

Returns true if the VR has a fixed byte length (AT, FL, FD, SL, SS, UL, US, SV, UV).

Parses a 2-byte VR string into an atom.

Returns true if the VR uses explicit length encoding with a 4-byte length field (the "long" VRs that use 2 reserved bytes + 4-byte length in Explicit VR).

Returns the maximum character/byte length for a VR, or :unlimited.

Returns true if the VR represents a numeric type.

Returns the list of numeric VR atoms.

Pads a binary value to even length per DICOM requirements.

Returns the padding byte for this VR.

Returns true if the VR represents a string type.

Returns the list of string VR atoms.

Converts a VR atom to its 2-byte binary representation.

Types

t()

@type t() ::
  :AE
  | :AS
  | :AT
  | :CS
  | :DA
  | :DS
  | :DT
  | :FL
  | :FD
  | :IS
  | :LO
  | :LT
  | :OB
  | :OD
  | :OF
  | :OL
  | :OV
  | :OW
  | :PN
  | :SH
  | :SL
  | :SQ
  | :SS
  | :ST
  | :SV
  | :TM
  | :UC
  | :UI
  | :UL
  | :UN
  | :UR
  | :US
  | :UT
  | :UV

Functions

all()

@spec all() :: [t()]

Returns a sorted list of all 34 VR atoms.

Examples

iex> :PN in Dicom.VR.all()
true

iex> length(Dicom.VR.all())
34

binary?(vr)

@spec binary?(t()) :: boolean()

Returns true if the VR represents binary/pixel data.

binary_vrs()

@spec binary_vrs() :: [t()]

Returns the list of binary VR atoms.

description(vr)

@spec description(t()) :: String.t()

Returns the human-readable description for a VR per PS3.5 Table 6.2-1.

Examples

iex> Dicom.VR.description(:PN)
"Person Name"

iex> Dicom.VR.description(:DA)
"Date"

fixed_length?(vr)

@spec fixed_length?(t()) :: boolean()

Returns true if the VR has a fixed byte length (AT, FL, FD, SL, SS, UL, US, SV, UV).

from_binary(arg1)

@spec from_binary(binary()) :: {:ok, t()} | {:error, :unknown_vr}

Parses a 2-byte VR string into an atom.

Examples

iex> Dicom.VR.from_binary("PN")
{:ok, :PN}

iex> Dicom.VR.from_binary("XX")
{:error, :unknown_vr}

long_length?(vr)

@spec long_length?(t()) :: boolean()

Returns true if the VR uses explicit length encoding with a 4-byte length field (the "long" VRs that use 2 reserved bytes + 4-byte length in Explicit VR).

max_length(vr)

@spec max_length(t()) :: pos_integer() | :unlimited

Returns the maximum character/byte length for a VR, or :unlimited.

Examples

iex> Dicom.VR.max_length(:PN)
64

iex> Dicom.VR.max_length(:UT)
:unlimited

numeric?(vr)

@spec numeric?(t()) :: boolean()

Returns true if the VR represents a numeric type.

numeric_vrs()

@spec numeric_vrs() :: [t()]

Returns the list of numeric VR atoms.

pad_value(value, vr)

@spec pad_value(binary(), t()) :: binary()

Pads a binary value to even length per DICOM requirements.

All DICOM value fields must have even length. If the value has odd length, a single padding byte is appended based on the VR.

padding_byte(vr)

@spec padding_byte(t()) :: byte()

Returns the padding byte for this VR.

Per PS3.5 Section 6.2: UI values are padded with NULL (0x00), other string VRs are padded with SPACE (0x20), and binary VRs are padded with 0x00.

string?(vr)

@spec string?(t()) :: boolean()

Returns true if the VR represents a string type.

string_vrs()

@spec string_vrs() :: [t()]

Returns the list of string VR atoms.

to_binary(vr)

@spec to_binary(t()) :: binary()

Converts a VR atom to its 2-byte binary representation.