go2com

package module
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: Feb 11, 2023 License: GPL-3.0 Imports: 15 Imported by: 0

README

go2com (DICOM image parser)

** This package is under active development and can be in a very broken state. Please use the latest released version **

TODO

  • Improve DICOM PixelData frame parser

Example

To parse a DICOM file


Supported Transfer Syntaxes

ImplicitVRLittleEndian                                     "1.2.840.10008.1.2"
ExplicitVRLittleEndian                                     "1.2.840.10008.1.2.1"
ExplicitVRBigEndian                                        "1.2.840.10008.1.2.2"
DeflatedExplicitVRLittleEndian                             "1.2.840.10008.1.2.1.99"
JPEGBaselineProcess1                                       "1.2.840.10008.1.2.4.50"
JPEGBaselineProcess2And4                                   "1.2.840.10008.1.2.4.51"
JPEGLosslessNonHierarchicalProcesses14                     "1.2.840.10008.1.2.4.57"
JPEGLosslessNonHierarchicalFirstOrderPredictionProcess14   "1.2.840.10008.1.2.4.70"
JPEGLSLosslessImageCompression                             "1.2.840.10008.1.2.4.80"
JPEGLSLossyNearLosslessImageCompression                    "1.2.840.10008.1.2.4.81"
JPEG2000ImageCompressionLosslessOnly                       "1.2.840.10008.1.2.4.90"
JPEG2000ImageCompression                                   "1.2.840.10008.1.2.4.91"
MPEG4AVCH264highProfile                                    "1.2.840.10008.1.2.4.102"
MPEG4AVCH264BDCompatibleHighProfile                        "1.2.840.10008.1.2.4.103"

Benchmark Result

Using 2 cores

Parsing result without skipping the PixelData option
goos: linux
goarch: amd64
pkg: github.com/okieraised/go2com
cpu: Intel(R) Core(TM) i9-9900K CPU @ 3.60GHz
BenchmarkNewParser-2         246           4898625 ns/op
BenchmarkNewParser-2         222           5023251 ns/op
BenchmarkNewParser-2         240           4900945 ns/op
BenchmarkNewParser-2         241           4957440 ns/op
BenchmarkNewParser-2         238           4911706 ns/op
BenchmarkNewParser-2         241           5001905 ns/op
BenchmarkNewParser-2         240           5062585 ns/op
BenchmarkNewParser-2         238           4964253 ns/op
BenchmarkNewParser-2         240           4904890 ns/op
BenchmarkNewParser-2         237           4882366 ns/op
BenchmarkNewParser-2         238           4971147 ns/op
BenchmarkNewParser-2         240           5134180 ns/op
BenchmarkNewParser-2         246           4930679 ns/op
BenchmarkNewParser-2         232           4971505 ns/op
BenchmarkNewParser-2         241           5002399 ns/op
BenchmarkNewParser-2         242           4868371 ns/op
BenchmarkNewParser-2         241           4897682 ns/op
BenchmarkNewParser-2         246           5014649 ns/op
BenchmarkNewParser-2         236           4989994 ns/op
BenchmarkNewParser-2         236           5238820 ns/op
Parsing result with skipping the PixelData option
goos: linux
goarch: amd64
pkg: github.com/okieraised/go2com
cpu: Intel(R) Core(TM) i9-9900K CPU @ 3.60GHz
BenchmarkNewParser-2         248           4977196 ns/op
BenchmarkNewParser-2         241           4799562 ns/op
BenchmarkNewParser-2         250           4847411 ns/op
BenchmarkNewParser-2         237           4818379 ns/op
BenchmarkNewParser-2         223           4738318 ns/op
BenchmarkNewParser-2         252           4687902 ns/op
BenchmarkNewParser-2         242           4769615 ns/op
BenchmarkNewParser-2         249           4670712 ns/op
BenchmarkNewParser-2         254           4817976 ns/op
BenchmarkNewParser-2         244           4680175 ns/op
BenchmarkNewParser-2         259           4749270 ns/op
BenchmarkNewParser-2         237           4674772 ns/op
BenchmarkNewParser-2         255           4621554 ns/op
BenchmarkNewParser-2         229           5062034 ns/op
BenchmarkNewParser-2         252           4587018 ns/op
BenchmarkNewParser-2         253           4697444 ns/op
BenchmarkNewParser-2         261           4802300 ns/op
BenchmarkNewParser-2         259           4789614 ns/op
BenchmarkNewParser-2         244           5045803 ns/op
BenchmarkNewParser-2         232           4986901 ns/op

Documentation

Index

Constants

View Source
const (
	MagicString = "DICM"
	PrivateTag  = "PrivateTag"
)
View Source
const (
	VLUndefinedLength uint32 = 0xFFFFFFFF
)

Variables

This section is empty.

Functions

func NewDICOMReader added in v0.5.0

func NewDICOMReader(reader *bufio.Reader, options ...func(*dcmReader)) *dcmReader

NewDICOMReader returns a new reader

func WithAllowNonCompliantDcm added in v0.5.0

func WithAllowNonCompliantDcm(allowNonCompliantDcm bool) func(*dcmReader)

WithAllowNonCompliantDcm provides option to keep trying to parse the file even if it's not DICOM compliant e.g.: Missing header, missing FileMetaInformationGroupLength,...

func WithSetFileSize added in v0.5.0

func WithSetFileSize(fileSize int64) func(*dcmReader)

WithSetFileSize provides option to set the file size to the reader

func WithSkipDataset added in v0.5.0

func WithSkipDataset(skipDataset bool) func(*dcmReader)

WithSkipDataset provides option to read only the metadata header. If true, only the meta header is read, else, the dataset will be read

func WithSkipPixelData added in v0.5.0

func WithSkipPixelData(skipPixelData bool) func(*dcmReader)

WithSkipPixelData provides option to skip reading pixel data (7FE0,0010). If true, pixel data is skipped. If false, pixel data will be read

Types

type Dataset added in v0.5.0

type Dataset struct {
	Elements []*Element `json:"elements"`
}

func (*Dataset) FindElementByTag added in v0.5.0

func (ds *Dataset) FindElementByTag(tagName tag.DicomTag) (*Element, error)

FindElementByTag returns the corresponding element of the input tag name.

func (*Dataset) FindElementByTagName added in v0.5.0

func (ds *Dataset) FindElementByTagName(tagName string) (*Element, error)

FindElementByTagName returns the corresponding element of the input tag name.

func (*Dataset) FindElementByTagStr added in v0.5.0

func (ds *Dataset) FindElementByTagStr(tagStr string) (*Element, error)

FindElementByTagStr returns the corresponding element of the input tag. Tag must be in 'ggggeeee' or '(gggg,eeee)' format

func (*Dataset) RetrieveFileUID added in v0.5.0

func (ds *Dataset) RetrieveFileUID() (*DicomUID, error)

type DicomUID added in v0.5.0

type DicomUID struct {
	StudyInstanceUID  string `json:"study_instance_uid"`
	SeriesInstanceUID string `json:"series_instance_uid"`
	SOPInstanceUID    string `json:"sop_instance_uid"`
}

type Element added in v0.5.0

type Element struct {
	Value                  Value        `json:"value"`
	TagName                string       `json:"tag_name"`
	ValueRepresentationStr string       `json:"value_representation_str"`
	ValueLength            uint32       `json:"value_length"`
	Tag                    tag.DicomTag `json:"tag"`
	ValueRepresentation    vr.VRKind    `json:"value_representation"`
}

Element defines the struct for each dicom tag element info. Ordered as below to decrease the memory footprint

func ReadElement added in v0.5.0

func ReadElement(r *dcmReader, isImplicit bool, binOrder binary.ByteOrder) (*Element, error)

ReadElement reads the DICOM file tag by tag and returns the pointer to the parsed Element

type MappedTag added in v0.1.2

type MappedTag map[string]tag.TagBrowser

func (MappedTag) GetElementByTagString added in v0.1.2

func (m MappedTag) GetElementByTagString(tagStr string) (interface{}, error)

GetElementByTagString returns the element value of the input tag Tag should be in (gggg,eeee) or ggggeeee format

type Value added in v0.5.0

type Value struct {
	RawValue interface{} `json:"raw_value"`
}

Directories

Path Synopsis
cmd
tag
internal
pkg

Jump to

Keyboard shortcuts

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