View Source ExDicom.Reader.ReadTag (EX_DICOM v0.2.0)
Provides a function to read a DICOM tag (group + element) from a ByteStream.
Corresponds to the JavaScript function:
export default function readTag(byteStream) {
if (byteStream === undefined) {
throw 'dicomParser.readTag: missing required parameter 'byteStream'';
}
const groupNumber = byteStream.readUint16() * 256 * 256;
const elementNumber = byteStream.readUint16();
const tag = `x${("00000000" + (groupNumber + elementNumber).toString(16)).substr(-8)}`;
return tag;
}
Summary
Functions
Reads a tag (group number and element number) from a ByteStream, returning
the tag in the format xggggeeee
where gggg
and eeee
are lowercase hex.
Functions
@spec read_tag(ExDicom.ByteStream.t() | nil) :: {:ok, String.t(), ExDicom.ByteStream.t()} | {:error, String.t()}
Reads a tag (group number and element number) from a ByteStream, returning
the tag in the format xggggeeee
where gggg
and eeee
are lowercase hex.
Examples
iex> {:ok, tag, updated_stream} = ExDicom.ReadTag.read_tag(stream)
iex> tag
"x00080020"
Returns:
{:ok, tag_string, updated_stream}
on success{:error, reason}
if there's a problem (e.g. missing stream)