godicom

package module
v0.17.0 Latest Latest
Warning

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

Go to latest
Published: Jul 13, 2026 License: MIT Imports: 23 Imported by: 0

README

godicom

Go 实现的 DICOM 文件读写库 — pydicom 的 Go 移植版。

CI Coverage Lint Go Version GoDoc

快速开始

import "github.com/godicom-dev/godicom"

// 读取 DICOM 文件(默认选项传 nil)
ds, err := godicom.ReadFile("ct.dcm", nil)
if err != nil {
    return err
}

// 带读取选项
ds, err = godicom.ReadFile("ct.dcm", &godicom.ReadOptions{Force: true})

// 访问元素
name, _ := ds.GetString(godicom.MustTag(0x00100010))
id, _ := ds.GetString(godicom.MustTag(0x00100020))

// 修改元素
ds.Set(godicom.NewDataElement(godicom.MustTag(0x00100010), godicom.VRPN, "Anonymous"))

// 写入文件
err = ds.SaveAs("output.dcm", nil)

I/O 入口:ReadFile / WriteFile(或 FileDataset.SaveAs)。

像素数据解码

封装像素经 encaps 拆帧后,由 pixels 按 Transfer Syntax 调度解码(依赖 golibjpeggoopenjpeggorle):

import (
    "github.com/godicom-dev/godicom"
    "github.com/godicom-dev/godicom/pixels"
)

ds, err := godicom.ReadFile("mr_j2k.dcm", nil)
if err != nil {
    return err
}

// 所有帧拼成一块 buffer(native 字节布局)
raw, err := ds.PixelBytes(pixels.WithRaw(true))
if err != nil {
    return err
}

// 或按帧解码
frames, err := ds.PixelFrames(pixels.WithRaw(true), pixels.WithFrameIndex(0))
if err != nil {
    return err
}
_ = raw
_ = frames

v0.2.0 像素读能力

能力 说明
单帧 / 多帧 PixelFramesNumberOfFrames 拆分;WithFrameIndex(n) 取单帧
封装分帧 Basic / Extended Offset Table、无 BOT + EOI 启发式
未压缩多帧 原生像素按帧切分(无需 encaps)

已支持的压缩格式(读)

类别 Transfer Syntax(示例 UID)
Native Explicit/Implicit VR Little/Big Endian、Deflated
RLE Lossless 1.2.840.10008.1.2.5
JPEG Baseline / Extended / Lossless / Lossless SV1 1.2.840.10008.1.2.4.50
JPEG-LS Lossless / Near-Lossless 1.2.840.10008.1.2.4.80 / .81
JPEG 2000 / HTJ2K 1.2.840.10008.1.2.4.90

回归验证样例(pydicom pixels_reference 采样点)

样例文件 内容
CT_small.dcm Native 16-bit 单帧
MR_small*.dcm J2K / RLE / JPEG-LS 单帧
emri_small*.dcm 10 帧 native / RLE / JPEG-LS / J2K(scripts/fetch-testdata.sh
SC_rgb_jpeg_*.dcm JPEG baseline / lossless SV1 RGB
JPGExtended.dcm JPEG extended 16-bit

多帧测试数据不在 pydicom submodule 内,CI 与本地需先执行:

bash scripts/fetch-testdata.sh

已知限制:仅解码路径(无压缩写入);WithRaw(true) 返回编解码库原始字节布局,不含 pydicom 式 reshape / YBR→RGB 后处理;像素 encode 与完整 encaps 生成未实现。细节见 TODO.md

DICOM JSON Model

import (
    "github.com/godicom-dev/godicom"
    "github.com/godicom-dev/godicom/dicomjson"
)

ds, err := godicom.ReadFile("ct.dcm", nil)
if err != nil {
    return err
}

jsonData, err := dicomjson.MarshalDataset(ds.Dataset)
if err != nil {
    return err
}

parsed, err := dicomjson.ParseDataset(jsonData)
if err != nil {
    return err
}
_ = parsed

功能

功能 状态
读取 Explicit VR Little Endian
读取 Implicit VR Little Endian
读取 Explicit VR Big Endian
读取 Deflated Explicit VR Little Endian
混合编码自动切换
文件 Meta 信息解析
序列 (SQ) 解析
嵌套私有 Tag
ReadOptions.SpecificTags
写入 Explicit VR Little Endian
写入 Implicit VR Little Endian
写入 Explicit VR Big Endian
写入 Deflated Explicit VR Little Endian
写入序列
基础 VR 值转换
DICOM 字符集 (ASCII/Latin-1/Greek 等) 🚧
DICOM 标准字典 (5189 Tag + 88 Repeater)
Pixel Data 解码 (Native)
Pixel Data 解码 (JPEG / JPEG-LS / JPEG 2000 / RLE)
JSON 序列化
DICOMweb / WADO-RS gonetdicom(计划中独立库,非 godicom 范围)

v0.2.0 起提供稳定的多帧像素能力;metadata 读写与 JSON 仍在持续对齐 pydicom。完整路线图见 TODO.md

测试

bash scripts/fetch-testdata.sh   # 多帧 emri_small 样例(首次或 CI)
go test -count=1 ./...
  • 47 个测试文件,667 个测试用例(含 subtest,8 个包)
  • 语句覆盖率见 Codecov badge
  • pydicom submodule 78 个 .dcm + testdata/dcm/ 5 个 emri_small*

项目结构

godicom/
├── tag.go / tag/           # Tag 类型与 keyword 子包
├── vr.go                   # VR 类型及分类
├── uid.go / uid/           # UID 类型与子包
├── errors.go               # 错误类型
├── element.go              # DataElement / RawDataElement / PersonName
├── dataset.go              # Dataset / FileDataset / PrivateBlock
├── sequence.go             # Sequence
├── multivalue.go           # MultiValue
├── values.go               # 值转换 (bytes → Go 类型)
├── charset.go              # DICOM 字符编码
├── dictionary.go           # 字典查询
├── dictionary_generated.go # 自动生成的 DICOM 字典
├── private_dictionary.go   # 私有字典查询与运行时扩展
├── private_dictionary_generated.go
├── io.go                   # I/O 基础
├── buffer.go               # 缓冲区工具
├── read.go                 # 文件读取
├── write.go                # 文件写入
├── pixeldata.go            # FileDataset.PixelBytes / PixelFrames
├── encaps/                 # 封装像素数据 (BOT / fragment / frame)
├── pixels/                 # 像素解码调度 (native / RLE / JPEG / J2K)
├── godicom.go              # 包文档
├── dicomjson/              # DICOM JSON Model (Part 18 Annex F)
├── generate_dict.py        # 字典生成脚本
├── cmd/godicom/            # CLI 工具 (read / readcopy)
└── pydicom/                # pydicom submodule (参考 / 测试数据)

许可

MIT

变更记录

See CHANGELOG.md.

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

View Source
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

View Source
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

View Source
var AmbiguousVRs = map[VR]bool{
	VRUsSS: true, VRObOw: true, VRUsOw: true, VRUsSsOw: true,
}

AmbiguousVRs are VRs that require context to resolve before explicit writing.

View Source
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.

View Source
var DefaultCharacterSet = "ISO_IR 6"
View Source
var DicomDictionaryGo = map[Tag]DictEntry{}/* 5189 elements not displayed */

ExplicitVRLength16 lists VRs that use 2-byte length fields for Explicit VR (Table 7.1-2, Part 5).

View Source
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.

View Source
var KnownUIDs = uid.Known

KnownUIDs maps UID strings to their info.

View Source
var PrivateDictionaries = map[string]map[string]PrivateDictEntry{}/* 449 elements not displayed */

PrivateDictionaries maps private creator names to tag pattern entries.

View Source
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

StandardVRs contains all standard VRs.

View Source
var UIDDictionary = uid.Dictionary

UIDDictionary maps UID values to their metadata.

Functions

func AddPrivateDictEntry

func AddPrivateDictEntry(creator string, tag Tag, vr VR, name string, vm ...string) error

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

func BufferLength(buf interface{}) (int64, error)

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

func ConvertCharacterSets(values []string) []string

ConvertCharacterSets normalizes DICOM Specific Character Set values for decoding.

func CorrectAmbiguousVR

func CorrectAmbiguousVR(ds *Dataset, isLittleEndian bool, ancestors []*Dataset) error

CorrectAmbiguousVR walks ds correcting ambiguous VR elements when possible. Mirrors pydicom.filewriter.correct_ambiguous_vr.

func CorrectAmbiguousVRPreservingRaw added in v0.6.0

func CorrectAmbiguousVRPreservingRaw(ds *Dataset, isLittleEndian bool, ancestors []*Dataset) error

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

func DecodeBytes(b []byte, encodings []string) string

DecodeBytes decodes using the first matching encoding (legacy helper).

func DecodeBytesWithDelimiters added in v0.5.0

func DecodeBytesWithDelimiters(b []byte, encodings []string, delimiters map[byte]bool) string

DecodeBytesWithDelimiters decodes a DICOM text byte string with ISO-2022 code extensions.

func DecodeString

func DecodeString(b []byte, encodingName string) (string, error)

func EncodeBytesWithCharsets added in v0.5.0

func EncodeBytesWithCharsets(s string, encodings []string) []byte

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 EncodeString

func EncodeString(s string, encodingName string) ([]byte, error)

func FormatNumberAsDS added in v0.15.0

func FormatNumberAsDS(val float64) (string, error)

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

func ISInRange(v int64) bool

ISInRange reports whether v fits the DICOM IS value range [-2^31, 2^31).

func IsAmbiguousVR

func IsAmbiguousVR(vr VR) bool

IsAmbiguousVR reports whether vr is an ambiguous VR from the DICOM dictionary.

func IsBinaryVR

func IsBinaryVR(vr VR) bool

IsBinaryVR returns true if the VR is a binary (bytes-like) VR.

func IsFloatVR

func IsFloatVR(vr VR) bool

IsFloatVR returns true if the VR is a floating-point VR.

func IsIntVR

func IsIntVR(vr VR) bool

IsIntVR returns true if the VR is an integer VR.

func IsRepeaterTag

func IsRepeaterTag(tag Tag) bool

IsRepeaterTag returns true if the tag matches a repeater pattern.

func IsStringVR

func IsStringVR(vr VR) bool

IsStringVR returns true if the VR is a string-like VR.

func IsValidDS added in v0.15.0

func IsValidDS(s string) bool

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

func IsValidIS(s string) bool

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

func PrivateDictionaryDescription(tag Tag, creator string) (string, error)

PrivateDictionaryDescription returns the name for a private element.

func PrivateDictionaryVM

func PrivateDictionaryVM(tag Tag, creator string) (string, error)

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

func ValidateUID(s string) error

ValidateUID checks if the UID string conforms to DICOM rules.

func WriteFile

func WriteFile(filename string, ds *Dataset, opts *WriteOptions) error

WriteFile writes a Dataset to a DICOM file.

Types

type BytesLengthError

type BytesLengthError struct {
	Expected int
	Actual   int
	VR       VR
}

BytesLengthError is returned when a value has an unexpected byte length.

func (*BytesLengthError) Error

func (e *BytesLengthError) Error() string

type DA added in v0.4.0

type DA struct {
	Time     time.Time
	Original string
}

DA holds a DICOM Date (VR=DA) value.

func ParseDA added in v0.4.0

func ParseDA(s string) (DA, error)

ParseDA parses a DICOM DA string.

func (DA) Equal added in v0.15.0

func (d DA) Equal(other DA) bool

func (DA) IsZero added in v0.4.0

func (d DA) IsZero() bool

func (DA) String added in v0.4.0

func (d DA) String() string

type DS added in v0.4.0

type DS struct {
	Value    float64
	Original string
}

DS holds a DICOM Decimal String (VR=DS) value.

func DSFromFloat added in v0.15.0

func DSFromFloat(val float64) (DS, error)

DSFromFloat builds a DS whose Original is a valid DICOM decimal string.

func ParseDS added in v0.4.0

func ParseDS(s string) (DS, error)

ParseDS parses a DICOM DS string.

func (DS) Equal added in v0.15.0

func (d DS) Equal(other DS) bool

func (DS) IsZero added in v0.4.0

func (d DS) IsZero() bool

func (DS) String added in v0.4.0

func (d DS) String() string

type DT added in v0.4.0

type DT struct {
	Time     time.Time
	Original string
}

DT holds a DICOM DateTime (VR=DT) value.

func ParseDT added in v0.4.0

func ParseDT(s string) (DT, error)

ParseDT parses a DICOM DT string.

func (DT) Equal added in v0.15.0

func (d DT) Equal(other DT) bool

func (DT) IsZero added in v0.4.0

func (d DT) IsZero() bool

func (DT) String added in v0.4.0

func (d DT) String() 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) BytesValue

func (d *Dataset) BytesValue(tag Tag) ([]byte, bool)

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) Clone

func (d *Dataset) Clone() *Dataset

Clone returns a deep copy of the dataset, including sequence items.

func (*Dataset) Delete

func (d *Dataset) Delete(tag Tag)

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

func (d *Dataset) Equal(other *Dataset) bool

Equal reports whether d and other contain the same tags, VRs, and values. Mirrors pydicom Dataset.__eq__ for Dataset values.

func (*Dataset) FloatValue

func (d *Dataset) FloatValue(tag Tag) (float64, bool)

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) Get

func (d *Dataset) Get(tag Tag) (*DataElement, bool)

func (*Dataset) GetBytes

func (d *Dataset) GetBytes(tag Tag) ([]byte, bool)

func (*Dataset) GetDA added in v0.4.0

func (d *Dataset) GetDA(tag Tag) (DA, bool)

func (*Dataset) GetDS added in v0.4.0

func (d *Dataset) GetDS(tag Tag) (DS, bool)

func (*Dataset) GetDT added in v0.4.0

func (d *Dataset) GetDT(tag Tag) (DT, bool)

func (*Dataset) GetDataElement

func (d *Dataset) GetDataElement(tag Tag) *DataElement

func (*Dataset) GetFloat

func (d *Dataset) GetFloat(tag Tag) (float64, bool)

func (*Dataset) GetIS added in v0.4.0

func (d *Dataset) GetIS(tag Tag) (IS, bool)

func (*Dataset) GetInt

func (d *Dataset) GetInt(tag Tag) (int, bool)

func (*Dataset) GetPN added in v0.5.0

func (d *Dataset) GetPN(tag Tag) (PersonName, bool)

func (*Dataset) GetSequence

func (d *Dataset) GetSequence(tag Tag) (*Sequence, bool)

func (*Dataset) GetString

func (d *Dataset) GetString(tag Tag) (string, bool)

func (*Dataset) GetTM added in v0.4.0

func (d *Dataset) GetTM(tag Tag) (TM, bool)

func (*Dataset) GroupDataset added in v0.14.0

func (d *Dataset) GroupDataset(group int) *Dataset

GroupDataset returns a new dataset containing only elements of the given group. Mirrors pydicom Dataset.group_dataset.

func (*Dataset) Has

func (d *Dataset) Has(tag Tag) bool

func (*Dataset) IntValue

func (d *Dataset) IntValue(tag Tag) (int, bool)

func (*Dataset) IsOriginalEncoding added in v0.14.0

func (d *Dataset) IsOriginalEncoding() bool

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) Len

func (d *Dataset) Len() int

func (*Dataset) LoadDeferred

func (d *Dataset) LoadDeferred(tag Tag) error

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) SaveAs

func (d *Dataset) SaveAs(filename string, opts *WriteOptions) error

func (*Dataset) SequenceValue

func (d *Dataset) SequenceValue(tag Tag) (*Sequence, bool)

func (*Dataset) Set

func (d *Dataset) Set(element *DataElement)

func (*Dataset) SetOriginalEncoding added in v0.14.0

func (d *Dataset) SetOriginalEncoding(isImplicit, isLittleEndian bool, charsets []string)

SetOriginalEncoding records the encoding used when the dataset was decoded. Mirrors pydicom Dataset.set_original_encoding.

func (*Dataset) SetWriteEncoding added in v0.14.0

func (d *Dataset) SetWriteEncoding(isImplicit, isLittleEndian bool)

SetWriteEncoding sets the VR/endianness that would be used for writing. Used with IsOriginalEncoding; nil write encoding means "same as original".

func (*Dataset) SortedTags

func (d *Dataset) SortedTags() []Tag

SortedTags returns all tags in ascending order.

func (*Dataset) String

func (d *Dataset) String() string

func (*Dataset) StringValue

func (d *Dataset) StringValue(tag Tag) (string, bool)

func (*Dataset) Top added in v0.16.0

func (d *Dataset) Top() string

Top returns a string representation of only top-level elements. Mirrors pydicom Dataset.top.

func (*Dataset) Update added in v0.14.0

func (d *Dataset) Update(other *Dataset)

Update copies elements from other into d (overwriting matching tags). Mirrors pydicom Dataset.update for Dataset sources.

func (*Dataset) Walk

func (d *Dataset) Walk(fn WalkFunc, recursive bool)

Walk visits each element in tag order, optionally recursing into sequences. Mirrors pydicom Dataset.walk.

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

func NewDicomWriter(w io.Writer) *DicomIO

NewDicomWriter creates a DICOM writer.

Deprecated: this constructor is internal and will be removed.

type DictEntry

type DictEntry struct {
	VR      string
	VM      string
	Name    string
	Retired bool
	Keyword string
}

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

func NewElement(tag Tag, vr VR, value interface{}) *Element

func (*Element) Equal

func (e *Element) Equal(other *Element) bool

func (*Element) IsEmpty

func (e *Element) IsEmpty() bool

func (*Element) IsPrivate

func (e *Element) IsPrivate() bool

func (*Element) IsRaw added in v0.6.0

func (e *Element) IsRaw() bool

func (*Element) Keyword

func (e *Element) Keyword() string

func (*Element) Name

func (e *Element) Name() string

func (*Element) ReprValue

func (e *Element) ReprValue() string

func (*Element) String

func (e *Element) String() string

func (*Element) VM

func (e *Element) VM() int

type EncodingInfo

type EncodingInfo struct {
	IsImplicitVR   bool
	IsLittleEndian bool
}

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

type FormatLinesOptions struct {
	ElementFormat         string
	SequenceElementFormat string
}

FormatLinesOptions controls Dataset.FormattedLines output.

type IS added in v0.4.0

type IS struct {
	Value    int64
	Original string
}

IS holds a DICOM Integer String (VR=IS) value.

func ParseIS added in v0.4.0

func ParseIS(s string) (IS, error)

ParseIS parses a DICOM IS string.

func (IS) Equal added in v0.15.0

func (i IS) Equal(other IS) bool

func (IS) IsZero added in v0.4.0

func (i IS) IsZero() bool

func (IS) String added in v0.4.0

func (i IS) String() string

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

type PersonName struct {
	Alphabetic  string
	Ideographic string
	Phonetic    string
	Original    string
}

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

type PrivateDictEntry struct {
	VR      string
	VM      string
	Name    string
	Retired bool
}

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 ReadOptions struct {
	DeferSize        uint32
	StopBeforePixels bool
	Force            bool
	SpecificTags     []Tag
}

type Sequence

type Sequence struct {
	IsUndefinedLength bool
	// contains filtered or unexported fields
}

Sequence holds a list of Dataset items (for VR SQ).

func NewSequence

func NewSequence(items []*Dataset) *Sequence

func (*Sequence) Append

func (s *Sequence) Append(ds *Dataset)

func (*Sequence) Get

func (s *Sequence) Get(i int) *Dataset

func (*Sequence) IsEmpty

func (s *Sequence) IsEmpty() bool

func (*Sequence) Items

func (s *Sequence) Items() []*Dataset

func (*Sequence) Len

func (s *Sequence) Len() int

type TM added in v0.4.0

type TM struct {
	Time     time.Time
	Original string
}

TM holds a DICOM Time (VR=TM) value.

func ParseTM added in v0.4.0

func ParseTM(s string) (TM, error)

ParseTM parses a DICOM TM string.

func (TM) Equal added in v0.15.0

func (t TM) Equal(other TM) bool

func (TM) IsZero added in v0.4.0

func (t TM) IsZero() bool

func (TM) String added in v0.4.0

func (t TM) String() string

type Tag

type Tag = tag.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 MustTag

func MustTag(arg interface{}, arg2 ...int) Tag

MustTag is like ParseTag but panics on error.

func NewTag

func NewTag(group, element int) Tag

NewTag creates a tag from group and element numbers.

func ParseTag

func ParseTag(arg interface{}, arg2 ...int) (Tag, error)

ParseTag creates a Tag from various forms:

  • ParseTag(0x00100010)
  • ParseTag(0x0010, 0x0010)
  • ParseTag("PatientName")
  • ParseTag("00100010")

func TagFromKeyword

func TagFromKeyword(keyword string) (Tag, error)

TagFromKeyword returns the tag for a given keyword.

type TagError

type TagError struct {
	Tag Tag
	Err error
}

TagError wraps an error with tag context.

func (*TagError) Error

func (e *TagError) Error() string

func (*TagError) Unwrap

func (e *TagError) Unwrap() error

type UID

type UID = uid.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
)

func LookupUID

func LookupUID(keyword string) (UID, bool)

LookupUID returns the UID for a dictionary keyword.

type UIDInfo

type UIDInfo = uid.Info

UIDInfo holds metadata about a UID.

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"
)

func LookupVR

func LookupVR(tag Tag) VR

LookupVR returns the VR for a tag, with fallback for unknown tags.

func PrivateDictionaryVR

func PrivateDictionaryVR(tag Tag, creator string) (VR, error)

PrivateDictionaryVR returns the VR for a private element.

type WalkFunc

type WalkFunc func(ds *Dataset, elem *Element)

WalkFunc is called for each element in a Dataset during Walk.

type WriteOptions

type WriteOptions struct {
	ImplicitVR        *bool
	LittleEndian      *bool
	EnforceFileFormat bool
}

WriteOptions controls DICOM file writing behavior.

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.

Jump to

Keyboard shortcuts

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