View Source Dicom.BinaryFormat (Dicom.ex v0.3.0)

DICOM binary format serialization/deserialization as defined in PS 3.5.

Summary

Types

Options for the de(serialization) of DICOM binaries.

Functions

Read the next data element from a binary.

Serialize a DIMSE command data set.

Serialize a data element according to the given serialization_options.

Serializes data_set into a full binary string following DICOM part 10.

Types

serialization_options()

@type serialization_options() :: [endianness: :little | :big, explicit: boolean()]

Options for the de(serialization) of DICOM binaries.

Both little and big endian byte ordering is supported by setting endianness to :little or :big respectively. Big endian encoding is discouraged for new files.

Setting explicit to true serializes the data elements with their value representations (VRs) included. If it is set to false, implicit VR encoding is used. Readers of implicit VR data sets must have access to a tag dictionary defining the VRs for all contained data elements.

Functions

from_binary(data, opts)

from_binary_until(data, until_tag, opts)

from_file(path)

@spec from_file(Path.t()) :: {:ok, Dicom.DataSet.t()} | {:error, atom()}

from_file!(path)

@spec from_file!(Path.t()) :: Dicom.DataSet.t()

read_next_data_element(data, arg2)

@spec read_next_data_element(
  data :: binary(),
  opts :: serialization_options()
) :: {:ok, {Dicom.DataElement.t(), binary()}} | {:error, atom()}

Read the next data element from a binary.

This function fails if the binary does not contain at least one complete data element. Any additional data following the data element is returned as the second element in the returned tuple.

serialize(data_set, serialization_options)

serialize_command_data_set(data_set)

Serialize a DIMSE command data set.

Command data sets are always encoded with little endian, implicit VR transfer syntax. In addition, the byte length of the command data set is prefixed as first element.

serialize_data_element(data_element, list)

@spec serialize_data_element(Dicom.DataElement.t(), serialization_options()) ::
  binary()

Serialize a data element according to the given serialization_options.

to_file_data(data_set, preamble \\ <<0::128*8>>)

Serializes data_set into a full binary string following DICOM part 10.