dicom 0.9.3 → 0.9.4
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG.rdoc +312 -290
- data/COPYING +674 -674
- data/Gemfile +3 -0
- data/dicom.gemspec +31 -0
- data/lib/dicom.rb +53 -51
- data/lib/dicom/anonymizer.rb +98 -123
- data/lib/dicom/audit_trail.rb +104 -116
- data/lib/dicom/constants.rb +219 -170
- data/lib/dicom/d_client.rb +122 -150
- data/lib/dicom/d_library.rb +219 -287
- data/lib/dicom/d_object.rb +451 -539
- data/lib/dicom/d_read.rb +151 -245
- data/lib/dicom/d_server.rb +329 -359
- data/lib/dicom/d_write.rb +327 -395
- data/lib/dicom/deprecated.rb +1 -72
- data/lib/dicom/dictionary/elements.txt +3646 -0
- data/lib/dicom/dictionary/uids.txt +334 -0
- data/lib/dicom/dictionary_element.rb +61 -0
- data/lib/dicom/element.rb +278 -218
- data/lib/dicom/elemental.rb +21 -27
- data/lib/dicom/file_handler.rb +121 -121
- data/lib/dicom/image_item.rb +819 -861
- data/lib/dicom/image_processor.rb +24 -15
- data/lib/dicom/image_processor_mini_magick.rb +21 -23
- data/lib/dicom/image_processor_r_magick.rb +39 -34
- data/lib/dicom/item.rb +133 -120
- data/lib/dicom/link.rb +1531 -1532
- data/lib/dicom/logging.rb +155 -158
- data/lib/dicom/parent.rb +782 -847
- data/lib/dicom/ruby_extensions.rb +248 -229
- data/lib/dicom/sequence.rb +109 -92
- data/lib/dicom/stream.rb +480 -511
- data/lib/dicom/uid.rb +82 -0
- data/lib/dicom/variables.rb +9 -9
- data/lib/dicom/version.rb +5 -5
- data/rakefile.rb +29 -0
- metadata +130 -76
- data/lib/dicom/dictionary.rb +0 -3280
data/lib/dicom/uid.rb
ADDED
@@ -0,0 +1,82 @@
|
|
1
|
+
module DICOM
|
2
|
+
|
3
|
+
# This class handles the various UID types (transfer syntax, SOP Class, LDAP OID, etc)
|
4
|
+
# found in the DICOM Data Dictionary (Annex A: Registry of DICOM unique identifiers,
|
5
|
+
# Table A-1).
|
6
|
+
#
|
7
|
+
class UID
|
8
|
+
|
9
|
+
# The UID name, e.g. 'Verification SOP Class'.
|
10
|
+
attr_reader :name
|
11
|
+
# The UID's retired status string, i.e. an empty string or 'R'.
|
12
|
+
attr_reader :retired
|
13
|
+
# The UID type, e.g. 'SOP Class'.
|
14
|
+
attr_reader :type
|
15
|
+
# The UID value, e.g. '1.2.840.10008.1.1'.
|
16
|
+
attr_reader :value
|
17
|
+
|
18
|
+
# Creates a new UID.
|
19
|
+
#
|
20
|
+
# @param [String] value the UID's value
|
21
|
+
# @param [String] name the UID's name
|
22
|
+
# @param [String] type the UID's type
|
23
|
+
# @param [String] retired the UID's retired status string
|
24
|
+
#
|
25
|
+
def initialize(value, name, type, retired)
|
26
|
+
@value = value
|
27
|
+
@name = name
|
28
|
+
@type = type
|
29
|
+
@retired = retired
|
30
|
+
end
|
31
|
+
|
32
|
+
# Checks if the UID is a Transfer Syntax that big endian byte order.
|
33
|
+
#
|
34
|
+
# @return [Boolean] true if the UID indicates big endian byte order, and false if not
|
35
|
+
#
|
36
|
+
def big_endian?
|
37
|
+
@value == EXPLICIT_BIG_ENDIAN ? true : false
|
38
|
+
end
|
39
|
+
|
40
|
+
# Checks if the UID is a Transfer Syntax that implies compressed pixel data.
|
41
|
+
#
|
42
|
+
# @return [Boolean] true if the UID indicates compressed pixel data, and false if not
|
43
|
+
#
|
44
|
+
def compressed_pixels?
|
45
|
+
transfer_syntax? ? (@name =~ /Implicit|Explicit/).nil? : false
|
46
|
+
end
|
47
|
+
|
48
|
+
# Checks if the UID is a Transfer Syntax that implies explicit encoding.
|
49
|
+
#
|
50
|
+
# @return [Boolean] true if the UID indicates explicit encoding, and false if not
|
51
|
+
#
|
52
|
+
def explicit?
|
53
|
+
transfer_syntax? ? (@name =~ /Implicit/).nil? : false
|
54
|
+
end
|
55
|
+
|
56
|
+
# Converts the retired status string to a boolean.
|
57
|
+
#
|
58
|
+
# @return [Boolean] true if the UID is retired, and false if not
|
59
|
+
#
|
60
|
+
def retired?
|
61
|
+
@retired =~ /R/ ? true : false
|
62
|
+
end
|
63
|
+
|
64
|
+
# Checks if the UID is a SOP Class.
|
65
|
+
#
|
66
|
+
# @return [Boolean] true if the UID is of type SOP Class, and false if not
|
67
|
+
#
|
68
|
+
def sop_class?
|
69
|
+
@type =~ /SOP Class/ ? true : false
|
70
|
+
end
|
71
|
+
|
72
|
+
# Checks if the UID is a Transfer Syntax.
|
73
|
+
#
|
74
|
+
# @return [Boolean] true if the UID is of type Transfer Syntax, and false if not
|
75
|
+
#
|
76
|
+
def transfer_syntax?
|
77
|
+
@type =~ /Transfer Syntax/ ? true : false
|
78
|
+
end
|
79
|
+
|
80
|
+
end
|
81
|
+
|
82
|
+
end
|
data/lib/dicom/variables.rb
CHANGED
@@ -17,17 +17,17 @@ module DICOM
|
|
17
17
|
# Module methods:
|
18
18
|
#++
|
19
19
|
|
20
|
-
# Generates a
|
20
|
+
# Generates a unique identifier string.
|
21
21
|
# The UID is composed of a DICOM root UID, a type prefix,
|
22
22
|
# a datetime part and a random number part.
|
23
|
-
# Returns the UID string.
|
24
23
|
#
|
25
|
-
#
|
24
|
+
# @param [String] root the DICOM root UID to be used for generating the UID string
|
25
|
+
# @param [String] prefix an integer string which is placed between the dicom root and the time/random part of the UID
|
26
|
+
# @return [String] the generated unique identifier
|
27
|
+
# @example Create a random UID with specified root and prefix
|
28
|
+
# uid = DICOM.generate_uid('1.2.840.999', '5')
|
26
29
|
#
|
27
|
-
|
28
|
-
# * <tt>prefix</tt> -- String. An integer string which is placed between the dicom root and the time/random part of the UID.
|
29
|
-
#
|
30
|
-
def generate_uid(root=UID, prefix=1)
|
30
|
+
def generate_uid(root=UID_ROOT, prefix=1)
|
31
31
|
# NB! For UIDs, leading zeroes immediately after a dot is not allowed.
|
32
32
|
date = Time.now.strftime("%Y%m%d").to_i.to_s
|
33
33
|
time = Time.now.strftime("%H%M%S").to_i.to_s
|
@@ -36,7 +36,7 @@ module DICOM
|
|
36
36
|
return uid
|
37
37
|
end
|
38
38
|
|
39
|
-
# Use tags as key. Example:
|
39
|
+
# Use tags as key. Example: '0010,0010'
|
40
40
|
#
|
41
41
|
def key_use_tags
|
42
42
|
@key_representation = :tag
|
@@ -65,6 +65,6 @@ module DICOM
|
|
65
65
|
# The default key representation.
|
66
66
|
self.key_representation = :name
|
67
67
|
# The default source application entity title.
|
68
|
-
self.source_app_title =
|
68
|
+
self.source_app_title = 'RUBY_DICOM'
|
69
69
|
|
70
70
|
end
|
data/lib/dicom/version.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
|
-
module DICOM
|
2
|
-
|
3
|
-
# The ruby-dicom version string.
|
4
|
-
VERSION =
|
5
|
-
|
1
|
+
module DICOM
|
2
|
+
|
3
|
+
# The ruby-dicom version string.
|
4
|
+
VERSION = '0.9.4'
|
5
|
+
|
6
6
|
end
|
data/rakefile.rb
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
# Available commands:
|
2
|
+
# Testing the specification:
|
3
|
+
# bundle exec rake spec
|
4
|
+
# Building a gem package from source:
|
5
|
+
# bundle exec rake package
|
6
|
+
# Create html documentation files:
|
7
|
+
# bundle exec rake yard
|
8
|
+
|
9
|
+
require 'rubygems/package_task'
|
10
|
+
require 'rspec/core/rake_task'
|
11
|
+
require 'yard'
|
12
|
+
|
13
|
+
# Build gem:
|
14
|
+
gem_spec = eval(File.read('dicom.gemspec'))
|
15
|
+
Gem::PackageTask.new(gem_spec) do |pkg|
|
16
|
+
pkg.gem_spec = gem_spec
|
17
|
+
pkg.need_tar = true
|
18
|
+
end
|
19
|
+
|
20
|
+
# RSpec 2:
|
21
|
+
RSpec::Core::RakeTask.new do |t|
|
22
|
+
t.rspec_opts = ["-c", "-f progress", "-r ./spec/spec_helper.rb"]
|
23
|
+
t.pattern = 'spec/**/*_spec.rb'
|
24
|
+
end
|
25
|
+
|
26
|
+
# Build documentation (YARD):
|
27
|
+
YARD::Rake::YardocTask.new do |t|
|
28
|
+
t.options += ['--title', "ruby-dicom #{DICOM::VERSION} Documentation"]
|
29
|
+
end
|
metadata
CHANGED
@@ -1,114 +1,166 @@
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
2
|
name: dicom
|
3
|
-
version: !ruby/object:Gem::Version
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.9.4
|
4
5
|
prerelease:
|
5
|
-
version: 0.9.3
|
6
6
|
platform: ruby
|
7
|
-
authors:
|
7
|
+
authors:
|
8
8
|
- Christoffer Lervag
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
- !ruby/object:Gem::Dependency
|
12
|
+
date: 2012-09-10 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
16
15
|
name: bundler
|
17
|
-
|
18
|
-
requirement: &id001 !ruby/object:Gem::Requirement
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
19
17
|
none: false
|
20
|
-
requirements:
|
21
|
-
- -
|
22
|
-
- !ruby/object:Gem::Version
|
18
|
+
requirements:
|
19
|
+
- - ! '>='
|
20
|
+
- !ruby/object:Gem::Version
|
23
21
|
version: 1.0.0
|
24
22
|
type: :development
|
25
|
-
version_requirements: *id001
|
26
|
-
- !ruby/object:Gem::Dependency
|
27
|
-
name: rake
|
28
23
|
prerelease: false
|
29
|
-
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ! '>='
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: 1.0.0
|
30
|
+
- !ruby/object:Gem::Dependency
|
31
|
+
name: rake
|
32
|
+
requirement: !ruby/object:Gem::Requirement
|
30
33
|
none: false
|
31
|
-
requirements:
|
32
|
-
- -
|
33
|
-
- !ruby/object:Gem::Version
|
34
|
+
requirements:
|
35
|
+
- - ! '>='
|
36
|
+
- !ruby/object:Gem::Version
|
34
37
|
version: 0.9.2.2
|
35
38
|
type: :development
|
36
|
-
version_requirements: *id002
|
37
|
-
- !ruby/object:Gem::Dependency
|
38
|
-
name: rspec
|
39
39
|
prerelease: false
|
40
|
-
|
40
|
+
version_requirements: !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
42
|
+
requirements:
|
43
|
+
- - ! '>='
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
version: 0.9.2.2
|
46
|
+
- !ruby/object:Gem::Dependency
|
47
|
+
name: rspec
|
48
|
+
requirement: !ruby/object:Gem::Requirement
|
41
49
|
none: false
|
42
|
-
requirements:
|
43
|
-
- -
|
44
|
-
- !ruby/object:Gem::Version
|
50
|
+
requirements:
|
51
|
+
- - ! '>='
|
52
|
+
- !ruby/object:Gem::Version
|
45
53
|
version: 2.9.0
|
46
54
|
type: :development
|
47
|
-
version_requirements: *id003
|
48
|
-
- !ruby/object:Gem::Dependency
|
49
|
-
name: mocha
|
50
55
|
prerelease: false
|
51
|
-
|
56
|
+
version_requirements: !ruby/object:Gem::Requirement
|
57
|
+
none: false
|
58
|
+
requirements:
|
59
|
+
- - ! '>='
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: 2.9.0
|
62
|
+
- !ruby/object:Gem::Dependency
|
63
|
+
name: mocha
|
64
|
+
requirement: !ruby/object:Gem::Requirement
|
52
65
|
none: false
|
53
|
-
requirements:
|
54
|
-
- -
|
55
|
-
- !ruby/object:Gem::Version
|
66
|
+
requirements:
|
67
|
+
- - ! '>='
|
68
|
+
- !ruby/object:Gem::Version
|
56
69
|
version: 0.10.5
|
57
70
|
type: :development
|
58
|
-
version_requirements: *id004
|
59
|
-
- !ruby/object:Gem::Dependency
|
60
|
-
name: narray
|
61
71
|
prerelease: false
|
62
|
-
|
72
|
+
version_requirements: !ruby/object:Gem::Requirement
|
73
|
+
none: false
|
74
|
+
requirements:
|
75
|
+
- - ! '>='
|
76
|
+
- !ruby/object:Gem::Version
|
77
|
+
version: 0.10.5
|
78
|
+
- !ruby/object:Gem::Dependency
|
79
|
+
name: narray
|
80
|
+
requirement: !ruby/object:Gem::Requirement
|
63
81
|
none: false
|
64
|
-
requirements:
|
65
|
-
- -
|
66
|
-
- !ruby/object:Gem::Version
|
82
|
+
requirements:
|
83
|
+
- - ! '>='
|
84
|
+
- !ruby/object:Gem::Version
|
67
85
|
version: 0.6.0.0
|
68
86
|
type: :development
|
69
|
-
version_requirements: *id005
|
70
|
-
- !ruby/object:Gem::Dependency
|
71
|
-
name: rmagick
|
72
87
|
prerelease: false
|
73
|
-
|
88
|
+
version_requirements: !ruby/object:Gem::Requirement
|
89
|
+
none: false
|
90
|
+
requirements:
|
91
|
+
- - ! '>='
|
92
|
+
- !ruby/object:Gem::Version
|
93
|
+
version: 0.6.0.0
|
94
|
+
- !ruby/object:Gem::Dependency
|
95
|
+
name: rmagick
|
96
|
+
requirement: !ruby/object:Gem::Requirement
|
74
97
|
none: false
|
75
|
-
requirements:
|
76
|
-
- -
|
77
|
-
- !ruby/object:Gem::Version
|
98
|
+
requirements:
|
99
|
+
- - ! '>='
|
100
|
+
- !ruby/object:Gem::Version
|
78
101
|
version: 2.12.0
|
79
102
|
type: :development
|
80
|
-
|
81
|
-
|
103
|
+
prerelease: false
|
104
|
+
version_requirements: !ruby/object:Gem::Requirement
|
105
|
+
none: false
|
106
|
+
requirements:
|
107
|
+
- - ! '>='
|
108
|
+
- !ruby/object:Gem::Version
|
109
|
+
version: 2.12.0
|
110
|
+
- !ruby/object:Gem::Dependency
|
82
111
|
name: mini_magick
|
112
|
+
requirement: !ruby/object:Gem::Requirement
|
113
|
+
none: false
|
114
|
+
requirements:
|
115
|
+
- - ! '>='
|
116
|
+
- !ruby/object:Gem::Version
|
117
|
+
version: 3.2.1
|
118
|
+
type: :development
|
83
119
|
prerelease: false
|
84
|
-
|
120
|
+
version_requirements: !ruby/object:Gem::Requirement
|
85
121
|
none: false
|
86
|
-
requirements:
|
87
|
-
- -
|
88
|
-
- !ruby/object:Gem::Version
|
122
|
+
requirements:
|
123
|
+
- - ! '>='
|
124
|
+
- !ruby/object:Gem::Version
|
89
125
|
version: 3.2.1
|
126
|
+
- !ruby/object:Gem::Dependency
|
127
|
+
name: yard
|
128
|
+
requirement: !ruby/object:Gem::Requirement
|
129
|
+
none: false
|
130
|
+
requirements:
|
131
|
+
- - ! '>='
|
132
|
+
- !ruby/object:Gem::Version
|
133
|
+
version: 0.8.2
|
90
134
|
type: :development
|
91
|
-
|
92
|
-
|
135
|
+
prerelease: false
|
136
|
+
version_requirements: !ruby/object:Gem::Requirement
|
137
|
+
none: false
|
138
|
+
requirements:
|
139
|
+
- - ! '>='
|
140
|
+
- !ruby/object:Gem::Version
|
141
|
+
version: 0.8.2
|
142
|
+
description: DICOM is a standard widely used throughout the world to store and transfer
|
143
|
+
medical image data. This library enables efficient and powerful handling of DICOM
|
144
|
+
in Ruby, to the benefit of any student or professional who would like to use their
|
145
|
+
favorite language to process DICOM files and communicate across the network.
|
93
146
|
email: chris.lervag@gmail.com
|
94
147
|
executables: []
|
95
|
-
|
96
148
|
extensions: []
|
97
|
-
|
98
149
|
extra_rdoc_files: []
|
99
|
-
|
100
|
-
files:
|
150
|
+
files:
|
101
151
|
- lib/dicom/anonymizer.rb
|
102
152
|
- lib/dicom/audit_trail.rb
|
103
153
|
- lib/dicom/constants.rb
|
154
|
+
- lib/dicom/deprecated.rb
|
155
|
+
- lib/dicom/dictionary/elements.txt
|
156
|
+
- lib/dicom/dictionary/uids.txt
|
157
|
+
- lib/dicom/dictionary_element.rb
|
104
158
|
- lib/dicom/d_client.rb
|
105
159
|
- lib/dicom/d_library.rb
|
106
160
|
- lib/dicom/d_object.rb
|
107
161
|
- lib/dicom/d_read.rb
|
108
162
|
- lib/dicom/d_server.rb
|
109
163
|
- lib/dicom/d_write.rb
|
110
|
-
- lib/dicom/deprecated.rb
|
111
|
-
- lib/dicom/dictionary.rb
|
112
164
|
- lib/dicom/element.rb
|
113
165
|
- lib/dicom/elemental.rb
|
114
166
|
- lib/dicom/file_handler.rb
|
@@ -123,38 +175,40 @@ files:
|
|
123
175
|
- lib/dicom/ruby_extensions.rb
|
124
176
|
- lib/dicom/sequence.rb
|
125
177
|
- lib/dicom/stream.rb
|
178
|
+
- lib/dicom/uid.rb
|
126
179
|
- lib/dicom/variables.rb
|
127
180
|
- lib/dicom/version.rb
|
128
181
|
- lib/dicom.rb
|
129
182
|
- CHANGELOG.rdoc
|
130
183
|
- COPYING
|
184
|
+
- dicom.gemspec
|
185
|
+
- Gemfile
|
186
|
+
- rakefile.rb
|
131
187
|
- README.rdoc
|
132
188
|
homepage: http://dicom.rubyforge.org/
|
133
|
-
licenses:
|
189
|
+
licenses:
|
134
190
|
- GPLv3
|
135
191
|
post_install_message:
|
136
192
|
rdoc_options: []
|
137
|
-
|
138
|
-
require_paths:
|
193
|
+
require_paths:
|
139
194
|
- lib
|
140
|
-
required_ruby_version: !ruby/object:Gem::Requirement
|
195
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
141
196
|
none: false
|
142
|
-
requirements:
|
143
|
-
- -
|
144
|
-
- !ruby/object:Gem::Version
|
197
|
+
requirements:
|
198
|
+
- - ! '>='
|
199
|
+
- !ruby/object:Gem::Version
|
145
200
|
version: 1.9.2
|
146
|
-
required_rubygems_version: !ruby/object:Gem::Requirement
|
201
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
147
202
|
none: false
|
148
|
-
requirements:
|
149
|
-
- -
|
150
|
-
- !ruby/object:Gem::Version
|
203
|
+
requirements:
|
204
|
+
- - ! '>='
|
205
|
+
- !ruby/object:Gem::Version
|
151
206
|
version: 1.8.6
|
152
207
|
requirements: []
|
153
|
-
|
154
208
|
rubyforge_project: dicom
|
155
|
-
rubygems_version: 1.8.
|
209
|
+
rubygems_version: 1.8.24
|
156
210
|
signing_key:
|
157
211
|
specification_version: 3
|
158
212
|
summary: Library for handling DICOM files and DICOM network communication.
|
159
213
|
test_files: []
|
160
|
-
|
214
|
+
has_rdoc:
|