Git Product home page Git Product logo

dicom.jl's Introduction

DICOM.jl

Julia interface for parsing/writing DICOM files

Usage

Installation

To install the package:

julia> Pkg.add("DICOM")

Load the package by

julia> using DICOM

Reading Data

Read a DICOM file by

julia> dcmData = dcm_parse("path/to/dicom/file")

The data in dcmData is structured as a dictionary, and individual DICOM elements can be accessed by their hex tag. For example, the hex tag of "Pixel Data" is 7FE0,0010, and it can be accessed in Julia by dcmData[(0x7FE0,0x0010)].

Writing Data

Data can be written to a DICOM file by

julia> dcm_write("path/to/output/file", dcmData)

Additional Notes

DICOM files use either explicit or implicit value representation (VR). For implicit files, DICOM.jl will use a lookup table to guess the VR from the DICOM element's hex tag. For explicit files, DICOM.jl will read the VRs from the file.

  • A user-defined dictionary can be supplied to override the default lookup table For example, the "Instance Number" - tag (0x0020,0x0013) - is an integer (default VR = "IS"). We can read this as a float by setting the VR to "DS" by:

    myVR = Dict( (0x0020,0x0013) => "DS" )
    dcmData = dcm_parse("path/to/dicom/file", dVR = myVR)
    

    Now dcmData[(0x0020,0x0013)] will return a float instead of an integer.

  • It is possible to skip an element by setting its VR to "". For example, we can skip reading the Instance Number by

    myVR = Dict( (0x0020,0x0013) => "" )
    dcmData = dcm_parse("path/to/dicom/file", dVR = myVR)
    

    and now dcmData[(0x0020,0x0013)] will return an error because the key (0x0020,0x0013) doesn't exist - it was skipped during reading.

  • The user-supplied VR can contain a master VR with the tag (0x0000,0x0000) which will be used whenever DICOM.jl is unable to guess the VR on its own. This is convenient for reading older dicom files and skipping retired elements - i.e. where the VR lookup fails - by:

    myVR = Dict( (0x0000,0x0000) => "" )
    dcmData = dcm_parse("path/to/dicom/file", dVR = myVR)
    
  • A user-supplied VR can also be supplied during writing, e.g.:

    # Note that dcm_write doesn't use a named input, unlike dcm_parse with "dVR ="
    julia> dcm_write("path/to/output/file", dcmData, dcmVR)
    

    where dcmVR is a dictionary which maps the hex tag to the VR.

  • A dictionary of VRs can be obtained by passing true as a 2nd argument to dcm_parse(), e.g.:

    julia> (dcmData, dcmVR) = dcm_parse("path/to/dicom/file", true)
    

    and dcmVR will contain a dictionary of VRs for all of the elements in dcmData

dicom.jl's People

Contributors

notzaki avatar ihnorton avatar simonster avatar ultradian avatar stefankarpinski avatar jeffbezanson avatar adambrewster avatar benrussert avatar carlobaldassi avatar keno avatar

Watchers

 avatar James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.