Coder Social home page Coder Social logo

buzprjs / ruby-dicom Goto Github PK

View Code? Open in Web Editor NEW

This project forked from dicom/ruby-dicom

0.0 2.0 0.0 4.08 MB

Library for reading, editing and writing DICOM files, as well as handling DICOM network communication. Written in the Ruby language.

Home Page: http://dicom.rubyforge.org/

License: GNU General Public License v3.0

Ruby 100.00%

ruby-dicom's Introduction

RUBY DICOM

Ruby DICOM is a small and simple library for handling DICOM in Ruby. DICOM (Digital Imaging and Communications in Medicine) is a standard for handling, storing, printing, and transmitting information in medical imaging. It includes a file format definition and a network communications protocol. Ruby DICOM supports reading from, editing and writing to this file format. It also features basic support for select network communication modalities like querying, moving, sending and receiving files.

INSTALLATION

gem install dicom

REQUIREMENTS

  • Ruby 1.9.3 (if you are still on Ruby 1.8, gems up to version 0.9.1 can be used)

BASIC USAGE

Load & Include

require 'dicom'
include DICOM

Read, modify and write

# Read file:
dcm = DObject.read("some_file.dcm")
# Extract the Patient's Name value:
dcm.patients_name.value
# Add or modify the Patient's Name element:
dcm.patients_name = "Anonymous"
# Remove a data element from the DICOM object:
dcm.pixel_data = nil
# Write to file:
dcm.write("new_file.dcm")

Modify using tag strings instead of dictionary method names

# Extract the Patient's Name value:
dcm.value("0010,0010")
# Modify the Patient's Name element:
dcm["0010,0010"].value = "Anonymous"
# Delete a data element from the DICOM object:
dcm.delete("7FE0,0010")

Extracting information about the DICOM object

# Display a short summary of the file's properties:
dcm.summary
# Print all data elements to screen:
dcm.print
# Convert the data element hierarchy to a nested hash:
dcm.to_hash

Handle pixel data

# Retrieve the pixel data in a Ruby Array:
dcm.pixels
# Load the pixel data to an numerical array (NArray):
dcm.narray
# Load the pixel data to an RMagick image object and display it on screen (X):
dcm.image.normalize.display

Transmit a DICOM file

# Send a local file to a server (PACS) over the network:
node = DClient.new("10.1.25.200", 104)
node.send("some_file.dcm")

Start a DICOM server

# Initiate a simple storage provider which can receive DICOM files of all modalities:
s = DServer.new(104, :host_ae => "MY_DICOM_SERVER")
s.start_scp("C:/temp/")

Log settings

# Change the log level so that only error messages are displayed:
DICOM.logger.level = Logger::ERROR
# Setting up a simple file log:
l = Logger.new('my_logfile.log')
DICOM.logger = l
# Create a logger which ages logfile daily/monthly:
DICOM.logger = Logger.new('foo.log', 'daily')
DICOM.logger = Logger.new('foo.log', 'monthly')

IRB Tip

When working with Ruby DICOM in irb, you may be annoyed with all the information that is printed to screen, regardless if you have set verbose as false. This is because in irb every variable loaded in the program is automatically printed to the screen. A useful hack to avoid this effect is to append ";0" after a command. Example:

dcm = DObject.read("some_file.dcm") ;0

RESOURCES

COPYRIGHT

Copyright 2008-2015 Christoffer Lervåg

This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/ .

ABOUT THE AUTHOR

  • Name: Christoffer Lervåg
  • Location: Norway
  • Email: chris.lervag [@nospam.com] @gmail.com

Please don't hesitate to email me if you have any feedback related to this project!

CONTRIBUTORS

ruby-dicom's People

Contributors

bjoernalbers avatar brettgoulder avatar cian avatar dicom avatar dmillar avatar felixpetriconi avatar icdark avatar jeffmax avatar johnae avatar maturin avatar stevenbedrick avatar

Watchers

 avatar  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.