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
| Name | What it is for |
|---|---|
Generate | A new UID under 2.25, from 128 random bits. |
UID, New | A UID value, with Info, IsValid, String. |
GetUIDInfo, UIDInfo | Name, keyword, type and retirement of a registered UID; nil when unknown. |
GetByName, GetByType, AllUIDInfos | Look the registry up the other way, or list it. |
IsTransferSyntax, IsSOPClass | What kind of UID it is. |
IsCompressed, IsLossless | Questions about a transfer syntax. |
ExplicitVRLittleEndian and the like | A few common UIDs as values. |
ImplementationClassUID, ImplementationVersionName | What 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.25is 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.