Skip to content

godicom-devDICOM for Go

Read, modify and write DICOM datasets, decode and encode Pixel Data, talk DIMSE and DICOMweb — from idiomatic Go, with no CGO for callers.

Read a file, change it, write it back

go
package main

import (
	"log"

	"github.com/godicom-dev/godicom"
	"github.com/godicom-dev/godicom/tag"
)

func main() {
	ds, err := godicom.ReadFile("ct.dcm", nil)
	if err != nil {
		log.Fatal(err)
	}
	if err := ds.SetString(tag.PatientID, "12345678"); err != nil {
		log.Fatal(err)
	}
	if err := ds.SaveAs("ct_updated.dcm", nil); err != nil {
		log.Fatal(err)
	}
}
bash
go get github.com/godicom-dev/godicom@latest

Where to go next

  • Getting started — install, read your first file, and find out what a malformed one is hiding.
  • The ecosystem — which module owns what, and which one pulls in which.
  • godicom — the dataset library in detail.
  • gonetdicom — if you need to move images between machines rather than parse them.

About this site

These pages are written against the released versions of each module and link to pkg.go.dev for the full API reference, which is generated from the source and therefore never out of date. Where the two disagree, pkg.go.dev is right.

Released under the MIT License.