dicom 0.9.3 → 0.9.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- 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
@@ -1,12 +1,14 @@
|
|
1
1
|
module DICOM
|
2
|
+
|
3
|
+
# This module is the general interface between the ImageItem class and the
|
4
|
+
# image methods found in the specific image processor modules.
|
5
|
+
#
|
2
6
|
module ImageProcessor
|
3
7
|
|
4
8
|
# Creates image objects from one or more compressed, binary string blobs.
|
5
|
-
# Returns an array of images. If decompression fails, returns false.
|
6
|
-
#
|
7
|
-
# === Parameters
|
8
9
|
#
|
9
|
-
#
|
10
|
+
# @param [Array<String>, String] blobs binary string blob(s) containing compressed pixel data
|
11
|
+
# @return [Array<MagickImage>, FalseClass] - an array of images, or false (if decompression failed)
|
10
12
|
#
|
11
13
|
def decompress(blobs)
|
12
14
|
raise ArgumentError, "Expected Array or String, got #{blobs.class}." unless [String, Array].include?(blobs.class)
|
@@ -20,9 +22,9 @@ module DICOM
|
|
20
22
|
|
21
23
|
# Extracts an array of pixels (integers) from an image object.
|
22
24
|
#
|
23
|
-
#
|
24
|
-
#
|
25
|
-
#
|
25
|
+
# @param [MagickImage] image a Magick image object
|
26
|
+
# @param [String] photometry a code describing the photometry of the pixel data (e.g. 'MONOCHROME1' or 'COLOR')
|
27
|
+
# @return [Array<Integer>] an array of pixel values
|
26
28
|
#
|
27
29
|
def export_pixels(image, photometry)
|
28
30
|
raise ArgumentError, "Expected String, got #{photometry.class}." unless photometry.is_a?(String)
|
@@ -31,20 +33,21 @@ module DICOM
|
|
31
33
|
|
32
34
|
# Creates an image object from a binary string blob.
|
33
35
|
#
|
34
|
-
#
|
35
|
-
#
|
36
|
-
#
|
37
|
-
#
|
38
|
-
#
|
39
|
-
#
|
40
|
-
# * <tt>photometry</tt> -- String describing the DICOM photometry of the pixel data. Example: 'MONOCHROME1', 'RGB'.
|
36
|
+
# @param [String] blob binary string blob containing pixel data
|
37
|
+
# @param [Integer] columns the number of columns
|
38
|
+
# @param [Integer] rows the number of rows
|
39
|
+
# @param [Integer] depth the bit depth of the encoded pixel data
|
40
|
+
# @param [String] photometry a code describing the photometry of the pixel data (e.g. 'MONOCHROME1' or 'COLOR')
|
41
|
+
# @return [MagickImage] a Magick image object
|
41
42
|
#
|
42
43
|
def import_pixels(blob, columns, rows, depth, photometry)
|
43
44
|
raise ArgumentError, "Expected String, got #{blob.class}." unless blob.is_a?(String)
|
44
45
|
image_module.import_pixels(blob, columns, rows, depth, photometry)
|
45
46
|
end
|
46
47
|
|
47
|
-
#
|
48
|
+
# Gives an array containing the image objects that are supported by the image processor.
|
49
|
+
#
|
50
|
+
# @return [Array] the valid image classes
|
48
51
|
#
|
49
52
|
def valid_image_objects
|
50
53
|
return [Magick::Image, MiniMagick::Image]
|
@@ -54,6 +57,12 @@ module DICOM
|
|
54
57
|
private
|
55
58
|
|
56
59
|
|
60
|
+
# Gives the specific image processor module corresponding to the specified
|
61
|
+
# image_processor module option.
|
62
|
+
#
|
63
|
+
# @raise [RuntimeError] if an unknown image processor is specified
|
64
|
+
# @return [DcmMiniMagick, DcmRMagick] the image processor module to be used
|
65
|
+
#
|
57
66
|
def image_module
|
58
67
|
case DICOM.image_processor
|
59
68
|
when :mini_magick
|
@@ -1,15 +1,16 @@
|
|
1
1
|
module DICOM
|
2
2
|
module ImageProcessor
|
3
|
+
|
4
|
+
# This module contains methods for interacting with pixel data using the mini_magick gem.
|
5
|
+
#
|
3
6
|
module DcmMiniMagick
|
4
7
|
|
5
8
|
class << self
|
6
9
|
|
7
10
|
# Creates image objects from an array of compressed, binary string blobs.
|
8
|
-
# Returns an array of images. If decompression fails, returns false.
|
9
|
-
#
|
10
|
-
# === Parameters
|
11
11
|
#
|
12
|
-
#
|
12
|
+
# @param [Array<String>] blobs an array of binary string blobs containing compressed pixel data
|
13
|
+
# @return [Array<MiniMagick::Image>, FalseClass] - an array of images, or false (if decompression failed)
|
13
14
|
#
|
14
15
|
def decompress(blobs)
|
15
16
|
images = Array.new
|
@@ -22,39 +23,36 @@ module DICOM
|
|
22
23
|
|
23
24
|
# Extracts an array of pixels (integers) from an image object.
|
24
25
|
#
|
25
|
-
#
|
26
|
-
#
|
27
|
-
# * This feature is not available as of yet in the mini_magick image processor. If this feature is needed, please try another image processor (RMagick).
|
26
|
+
# @note This feature is not available as of yet in the mini_magick image processor.
|
27
|
+
# If this feature is needed, please try another image processor (RMagick).
|
28
28
|
#
|
29
|
-
#
|
30
|
-
#
|
31
|
-
#
|
29
|
+
# @param [MiniMagick::Image] image a mini_magick image object
|
30
|
+
# @param [String] photometry a code describing the photometry of the pixel data (e.g. 'MONOCHROME1' or 'COLOR')
|
31
|
+
# @return [Array<Integer>] an array of pixel values
|
32
32
|
#
|
33
33
|
def export_pixels(image, photometry)
|
34
34
|
raise ArgumentError, "Expected MiniMagick::Image, got #{image.class}." unless image.is_a?(MiniMagick::Image)
|
35
35
|
raise "Exporting pixels is not yet available with the mini_magick processor. Please try another image processor (RMagick)."
|
36
36
|
end
|
37
37
|
|
38
|
-
# Creates an image object from a binary string blob
|
39
|
-
#
|
40
|
-
# === Parameters
|
38
|
+
# Creates an image object from a binary string blob.
|
41
39
|
#
|
42
|
-
#
|
43
|
-
#
|
44
|
-
#
|
45
|
-
#
|
46
|
-
#
|
47
|
-
#
|
40
|
+
# @param [String] blob binary string blob containing pixel data
|
41
|
+
# @param [Integer] columns the number of columns
|
42
|
+
# @param [Integer] rows the number of rows
|
43
|
+
# @param [Integer] depth the bit depth of the encoded pixel data
|
44
|
+
# @param [String] photometry a code describing the photometry of the pixel data (e.g. 'MONOCHROME1' or 'COLOR')
|
45
|
+
# @param [String] format the image format to use
|
46
|
+
# @return [Magick::Image] a mini_magick image object
|
48
47
|
#
|
49
48
|
def import_pixels(blob, columns, rows, depth, photometry, format="png")
|
50
49
|
image = MiniMagick::Image.import_pixels(blob, columns, rows, depth, im_map(photometry), format)
|
51
50
|
end
|
52
51
|
|
53
|
-
#
|
54
|
-
#
|
55
|
-
# === Parameters
|
52
|
+
# Converts a given DICOM photometry string to a mini_magick pixel map string.
|
56
53
|
#
|
57
|
-
#
|
54
|
+
# @param [String] photometry a code describing the photometry of the pixel data (e.g. 'MONOCHROME1' or 'COLOR')
|
55
|
+
# @return [String] a mini_magick pixel map string
|
58
56
|
#
|
59
57
|
def im_map(photometry)
|
60
58
|
raise ArgumentError, "Expected String, got #{photometry.class}." unless photometry.is_a?(String)
|
@@ -1,35 +1,38 @@
|
|
1
1
|
module DICOM
|
2
2
|
module ImageProcessor
|
3
|
+
|
4
|
+
# This module contains methods for interacting with pixel data using the RMagick gem.
|
5
|
+
#
|
3
6
|
module DcmRMagick
|
4
7
|
|
5
8
|
class << self
|
6
9
|
|
7
10
|
# Creates image objects from an array of compressed, binary string blobs.
|
8
|
-
# Returns an array of images. If decompression fails, returns false.
|
9
11
|
#
|
10
|
-
# ===
|
12
|
+
# === Note
|
11
13
|
#
|
12
|
-
# The method tries to use RMagick
|
13
|
-
#
|
14
|
-
#
|
14
|
+
# The method tries to use RMagick for unpacking, but unortunately, it seems that
|
15
|
+
# ImageMagick is not able to handle most of the compressed image variants used in the DICOM
|
16
|
+
# standard. To get a more robust implementation which is able to handle most types of
|
17
|
+
# compressed DICOM files, something else is needed.
|
15
18
|
#
|
16
|
-
# Probably a good candidate to use is the PVRG-JPEG library, which seems to be able to handle
|
17
|
-
# It exists in the Ubuntu repositories, where it can be installed and
|
18
|
-
# additional information, check this link:
|
19
|
+
# Probably a good candidate to use is the PVRG-JPEG library, which seems to be able to handle
|
20
|
+
# everything that is jpeg. It exists in the Ubuntu repositories, where it can be installed and
|
21
|
+
# run through terminal. For source code, and some additional information, check out this link:
|
22
|
+
# http://www.panix.com/~eli/jpeg/
|
19
23
|
#
|
20
24
|
# Another idea would be to study how other open source libraries, like GDCM handle these files.
|
21
25
|
#
|
22
|
-
#
|
23
|
-
#
|
24
|
-
# * <tt>blobs</tt> -- An array of binary string blobs containing compressed pixel data.
|
25
|
-
#
|
26
|
-
#--
|
27
|
-
# The following transfer syntaxes have been verified as failing with ImageMagick:
|
28
|
-
# TXS_JPEG_LOSSLESS_NH is not supported by (my) ImageMagick version: "Unsupported JPEG process: SOF type 0xc3"
|
29
|
-
# TXS_JPEG_LOSSLESS_NH_FOP is not supported by (my) ImageMagick version: "Unsupported JPEG process: SOF type 0xc3"
|
30
|
-
# TXS_JPEG_2000_PART1_LOSSLESS is not supported by (my) ImageMagick version: "jpc_dec_decodepkts failed"
|
26
|
+
# @param [Array<String>] blobs an array of binary string blobs containing compressed pixel data
|
27
|
+
# @return [Array<Magick::Image>, FalseClass] - an array of images, or false (if decompression failed)
|
31
28
|
#
|
32
29
|
def decompress(blobs)
|
30
|
+
# FIXME:
|
31
|
+
# The following transfer syntaxes have been verified as failing with ImageMagick:
|
32
|
+
# TXS_JPEG_LOSSLESS_NH is not supported by (my) ImageMagick version: "Unsupported JPEG process: SOF type 0xc3"
|
33
|
+
# TXS_JPEG_LOSSLESS_NH_FOP is not supported by (my) ImageMagick version: "Unsupported JPEG process: SOF type 0xc3"
|
34
|
+
# TXS_JPEG_2000_PART1_LOSSLESS is not supported by (my) ImageMagick version: "jpc_dec_decodepkts failed"
|
35
|
+
#
|
33
36
|
images = Array.new
|
34
37
|
# We attempt to decompress the pixels using ImageMagick:
|
35
38
|
blobs.each do |string|
|
@@ -40,9 +43,9 @@ module DICOM
|
|
40
43
|
|
41
44
|
# Extracts an array of pixels (integers) from an image object.
|
42
45
|
#
|
43
|
-
#
|
44
|
-
#
|
45
|
-
#
|
46
|
+
# @param [Magick::Image] image an RMagick image object
|
47
|
+
# @param [String] photometry a code describing the photometry of the pixel data (e.g. 'MONOCHROME1' or 'COLOR')
|
48
|
+
# @return [Array<Integer>] an array of pixel values
|
46
49
|
#
|
47
50
|
def export_pixels(image, photometry)
|
48
51
|
raise ArgumentError, "Expected Magick::Image, got #{image.class}." unless image.is_a?(Magick::Image)
|
@@ -50,22 +53,25 @@ module DICOM
|
|
50
53
|
return pixels
|
51
54
|
end
|
52
55
|
|
53
|
-
# Creates an image object from a binary string blob
|
56
|
+
# Creates an image object from a binary string blob.
|
54
57
|
#
|
55
|
-
#
|
56
|
-
#
|
57
|
-
#
|
58
|
-
#
|
59
|
-
#
|
60
|
-
#
|
61
|
-
#
|
62
|
-
# * <tt>format</tt> -- String describing the image format to be used when creating the image object. Defaults to 'png'.
|
58
|
+
# @param [String] blob binary string blob containing pixel data
|
59
|
+
# @param [Integer] columns the number of columns
|
60
|
+
# @param [Integer] rows the number of rows
|
61
|
+
# @param [Integer] depth the bit depth of the encoded pixel data
|
62
|
+
# @param [String] photometry a code describing the photometry of the pixel data (e.g. 'MONOCHROME1' or 'COLOR')
|
63
|
+
# @param [String] format the image format to use
|
64
|
+
# @return [Magick::Image] an RMagick image object
|
63
65
|
#
|
64
66
|
def import_pixels(blob, columns, rows, depth, photometry, format="png")
|
65
67
|
image = Magick::Image.new(columns,rows).import_pixels(0, 0, columns, rows, rm_map(photometry), blob, rm_data_type(depth))
|
66
68
|
end
|
67
69
|
|
68
|
-
#
|
70
|
+
# Converts a given bit depth to an RMagick StorageType.
|
71
|
+
#
|
72
|
+
# @raise [ArgumentError] if given an unsupported bit depth
|
73
|
+
# @param [Integer] bit_depth the bit depth of the pixel data
|
74
|
+
# @return [Magick::CharPixel, Magick::ShortPixel] the proper storage type
|
69
75
|
#
|
70
76
|
def rm_data_type(bit_depth)
|
71
77
|
return case bit_depth
|
@@ -78,11 +84,10 @@ module DICOM
|
|
78
84
|
end
|
79
85
|
end
|
80
86
|
|
81
|
-
#
|
82
|
-
#
|
83
|
-
# === Parameters
|
87
|
+
# Converts a given DICOM photometry string to an RMagick pixel map string.
|
84
88
|
#
|
85
|
-
#
|
89
|
+
# @param [String] photometry a code describing the photometry of the pixel data (e.g. 'MONOCHROME1' or 'COLOR')
|
90
|
+
# @return [String] an RMagick pixel map string
|
86
91
|
#
|
87
92
|
def rm_map(photometry)
|
88
93
|
raise ArgumentError, "Expected String, got #{photometry.class}." unless photometry.is_a?(String)
|
data/lib/dicom/item.rb
CHANGED
@@ -1,121 +1,134 @@
|
|
1
|
-
module DICOM
|
2
|
-
|
3
|
-
# The Item class handles information related to items - the elements contained in sequences.
|
4
|
-
#
|
5
|
-
# === Inheritance
|
6
|
-
#
|
7
|
-
# As the Item class inherits from the ImageItem class, which itself inherits from the Parent class,
|
8
|
-
# all ImageItem and Parent methods are also available to instances of Item.
|
9
|
-
#
|
10
|
-
class Item < ImageItem
|
11
|
-
|
12
|
-
# Include the Elemental mix-in module:
|
13
|
-
include Elemental
|
14
|
-
|
15
|
-
# The index of this Item in the group of items belonging to its parent. If the Item is without parent, index is nil.
|
16
|
-
attr_accessor :index
|
17
|
-
|
18
|
-
# Creates an Item instance.
|
19
|
-
#
|
20
|
-
#
|
21
|
-
#
|
22
|
-
#
|
23
|
-
#
|
24
|
-
#
|
25
|
-
#
|
26
|
-
#
|
27
|
-
#
|
28
|
-
#
|
29
|
-
#
|
30
|
-
#
|
31
|
-
#
|
32
|
-
#
|
33
|
-
#
|
34
|
-
#
|
35
|
-
#
|
36
|
-
#
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
#
|
76
|
-
#
|
77
|
-
#
|
78
|
-
#
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
#
|
105
|
-
#
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
#
|
115
|
-
#
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
1
|
+
module DICOM
|
2
|
+
|
3
|
+
# The Item class handles information related to items - the elements contained in sequences.
|
4
|
+
#
|
5
|
+
# === Inheritance
|
6
|
+
#
|
7
|
+
# As the Item class inherits from the ImageItem class, which itself inherits from the Parent class,
|
8
|
+
# all ImageItem and Parent methods are also available to instances of Item.
|
9
|
+
#
|
10
|
+
class Item < ImageItem
|
11
|
+
|
12
|
+
# Include the Elemental mix-in module:
|
13
|
+
include Elemental
|
14
|
+
|
15
|
+
# The index of this Item in the group of items belonging to its parent. If the Item is without parent, index is nil.
|
16
|
+
attr_accessor :index
|
17
|
+
|
18
|
+
# Creates an Item instance.
|
19
|
+
#
|
20
|
+
# Normally, an Item contains data elements and/or sequences. However,
|
21
|
+
# in some cases, an Item will instead/also carry binary string data,
|
22
|
+
# like the pixel data of an encapsulated image fragment.
|
23
|
+
#
|
24
|
+
# @param [Hash] options the options to use for creating the item
|
25
|
+
# @option options [String] :bin a binary string to be carried by the item
|
26
|
+
# @option options [String] :indexif the item is to be inserted at a specific index (Item number), this option parameter needs to set
|
27
|
+
# @option options [String] :length theiItem length (which either refers to the length of the encoded string of children of this item, or the length of its binary data)
|
28
|
+
# @option options [String] :name the name of the item may be specified upon creation (if not, a default name is used)
|
29
|
+
# @option options [String] :parent a Sequence or DObject instance which the item instance shall belong to
|
30
|
+
# @option options [String] :vr the value representation of the item may be specified upon creation (if not, a default vr is used)
|
31
|
+
#
|
32
|
+
# @example Create an empty Item and connect it to the "Structure Set ROI Sequence"
|
33
|
+
# item = Item.new(:parent => dcm["3006,0020"])
|
34
|
+
# @example Create a "Pixel Data Item" which carries an encapsulated image frame (a pre-encoded binary)
|
35
|
+
# pixel_item = Item.new(:bin => processed_pixel_data, :parent => dcm["7FE0,0010"][1])
|
36
|
+
#
|
37
|
+
def initialize(options={})
|
38
|
+
# Set common parent variables:
|
39
|
+
initialize_parent
|
40
|
+
# Set instance variables:
|
41
|
+
@tag = ITEM_TAG
|
42
|
+
@value = nil
|
43
|
+
@name = options[:name] || "Item"
|
44
|
+
@vr = options[:vr] || ITEM_VR
|
45
|
+
if options[:bin]
|
46
|
+
self.bin = options[:bin]
|
47
|
+
else
|
48
|
+
@length = options[:length] || -1
|
49
|
+
end
|
50
|
+
if options[:parent]
|
51
|
+
@parent = options[:parent]
|
52
|
+
@index = options[:index] if options[:index]
|
53
|
+
@parent.add_item(self, :index => options[:index], :no_follow => true)
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
# Checks for equality.
|
58
|
+
#
|
59
|
+
# Other and self are considered equivalent if they are
|
60
|
+
# of compatible types and their attributes are equivalent.
|
61
|
+
#
|
62
|
+
# @param other an object to be compared with self.
|
63
|
+
# @return [Boolean] true if self and other are considered equivalent
|
64
|
+
#
|
65
|
+
def ==(other)
|
66
|
+
if other.respond_to?(:to_item)
|
67
|
+
other.send(:state) == state
|
68
|
+
end
|
69
|
+
end
|
70
|
+
|
71
|
+
alias_method :eql?, :==
|
72
|
+
|
73
|
+
# Sets the binary string that the Item will contain.
|
74
|
+
#
|
75
|
+
# @param [String] new_bin a binary string of encoded data
|
76
|
+
# @example Insert a custom jpeg in the (encapsulated) pixel data element (in it's first pixel data item)
|
77
|
+
# dcm['7FE0,0010'][1].children.first.bin = jpeg_binary_string
|
78
|
+
#
|
79
|
+
def bin=(new_bin)
|
80
|
+
raise ArgumentError, "Invalid parameter type. String was expected, got #{new_bin.class}." unless new_bin.is_a?(String)
|
81
|
+
# Add an empty byte at the end if the length of the binary is odd:
|
82
|
+
if new_bin.length.odd?
|
83
|
+
@bin = new_bin + "\x00"
|
84
|
+
else
|
85
|
+
@bin = new_bin
|
86
|
+
end
|
87
|
+
@value = nil
|
88
|
+
@length = @bin.length
|
89
|
+
end
|
90
|
+
|
91
|
+
# Computes a hash code for this object.
|
92
|
+
#
|
93
|
+
# @note Two objects with the same attributes will have the same hash code.
|
94
|
+
#
|
95
|
+
# @return [Fixnum] the object's hash code
|
96
|
+
#
|
97
|
+
def hash
|
98
|
+
state.hash
|
99
|
+
end
|
100
|
+
|
101
|
+
# Loads data from an encoded DICOM string and creates
|
102
|
+
# sequences and elements which are linked to this instance.
|
103
|
+
#
|
104
|
+
# @param [String] bin an encoded binary string containing DICOM information
|
105
|
+
# @param [String] syntax the transfer syntax to use when decoding the DICOM string
|
106
|
+
#
|
107
|
+
def parse(bin, syntax)
|
108
|
+
raise ArgumentError, "Invalid argument 'bin'. Expected String, got #{bin.class}." unless bin.is_a?(String)
|
109
|
+
raise ArgumentError, "Invalid argument 'syntax'. Expected String, got #{syntax.class}." unless syntax.is_a?(String)
|
110
|
+
read(bin, signature=false, :syntax => syntax)
|
111
|
+
end
|
112
|
+
|
113
|
+
# Returns self.
|
114
|
+
#
|
115
|
+
# @return [Item] self
|
116
|
+
#
|
117
|
+
def to_item
|
118
|
+
self
|
119
|
+
end
|
120
|
+
|
121
|
+
|
122
|
+
private
|
123
|
+
|
124
|
+
|
125
|
+
# Collects the attributes of this instance.
|
126
|
+
#
|
127
|
+
# @return [Array<String, Sequence, Element>] an array of attributes
|
128
|
+
#
|
129
|
+
def state
|
130
|
+
[@vr, @name, @tags]
|
131
|
+
end
|
132
|
+
|
133
|
+
end
|
121
134
|
end
|