opendcm

package module
v0.0.0-...-c6cda5e Latest Latest
Warning

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

Go to latest
Published: May 12, 2018 License: MIT Imports: 25 Imported by: 0

README

OpenDCM

A set of lightweight, feature-rich DICOM tools, including a fully-fledged server (SCP).

Go Report Card Build Status


Note: This project is, compared to other DICOM softwares, relatively young. As such, there are likely a number of bugs present. Users are encouraged to submit reports via the issues section. See the roadmap for an overview of current development efforts.



DICOM® is the registered trademark of the National Electrical Manufacturers Association (NEMA) for its standards publications relating to digital communications of medical information.

Documentation

Index

Constants

View Source
const OpenDCMRootUID = "1.2.826.0.1.3680043.9.7484."

OpenDCMRootUID contains the official designated root UID prefix for OpenDCM Issued by Medical Connections Ltd

View Source
const OpenDCMVersion = "0.2"

OpenDCMVersion equals the current (or aimed for) version of the software. It is used commonly in creating ImplementationClassUID(0002,0012)

View Source
const SCPMaxBytes = 2 * 1024 * 1024

Variables

View Source
var (

	// RecognisedVRs lists all VRs that are recognised by OpenDCM.
	// See “6.2 Value Representation (VR)“ for more information
	RecognisedVRs = []string{
		"AE", "AS", "AT", "CS", "DA", "DS", "DT", "FL", "FD", "IS", "LO", "LT", "OB", "OD",
		"OF", "OW", "PN", "SH", "SL", "SQ", "SS", "ST", "TM", "UI", "UL", "UN", "US", "UT",
	}

	// CharacterSetMap provides a mapping between character set name, and character set characteristics.
	CharacterSetMap = map[string]*CharacterSet{
		"Default":         {Name: "Default", Description: "Unicode (UTF-8)", Encoding: unicode.UTF8},
		"ISO_IR 13":       {Name: "ISO_IR 13", Description: "Japanese", Encoding: japanese.ShiftJIS},
		"ISO_IR 100":      {Name: "ISO_IR 100", Description: "Latin alphabet No. 1", Encoding: charmap.ISO8859_1},
		"ISO_IR 101":      {Name: "ISO_IR 101", Description: "Latin alphabet No. 2", Encoding: charmap.ISO8859_2},
		"ISO_IR 109":      {Name: "ISO_IR 109", Description: "Latin alphabet No. 3", Encoding: charmap.ISO8859_3},
		"ISO_IR 110":      {Name: "ISO_IR 110", Description: "Latin alphabet No. 4", Encoding: charmap.ISO8859_4},
		"ISO_IR 126":      {Name: "ISO_IR 126", Description: "Greek", Encoding: charmap.ISO8859_7},
		"ISO_IR 127":      {Name: "ISO_IR 127", Description: "Arabic", Encoding: charmap.ISO8859_6},
		"ISO_IR 138":      {Name: "ISO_IR 138", Description: "Hebrew", Encoding: charmap.ISO8859_8},
		"ISO_IR 144":      {Name: "ISO_IR 144", Description: "Cyrillic", Encoding: charmap.ISO8859_5},
		"ISO_IR 148":      {Name: "ISO_IR 148", Description: "Latin alphabet No. 5", Encoding: charmap.ISO8859_9},
		"ISO_IR 166":      {Name: "ISO_IR 166", Description: "Thai", Encoding: charmap.Windows874},
		"ISO_IR 192":      {Name: "ISO_IR 192", Description: "Unicode (UTF-8)", Encoding: unicode.UTF8},
		"ISO 2022 IR 6":   {Name: "ISO 2022 IR 6", Description: "ASCII", Encoding: unicode.UTF8},
		"ISO 2022 IR 13":  {Name: "ISO 2022 IR 13", Description: "Japanese (Shift JIS)", Encoding: japanese.ShiftJIS},
		"ISO 2022 IR 87":  {Name: "ISO 2022 IR 87", Description: "Japanese (Kanji)", Encoding: japanese.ISO2022JP},
		"ISO 2022 IR 100": {Name: "ISO 2022 IR 100", Description: "Latin alphabet No. 1", Encoding: charmap.ISO8859_1},
		"ISO 2022 IR 101": {Name: "ISO 2022 IR 101", Description: "Latin alphabet No. 2", Encoding: charmap.ISO8859_2},
		"ISO 2022 IR 109": {Name: "ISO 2022 IR 109", Description: "Latin alphabet No. 3", Encoding: charmap.ISO8859_3},
		"ISO 2022 IR 110": {Name: "ISO 2022 IR 110", Description: "Latin alphabet No. 4", Encoding: charmap.ISO8859_4},
		"ISO 2022 IR 127": {Name: "ISO 2022 IR 127", Description: "Arabic", Encoding: charmap.ISO8859_6},
		"ISO 2022 IR 138": {Name: "ISO 2022 IR 138", Description: "Hebrew", Encoding: charmap.ISO8859_8},
		"ISO 2022 IR 144": {Name: "ISO 2022 IR 144", Description: "Cyrillic", Encoding: charmap.ISO8859_5},
		"ISO 2022 IR 148": {Name: "ISO 2022 IR 148", Description: "Latin alphabet No. 5", Encoding: charmap.ISO8859_9},
		"ISO 2022 IR 149": {Name: "ISO 2022 IR 149", Description: "Korean", Encoding: korean.EUCKR},
		"ISO 2022 IR 159": {Name: "ISO 2022 IR 159", Description: "Japanese (Supplementary Kanji)", Encoding: japanese.ISO2022JP},
		"ISO 2022 IR 166": {Name: "ISO 2022 IR 166", Description: "Thai", Encoding: charmap.Windows874},
		"GB18030":         {Name: "GB18030", Description: "Chinese (Simplified)", Encoding: simplifiedchinese.GB18030},
	}
)
View Source
var ExitOnFatalLog = true

ExitOnFatalLog specifies whether the application should `os.Exit(1)` on a fatal log message

Functions

func ConcurrentlyWalkDir

func ConcurrentlyWalkDir(dirPath string, onFile func(file string)) error

ConcurrentlyWalkDir recursively traverses a directory and calls `onFile` for each found file inside a goroutine.

func Debug

func Debug(v ...interface{})

Debug calls `debuglog.Output` to print to the logger. Arguments are handled in the manner of fmt.Print

func Debugf

func Debugf(format string, v ...interface{})

Debugf calls `debuglog.Output` to print to the logger. Arguments are handled in the manner of fmt.Printf

func Error

func Error(v ...interface{})

Error calls `errorlog.Output` to print to the logger. Arguments are handled in the manner of fmt.Print

func Errorf

func Errorf(format string, v ...interface{})

Errorf calls `errorlog.Output` to print to the logger. Arguments are handled in the manner of fmt.Printf

func Fatal

func Fatal(v ...interface{})

Fatal calls `fatallog.Output` to print to the logger. ANSI Red colour is added if the output is a character device Stack is also printed to `os.Stderr` Arguments are handled in the manner of fmt.Print

func Fatalf

func Fatalf(format string, v ...interface{})

Fatalf calls `fatallog.Output` to print to the logger. ANSI Red colour is added if the output is a character device Stack is also printed to `os.Stderr` Arguments are handled in the manner of fmt.Printf

func FatalfDepth

func FatalfDepth(calldepth int, format string, v ...interface{})

FatalfDepth calls `fatallog.Output` to print to the logger. `calldepth` is used to allow for better formatting in case of `check()` ANSI Red colour is added if the output is a character device Stack is also printed to `os.Stderr` Arguments are handled in the manner of fmt.Printf

func GetImplementationUID

func GetImplementationUID(synthetic bool) string

GetImplementationUID generates a DICOM implementation UID from OpenDCMRootUID and OpenDCMVersion NOTE: OpenDCM Implementation UIDs conform to the format: <<ROOT>>.<<VERSION>>.<<InstanceType>> Where ROOT = OpenDCMRootUID, VERSION = OpenDCMVersion, InstanceType= (1 for synthetic data, 0 for others)

func Info

func Info(v ...interface{})

Info calls `infolog.Output` to print to the logger. Arguments are handled in the manner of fmt.Print

func Infof

func Infof(format string, v ...interface{})

Infof calls `infolog.Output` to print to the logger. Arguments are handled in the manner of fmt.Printf

func NewRandInstanceUID

func NewRandInstanceUID() (string, error)

NewRandInstanceUID generates a DICOM random instance UID from OpenDCMRootUID

func OverrideConfig

func OverrideConfig(newconfig Config)

OverrideConfig overrides the configuration parsed from environment with the one provided

func SetLoggingLevel

func SetLoggingLevel(level string)

SetLoggingLevel takes a level string and accordingly enables/disables loggers Supported values: "debug" / "5": all logging enabled "info" / "4": info and above enabled "warn" / "3": warn and above enabled "error" / "2": error and above enabled "fatal" / "1": only fatal enabled "disabled" / "none" / "off", "0": all loggers disabled

func SupportsColour

func SupportsColour(f *os.File) bool

SupportsColour returns whether `f` is a character device (UNIX terminal)

func Warn

func Warn(v ...interface{})

Warn calls `warnlog.Output` to print to the logger. Arguments are handled in the manner of fmt.Print

func Warnf

func Warnf(format string, v ...interface{})

Warnf calls `warnlog.Output` to print to the logger. Arguments are handled in the manner of fmt.Printf

Types

type CharacterSet

type CharacterSet struct {
	Name        string
	Description string
	Encoding    encoding.Encoding
}

CharacterSet provides a link between character encoding, description, and decode + encode functions.

type Config

type Config struct {
	Version       string
	OpenFileLimit int
	RootUID       string
	LogLevel      string
	/* By enabling `StrictMode`, the parser will reject DICOM inputs which either:
	   - TODO: Contain an element with a value length exceeding the maximum allowed for its VR
	   - Contain an element with a value length exceeding the remaining file size. For example incomplete Pixel Data.
	*/
	StrictMode bool

	// DicomReadBufferSize is the number of bytes to be buffered from disk when parsing dicoms
	DicomReadBufferSize int

	// AET
	AET        string
	AEBindIP   string
	AEBindPort int
	// contains filtered or unexported fields
}

Config represents the application configuration

type DataSet

type DataSet map[uint32]Element

DataSet represents a single Data Set, as per: http://dicom.nema.org/dicom/2013/output/chtml/part10/sect_7.2.html

func (*DataSet) GetCharacterSet

func (ds *DataSet) GetCharacterSet() (cs *CharacterSet)

GetCharacterSet returns either the character set as defined in (0008,0005), or ISO_IR 100 (default character set)

func (*DataSet) GetElement

func (ds *DataSet) GetElement(tag uint32, dst *Element) bool

GetElement writes the element indexed by `tag` into `dst` its return value indicates whether the DataSet contains said `tag`.

func (*DataSet) GetElementValue

func (ds *DataSet) GetElementValue(tag uint32, dst interface{}) (bool, error)

GetElementValue writes the element's value indexed by `tag` into `dst` its return value (bool) indicates whether the DataSet contains said `tag`. its return value (error) indicates whether there are any other problems.

func (*DataSet) HasElement

func (ds *DataSet) HasElement(tag uint32) bool

HasElement returns whether the element indexed by `tag` exists.

func (*DataSet) Len

func (ds *DataSet) Len() int

Len returns the number of elements.

type Dicom

type Dicom struct {
	DataSet
	// contains filtered or unexported fields
}

Dicom represents a file containing one SOP Instance as per http://dicom.nema.org/dicom/2013/output/chtml/part10/chapter_7.html

func FromFile

func FromFile(path string) (Dicom, error)

FromFile decodes a dicom file from the given file path See: FromReader for more information

func FromReader

func FromReader(source io.Reader) (Dicom, error)

FromReader decodes a dicom file from `source`, returning an error if something went wrong during the process. This takes ownership of `source`; do not use it after passing through.

func (*Dicom) GetPixelData

func (dcm *Dicom) GetPixelData() *PixelData

func (*Dicom) GetPreamble

func (dcm *Dicom) GetPreamble() [128]byte

GetPreamble returns the "preamble" component

type Element

type Element struct {
	// contains filtered or unexported fields
}

Element represents a Data Element, as per http://dicom.nema.org/dicom/2013/output/chtml/part05/chapter_7.html#sect_7.1

func NewElement

func NewElement() Element

NewElement returns a fresh Element

func NewElementWithTag

func NewElementWithTag(t uint32) Element

NewElementWithTag returns a fresh Element with its VR, VM, Name and NameHuman pre-looked up according to "t".

func (*Element) GetItems

func (e *Element) GetItems() []Item

GetItems returns nested items within this element

func (*Element) GetName

func (e *Element) GetName() string

GetName returns the Element's "Name" component

func (*Element) GetTag

func (e *Element) GetTag() uint32

GetTag returns the Element's "Tag" component

func (*Element) GetVM

func (e *Element) GetVM() string

GetVM returns the Element's "VM" component

func (*Element) GetVR

func (e *Element) GetVR() string

GetVR returns the Element's "VR" component

func (*Element) GetValue

func (e *Element) GetValue(dst interface{}) error

GetValue writes the element's "value" component to "dst". "dst" should be writable (pointer type)

func (*Element) HasItems

func (e *Element) HasItems() bool

HasItems returns whether the element contains nested items

func (*Element) Len

func (e *Element) Len() int

Len returns the data literal bytelength

type ElementReader

type ElementReader struct {
	// contains filtered or unexported fields
}

ElementReader extends `bin.Reader` to export methods to assist in decoding DICOM Elements, i.e. "ReadElement".

func NewElementReader

func NewElementReader(source bin.Reader) (er ElementReader)

NewElementReader returns a fresh ElementReader set up to use `source` for its data.

For futureproofing, it is suggested to use these constructors rather than manually creating an instance (i.e. `elr := ElementReader{}`)

func (*ElementReader) IsImplicitVR

func (elr *ElementReader) IsImplicitVR() bool

IsImplicitVR returns whether this ElementReader is set to parse data according to the VR component being implicitly defined

func (*ElementReader) IsLittleEndian

func (elr *ElementReader) IsLittleEndian() bool

IsLittleEndian returns whether this ElementReader is set to parse data according to Little Endian byte ordering.

func (*ElementReader) ReadElement

func (elr *ElementReader) ReadElement(dst *Element) error

ReadElement attempts to completely read an element into `dst`.

All types of elements are expected to be compatible.

func (*ElementReader) SetImplicitVR

func (elr *ElementReader) SetImplicitVR(isImplicitVR bool)

SetImplicitVR returns whether this ElementReader should parse data according to the VR component being implicitly defined

func (*ElementReader) SetLittleEndian

func (elr *ElementReader) SetLittleEndian(isLittleEndian bool)

SetLittleEndian setswhether this ElementReader should parse data according to Little Endian byte ordering.

type Item

type Item struct {
	// contains filtered or unexported fields
}

Item represents an Item, as may be found within nested data sequences, as per http://dicom.nema.org/dicom/2013/output/chtml/part05/sect_7.5.html

func NewItem

func NewItem() Item

NewItem returns a fresh Item with a blank data set.

type PixelData

type PixelData struct {
	// contains filtered or unexported fields
}

func (*PixelData) GetFrame

func (pd *PixelData) GetFrame(index int) []byte

func (*PixelData) NumFrames

func (pd *PixelData) NumFrames() int

Directories

Path Synopsis
cmd
opendcm-view command
Code generated using util:gendatadict.
Code generated using util:gendatadict.

Jump to

Keyboard shortcuts

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