Saturday, October 16, 2010

Testing ruby-dicom

I tested ruby-dicom to read and display a sample dicom image.

1. Here is a ruby program that read a dicom file and display its image using RMagick.
# test-dicom.rb
# 
# read a sample dicom file and displays it using RMagick lib
#
# based on sample: 
# http://github.com/cuthbert/ruby-dicom
# The sample dicom file was downloaded from: 
# http://www.barre.nom.fr/medical/samples/

require 'rubygems'
require 'dicom'
require 'RMagick'
include Magick

obj = DICOM::DObject.new("samples/MR-MONO2-16-knee.dcm")
obj.information
obj.print
image = obj.get_image_magick.normalize
image.display

2. Here is the image displayed by RMagick.



3. Here is the terminal output.
$ ruby test-dicom.rb

System Properties:
-------------------------------------------
Ruby DICOM version:   0.8
Byte Order (CPU):     Little Endian

DICOM Object Properties:
-------------------------------------------
File:                 samples/MR-MONO2-16-knee.dcm
Modality:             MR Image Storage
Value Representation: Implicit
Byte Order (File):    Little Endian
Pixel Data:           Yes
Image Size:           256*256
Number of frames:     1
Photometry:           MONOCHROME2
Compression:          No
Bits per Pixel:       16
-------------------------------------------
 1 0002,0000 File Meta Information Group Length UL      4 180
 2 0002,0001 File Meta Information Version      OB      2 
 3 0002,0002 Media Storage SOP Class UID        UI     26 1.2.840.10008.5.1.4.1.1.4
 4 0002,0003 Media Storage SOP Instance UID     UI     44 1.2.840.113619.2.1.2.139348932.2.9.602503126
 5 0002,0010 Transfer Syntax UID                UI     18 1.2.840.10008.1.2
 6 0002,0012 Implementation Class UID           UI     18 1.2.840.113619.6.5
 7 0002,0013 Implementation Version Name        SH      6 1_2_5
 8 0002,0016 Source Application Entity Title    AE      6 sdc21
 9 0008,0000 Group Length                       UL      4 414
10 0008,0008 Image Type                         CS     16 ORIGINAL\PRIMARY
11 0008,0016 SOP Class UID                      UI     26 1.2.840.10008.5.1.4.1.1.4
12 0008,0018 SOP Instance UID                   UI     44 1.2.840.113619.2.1.2.139348932.2.9.602503126
13 0008,0020 Study Date                         DA     10 1989.02.03
14 0008,0021 Series Date                        DA     10 1989.02.03
15 0008,0023 Content Date                       DA     10 1989.02.03
16 0008,0030 Study Time                         TM      8 09:26:18
17 0008,0031 Series Time                        TM      8 09:58:19
18 0008,0033 Content Time                       TM      8 09:58:46
19 0008,0060 Modality                           CS      2 MR
20 0008,0070 Manufacturer                       LO     18 GE MEDICAL SYSTEMS
21 0008,0080 Institution Name                   LO     28 THOMAS JEFF UNIVHOSPITAL MRI
22 0008,0090 Referring Physician's Name         PN     10 Anonymized
23 0008,1010 Station Name                       SH      8 FOR.IC0
24 0008,1030 Study Description                  LO      4 KNEE
25 0008,103E Series Description                 LO      6 SAG 3D
26 0008,1060 Name of Physician(s) Reading Study PN     10 Anonymized
27 0008,1070 Operators' Name                    PN     10 Anonymized
28 0008,1090 Manufacturer's Model Name          LO     14 GENESIS_SIGNA
29 0010,0000 Group Length                       UL      4 18
30 0010,0010 Patient's Name                     PN     10 Anonymized
31 0018,0000 Group Length                       UL      4 368
32 0018,0010 Contrast/Bolus Agent               LO      4 NONE
33 0018,0020 Scanning Sequence                  CS      2 GR
34 0018,0021 Sequence Variant                   CS      2 GR
35 0018,0022 Scan Options                       CS     10 GRAPH_GEMS
36 0018,0023 MR Acquisition Type                CS      2 3D
37 0018,0025 Angio Flag                         CS      2 N
38 0018,0050 Slice Thickness                    DS      8 3.000000
39 0018,0080 Repetition Time                    DS     10 33.000000
40 0018,0081 Echo Time                          DS     10 15.000000
41 0018,0083 Number of Averages                 DS      8 1.000000
42 0018,0084 Imaging Frequency                  DS     12 0.0000000000
43 0018,0085 Imaged Nucleus                     SH      2 H1
44 0018,0086 Echo Number(s)                     IS      2 1
45 0018,0087 Magnetic Field Strength            DS      6 15000
46 0018,0088 Spacing Between Slices             DS      8 3.000000
47 0018,0091 Echo Train Length                  IS      2 0
48 0018,0093 Percent Sampling                   DS     10 100.000000
49 0018,0094 Percent Phase Field of View        DS     10 100.000000
50 0018,1062 Nominal Interval                   IS      6 33000
51 0018,1088 Heart Rate                         IS      2 0
52 0018,1090 Cardiac Number of Images           IS      2 0
53 0018,1094 Trigger Window                     IS      2 10
54 0018,1100 Reconstruction Diameter            DS     14 160.0000000000
55 0018,1314 Flip Angle                         DS      2 30
56 0018,1315 Variable Flip Angle Flag           CS      2 N
57 0018,1316 SAR                                DS      8 0.009903
58 0018,5100 Patient Position                   CS      4 FFS
59 0020,0000 Group Length                       UL      4 304
60 0020,000D Study Instance UID                 UI     40 1.2.840.113619.2.1.2.139348932.602501178
61 0020,000E Series Instance UID                UI     42 1.2.840.113619.2.1.2.139348932.2.602503099
62 0020,0011 Series Number                      IS      2 2
63 0020,0012 Acquisition Number                 IS      2 0
64 0020,0013 Instance Number                    IS      2 9
65 0020,0032 Image Position (Patient)           DS     32 16.500000\-80.000000\ 84.726562
66 0020,0037 Image Orientation (Patient)        DS     56 0.000000\1.000000\0.000000\0.000000\0.000000\ -1.000000
67 0020,0052 Frame of Reference UID             UI     32 1.2.840.113619.2.1.2.139348932.0
68 0020,1040 Position Reference Indicator       LO      2 KN
69 0020,1041 Slice Location                     DS     14 -16.5000000000
70 0028,0000 Group Length                       UL      4 132
71 0028,0002 Samples per Pixel                  US      2 1
72 0028,0004 Photometric Interpretation         CS     12 MONOCHROME2
73 0028,0010 Rows                               US      2 256
74 0028,0011 Columns                            US      2 256
75 0028,0030 Pixel Spacing                      DS     12 0.625\0.625
76 0028,0100 Bits Allocated                     US      2 16
77 0028,0101 Bits Stored                        US      2 16
78 0028,0102 High Bit                           US      2 15
79 0028,0103 Pixel Representation               US      2 1
80 0028,1050 Window Center                      DS      4 1095
81 0028,1051 Window Width                       DS      2 84
82 7FE0,0000 Group Length                       UL      4 131080
83 7FE0,0010 Pixel Data                         OW 131072 

4. Resources.

a. Ruby-dicom official home page: http://dicom.rubyforge.org/
b. github: http://github.com/cuthbert/ruby-dicom
c. Ruby-dicom forum: http://groups.google.com/group/ruby-dicom
d. Dicom sample images: http://www.barre.nom.fr/medical/samples/

No comments:

Post a Comment