Documentation
¶
Overview ¶
Package godicom provides DICOM file reading, writing, and data manipulation.
Usage:
ds, err := godicom.ReadFile("file.dcm", nil)
if err != nil { ... }
// 带选项:godicom.ReadFile("file.dcm", &godicom.ReadOptions{Force: true})
fmt.Println(ds)
ds.Set(godicom.NewElement(godicom.MustTag(0x00100010), godicom.VRPN, "Test^Patient"))
ds.SaveAs("output.dcm", nil)
Index ¶
- Constants
- Variables
- func AddPrivateDictEntry(creator string, tag Tag, vr VR, name string, vm ...string) error
- func BufferEquality(a, b interface{}) bool
- func BufferLength(buf interface{}) (int64, error)
- func CheckBuffer(buf interface{}) error
- func ConvertCharacterSets(values []string) []string
- func CorrectAmbiguousVR(ds *Dataset, isLittleEndian bool, ancestors []*Dataset) error
- func CorrectAmbiguousVRPreservingRaw(ds *Dataset, isLittleEndian bool, ancestors []*Dataset) error
- func DecodeBytes(b []byte, encodings []string) string
- func DecodeBytesWithDelimiters(b []byte, encodings []string, delimiters map[byte]bool) string
- func DecodeString(b []byte, encodingName string) (string, error)
- func EncodeBytesWithCharsets(s string, encodings []string) []byte
- func EncodePersonNameWithCharsets(pn PersonName, encodings []string) []byte
- func EncodeString(s string, encodingName string) ([]byte, error)
- func FormatNumberAsDS(val float64) (string, error)
- func ISInRange(v int64) bool
- func IsAmbiguousVR(vr VR) bool
- func IsBinaryVR(vr VR) bool
- func IsFloatVR(vr VR) bool
- func IsIntVR(vr VR) bool
- func IsRepeaterTag(tag Tag) bool
- func IsStringVR(vr VR) bool
- func IsValidDS(s string) bool
- func IsValidIS(s string) bool
- func ParseCharacterSets(value interface{}) []string
- func PrivateDictionaryDescription(tag Tag, creator string) (string, error)
- func PrivateDictionaryVM(tag Tag, creator string) (string, error)
- func ResetExtraPrivateDictionaries()
- func ValidateFileMeta(fileMeta *FileMetaDataset, enforceStandard bool) error
- func ValidateUID(s string) error
- func WriteFile(filename string, ds *Dataset, opts *WriteOptions) error
- type BytesLengthError
- type DA
- type DS
- type DT
- type DataElement
- type Dataset
- func (d *Dataset) BytesValue(tag Tag) ([]byte, bool)
- func (d *Dataset) Clear()
- func (d *Dataset) Clone() *Dataset
- func (d *Dataset) Delete(tag Tag)
- func (d *Dataset) ElementByKeyword(keyword string) (*DataElement, bool)
- func (d *Dataset) Elements() map[Tag]*DataElement
- func (d *Dataset) Equal(other *Dataset) bool
- func (d *Dataset) FloatValue(tag Tag) (float64, bool)
- func (d *Dataset) FormattedLines(opts *FormatLinesOptions) []string
- func (d *Dataset) Get(tag Tag) (*DataElement, bool)
- func (d *Dataset) GetBytes(tag Tag) ([]byte, bool)
- func (d *Dataset) GetDA(tag Tag) (DA, bool)
- func (d *Dataset) GetDS(tag Tag) (DS, bool)
- func (d *Dataset) GetDT(tag Tag) (DT, bool)
- func (d *Dataset) GetDataElement(tag Tag) *DataElement
- func (d *Dataset) GetFloat(tag Tag) (float64, bool)
- func (d *Dataset) GetIS(tag Tag) (IS, bool)
- func (d *Dataset) GetInt(tag Tag) (int, bool)
- func (d *Dataset) GetPN(tag Tag) (PersonName, bool)
- func (d *Dataset) GetSequence(tag Tag) (*Sequence, bool)
- func (d *Dataset) GetString(tag Tag) (string, bool)
- func (d *Dataset) GetTM(tag Tag) (TM, bool)
- func (d *Dataset) GroupDataset(group int) *Dataset
- func (d *Dataset) Has(tag Tag) bool
- func (d *Dataset) IntValue(tag Tag) (int, bool)
- func (d *Dataset) IsOriginalEncoding() bool
- func (d *Dataset) Iter() []*DataElement
- func (d *Dataset) IterAll() []*DataElement
- func (d *Dataset) Len() int
- func (d *Dataset) LoadDeferred(tag Tag) error
- func (d *Dataset) Pop(tag Tag) (*DataElement, bool)
- func (d *Dataset) PrivateBlock(group int, creator string) *PrivateBlock
- func (d *Dataset) RemovePrivateTags()
- func (d *Dataset) SaveAs(filename string, opts *WriteOptions) error
- func (d *Dataset) SequenceValue(tag Tag) (*Sequence, bool)
- func (d *Dataset) Set(element *DataElement)
- func (d *Dataset) SetOriginalEncoding(isImplicit, isLittleEndian bool, charsets []string)
- func (d *Dataset) SetWriteEncoding(isImplicit, isLittleEndian bool)
- func (d *Dataset) SortedTags() []Tag
- func (d *Dataset) String() string
- func (d *Dataset) StringValue(tag Tag) (string, bool)
- func (d *Dataset) Top() string
- func (d *Dataset) Update(other *Dataset)
- func (d *Dataset) Walk(fn WalkFunc, recursive bool)
- type DicomBytesIOdeprecated
- type DicomIOdeprecated
- type DictEntry
- type Element
- func (e *Element) Equal(other *Element) bool
- func (e *Element) IsEmpty() bool
- func (e *Element) IsPrivate() bool
- func (e *Element) IsRaw() bool
- func (e *Element) Keyword() string
- func (e *Element) Name() string
- func (e *Element) ReprValue() string
- func (e *Element) String() string
- func (e *Element) VM() int
- type EncodingInfo
- type FileDataset
- type FileMetaDataset
- type FormatLinesOptions
- type IS
- type InvalidDICOMError
- type MultiValue
- type PersonName
- func (pn PersonName) Components() []string
- func (pn PersonName) Equal(other PersonName) bool
- func (pn PersonName) FamilyCommaGiven() string
- func (pn PersonName) FamilyName() string
- func (pn PersonName) Formatted(format string) string
- func (pn PersonName) GivenName() string
- func (pn PersonName) IsZero() bool
- func (pn PersonName) MiddleName() string
- func (pn PersonName) NamePrefix() string
- func (pn PersonName) NameSuffix() string
- func (pn PersonName) String() string
- type PersonNameParts
- type PrivateBlock
- type PrivateDictEntry
- type RawDataElement
- type ReadOptions
- type Sequence
- type TM
- type Tag
- type TagError
- type UID
- type UIDInfo
- type VR
- type WalkFunc
- type WriteOptions
Constants ¶
const ( // DefaultElementFormat matches pydicom Dataset.default_element_format. DefaultElementFormat = "%(tag)s %(name)-35.35s %(VR)s: %(repval)s" // DefaultSequenceElementFormat matches pydicom Dataset.default_sequence_element_format. DefaultSequenceElementFormat = "%(tag)s %(name)-35.35s %(VR)s: %(repval)s" )
Variables ¶
var ( BytesVR = map[VR]bool{VROB: true, VROD: true, VROF: true, VROL: true, VROV: true, VROW: true, VRUN: true} FloatVR = map[VR]bool{VRDS: true, VRFD: true, VRFL: true} IntVR = map[VR]bool{VRAT: true, VRIS: true, VRSL: true, VRSS: true, VRSV: true, VRUL: true, VRUS: true, VRUV: true} ListVR = map[VR]bool{VRSQ: true} DefaultCharsetVR = map[VR]bool{VRAE: true, VRAS: true, VRCS: true, VRDA: true, VRDS: true, VRDT: true, VRIS: true, VRTM: true, VRUI: true, VRUR: true} CustomCharsetVR = map[VR]bool{VRLO: true, VRLT: true, VRPN: true, VRSH: true, VRST: true, VRUC: true, VRUT: true} StrVR = func() map[VR]bool { m := make(map[VR]bool) for k, v := range DefaultCharsetVR { m[k] = v } for k, v := range CustomCharsetVR { m[k] = v } return m }() AllowBackslash = func() map[VR]bool { m := make(map[VR]bool) for k, v := range BytesVR { m[k] = v } m[VRLT] = true m[VRST] = true m[VRUT] = true return m }() )
VR classification sets
var AmbiguousVRs = map[VR]bool{ VRUsSS: true, VRObOw: true, VRUsOw: true, VRUsSsOw: true, }
AmbiguousVRs are VRs that require context to resolve before explicit writing.
var BufferableVRs = func() map[VR]bool { m := make(map[VR]bool) for vr := range BytesVR { if vr != VRUN { m[vr] = true } } return m }()
BufferableVRs are VRs that support buffered values.
var DefaultCharacterSet = "ISO_IR 6"
var DicomDictionaryGo = map[Tag]DictEntry{}/* 5189 elements not displayed */
var ExplicitVRLength16 = map[VR]bool{ VRAE: true, VRAS: true, VRAT: true, VRCS: true, VRDA: true, VRDS: true, VRDT: true, VRFL: true, VRFD: true, VRIS: true, VRLO: true, VRLT: true, VRPN: true, VRSH: true, VRSL: true, VRSS: true, VRST: true, VRTM: true, VRUI: true, VRUL: true, VRUS: true, }
ExplicitVRLength16 lists VRs that use 2-byte length fields for Explicit VR (Table 7.1-2, Part 5).
var ExplicitVRLength32 = func() map[VR]bool { m := make(map[VR]bool) for vr := range StandardVRs { if !ExplicitVRLength16[vr] { m[vr] = true } } return m }()
ExplicitVRLength32 lists VRs that use 4-byte length fields for Explicit VR.
var KnownUIDs = uid.Known
KnownUIDs maps UID strings to their info.
var PrivateDictionaries = map[string]map[string]PrivateDictEntry{}/* 449 elements not displayed */
PrivateDictionaries maps private creator names to tag pattern entries.
var RepeatersDictionaryGo = map[string]DictEntry{ "002031xx": {VR: "CS", VM: "1-n", Name: "Source Image IDs", Retired: true, Keyword: "SourceImageIDs"}, "002804x0": {VR: "US", VM: "1", Name: "Rows For Nth Order Coefficients", Retired: true, Keyword: "RowsForNthOrderCoefficients"}, "002804x1": {VR: "US", VM: "1", Name: "Columns For Nth Order Coefficients", Retired: true, Keyword: "ColumnsForNthOrderCoefficients"}, "002804x2": {VR: "LO", VM: "1-n", Name: "Coefficient Coding", Retired: true, Keyword: "CoefficientCoding"}, "002804x3": {VR: "AT", VM: "1-n", Name: "Coefficient Coding Pointers", Retired: true, Keyword: "CoefficientCodingPointers"}, "002808x0": {VR: "CS", VM: "1-n", Name: "Code Label", Retired: true, Keyword: "CodeLabel"}, "002808x2": {VR: "US", VM: "1", Name: "Number of Tables", Retired: true, Keyword: "NumberOfTables"}, "002808x3": {VR: "AT", VM: "1-n", Name: "Code Table Location", Retired: true, Keyword: "CodeTableLocation"}, "002808x4": {VR: "US", VM: "1", Name: "Bits For Code Word", Retired: true, Keyword: "BitsForCodeWord"}, "002808x8": {VR: "AT", VM: "1-n", Name: "Image Data Location", Retired: true, Keyword: "ImageDataLocation"}, "1000xxx0": {VR: "US", VM: "3", Name: "Escape Triplet", Retired: true, Keyword: "EscapeTriplet"}, "1000xxx1": {VR: "US", VM: "3", Name: "Run Length Triplet", Retired: true, Keyword: "RunLengthTriplet"}, "1000xxx2": {VR: "US", VM: "1", Name: "Huffman Table Size", Retired: true, Keyword: "HuffmanTableSize"}, "1000xxx3": {VR: "US", VM: "3", Name: "Huffman Table Triplet", Retired: true, Keyword: "HuffmanTableTriplet"}, "1000xxx4": {VR: "US", VM: "1", Name: "Shift Table Size", Retired: true, Keyword: "ShiftTableSize"}, "1000xxx5": {VR: "US", VM: "3", Name: "Shift Table Triplet", Retired: true, Keyword: "ShiftTableTriplet"}, "1010xxxx": {VR: "US", VM: "1-n", Name: "Zonal Map", Retired: true, Keyword: "ZonalMap"}, "50xx0005": {VR: "US", VM: "1", Name: "Curve Dimensions", Retired: true, Keyword: "CurveDimensions"}, "50xx0010": {VR: "US", VM: "1", Name: "Number of Points", Retired: true, Keyword: "NumberOfPoints"}, "50xx0020": {VR: "CS", VM: "1", Name: "Type of Data", Retired: true, Keyword: "TypeOfData"}, "50xx0022": {VR: "LO", VM: "1", Name: "Curve Description", Retired: true, Keyword: "CurveDescription"}, "50xx0030": {VR: "SH", VM: "1-n", Name: "Axis Units", Retired: true, Keyword: "AxisUnits"}, "50xx0040": {VR: "SH", VM: "1-n", Name: "Axis Labels", Retired: true, Keyword: "AxisLabels"}, "50xx0103": {VR: "US", VM: "1", Name: "Data Value Representation", Retired: true, Keyword: "DataValueRepresentation"}, "50xx0104": {VR: "US", VM: "1-n", Name: "Minimum Coordinate Value", Retired: true, Keyword: "MinimumCoordinateValue"}, "50xx0105": {VR: "US", VM: "1-n", Name: "Maximum Coordinate Value", Retired: true, Keyword: "MaximumCoordinateValue"}, "50xx0106": {VR: "SH", VM: "1-n", Name: "Curve Range", Retired: true, Keyword: "CurveRange"}, "50xx0110": {VR: "US", VM: "1-n", Name: "Curve Data Descriptor", Retired: true, Keyword: "CurveDataDescriptor"}, "50xx0112": {VR: "US", VM: "1-n", Name: "Coordinate Start Value", Retired: true, Keyword: "CoordinateStartValue"}, "50xx0114": {VR: "US", VM: "1-n", Name: "Coordinate Step Value", Retired: true, Keyword: "CoordinateStepValue"}, "50xx1001": {VR: "CS", VM: "1", Name: "Curve Activation Layer", Retired: true, Keyword: "CurveActivationLayer"}, "50xx2000": {VR: "US", VM: "1", Name: "Audio Type", Retired: true, Keyword: "AudioType"}, "50xx2002": {VR: "US", VM: "1", Name: "Audio Sample Format", Retired: true, Keyword: "AudioSampleFormat"}, "50xx2004": {VR: "US", VM: "1", Name: "Number of Channels", Retired: true, Keyword: "NumberOfChannels"}, "50xx2006": {VR: "UL", VM: "1", Name: "Number of Samples", Retired: true, Keyword: "NumberOfSamples"}, "50xx2008": {VR: "UL", VM: "1", Name: "Sample Rate", Retired: true, Keyword: "SampleRate"}, "50xx200A": {VR: "UL", VM: "1", Name: "Total Time", Retired: true, Keyword: "TotalTime"}, "50xx200C": {VR: "OB or OW", VM: "1", Name: "Audio Sample Data", Retired: true, Keyword: "AudioSampleData"}, "50xx200E": {VR: "LT", VM: "1", Name: "Audio Comments", Retired: true, Keyword: "AudioComments"}, "50xx2500": {VR: "LO", VM: "1", Name: "Curve Label", Retired: true, Keyword: "CurveLabel"}, "50xx2600": {VR: "SQ", VM: "1", Name: "Curve Referenced Overlay Sequence", Retired: true, Keyword: "CurveReferencedOverlaySequence"}, "50xx2610": {VR: "US", VM: "1", Name: "Curve Referenced Overlay Group", Retired: true, Keyword: "CurveReferencedOverlayGroup"}, "50xx3000": {VR: "OB or OW", VM: "1", Name: "Curve Data", Retired: true, Keyword: "CurveData"}, "60xx0010": {VR: "US", VM: "1", Name: "Overlay Rows", Retired: false, Keyword: "OverlayRows"}, "60xx0011": {VR: "US", VM: "1", Name: "Overlay Columns", Retired: false, Keyword: "OverlayColumns"}, "60xx0012": {VR: "US", VM: "1", Name: "Overlay Planes", Retired: true, Keyword: "OverlayPlanes"}, "60xx0015": {VR: "IS", VM: "1", Name: "Number of Frames in Overlay", Retired: false, Keyword: "NumberOfFramesInOverlay"}, "60xx0022": {VR: "LO", VM: "1", Name: "Overlay Description", Retired: false, Keyword: "OverlayDescription"}, "60xx0040": {VR: "CS", VM: "1", Name: "Overlay Type", Retired: false, Keyword: "OverlayType"}, "60xx0045": {VR: "LO", VM: "1", Name: "Overlay Subtype", Retired: false, Keyword: "OverlaySubtype"}, "60xx0050": {VR: "SS", VM: "2", Name: "Overlay Origin", Retired: false, Keyword: "OverlayOrigin"}, "60xx0051": {VR: "US", VM: "1", Name: "Image Frame Origin", Retired: false, Keyword: "ImageFrameOrigin"}, "60xx0052": {VR: "US", VM: "1", Name: "Overlay Plane Origin", Retired: true, Keyword: "OverlayPlaneOrigin"}, "60xx0060": {VR: "CS", VM: "1", Name: "Overlay Compression Code", Retired: true, Keyword: "OverlayCompressionCode"}, "60xx0061": {VR: "SH", VM: "1", Name: "Overlay Compression Originator", Retired: true, Keyword: "OverlayCompressionOriginator"}, "60xx0062": {VR: "SH", VM: "1", Name: "Overlay Compression Label", Retired: true, Keyword: "OverlayCompressionLabel"}, "60xx0063": {VR: "CS", VM: "1", Name: "Overlay Compression Description", Retired: true, Keyword: "OverlayCompressionDescription"}, "60xx0066": {VR: "AT", VM: "1-n", Name: "Overlay Compression Step Pointers", Retired: true, Keyword: "OverlayCompressionStepPointers"}, "60xx0068": {VR: "US", VM: "1", Name: "Overlay Repeat Interval", Retired: true, Keyword: "OverlayRepeatInterval"}, "60xx0069": {VR: "US", VM: "1", Name: "Overlay Bits Grouped", Retired: true, Keyword: "OverlayBitsGrouped"}, "60xx0100": {VR: "US", VM: "1", Name: "Overlay Bits Allocated", Retired: false, Keyword: "OverlayBitsAllocated"}, "60xx0102": {VR: "US", VM: "1", Name: "Overlay Bit Position", Retired: false, Keyword: "OverlayBitPosition"}, "60xx0110": {VR: "CS", VM: "1", Name: "Overlay Format", Retired: true, Keyword: "OverlayFormat"}, "60xx0200": {VR: "US", VM: "1", Name: "Overlay Location", Retired: true, Keyword: "OverlayLocation"}, "60xx0800": {VR: "CS", VM: "1-n", Name: "Overlay Code Label", Retired: true, Keyword: "OverlayCodeLabel"}, "60xx0802": {VR: "US", VM: "1", Name: "Overlay Number of Tables", Retired: true, Keyword: "OverlayNumberOfTables"}, "60xx0803": {VR: "AT", VM: "1-n", Name: "Overlay Code Table Location", Retired: true, Keyword: "OverlayCodeTableLocation"}, "60xx0804": {VR: "US", VM: "1", Name: "Overlay Bits For Code Word", Retired: true, Keyword: "OverlayBitsForCodeWord"}, "60xx1001": {VR: "CS", VM: "1", Name: "Overlay Activation Layer", Retired: false, Keyword: "OverlayActivationLayer"}, "60xx1100": {VR: "US", VM: "1", Name: "Overlay Descriptor - Gray", Retired: true, Keyword: "OverlayDescriptorGray"}, "60xx1101": {VR: "US", VM: "1", Name: "Overlay Descriptor - Red", Retired: true, Keyword: "OverlayDescriptorRed"}, "60xx1102": {VR: "US", VM: "1", Name: "Overlay Descriptor - Green", Retired: true, Keyword: "OverlayDescriptorGreen"}, "60xx1103": {VR: "US", VM: "1", Name: "Overlay Descriptor - Blue", Retired: true, Keyword: "OverlayDescriptorBlue"}, "60xx1200": {VR: "US", VM: "1-n", Name: "Overlays - Gray", Retired: true, Keyword: "OverlaysGray"}, "60xx1201": {VR: "US", VM: "1-n", Name: "Overlays - Red", Retired: true, Keyword: "OverlaysRed"}, "60xx1202": {VR: "US", VM: "1-n", Name: "Overlays - Green", Retired: true, Keyword: "OverlaysGreen"}, "60xx1203": {VR: "US", VM: "1-n", Name: "Overlays - Blue", Retired: true, Keyword: "OverlaysBlue"}, "60xx1301": {VR: "IS", VM: "1", Name: "ROI Area", Retired: false, Keyword: "ROIArea"}, "60xx1302": {VR: "DS", VM: "1", Name: "ROI Mean", Retired: false, Keyword: "ROIMean"}, "60xx1303": {VR: "DS", VM: "1", Name: "ROI Standard Deviation", Retired: false, Keyword: "ROIStandardDeviation"}, "60xx1500": {VR: "LO", VM: "1", Name: "Overlay Label", Retired: false, Keyword: "OverlayLabel"}, "60xx3000": {VR: "OB or OW", VM: "1", Name: "Overlay Data", Retired: false, Keyword: "OverlayData"}, "60xx4000": {VR: "LT", VM: "1", Name: "Overlay Comments", Retired: true, Keyword: "OverlayComments"}, "7Fxx0010": {VR: "OB or OW", VM: "1", Name: "Variable Pixel Data", Retired: true, Keyword: "VariablePixelData"}, "7Fxx0011": {VR: "US", VM: "1", Name: "Variable Next Data Group", Retired: true, Keyword: "VariableNextDataGroup"}, "7Fxx0020": {VR: "OW", VM: "1", Name: "Variable Coefficients SDVN", Retired: true, Keyword: "VariableCoefficientsSDVN"}, "7Fxx0030": {VR: "OW", VM: "1", Name: "Variable Coefficients SDHN", Retired: true, Keyword: "VariableCoefficientsSDHN"}, "7Fxx0040": {VR: "OW", VM: "1", Name: "Variable Coefficients SDDN", Retired: true, Keyword: "VariableCoefficientsSDDN"}, }
RepeatersDictionaryGo maps mask patterns to entries
var StandardVRs = map[VR]bool{ VRAE: true, VRAS: true, VRAT: true, VRCS: true, VRDA: true, VRDS: true, VRDT: true, VRFD: true, VRFL: true, VRIS: true, VRLO: true, VRLT: true, VROB: true, VROD: true, VROF: true, VROL: true, VROW: true, VROV: true, VRPN: true, VRSH: true, VRSL: true, VRSQ: true, VRSS: true, VRST: true, VRSV: true, VRTM: true, VRUC: true, VRUI: true, VRUL: true, VRUN: true, VRUR: true, VRUS: true, VRUT: true, VRUV: true, }
StandardVRs contains all standard VRs.
var UIDDictionary = uid.Dictionary
UIDDictionary maps UID values to their metadata.
Functions ¶
func AddPrivateDictEntry ¶
AddPrivateDictEntry adds or updates a runtime private dictionary entry.
func BufferEquality ¶
func BufferEquality(a, b interface{}) bool
BufferEquality checks if two buffers are equal.
func BufferLength ¶
BufferLength returns the length of a buffer.
func CheckBuffer ¶
func CheckBuffer(buf interface{}) error
CheckBuffer validates a buffer for bulk data VRs.
func ConvertCharacterSets ¶ added in v0.5.0
ConvertCharacterSets normalizes DICOM Specific Character Set values for decoding.
func CorrectAmbiguousVR ¶
CorrectAmbiguousVR walks ds correcting ambiguous VR elements when possible. Mirrors pydicom.filewriter.correct_ambiguous_vr.
func CorrectAmbiguousVRPreservingRaw ¶ added in v0.6.0
CorrectAmbiguousVRPreservingRaw corrects ambiguous VR elements that are not stored as raw bytes. Used before implicit writes with in-memory values while keeping raw element roundtrips intact.
func DecodeBytes ¶
DecodeBytes decodes using the first matching encoding (legacy helper).
func DecodeBytesWithDelimiters ¶ added in v0.5.0
DecodeBytesWithDelimiters decodes a DICOM text byte string with ISO-2022 code extensions.
func EncodeBytesWithCharsets ¶ added in v0.5.0
EncodeBytesWithCharsets encodes a Unicode string for DICOM text VRs.
func EncodePersonNameWithCharsets ¶ added in v0.5.0
func EncodePersonNameWithCharsets(pn PersonName, encodings []string) []byte
EncodePersonNameWithCharsets encodes a PersonName for writing.
func FormatNumberAsDS ¶ added in v0.15.0
FormatNumberAsDS formats a float as a DICOM Decimal String (≤16 chars). Mirrors pydicom.valuerep.format_number_as_ds.
func ISInRange ¶ added in v0.15.0
ISInRange reports whether v fits the DICOM IS value range [-2^31, 2^31).
func IsAmbiguousVR ¶
IsAmbiguousVR reports whether vr is an ambiguous VR from the DICOM dictionary.
func IsBinaryVR ¶
IsBinaryVR returns true if the VR is a binary (bytes-like) VR.
func IsRepeaterTag ¶
IsRepeaterTag returns true if the tag matches a repeater pattern.
func IsStringVR ¶
IsStringVR returns true if the VR is a string-like VR.
func IsValidDS ¶ added in v0.15.0
IsValidDS reports whether s is a valid DICOM Decimal String (VR=DS). Mirrors pydicom.valuerep.is_valid_ds.
func IsValidIS ¶ added in v0.15.0
IsValidIS reports whether s is a valid DICOM Integer String (VR=IS) by length and character set (not numeric range).
func ParseCharacterSets ¶ added in v0.5.0
func ParseCharacterSets(value interface{}) []string
ParseCharacterSets splits a Specific Character Set value into DICOM encoding names.
func PrivateDictionaryDescription ¶
PrivateDictionaryDescription returns the name for a private element.
func PrivateDictionaryVM ¶
PrivateDictionaryVM returns the VM for a private element.
func ResetExtraPrivateDictionaries ¶
func ResetExtraPrivateDictionaries()
ResetExtraPrivateDictionaries clears runtime private dictionary additions. Intended for tests.
func ValidateFileMeta ¶
func ValidateFileMeta(fileMeta *FileMetaDataset, enforceStandard bool) error
ValidateFileMeta validates File Meta Information elements. Mirrors pydicom.dataset.validate_file_meta.
func ValidateUID ¶
ValidateUID checks if the UID string conforms to DICOM rules.
Types ¶
type BytesLengthError ¶
BytesLengthError is returned when a value has an unexpected byte length.
func (*BytesLengthError) Error ¶
func (e *BytesLengthError) Error() string
type DS ¶ added in v0.4.0
DS holds a DICOM Decimal String (VR=DS) value.
func DSFromFloat ¶ added in v0.15.0
DSFromFloat builds a DS whose Original is a valid DICOM decimal string.
type DataElement ¶
type DataElement = Element
DataElement is an alias for Element.
func NewDataElement ¶
func NewDataElement(tag Tag, vr VR, value interface{}) *DataElement
NewDataElement creates a DICOM data element.
type Dataset ¶
type Dataset struct {
IsUndefinedLengthSequenceItem bool
// contains filtered or unexported fields
}
Dataset represents a DICOM Dataset - a collection of DataElements keyed by Tag.
func NewDataset ¶
func NewDataset() *Dataset
func (*Dataset) Clear ¶ added in v0.14.0
func (d *Dataset) Clear()
Clear removes all elements from the dataset. Mirrors pydicom Dataset.clear.
func (*Dataset) ElementByKeyword ¶ added in v0.14.0
func (d *Dataset) ElementByKeyword(keyword string) (*DataElement, bool)
ElementByKeyword returns the element for a DICOM keyword, if present. Mirrors pydicom Dataset.data_element.
func (*Dataset) Elements ¶
func (d *Dataset) Elements() map[Tag]*DataElement
func (*Dataset) Equal ¶ added in v0.14.0
Equal reports whether d and other contain the same tags, VRs, and values. Mirrors pydicom Dataset.__eq__ for Dataset values.
func (*Dataset) FormattedLines ¶ added in v0.16.0
func (d *Dataset) FormattedLines(opts *FormatLinesOptions) []string
FormattedLines returns formatted lines for every element, recursing into sequences. Mirrors pydicom Dataset.formatted_lines.
func (*Dataset) GetDataElement ¶
func (d *Dataset) GetDataElement(tag Tag) *DataElement
func (*Dataset) GroupDataset ¶ added in v0.14.0
GroupDataset returns a new dataset containing only elements of the given group. Mirrors pydicom Dataset.group_dataset.
func (*Dataset) IsOriginalEncoding ¶ added in v0.14.0
IsOriginalEncoding reports whether the current write encoding and SpecificCharacterSet match those captured when the dataset was read. Mirrors pydicom Dataset.is_original_encoding.
func (*Dataset) Iter ¶
func (d *Dataset) Iter() []*DataElement
Iter returns all elements sorted by tag.
func (*Dataset) IterAll ¶ added in v0.14.0
func (d *Dataset) IterAll() []*DataElement
IterAll returns all elements in tag order, recursing into sequences. Mirrors pydicom Dataset.iterall.
func (*Dataset) LoadDeferred ¶
LoadDeferred reads a deferred element's value from the source file/buffer. Mirrors pydicom deferred read triggered by Dataset.__getitem__.
func (*Dataset) Pop ¶ added in v0.14.0
func (d *Dataset) Pop(tag Tag) (*DataElement, bool)
Pop removes and returns the element for tag. Mirrors pydicom Dataset.pop for tag keys.
func (*Dataset) PrivateBlock ¶
func (d *Dataset) PrivateBlock(group int, creator string) *PrivateBlock
func (*Dataset) RemovePrivateTags ¶ added in v0.14.0
func (d *Dataset) RemovePrivateTags()
RemovePrivateTags deletes all private elements, including nested sequences. Mirrors pydicom Dataset.remove_private_tags.
func (*Dataset) Set ¶
func (d *Dataset) Set(element *DataElement)
func (*Dataset) SetOriginalEncoding ¶ added in v0.14.0
SetOriginalEncoding records the encoding used when the dataset was decoded. Mirrors pydicom Dataset.set_original_encoding.
func (*Dataset) SetWriteEncoding ¶ added in v0.14.0
SetWriteEncoding sets the VR/endianness that would be used for writing. Used with IsOriginalEncoding; nil write encoding means "same as original".
func (*Dataset) SortedTags ¶
SortedTags returns all tags in ascending order.
func (*Dataset) Top ¶ added in v0.16.0
Top returns a string representation of only top-level elements. Mirrors pydicom Dataset.top.
type DicomBytesIO
deprecated
type DicomBytesIO = dicomBytesIO
DicomBytesIO wraps an in-memory DICOM byte reader.
Deprecated: this type is internal and will be removed.
func NewDicomBytesIO
deprecated
func NewDicomBytesIO(data []byte) *DicomBytesIO
NewDicomBytesIO creates an in-memory DICOM byte reader.
Deprecated: this constructor is internal and will be removed.
type DicomIO
deprecated
type DicomIO = dicomIO
DicomIO reads and writes DICOM primitive values.
Deprecated: this type is internal and will be removed.
func NewDicomReader
deprecated
func NewDicomReader(r io.ReadSeeker) *DicomIO
NewDicomReader creates a DICOM reader.
Deprecated: this constructor is internal and will be removed.
func NewDicomWriter
deprecated
type Element ¶
type Element struct {
Tag Tag
VR VR
Value interface{}
RawValue []byte // original value bytes from read; written verbatim when set
ValueTell int64 // value offset in source; used for deferred reads
ValueLength uint32 // byte length when deferred
Deferred bool // value not yet loaded from source
IsImplicitVR bool // encoding at read time; for deferred load
IsLittleEndian bool
FileTell int64
IsUndefinedLength bool
PrivateCreator string
// contains filtered or unexported fields
}
Element holds a single DICOM data element.
func NewElement ¶
type EncodingInfo ¶
EncodingInfo describes the DICOM encoding used when reading/writing.
type FileDataset ¶
type FileDataset struct {
*Dataset
Filename string
Preamble []byte
FileMeta *FileMetaDataset
Timestamp string // file modification time as Unix seconds (deferred read checks)
}
FileDataset extends Dataset with file-specific info.
func ReadFile ¶
func ReadFile(filename string, opts *ReadOptions) (*FileDataset, error)
ReadFile reads a DICOM file from filename.
func (*FileDataset) PixelBytes ¶
func (fd *FileDataset) PixelBytes(opts ...pixels.DecodeOption) ([]byte, error)
PixelBytes returns decoded pixel data as a contiguous byte buffer. For multi-frame images, frames are concatenated in order.
func (*FileDataset) PixelFrames ¶
func (fd *FileDataset) PixelFrames(opts ...pixels.DecodeOption) ([][]byte, error)
PixelFrames returns decoded pixel data, one slice per frame.
func (*FileDataset) SaveAs ¶
func (fd *FileDataset) SaveAs(filename string, opts *WriteOptions) error
func (*FileDataset) TransferSyntaxUID ¶
func (fd *FileDataset) TransferSyntaxUID() (string, bool)
TransferSyntaxUID returns the file meta transfer syntax UID string.
type FileMetaDataset ¶
type FileMetaDataset struct {
*Dataset
}
FileMetaDataset holds DICOM File Meta Information (group 0x0002).
func NewFileMetaDataset ¶
func NewFileMetaDataset() *FileMetaDataset
type FormatLinesOptions ¶ added in v0.16.0
FormatLinesOptions controls Dataset.FormattedLines output.
type InvalidDICOMError ¶
type InvalidDICOMError struct {
Message string
}
InvalidDICOMError is returned when data is not valid DICOM.
func (*InvalidDICOMError) Error ¶
func (e *InvalidDICOMError) Error() string
type MultiValue ¶
type MultiValue[T any] struct { // contains filtered or unexported fields }
MultiValue holds a DICOM multi-valued element. All items must be of the same type.
func NewMultiValue ¶
func NewMultiValue[T any](items []T) *MultiValue[T]
func (*MultiValue[T]) Append ¶
func (mv *MultiValue[T]) Append(v T)
func (*MultiValue[T]) Get ¶
func (mv *MultiValue[T]) Get(i int) T
func (*MultiValue[T]) IsEmpty ¶
func (mv *MultiValue[T]) IsEmpty() bool
func (*MultiValue[T]) Len ¶
func (mv *MultiValue[T]) Len() int
func (*MultiValue[T]) Set ¶
func (mv *MultiValue[T]) Set(i int, v T)
func (*MultiValue[T]) Values ¶
func (mv *MultiValue[T]) Values() []T
type PersonName ¶
PersonName holds a DICOM Person Name (VR=PN) value.
func FromNamedComponents ¶ added in v0.5.0
func FromNamedComponents(family, given, middle, prefix, suffix string) PersonName
FromNamedComponents builds a PersonName from alphabetic name parts.
func ParsePersonName ¶
func ParsePersonName(s string) PersonName
ParsePersonName parses a decoded PN string into components.
func PersonNameFromParts ¶ added in v0.15.0
func PersonNameFromParts(p PersonNameParts) PersonName
PersonNameFromParts builds a PersonName from structured component parts.
func PersonNameFromVeterinary ¶ added in v0.15.0
func PersonNameFromVeterinary(responsibleParty, patientName string) PersonName
PersonNameFromVeterinary builds a veterinary PN (responsible party ^ patient name). Mirrors pydicom PersonName.from_named_components_veterinary.
func (PersonName) Components ¶ added in v0.5.0
func (pn PersonName) Components() []string
Components returns the alphabetic, ideographic, and phonetic groups.
func (PersonName) Equal ¶ added in v0.15.0
func (pn PersonName) Equal(other PersonName) bool
func (PersonName) FamilyCommaGiven ¶ added in v0.5.0
func (pn PersonName) FamilyCommaGiven() string
FamilyCommaGiven returns "Family, Given" for the alphabetic group.
func (PersonName) FamilyName ¶ added in v0.5.0
func (pn PersonName) FamilyName() string
FamilyName returns the first ^-delimited component of the alphabetic group.
func (PersonName) Formatted ¶ added in v0.5.0
func (pn PersonName) Formatted(format string) string
Formatted substitutes named components into a format string. Supported names: family_name, given_name, middle_name, name_prefix, name_suffix, ideographic, phonetic.
func (PersonName) GivenName ¶ added in v0.5.0
func (pn PersonName) GivenName() string
GivenName returns the second ^-delimited component of the alphabetic group.
func (PersonName) IsZero ¶ added in v0.5.0
func (pn PersonName) IsZero() bool
func (PersonName) MiddleName ¶ added in v0.5.0
func (pn PersonName) MiddleName() string
MiddleName returns the third ^-delimited component of the alphabetic group.
func (PersonName) NamePrefix ¶ added in v0.5.0
func (pn PersonName) NamePrefix() string
NamePrefix returns the fourth ^-delimited component of the alphabetic group.
func (PersonName) NameSuffix ¶ added in v0.5.0
func (pn PersonName) NameSuffix() string
NameSuffix returns the fifth ^-delimited component of the alphabetic group.
func (PersonName) String ¶
func (pn PersonName) String() string
type PersonNameParts ¶ added in v0.15.0
type PersonNameParts struct {
FamilyName string
GivenName string
MiddleName string
NamePrefix string
NameSuffix string
FamilyNameIdeographic string
GivenNameIdeographic string
MiddleNameIdeographic string
NamePrefixIdeographic string
NameSuffixIdeographic string
FamilyNamePhonetic string
GivenNamePhonetic string
MiddleNamePhonetic string
NamePrefixPhonetic string
NameSuffixPhonetic string
}
PersonNameParts holds named PN components across alphabetic/ideographic/phonetic groups. Mirrors pydicom PersonName.from_named_components keyword arguments.
type PrivateBlock ¶
type PrivateBlock struct {
Group int
PrivateCreator string
// contains filtered or unexported fields
}
PrivateBlock represents a private block in the dataset.
func (*PrivateBlock) Get ¶
func (pb *PrivateBlock) Get(offset int) (*DataElement, bool)
func (*PrivateBlock) GetTag ¶
func (pb *PrivateBlock) GetTag(offset int) Tag
func (*PrivateBlock) Set ¶
func (pb *PrivateBlock) Set(offset int, vr VR, value interface{})
type PrivateDictEntry ¶
PrivateDictEntry holds metadata for a private DICOM element.
type RawDataElement ¶
type RawDataElement struct {
Tag Tag
VR VR
Length uint32
Value []byte
ValueTell int64
IsImplicitVR bool
IsLittleEndian bool
IsRaw bool
}
RawDataElement holds raw (undecoded) element data from a file.
type ReadOptions ¶
type Sequence ¶
type Sequence struct {
IsUndefinedLength bool
// contains filtered or unexported fields
}
Sequence holds a list of Dataset items (for VR SQ).
func NewSequence ¶
type Tag ¶
Tag represents a DICOM element (group, element) tag as a 32-bit integer.
const ( ItemTag Tag = tag.Item ItemDelimiterTag Tag = tag.ItemDelimiter SequenceDelimiterTag Tag = tag.SequenceDelimiter TagPixelRep Tag = tag.PixelRepresentation TagCharset Tag = tag.SpecificCharacterSet )
func ParseTag ¶
ParseTag creates a Tag from various forms:
- ParseTag(0x00100010)
- ParseTag(0x0010, 0x0010)
- ParseTag("PatientName")
- ParseTag("00100010")
func TagFromKeyword ¶
TagFromKeyword returns the tag for a given keyword.
type UID ¶
UID represents a DICOM Unique Identifier.
const ( ImplicitVRLittleEndian UID = uid.ImplicitVRLittleEndian ExplicitVRLittleEndian UID = uid.ExplicitVRLittleEndian DeflatedExplicitVRLittleEndian UID = uid.DeflatedExplicitVRLittleEndian ExplicitVRBigEndian UID = uid.ExplicitVRBigEndian JPEGBaseline UID = uid.JPEGBaseline JPEGExtended UID = uid.JPEGExtended JPEGLossless UID = uid.JPEGLossless JPEGLosslessSV1 UID = uid.JPEGLosslessSV1 JPEGLSLossless UID = uid.JPEGLSLossless JPEGLSLossy UID = uid.JPEGLSLossy JPEG2000Lossless UID = uid.JPEG2000Lossless JPEG2000 UID = uid.JPEG2000 RLELossless UID = uid.RLELossless NativePixels UID = uid.NativePixels VerificationSOPClass UID = uid.VerificationSOPClass CTImageStorage UID = uid.CTImageStorage PYDICOMImplementationUID UID = uid.PYDICOMImplementationUID GodicomImplementationUID UID = uid.GodicomImplementationUID )
type VR ¶
type VR string
VR represents a DICOM Value Representation.
const ( VRAE VR = "AE" VRAS VR = "AS" VRAT VR = "AT" VRCS VR = "CS" VRDA VR = "DA" VRDS VR = "DS" VRDT VR = "DT" VRFD VR = "FD" VRFL VR = "FL" VRIS VR = "IS" VRLO VR = "LO" VRLT VR = "LT" VROB VR = "OB" VROD VR = "OD" VROF VR = "OF" VROL VR = "OL" VROW VR = "OW" VROV VR = "OV" VRPN VR = "PN" VRSH VR = "SH" VRSL VR = "SL" VRSQ VR = "SQ" VRSS VR = "SS" VRST VR = "ST" VRSV VR = "SV" VRTM VR = "TM" VRUC VR = "UC" VRUI VR = "UI" VRUL VR = "UL" VRUN VR = "UN" VRUR VR = "UR" VRUS VR = "US" VRUT VR = "UT" VRUV VR = "UV" // Ambiguous VRs from DICOM PS3.6 Tables 6-1, 7-1 and 8-1 VRUsSS VR = "US or SS" VRObOw VR = "OB or OW" VRUsOw VR = "US or OW" VRUsSsOw VR = "US or SS or OW" )
type WriteOptions ¶
WriteOptions controls DICOM file writing behavior.
Source Files
¶
Directories
¶
| Path | Synopsis |
|---|---|
|
cmd
|
|
|
godicom
command
|
|
|
testread
command
|
|
|
Package dicomjson converts DICOM datasets to and from JSON.
|
Package dicomjson converts DICOM datasets to and from JSON. |
|
Package encaps parses DICOM encapsulated (compressed) pixel data.
|
Package encaps parses DICOM encapsulated (compressed) pixel data. |
|
Package pixels decodes DICOM native and encapsulated pixel data.
|
Package pixels decodes DICOM native and encapsulated pixel data. |
|
Package tag provides DICOM tag constants and keyword lookup.
|
Package tag provides DICOM tag constants and keyword lookup. |
|
Package uid provides DICOM UID constants and lookup.
|
Package uid provides DICOM UID constants and lookup. |