examples/

directory
v1.5.0 Latest Latest
Warning

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

Go to latest
Published: Aug 14, 2026 License: MIT

README

go-dicom Examples

Standalone examples demonstrating the go-dicom library. Each example is its own main package and can be run directly with go run.

Input/Output

Read a DICOM file
go run ./input_output/read_dicom <file.dcm>

Reads a DICOM file, displays file meta information, and prints the first 20 data elements.

Write a DICOM file
go run ./input_output/write_dicom <output.dcm>

Creates a minimal DICOM file from scratch with patient and study information using the filewriter package.

Print a dataset
go run ./input_output/printing_dataset

Builds a dataset in memory and demonstrates the various String(), PrettyString(), CompactString(), and FormatString() methods.

Modify a DICOM file
go run ./input_output/modify_dicom <file.dcm>

Reads a DICOM file, modifies element values (patient name, ID, etc.), removes elements for anonymization, and saves the result.

Read element values
go run ./input_output/read_element_values <file.dcm>

Reads a DICOM file and extracts specific element values by keyword (patient info, study info, image dimensions).

Metadata Processing

Sequences
go run ./metadata_processing/sequences

Demonstrates creating, nesting, iterating, and modifying DICOM sequences using the sequence and dataset packages.

Image Processing

These examples are conceptual demonstrations that explain algorithms and DICOM image data structures. They use simulated data and do not require DICOM files.

Downsize image
go run ./image_processing/downsize_image

Shows the pixel downsampling algorithm and memory calculations.

Reslice
go run ./image_processing/reslice

Explains multi-slice volume reconstruction and multiplanar reformatting (axial, sagittal, coronal).

Waveforms
go run ./image_processing/waveforms

Explains DICOM waveform data structure (ECG/EEG), multiplex format, and channel extraction.

Directories

Path Synopsis
image_processing
downsize_image command
reslice command
waveforms command
input_output
modify_dicom command
read_dicom command
read_element_values command
Example: Read and Access DICOM Element Values
Example: Read and Access DICOM Element Values
write_dicom command
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
Example: DICOM Networking with go-dicom
Example: DICOM Networking with go-dicom

Jump to

Keyboard shortcuts

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