Skip to Content
go-dicom(3)
Packages

uid

UIDs: generating new ones, the registry of well-known UIDs (transfer syntaxes, SOP classes and the rest) with their names and keywords, and a few questions about transfer syntaxes.

import "github.com/amrshadid/go-dicom/uid" · pkg.go.dev

When to use it

  • A new SOP Instance, Series or Study Instance UID: uid.Generate().
  • The name of a UID in a file or an association: uid.GetUIDInfo(s).
  • Whether a transfer syntax is compressed or lossless.
  • The library's own Implementation Class UID and Version Name, written in every file meta group and association.

Writing a UID as a file name is fileutil's InstanceFilePath. The network package has its own list of transfer syntax and SOP class constants for negotiation.

Key types and functions

NameWhat it is for
GenerateA new UID under 2.25, from 128 random bits.
UID, NewA UID value, with Info, IsValid, String.
GetUIDInfo, UIDInfoName, keyword, type and retirement of a registered UID; nil when unknown.
GetByName, GetByType, AllUIDInfosLook the registry up the other way, or list it.
IsTransferSyntax, IsSOPClassWhat kind of UID it is.
IsCompressed, IsLosslessQuestions about a transfer syntax.
ExplicitVRLittleEndian and the likeA few common UIDs as values.
ImplementationClassUID, ImplementationVersionNameWhat this library calls itself.

Example

// Generate a UID, check one, and name a transfer syntax.
package main

import (
	"fmt"

	"github.com/amrshadid/go-dicom/uid"
)

func main() {
	fmt.Println("new:", uid.Generate())

	ts := uid.New("1.2.840.10008.1.2.4.90")
	if info := ts.Info(); info != nil {
		fmt.Println(info.Name, "|", info.Keyword, "|", info.Type)
	}
	fmt.Println("valid:", ts.IsValid(), "transfer syntax:", uid.IsTransferSyntax(ts.String()),
		"compressed:", uid.IsCompressed(ts), "lossless:", uid.IsLossless(ts))
}

It prints a new 2.25. UID, JPEG 2000 Image Compression (Lossless Only) | JPEG2000Lossless | TransferSyntax, and valid: true transfer syntax: true compressed: true lossless: true.

Notes

  • A UID under 2.25 is unique but says nothing about who made it. An organization with a registered root may prefer UIDs under it.

Warning

UID.IsValid checks only that the value is dot-separated digits with at least two components. It accepts a component with a leading zero (1.2.03) and a value longer than 64 characters, neither of which PS3.5 9.1 allows. valuerep.ValidateUID checks both.

See also

fileutil · valuerep · network · anonymize

On this page