Documentation
¶
Overview ¶
Command dicom is a command-line interface for reading, writing, and networking DICOM (Digital Imaging and Communications in Medicine) data.
It is the executable front end to the go-dicom library. Every subcommand is a thin wrapper over the packages listed under [Library packages] below, so anything the CLI does can also be done programmatically.
Installation ¶
go install github.com/amrshadid/go-dicom@latest
Prebuilt binaries for Linux, macOS, and Windows are attached to each release at https://github.com/amrshadid/go-dicom/releases.
File commands ¶
Inspect and convert DICOM files. These accept .dcm, .ima, DICOMDIR, and raw DICOM streams.
dicom show patient.dcm # display the data elements dicom info patient.dcm # display file metadata dicom convert patient.dcm out.json # convert to DICOM JSON, CSV, or NIfTI dicom tag-doc 0010,0010 # look up a tag in the data dictionary dicom codify patient.dcm # emit Go source that rebuilds the file
Network commands ¶
Act as a DICOM Service Class User (client) or Service Class Provider (server) over the DICOM Upper Layer Protocol.
dicom echoscu pacs.hospital.com:11112 # C-ECHO verification dicom echoscp -port 11112 # verification server dicom storescu -aec PACS pacs:11112 study/*.dcm # send files dicom storescp -port 11112 -output ./received/ # receive and save files dicom findscu -patient-name "Smith*" pacs:11112 # query dicom movescu -dest MY_SCP -study 1.2.3.4 pacs:11112 dicom getscu -study 1.2.3.4 pacs:11112 dicom qrscp -port 11112 # combined store + Q/R server
Run "dicom help <command>" for the flags a given subcommand accepts.
Library packages ¶
The library is organized into focused packages. The most common entry points are:
- github.com/amrshadid/go-dicom/filereader — read DICOM files, including nested sequences and encapsulated pixel data
- github.com/amrshadid/go-dicom/filewriter — write DICOM Part 10 files
- github.com/amrshadid/go-dicom/dataset — the in-memory data set, safe for concurrent use
- github.com/amrshadid/go-dicom/network — SCU and SCP, DIMSE services, PDU encoding, TLS
- github.com/amrshadid/go-dicom/tag — the data dictionary, 5,000+ standard and 10,500+ private tags
- github.com/amrshadid/go-dicom/anonymize — de-identification per DICOM PS3.15 Annex E
Supporting packages cover character sets (github.com/amrshadid/go-dicom/charset), compression (github.com/amrshadid/go-dicom/compress), pixel data (github.com/amrshadid/go-dicom/pixels), overlays, waveforms, structured reports, and the DICOM JSON Model (github.com/amrshadid/go-dicom/jsonrep).
Reading a file ¶
file, err := os.Open("patient.dcm")
if err != nil {
log.Fatal(err)
}
defer file.Close()
dicomFile, err := filereader.ReadDICOMFile(filebase.NewFileReader(file))
if err != nil {
log.Fatal(err)
}
ds := dicomFile.GetDataset()
if elem, ok := ds.Get(tag.New(0x0010, 0x0010)); ok {
fmt.Printf("Patient: %s\n", elem.GetValue())
}
Receiving over the network ¶
scp := network.NewSCP(network.SCPConfig{AETitle: "MY_SCP", Port: 11112})
scp.SetHandler(&network.StorageHandler{
OnStore: func(ctx context.Context, sopClass, sopInstance string, ds *dataset.Dataset) uint16 {
// persist, forward, or index the received instance
return network.StatusSuccess
},
})
log.Fatal(scp.ListenAndServe(context.Background()))
Handling protected health information ¶
DICOM data routinely contains protected health information. The github.com/amrshadid/go-dicom/anonymize package implements the de-identification profiles in DICOM PS3.15 Annex E. Note that PHI can appear in places a tag-based profile will not reach, including burned-in annotations in pixel data, private vendor tags, and structured report content. See SECURITY.md for the project's guidance.
Standards ¶
go-dicom implements PS3.5 (data structures and encoding), PS3.6 (the data dictionary), PS3.7 (message exchange), PS3.8 (network communication), PS3.10 (media storage and the file format), PS3.15 (security profiles), and the DICOM JSON Model from PS3.18.
Known gaps are listed in Section 8 of CONFORMANCE.md and the Limitations section of the README rather than left implicit. The two most significant: JPEG 2000 pixel data needs a decoder you supply, and RLE Lossless is the only transfer syntax this library compresses to, so a C-STORE over any other compressed context fails rather than sending mislabelled bytes.
Directories
¶
| Path | Synopsis |
|---|---|
|
Package anonymize removes protected health information from DICOM data sets, implementing the de-identification profiles defined in DICOM PS3.15 Annex E.
|
Package anonymize removes protected health information from DICOM data sets, implementing the de-identification profiles defined in DICOM PS3.15 Annex E. |
|
Package charset provides DICOM character set encoding and decoding support.
|
Package charset provides DICOM character set encoding and decoding support. |
|
Package cli provides a command-line interface framework for DICOM tools.
|
Package cli provides a command-line interface framework for DICOM tools. |
|
Package compress provides comprehensive compression and encapsulation handling for DICOM pixel data.
|
Package compress provides comprehensive compression and encapsulation handling for DICOM pixel data. |
|
Package config provides centralized, thread-safe global configuration management for DICOM operations.
|
Package config provides centralized, thread-safe global configuration management for DICOM operations. |
|
Package dataelem provides core DICOM data element structures and operations.
|
Package dataelem provides core DICOM data element structures and operations. |
|
Package dataset provides high-level data structure and operations for in-memory DICOM datasets.
|
Package dataset provides high-level data structure and operations for in-memory DICOM datasets. |
|
Package dcmstore is an on-disk store of DICOM instances with an index that answers the hierarchical queries a C-FIND asks.
|
Package dcmstore is an on-disk store of DICOM instances with an index that answers the hierarchical queries a C-FIND asks. |
|
Package encaps provides DICOM encapsulation parsing and frame extraction.
|
Package encaps provides DICOM encapsulation parsing and frame extraction. |
|
Package errors provides comprehensive error handling for DICOM operations.
|
Package errors provides comprehensive error handling for DICOM operations. |
|
examples
|
|
|
image_processing/downsize_image
command
|
|
|
image_processing/reslice
command
|
|
|
image_processing/waveforms
command
|
|
|
input_output/modify_dicom
command
|
|
|
input_output/printing_dataset
command
|
|
|
input_output/read_dicom
command
|
|
|
input_output/read_element_values
command
Example: Read and Access DICOM Element Values
|
Example: Read and Access DICOM Element Values |
|
input_output/write_dicom
command
|
|
|
jpeg2000
Package jpeg2000 is a reference external decoder for JPEG 2000 pixel data.
|
Package jpeg2000 is a reference external decoder for JPEG 2000 pixel data. |
|
metadata_processing/sequences
command
|
|
|
networking
command
Example: DICOM Networking with go-dicom
|
Example: DICOM Networking with go-dicom |
|
Package filebase provides low-level file I/O abstractions for DICOM file operations.
|
Package filebase provides low-level file I/O abstractions for DICOM file operations. |
|
Package filereader provides comprehensive DICOM file reading support.
|
Package filereader provides comprehensive DICOM file reading support. |
|
Package fileset provides comprehensive management of DICOM file collections organized in directory structures.
|
Package fileset provides comprehensive management of DICOM file collections organized in directory structures. |
|
Package fileutil provides comprehensive file and data utilities for DICOM processing.
|
Package fileutil provides comprehensive file and data utilities for DICOM processing. |
|
Package filewriter provides comprehensive DICOM file writing support.
|
Package filewriter provides comprehensive DICOM file writing support. |
|
Package hooks provides DICOM parsing and processing hook support.
|
Package hooks provides DICOM parsing and processing hook support. |
|
Package jsonrep provides DICOM JSON Model representation support.
|
Package jsonrep provides DICOM JSON Model representation support. |
|
Package multival provides type-safe multi-value lists with constructor-based type enforcement.
|
Package multival provides type-safe multi-value lists with constructor-based type enforcement. |
|
Package network implements DICOM networking: the Upper Layer Protocol from PS3.8, the DIMSE message exchange from PS3.7, and the service classes that run over them.
|
Package network implements DICOM networking: the Upper Layer Protocol from PS3.8, the DIMSE message exchange from PS3.7, and the service classes that run over them. |
|
Package overlays provides comprehensive support for DICOM overlay management.
|
Package overlays provides comprehensive support for DICOM overlay management. |
|
Package pixels provides comprehensive access to and manipulation of DICOM pixel data.
|
Package pixels provides comprehensive access to and manipulation of DICOM pixel data. |
|
scripts
|
|
|
jpeglossless-check
command
Command jpeglossless-check decodes dcmtk-encoded lossless JPEG fixtures and compares them with the uncompressed pixels they were made from.
|
Command jpeglossless-check decodes dcmtk-encoded lossless JPEG fixtures and compares them with the uncompressed pixels they were made from. |
|
roundtrip-check
command
Command roundtrip-check reads every DICOM file in a directory and writes it back out, so another toolkit can judge the result.
|
Command roundtrip-check reads every DICOM file in a directory and writes it back out, so another toolkit can judge the result. |
|
Package sequence provides a thread-safe ordered sequence container for DICOM datasets.
|
Package sequence provides a thread-safe ordered sequence container for DICOM datasets. |
|
Package sr provides comprehensive support for DICOM Structured Reports.
|
Package sr provides comprehensive support for DICOM Structured Reports. |
|
Package tag provides DICOM tag handling and dictionary lookup functionality.
|
Package tag provides DICOM tag handling and dictionary lookup functionality. |
|
Package uid provides utilities for DICOM Unique Identifier (UID) management.
|
Package uid provides utilities for DICOM Unique Identifier (UID) management. |
|
Package util provides utility functions for DICOM data manipulation and analysis.
|
Package util provides utility functions for DICOM data manipulation and analysis. |
|
Package valuerep provides utilities for DICOM Value Representation (VR) handling and validation.
|
Package valuerep provides utilities for DICOM Value Representation (VR) handling and validation. |
|
Package values provides utilities for DICOM value conversion and handling.
|
Package values provides utilities for DICOM value conversion and handling. |
|
Package waveforms provides support for managing and analyzing DICOM waveform data.
|
Package waveforms provides support for managing and analyzing DICOM waveform data. |