element

package
v0.4.5 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 20, 2020 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const (
	UnknownGroupName = "Unknown Group"
	PrivateGroupName = "Private Data"
)

Constants

View Source
const VLUndefinedLength uint32 = 0xffffffff

Variables

View Source
var EndOfData = &Element{Tag: dicomtag.Tag{Group: 0x7fff, Element: 0x7fff}}

EndOfData is an pseudoelement to cause the caller to stop reading the input.

Functions

This section is empty.

Types

type DataSet

type DataSet struct {
	// Elements in the file, in order of appearance.
	//
	// Note: unlike pydicom, Elements also contains meta elements (those
	// with Tag.Group==2).
	Elements []*Element
}

DataSet represents contents of one DICOM file.

func (*DataSet) FindElementByName

func (f *DataSet) FindElementByName(name string) (*Element, error)

FindByName finds an element from the dataset given the element name, such as "PatientName".

func (*DataSet) FindElementByTag

func (f *DataSet) FindElementByTag(tag dicomtag.Tag) (*Element, error)

FindByTag finds an element from the dataset given its tag, such as Tag{0x0010, 0x0010}.

func (*DataSet) TransferSyntax

func (ds *DataSet) TransferSyntax() (bo binary.ByteOrder, implicit dicomio.IsImplicitVR, err error)

type Element

type Element struct {
	// Tag is a pair of <group, element>. See tags.go for possible values.
	Tag dicomtag.Tag

	// List of values in the element. Their types depends on value
	// representation (VR) of the Tag; Cf. tag.go.
	//
	// If Tag==TagPixelData, len(Value)==1, and Value[0] is PixelDataInfo.
	// Else if Tag==TagItem, each Value[i] is a *Element.
	//    a value's Tag can be any (including TagItem, which represents a nested Item)
	// Else if VR=="SQ", Value[i] is a *Element, with Tag=TagItem.
	// Else if VR=="OW", "OB", then len(Value)==1, and Value[0] is []byte.
	// Else if VR=="LT", or "UT", then len(Value)==1, and Value[0] is string
	// Else if VR=="DA", then len(Value)==1, and Value[0] is string. Use ParseDate() to parse the date string.
	// Else if VR=="US", Value[] is a list of uint16s
	// Else if VR=="UL", Value[] is a list of uint32s
	// Else if VR=="SS", Value[] is a list of int16s
	// Else if VR=="SL", Value[] is a list of int32s
	// Else if VR=="FL", Value[] is a list of float32s
	// Else if VR=="FD", Value[] is a list of float64s
	// Else if VR=="AT", Value[] is a list of Tag's.
	// Else, Value[] is a list of strings.
	//
	// Note: Use GetVRKind() to map VR string to the go representation of
	// VR.
	Value []interface{} // Value Multiplicity PS 3.5 6.4

	// VR defines the encoding of Value[] in two-letter alphabets, e.g.,
	// "AE", "UL". See P3.5 6.2. This field MUST be set.
	//
	// dicom.ReadElement() will fill this field with the VR of the tag,
	// either read from input stream (for explicit repl), or from the dicom
	// tag table (for implicit decl). This field need not be set in
	// WriteElement().
	//
	// Note: In a conformant DICOM file, the VR value of an element is
	// determined by its Tag, so this field is redundant.  This field is
	// still required because a non-conformant file with with explicitVR
	// encoding may have an element with VR that's different from the
	// standard's. In such case, this library honors the VR value found in
	// the file, and this field stores the VR used for parsing Values[].
	VR string

	// UndefinedLength is true if, in the DICOM file, the element is encoded
	// as having undefined length, and is delimited by end-sequence or
	// end-item element.  This flag is meaningful only if VR=="SQ" or
	// VR=="NA". Feel free to ignore this field if you don't understand what
	// this means.  It's one of the pointless complexities in the DICOM
	// standard.
	UndefinedLength bool
}

Element represents a single DICOM element. Use NewElement() to create a element denovo. Avoid creating a struct manually, because setting the VR field is a bit tricky.

func FindByName

func FindByName(elems []*Element, name string) (*Element, error)

FindByName finds an element with the given Element.Name in "elems" If not found, returns an error.

func FindByTag

func FindByTag(elems []*Element, tag dicomtag.Tag) (*Element, error)

FindByTag finds an element with the given Element.Tag in "elems" If not found, returns an error. TODO: consider a map lookup table perhaps in DataSet

func MustNewElement

func MustNewElement(tag dicomtag.Tag, values ...interface{}) *Element

MustNewElement is similar to NewElement, but it crashes the process on any error.

func NewElement

func NewElement(tag dicomtag.Tag, values ...interface{}) (*Element, error)

NewElement creates a new Element with the given tag and values. The type of each each value must match the VR (value representation) of the tag (see tag_definition.go).

func (*Element) GetInt added in v0.4.2

func (e *Element) GetInt() (int64, error)

GetInt retrieves some type of embedded int value (uint32, int16, etc) as an int64

func (*Element) GetInts added in v0.4.2

func (e *Element) GetInts() ([]int64, error)

GetInts returns a slice of int like values stored in the element.

func (*Element) GetString

func (e *Element) GetString() (string, error)

GetString gets a string value from an element. It returns an error if the element contains zero or >1 values, or the value is not a string.

func (*Element) GetStrings

func (e *Element) GetStrings() ([]string, error)

GetStrings returns the list of strings stored in the element. Returns an error if the VR of e.Tag is not a string.

func (*Element) MustGetInt added in v0.4.2

func (e *Element) MustGetInt() int64

MustGetInt retrieves some type of embedded int value as an int64. Panics if unable to do so.

func (*Element) MustGetInts added in v0.4.2

func (e *Element) MustGetInts() []int64

MustGetInts returns a slice of int like values stored in the element. Panics if unable to do so.

func (*Element) MustGetString

func (e *Element) MustGetString() string

MustGetString is similar to GetString(), but panics on error. TODO(saito): Add other variants of MustGet<type>.

func (*Element) MustGetStrings

func (e *Element) MustGetStrings() []string

MustGetStrings is similar to GetStrings, but crashes the process on error.

func (*Element) String

func (e *Element) String() string

Stringer

type PixelDataInfo

type PixelDataInfo struct {
	Offsets        []uint32      // BasicOffsetTable
	IsEncapsulated bool          // is the data encapsulated/jpeg encoded?
	Frames         []frame.Frame // Frames
}

PixelDataInfo is the Element.Value payload for PixelData element.

func (PixelDataInfo) String

func (data PixelDataInfo) String() string

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL