1. Ruby DICOM
Perry Horwich, MD1 , Christoffer Lervåg2, Jeff Miller3
1Guthrie Health, Sayre, PA 2Helse Møre og Romsdal HF, Norway 3Center for Biomedical Informatics, Children's Hospital of Philadelphia, PA
References
Example Application
Current Uses
1. Informatics in Radiology: Use of CouchDB for Document-based Storage of
DICOM Objects, Rascovsky, Delgado, Sanz, Calvo & Castrillón,
RadioGraphics, 2012; 32: 913–927
2. Adaptive radiotherapy based on contrast enhanced cone beam CT imaging
Søvik, Rødal, Skogmo, Lervåg, Eilertsen & Malinen, Acta Oncologica, 2010;
49: 972–977
3. Evaluation of adaptive radiotherapy of bladder cancer by image-based
tumour control probability modeling, Wright, Muren, Høyer & Malinen, Acta
Oncologica, 2010; 49: 1045–1051
4. Conversion of Eclipse RTDose Pixel Data to facilitate further simulations in
IDL., Kalpathy-Cramer & Fuller, AMIA 2010 Annual Symposium
Introduction
PROBLEM: For radiologists, generating and maintaining a
list of clinical cases can be both time consuming and
technically challenging.
CONSIDERATIONS: The radiologist may work at multiple
computers, may use differing operating systems, may use
differing vendor applications, and may work in separate and
distant locations.
SOLUTION: Allow the radiologist to maintain a list of cases
in a text file on a shared network drive (Figure 5). Use one
line of text to represent each case. Using Ruby and Rails,
allow for the import, parsing, and editing of the text file.
Individual cases may be entered via the Rails application
interface as well.
FUNCTIONALITY: When the user is editing or authoring a
case with the Rails application, check to see if the radiologist
has included a medical record number or accession number.
If so, automatically open a DICOM viewer that displays the
corresponding series and images (Figure 8). Allow the
radiologist to save key images with the case for later display.
RESULT: A shortened cycle for case identification and image
association. The resultant case, containing both text and
key images, can be reviewed with a web browser.
ADVANTAGES: The process is vendor neutral. Having
followed agile development principles, this base application
can be adapted to other uses.
Written by Christoffer Lervåg and publicly posted five years
ago, Ruby DICOM represents a mature cross-platform
Ruby language library that facilitates the handling of
DICOM files and network communication. The library
manages the reading, editing and writing of DICOM files
as well as querying, retrieving and sending of files to and
from DICOM nodes (Figures 1-2).
By combining Ruby DICOM with other open source
packages, such as NArray or RMagick, one may perform
both image processing and display (Figure 3).
When combined with Rails, the Ruby DICOM gem
integrates successfully with the Rails web-application
framework and includes everything needed to create
database-backed web applications utilizing the Model-
View-Controller (MVC) development pattern. This
presentation includes an example of a Rails application
that demonstrates this particular approach.
Ruby DICOM has been an integral component in
academic publications.1-4 Ruby DICOM is open source
and has drawn nine additional coding contributors since its
public release. The work is further supported by a
community of more than 40 active discussion group
members. You can find additional information at
http://dicom.rubyforge.org
The author’s personal case list has grown by over a
thousand cases in the past 24 months. Currently this
method is useful for tracking:
• Interesting cases for teaching
• Consults with associated history and clinical correlation
• Cases for follow-up to be reviewed with future surgical,
future clinical, or future imaging exam correlation.
• Quality improvement cases
Figure 6: Account validation allows the application to be
selectively used by different users. A user with no account
may view publicly published case material.
Figure 7: Case data may be searched.
Figure 8: When editing or authoring a specific case, the
user is automatically presented with a javascript DICOM
viewer displaying the exam images. Images of interest
may be selected by the user and associated with the case
being authored.
RUBY
CT abd/pel pt had acute diverticulitis and came back with acute appendicitis 132117 3816145
cr chest cxr nml shoulder with lung mass teaching case 3815168
mr knee equivical osteochondral injury and displaced fragment on .22T hope to see a f/u at 1.5T 3819643
CT arthrogram nice example osteochondral injury 3821462
MR shoulder thorax includes entire scapula normal nice imaging 3820930
MR knee illiotibial band friction syndrome 3821781
MR thigh probable pyomyositis with osteomyelitis rapid change on serial CR in femoral cortex 3825457 400904
CT abd/pel missed SMA aneyrysm 3826653
CR shoulder nice example of hydroxyappetite deposition 3584240
cr hip nice example of polyethelene wear and particulate disease hardware loosening 3825650
cr leg nice example of "subtle" toddlers fracture with follow-up images showing callus formation 1242423
cr forearm soft tissue mass f/u mri 3828160 mri 3832813 f/u clinical
MR knee acl rupture with posterior lateral corner injury LCL sprain nice example 3830023
mr forefoot nice example of tibial sesimoiditis 3830957
Figure 5: Use a text file to track cases of interest.
Open Source
The example application presented makes use of more than
60 open source software libraries, mostly through the use of
ruby gems. Studycentric, the open source javascript DICOM
viewer used here, was written by Jeff Miller at The Center for
Biomedical Informatics, Children’s Hospital of Philadelphia.
Figure 3: Example Ruby code that loads a DICOM object
and saves the image data as a PNG file.
require 'dicom'
require 'RMagick'
dcm = DICOM::DObject.read("myFile.dcm")
image = dcm.image
image.write("dicom.png")
require 'dicom'
a = DICOM::Anonymizer.new
a.anonymize("c:/dicom")
Figure 4: Example Ruby code that anonymizes files in a
target directory. It’s this easy. Or, if you prefer, many
options can be utilized as seen in this tutorial:
http://dicom.rubyforge.org/tutorial2.html
File Handling
require 'dicom'
server = DICOM::DServer.new(104, :host_ae =>
"RUBY_SERVER")
Figure 1: An example method for starting a DICOM
server on the local host at port 104 with an AE of
RUBY_SERVER. It really is just this simple. If you like,
you can make use of many server options including custom
file handlers, transaction logging, and more.
require 'dicom'
node = DICOM::DClient.new(remote_server_ip,
104)
node.move_study("LOCAL_DICOM_SERVER",
'0010,0020' => pat_id, '0020,000D' => study_uid)
Figure 2: Example Ruby code that performs a DICOM
Move, transferring a study identified with study_uid from a
remote DICOM server at remote_server_ip to local DICOM
storage named LOCAL_DICOM_SERVER.
Networking