View Source ExDicom.Reader.ReadSequenceItem (EX_DICOM v0.2.0)

Internal helper functions for parsing DICOM elements

Summary

Functions

Reads the tag and length of a sequence item.

Types

sequence_item()

@type sequence_item() :: %{
  tag: String.t(),
  length: non_neg_integer(),
  data_offset: non_neg_integer()
}

Functions

read_sequence_item(byte_stream)

@spec read_sequence_item(ExDicom.ByteStream.t() | nil) ::
  {:ok, sequence_item(), ExDicom.ByteStream.t()} | no_return()

Reads the tag and length of a sequence item.

Returns a tuple of {:ok, element, byte_stream} where:

  • element is a map with the following keys:
    • :tag - string for the tag of this element in the format xggggeeee
    • :length - the number of bytes in this item or 4294967295 if undefined
    • :data_offset - the offset into the byteStream of the data for this item
  • byte_stream is the remaining byte stream after reading

Parameters

  • byte_stream - The byte stream to read from. Must implement the ByteStream protocol

Returns

  • {:ok, element, byte_stream} - Successfully read sequence item
  • raises ArgumentError - If byte_stream is nil
  • raises RuntimeError - If the sequence item tag (FFFE,E000) is not found