dicom 0.9.3 → 0.9.4

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,117 +1,105 @@
1
- module DICOM
2
-
3
- # The AuditTrail class handles key/value storage for the Anonymizer.
4
- # When using the advanced Anonymization options such as enumeration
5
- # and UID replacement, the AuditTrail class keeps track of key/value
6
- # pairs and dumps this information to a text file using the json format.
7
- # This enables us to ensure a unique relationship between the anonymized
8
- # values and the original values, as well as preserving this relationship
9
- # for later restoration of original values.
10
- #
11
- class AuditTrail
12
-
13
- # The hash used for storing the key/value pairs of this instace.
14
- attr_reader :dictionary
15
-
16
- # Creates a new AuditTrail instance by loading the information stored
17
- # in the specified file.
18
- #
19
- # === Parameters
20
- #
21
- # * <tt>file_name</tt> -- The path to a file containing a previously stored audit trail.
22
- #
23
- def self.read(file_name)
24
- audit_trail = AuditTrail.new
25
- audit_trail.load(file_name)
26
- return audit_trail
27
- end
28
-
29
- # Creates a new AuditTrail instance.
30
- #
31
- def initialize
32
- # The AuditTrail requires JSON for serialization:
33
- require 'json'
34
- # Define the key/value hash used for tag records:
35
- @dictionary = Hash.new
36
- end
37
-
38
- # Adds a tag record to the log.
39
- #
40
- # === Parameters
41
- #
42
- # * <tt>tag</tt> -- The tag string (e.q. "0010,0010").
43
- # * <tt>original</tt> -- The original value (e.q. "John Doe").
44
- # * <tt>replacement</tt> -- The replacement value (e.q. "Patient1").
45
- #
46
- def add_record(tag, original, replacement)
47
- @dictionary[tag] = Hash.new unless @dictionary.key?(tag)
48
- @dictionary[tag][original] = replacement
49
- end
50
-
51
- # Loads the key/value dictionary hash from a specified file.
52
- #
53
- # === Parameters
54
- #
55
- # * <tt>file_name</tt> -- The path to a file containing a previously stored audit trail.
56
- #
57
- def load(file_name)
58
- @dictionary = JSON.load(File.new(file_name, "r"))
59
- end
60
-
61
- # Retrieves the replacement value used for the given tag and its original value.
62
- #
63
- # === Parameters
64
- #
65
- # * <tt>tag</tt> -- The tag string (e.q. "0010,0010").
66
- # * <tt>replacement</tt> -- The replacement value (e.q. "Patient1").
67
- #
68
- def original(tag, replacement)
69
- original = nil
70
- if @dictionary.key?(tag)
71
- original = @dictionary[tag].key(replacement)
72
- end
73
- return original
74
- end
75
-
76
- # Returns the key/value pairs for a specific tag.
77
- #
78
- # === Parameters
79
- #
80
- # * <tt>tag</tt> -- The tag string (e.q. "0010,0010").
81
- #
82
- def records(tag)
83
- if @dictionary.key?(tag)
84
- return @dictionary[tag]
85
- else
86
- return Hash.new
87
- end
88
- end
89
-
90
- # Retrieves the replacement value used for the given tag and its original value.
91
- #
92
- # === Parameters
93
- #
94
- # * <tt>tag</tt> -- The tag string (e.q. "0010,0010").
95
- # * <tt>original</tt> -- The original value (e.q. "John Doe").
96
- #
97
- def replacement(tag, original)
98
- replacement = nil
99
- replacement = @dictionary[tag][original] if @dictionary.key?(tag)
100
- return replacement
101
- end
102
-
103
- # Dumps the key/value pairs to a json string which is written to
104
- # file as specified by the @file_name attribute of this instance.
105
- #
106
- #
107
- # === Parameters
108
- #
109
- # * <tt>file_name</tt> -- The file name string to be used for storing & retrieving key/value pairs on disk.
110
- #
111
- def write(file_name)
112
- str = JSON.pretty_generate(@dictionary)
113
- File.open(file_name, 'w') {|f| f.write(str) }
114
- end
115
-
116
- end
1
+ module DICOM
2
+
3
+ # The AuditTrail class handles key/value storage for the Anonymizer.
4
+ # When using the advanced Anonymization options such as enumeration
5
+ # and UID replacement, the AuditTrail class keeps track of key/value
6
+ # pairs and dumps this information to a text file using the json format.
7
+ # This enables us to ensure a unique relationship between the anonymized
8
+ # values and the original values, as well as preserving this relationship
9
+ # for later restoration of original values.
10
+ #
11
+ class AuditTrail
12
+
13
+ # The hash used for storing the key/value pairs of this instace.
14
+ attr_reader :dictionary
15
+
16
+ # Creates a new AuditTrail instance by loading the information stored
17
+ # in the specified file.
18
+ #
19
+ # @param [String] file_name the path to a file containing a previously stored audit trail
20
+ # @return [AuditTrail] the created AuditTrail instance
21
+ #
22
+ def self.read(file_name)
23
+ audit_trail = AuditTrail.new
24
+ audit_trail.load(file_name)
25
+ return audit_trail
26
+ end
27
+
28
+ # Creates a new AuditTrail instance.
29
+ #
30
+ def initialize
31
+ # The AuditTrail requires JSON for serialization:
32
+ require 'json'
33
+ # Define the key/value hash used for tag records:
34
+ @dictionary = Hash.new
35
+ end
36
+
37
+ # Adds a tag record to the log.
38
+ #
39
+ # @param [String] tag the tag string (e.q. '0010,0010')
40
+ # @param [String, Integer, Float] original the original value (e.q. 'John Doe')
41
+ # @param [String, Integer, Float] replacement the replacement value (e.q. 'Patient1')
42
+ #
43
+ def add_record(tag, original, replacement)
44
+ @dictionary[tag] = Hash.new unless @dictionary.key?(tag)
45
+ @dictionary[tag][original] = replacement
46
+ end
47
+
48
+ # Loads the key/value dictionary hash from a specified file.
49
+ #
50
+ # @param [String] file_name the path to a file containing a previously stored audit trail
51
+ #
52
+ def load(file_name)
53
+ @dictionary = JSON.load(File.new(file_name, "r:UTF-8"))
54
+ end
55
+
56
+ # Retrieves the original value used for the given combination of tag & replacement value.
57
+ #
58
+ # @param [String] tag the tag string (e.q. '0010,0010')
59
+ # @param [String, Integer, Float] replacement the replacement value (e.q. 'Patient1')
60
+ # @return [String, Integer, Float] the original value of the given tag
61
+ #
62
+ def original(tag, replacement)
63
+ original = nil
64
+ if @dictionary.key?(tag)
65
+ original = @dictionary[tag].key(replacement)
66
+ end
67
+ return original
68
+ end
69
+
70
+ # Gives the key/value pairs for a specific tag.
71
+ #
72
+ # @param [String] tag the tag string (e.q. '0010,0010')
73
+ # @return [Hash] the key/value pairs of a specific tag
74
+ #
75
+ def records(tag)
76
+ if @dictionary.key?(tag)
77
+ return @dictionary[tag]
78
+ else
79
+ return Hash.new
80
+ end
81
+ end
82
+
83
+ # Retrieves the replacement value used for the given combination of tag & original value.
84
+ #
85
+ # @param [String] tag the tag string (e.q. '0010,0010')
86
+ # @param [String, Integer, Float] original the original value (e.q. 'John Doe')
87
+ # @return [String, Integer, Float] the replacement value of the given tag
88
+ #
89
+ def replacement(tag, original)
90
+ replacement = nil
91
+ replacement = @dictionary[tag][original] if @dictionary.key?(tag)
92
+ return replacement
93
+ end
94
+
95
+ # Dumps the key/value pairs to a json string which is written to the specified file.
96
+ #
97
+ # @param [String] file_name the path to be used for storing key/value pairs on disk
98
+ #
99
+ def write(file_name)
100
+ str = JSON.pretty_generate(@dictionary)
101
+ File.open(file_name, 'w') {|f| f.write(str) }
102
+ end
103
+
104
+ end
117
105
  end
@@ -1,170 +1,219 @@
1
- module DICOM
2
-
3
- # Ruby DICOM's registered DICOM UID root (Implementation Class UID).
4
- UID = "1.2.826.0.1.3680043.8.641"
5
- # Ruby DICOM name & version (max 16 characters).
6
- NAME = "RUBY_DCM_" + DICOM::VERSION
7
-
8
- # Item tag.
9
- ITEM_TAG = "FFFE,E000"
10
- # All Item related tags (includes both types of delimitation items).
11
- ITEM_TAGS = ["FFFE,E000", "FFFE,E00D", "FFFE,E0DD"]
12
- # Item delimiter tag.
13
- ITEM_DELIMITER = "FFFE,E00D"
14
- # Sequence delimiter tag.
15
- SEQUENCE_DELIMITER = "FFFE,E0DD"
16
- # All delimiter tags.
17
- DELIMITER_TAGS = ["FFFE,E00D", "FFFE,E0DD"]
18
-
19
- # The VR used for the item elements.
20
- ITEM_VR = " "
21
-
22
- # Pixel tag.
23
- PIXEL_TAG = "7FE0,0010"
24
- # Name of the pixel tag when holding encapsulated data.
25
- ENCAPSULATED_PIXEL_NAME = "Encapsulated Pixel Data"
26
- # Name of encapsulated items.
27
- PIXEL_ITEM_NAME = "Pixel Data Item"
28
-
29
- # File meta group.
30
- META_GROUP = "0002"
31
-
32
- # Group length element.
33
- GROUP_LENGTH = "0000"
34
-
35
- # Implicit, little endian (the default transfer syntax).
36
- IMPLICIT_LITTLE_ENDIAN = "1.2.840.10008.1.2"
37
- # Explicit, little endian transfer syntax.
38
- EXPLICIT_LITTLE_ENDIAN = "1.2.840.10008.1.2.1"
39
- # Explicit, big endian transfer syntax.
40
- EXPLICIT_BIG_ENDIAN = "1.2.840.10008.1.2.2"
41
-
42
- # Verification SOP class UID.
43
- VERIFICATION_SOP = "1.2.840.10008.1.1"
44
- # Application context SOP class UID.
45
- APPLICATION_CONTEXT = "1.2.840.10008.3.1.1.1"
46
-
47
- # Network transmission successful.
48
- SUCCESS = 0
49
- # Network proposition accepted.
50
- ACCEPTANCE = 0
51
- # Presentation context rejected by abstract syntax.
52
- ABSTRACT_SYNTAX_REJECTED = 3
53
- # Presentation context rejected by transfer syntax.
54
- TRANSFER_SYNTAX_REJECTED = 4
55
-
56
- # Some network command element codes:
57
- C_STORE_RQ = 1 # (encodes to 0001H as US)
58
- C_GET_RQ = 16 # (encodes to 0010H as US)
59
- C_FIND_RQ = 32 # (encodes to 0020H as US)
60
- C_MOVE_RQ = 33 # (encodes to 0021H as US)
61
- C_ECHO_RQ = 48 # (encodes to 0030 as US)
62
- C_CANCEL_RQ = 4095 # (encodes to 0FFFH as US)
63
- C_STORE_RSP = 32769 # (encodes to 8001H as US)
64
- C_GET_RSP = 32784 # (encodes to 8010H as US)
65
- C_FIND_RSP = 32800 # (encodes to 8020H as US)
66
- C_MOVE_RSP = 32801 # (encodes to 8021H as US)
67
- C_ECHO_RSP = 32816 # (encodes to 8030H as US)
68
- NO_DATA_SET_PRESENT = 257 # (encodes to 0101H as US)
69
- DATA_SET_PRESENT = 1
70
- DEFAULT_MESSAGE_ID = 1
71
-
72
- # The network communication flags:
73
- DATA_MORE_FRAGMENTS = "00"
74
- COMMAND_MORE_FRAGMENTS = "01"
75
- DATA_LAST_FRAGMENT = "02"
76
- COMMAND_LAST_FRAGMENT = "03"
77
-
78
- # Network communication PDU types:
79
- PDU_ASSOCIATION_REQUEST = "01"
80
- PDU_ASSOCIATION_ACCEPT = "02"
81
- PDU_ASSOCIATION_REJECT = "03"
82
- PDU_DATA = "04"
83
- PDU_RELEASE_REQUEST = "05"
84
- PDU_RELEASE_RESPONSE = "06"
85
- PDU_ABORT = "07"
86
-
87
- # Network communication item types:
88
- ITEM_APPLICATION_CONTEXT = "10"
89
- ITEM_PRESENTATION_CONTEXT_REQUEST = "20"
90
- ITEM_PRESENTATION_CONTEXT_RESPONSE = "21"
91
- ITEM_ABSTRACT_SYNTAX = "30"
92
- ITEM_TRANSFER_SYNTAX = "40"
93
- ITEM_USER_INFORMATION = "50"
94
- ITEM_MAX_LENGTH = "51"
95
- ITEM_IMPLEMENTATION_UID = "52"
96
- ITEM_MAX_OPERATIONS_INVOKED = "53"
97
- ITEM_ROLE_NEGOTIATION = "54"
98
- ITEM_IMPLEMENTATION_VERSION = "55"
99
-
100
- # Varaibles used to determine endianness.
101
- x = 0xdeadbeef
102
- endian_type = {
103
- Array(x).pack("V*") => false, # Little
104
- Array(x).pack("N*") => true # Big
105
- }
106
- # System (CPU) Endianness.
107
- CPU_ENDIAN = endian_type[Array(x).pack("L*")]
108
-
109
- # Custom string used for (un)packing big endian signed short.
110
- CUSTOM_SS = "k*"
111
- # Custom string used for (un)packing big endian signed long.
112
- CUSTOM_SL = "r*"
113
-
114
- # Ruby DICOM's library (data dictionary).
115
- LIBRARY = DICOM::DLibrary.new
116
-
117
- # Transfer Syntaxes
118
- # Taken from DICOM Specification PS 3.5, Chapter 10
119
-
120
- # General
121
- TXS_IMPLICIT_LITTLE_ENDIAN = '1.2.840.10008.1.2' # also defined as IMPLICIT_LITTLE_ENDIAN, default transfer syntax
122
- TXS_EXPLICIT_LITTLE_ENDIAN = '1.2.840.10008.1.2.1' # also defined as EXPLICIT_LITTLE_ENDIAN
123
- TXS_EXPLICIT_BIG_ENDIAN = '1.2.840.10008.1.2.2' # also defined as EXPLICIT_BIG_ENDIAN
124
-
125
- # TRANSFER SYNTAXES FOR ENCAPSULATION OF ENCODED PIXEL DATA
126
- TXS_JPEG_BASELINE = '1.2.840.10008.1.2.4.50'
127
- TXS_JPEG_EXTENDED = '1.2.840.10008.1.2.4.51'
128
- TXS_JPEG_LOSSLESS_NH = '1.2.840.10008.1.2.4.57' # NH: non-hirarchical
129
- TXS_JPEG_LOSSLESS_NH_FOP = '1.2.840.10008.1.2.4.70' # NH: non-hirarchical, FOP: first-order prediction
130
-
131
- TXS_JPEG_LS_LOSSLESS = '1.2.840.10008.1.2.4.80'
132
- TXS_JPEG_LS_NEAR_LOSSLESS = '1.2.840.10008.1.2.4.81'
133
-
134
- TXS_JPEG_2000_PART1_LOSSLESS = '1.2.840.10008.1.2.4.90'
135
- TXS_JPEG_2000_PART1_LOSSLESS_OR_LOSSY = '1.2.840.10008.1.2.4.91'
136
- TXS_JPEG_2000_PART2_LOSSLESS = '1.2.840.10008.1.2.4.92'
137
- TXS_JPEG_2000_PART2_LOSSLESS_OR_LOSSY = '1.2.840.10008.1.2.4.93'
138
-
139
- TXS_MPEG2_MP_ML = '1.2.840.10008.1.2.4.100'
140
- TXS_MPEG2_MP_HL = '1.2.840.10008.1.2.4.101'
141
-
142
- TXS_DEFLATED_LITTLE_ENDIAN = '1.2.840.10008.1.2.1.99' # ZIP Compression
143
-
144
- TXS_JPIP = '1.2.840.10008.1.2.4.94'
145
- TXS_JPIP_DEFLATE = '1.2.840.10008.1.2.4.95'
146
-
147
- TXS_RLE = '1.2.840.10008.1.2.5'
148
-
149
-
150
- # Photometric Interpretations
151
- # Taken from DICOM Specification PS 3.3 C.7.6.3.1.2 Photometric Interpretation
152
-
153
- PI_MONOCHROME1 = 'MONOCHROME1'
154
- PI_MONOCHROME2 = 'MONOCHROME2'
155
- PI_PALETTE_COLOR = 'PALETTE COLOR'
156
- PI_RGB = 'RGB'
157
- PI_YBR_FULL = 'YBR_FULL'
158
- PI_YBR_FULL_422 = 'YBR_FULL_422 '
159
- PI_YBR_PARTIAL_422 = 'YBR_PARTIAL_422'
160
- PI_YBR_PARTIAL_420 = 'YBR_PARTIAL_420'
161
- PI_YBR_ICT = 'YBR_ICT'
162
- PI_YBR_RCT = 'YBR_RCT'
163
-
164
- # Retired Photometric Interpretations, are those needed to be supported?
165
- PI_HSV = 'HSV'
166
- PI_ARGB = 'ARGB'
167
- PI_CMYK = 'CMYK'
168
-
169
- end
170
-
1
+ module DICOM
2
+
3
+ # Defines the gem root directory in the file system.
4
+ ROOT_DIR = "#{File.dirname(__FILE__)}"
5
+
6
+ # Ruby DICOM's registered DICOM UID root (Implementation Class UID).
7
+ UID_ROOT = "1.2.826.0.1.3680043.8.641"
8
+ # Ruby DICOM name & version (max 16 characters).
9
+ NAME = "RUBY_DCM_" + DICOM::VERSION
10
+
11
+ # Item tag.
12
+ ITEM_TAG = "FFFE,E000"
13
+ # All Item related tags (includes both types of delimitation items).
14
+ ITEM_TAGS = ["FFFE,E000", "FFFE,E00D", "FFFE,E0DD"]
15
+ # Item delimiter tag.
16
+ ITEM_DELIMITER = "FFFE,E00D"
17
+ # Sequence delimiter tag.
18
+ SEQUENCE_DELIMITER = "FFFE,E0DD"
19
+ # All delimiter tags.
20
+ DELIMITER_TAGS = ["FFFE,E00D", "FFFE,E0DD"]
21
+
22
+ # The VR used for the item elements.
23
+ ITEM_VR = " "
24
+
25
+ # Pixel tag.
26
+ PIXEL_TAG = "7FE0,0010"
27
+ # Name of the pixel tag when holding encapsulated data.
28
+ ENCAPSULATED_PIXEL_NAME = "Encapsulated Pixel Data"
29
+ # Name of encapsulated items.
30
+ PIXEL_ITEM_NAME = "Pixel Data Item"
31
+
32
+ # File meta group.
33
+ META_GROUP = "0002"
34
+
35
+ # Group length element.
36
+ GROUP_LENGTH = "0000"
37
+
38
+ # Implicit, little endian (the default transfer syntax).
39
+ IMPLICIT_LITTLE_ENDIAN = "1.2.840.10008.1.2"
40
+ # Explicit, little endian transfer syntax.
41
+ EXPLICIT_LITTLE_ENDIAN = "1.2.840.10008.1.2.1"
42
+ # Explicit, big endian transfer syntax.
43
+ EXPLICIT_BIG_ENDIAN = "1.2.840.10008.1.2.2"
44
+
45
+ # Verification SOP class UID.
46
+ VERIFICATION_SOP = "1.2.840.10008.1.1"
47
+ # Application context SOP class UID.
48
+ APPLICATION_CONTEXT = "1.2.840.10008.3.1.1.1"
49
+
50
+ # Network transmission successful.
51
+ SUCCESS = 0
52
+ # Network proposition accepted.
53
+ ACCEPTANCE = 0
54
+ # Presentation context rejected by abstract syntax.
55
+ ABSTRACT_SYNTAX_REJECTED = 3
56
+ # Presentation context rejected by transfer syntax.
57
+ TRANSFER_SYNTAX_REJECTED = 4
58
+
59
+ # Some network command element codes:
60
+ C_STORE_RQ = 1 # (encodes to 0001H as US)
61
+ C_GET_RQ = 16 # (encodes to 0010H as US)
62
+ C_FIND_RQ = 32 # (encodes to 0020H as US)
63
+ C_MOVE_RQ = 33 # (encodes to 0021H as US)
64
+ C_ECHO_RQ = 48 # (encodes to 0030 as US)
65
+ C_CANCEL_RQ = 4095 # (encodes to 0FFFH as US)
66
+ C_STORE_RSP = 32769 # (encodes to 8001H as US)
67
+ C_GET_RSP = 32784 # (encodes to 8010H as US)
68
+ C_FIND_RSP = 32800 # (encodes to 8020H as US)
69
+ C_MOVE_RSP = 32801 # (encodes to 8021H as US)
70
+ C_ECHO_RSP = 32816 # (encodes to 8030H as US)
71
+ NO_DATA_SET_PRESENT = 257 # (encodes to 0101H as US)
72
+ DATA_SET_PRESENT = 1
73
+ DEFAULT_MESSAGE_ID = 1
74
+
75
+ # The network communication flags:
76
+ DATA_MORE_FRAGMENTS = "00"
77
+ COMMAND_MORE_FRAGMENTS = "01"
78
+ DATA_LAST_FRAGMENT = "02"
79
+ COMMAND_LAST_FRAGMENT = "03"
80
+
81
+ # Network communication PDU types:
82
+ PDU_ASSOCIATION_REQUEST = "01"
83
+ PDU_ASSOCIATION_ACCEPT = "02"
84
+ PDU_ASSOCIATION_REJECT = "03"
85
+ PDU_DATA = "04"
86
+ PDU_RELEASE_REQUEST = "05"
87
+ PDU_RELEASE_RESPONSE = "06"
88
+ PDU_ABORT = "07"
89
+
90
+ # Network communication item types:
91
+ ITEM_APPLICATION_CONTEXT = "10"
92
+ ITEM_PRESENTATION_CONTEXT_REQUEST = "20"
93
+ ITEM_PRESENTATION_CONTEXT_RESPONSE = "21"
94
+ ITEM_ABSTRACT_SYNTAX = "30"
95
+ ITEM_TRANSFER_SYNTAX = "40"
96
+ ITEM_USER_INFORMATION = "50"
97
+ ITEM_MAX_LENGTH = "51"
98
+ ITEM_IMPLEMENTATION_UID = "52"
99
+ ITEM_MAX_OPERATIONS_INVOKED = "53"
100
+ ITEM_ROLE_NEGOTIATION = "54"
101
+ ITEM_IMPLEMENTATION_VERSION = "55"
102
+
103
+ # Varaibles used to determine endianness.
104
+ x = 0xdeadbeef
105
+ endian_type = {
106
+ Array(x).pack("V*") => false, # Little
107
+ Array(x).pack("N*") => true # Big
108
+ }
109
+ # System (CPU) Endianness.
110
+ CPU_ENDIAN = endian_type[Array(x).pack("L*")]
111
+
112
+ # Custom string used for (un)packing big endian signed short.
113
+ CUSTOM_SS = "k*"
114
+ # Custom string used for (un)packing big endian signed long.
115
+ CUSTOM_SL = "r*"
116
+
117
+ # ruby-dicom's library instance (data dictionary).
118
+ LIBRARY = DICOM::DLibrary.new
119
+
120
+ # Transfer Syntaxes (taken from the DICOM Specification PS 3.5, Chapter 10).
121
+
122
+ # General
123
+ TXS_IMPLICIT_LITTLE_ENDIAN = '1.2.840.10008.1.2' # also defined as IMPLICIT_LITTLE_ENDIAN, default transfer syntax
124
+ TXS_EXPLICIT_LITTLE_ENDIAN = '1.2.840.10008.1.2.1' # also defined as EXPLICIT_LITTLE_ENDIAN
125
+ TXS_EXPLICIT_BIG_ENDIAN = '1.2.840.10008.1.2.2' # also defined as EXPLICIT_BIG_ENDIAN
126
+
127
+ # TRANSFER SYNTAXES FOR ENCAPSULATION OF ENCODED PIXEL DATA
128
+ TXS_JPEG_BASELINE = '1.2.840.10008.1.2.4.50'
129
+ TXS_JPEG_EXTENDED = '1.2.840.10008.1.2.4.51'
130
+ TXS_JPEG_LOSSLESS_NH = '1.2.840.10008.1.2.4.57' # NH: non-hirarchical
131
+ TXS_JPEG_LOSSLESS_NH_FOP = '1.2.840.10008.1.2.4.70' # NH: non-hirarchical, FOP: first-order prediction
132
+
133
+ TXS_JPEG_LS_LOSSLESS = '1.2.840.10008.1.2.4.80'
134
+ TXS_JPEG_LS_NEAR_LOSSLESS = '1.2.840.10008.1.2.4.81'
135
+
136
+ TXS_JPEG_2000_PART1_LOSSLESS = '1.2.840.10008.1.2.4.90'
137
+ TXS_JPEG_2000_PART1_LOSSLESS_OR_LOSSY = '1.2.840.10008.1.2.4.91'
138
+ TXS_JPEG_2000_PART2_LOSSLESS = '1.2.840.10008.1.2.4.92'
139
+ TXS_JPEG_2000_PART2_LOSSLESS_OR_LOSSY = '1.2.840.10008.1.2.4.93'
140
+
141
+ TXS_MPEG2_MP_ML = '1.2.840.10008.1.2.4.100'
142
+ TXS_MPEG2_MP_HL = '1.2.840.10008.1.2.4.101'
143
+
144
+ TXS_DEFLATED_LITTLE_ENDIAN = '1.2.840.10008.1.2.1.99' # ZIP Compression
145
+
146
+ TXS_JPIP = '1.2.840.10008.1.2.4.94'
147
+ TXS_JPIP_DEFLATE = '1.2.840.10008.1.2.4.95'
148
+
149
+ TXS_RLE = '1.2.840.10008.1.2.5'
150
+
151
+
152
+ # Photometric Interpretations
153
+ # Taken from DICOM Specification PS 3.3 C.7.6.3.1.2 Photometric Interpretation
154
+
155
+ PI_MONOCHROME1 = 'MONOCHROME1'
156
+ PI_MONOCHROME2 = 'MONOCHROME2'
157
+ PI_PALETTE_COLOR = 'PALETTE COLOR'
158
+ PI_RGB = 'RGB'
159
+ PI_YBR_FULL = 'YBR_FULL'
160
+ PI_YBR_FULL_422 = 'YBR_FULL_422 '
161
+ PI_YBR_PARTIAL_422 = 'YBR_PARTIAL_422'
162
+ PI_YBR_PARTIAL_420 = 'YBR_PARTIAL_420'
163
+ PI_YBR_ICT = 'YBR_ICT'
164
+ PI_YBR_RCT = 'YBR_RCT'
165
+
166
+ # Retired Photometric Interpretations, are those needed to be supported?
167
+ PI_HSV = 'HSV'
168
+ PI_ARGB = 'ARGB'
169
+ PI_CMYK = 'CMYK'
170
+
171
+ # The relationship between DICOM Character Set and Encoding name.
172
+ ENCODING_NAME = {
173
+ 'ISO_IR 100' => 'ISO-8859-1',
174
+ 'ISO_IR 101' => 'ISO-8859-2',
175
+ 'ISO_IR 109' => 'ISO-8859-3',
176
+ 'ISO_IR 110' => 'ISO-8859-4',
177
+ 'ISO_IR 144' => 'ISO-8859-5',
178
+ 'ISO_IR 127' => 'ISO-8859-6',
179
+ 'ISO_IR 126' => 'ISO-8859-7',
180
+ 'ISO_IR 138' => 'ISO-8859-8',
181
+ 'ISO_IR 148' => 'ISO-8859-9',
182
+ 'ISO_IR 13' => 'JIS_X0201',
183
+ 'ISO_IR 166' => 'ISO-8859-11',
184
+ 'GB18030' => 'GB18030',
185
+ 'ISO_IR 192' => 'UTF-8'
186
+ }
187
+
188
+ # The type conversion (method) used for the various value representations.
189
+ VALUE_CONVERSION = {
190
+ 'BY' => :to_i,
191
+ 'US' => :to_i,
192
+ 'SS' => :to_i,
193
+ 'UL' => :to_i,
194
+ 'SL' => :to_i,
195
+ 'OB' => :to_i,
196
+ 'OW' => :to_i,
197
+ 'OF' => :to_f,
198
+ 'FL' => :to_f,
199
+ 'FD' => :to_f,
200
+ 'AT' => :to_s,
201
+ 'AE' => :to_s,
202
+ 'AS' => :to_s,
203
+ 'CS' => :to_s,
204
+ 'DA' => :to_s,
205
+ 'DS' => :to_s,
206
+ 'DT' => :to_s,
207
+ 'IS' => :to_s,
208
+ 'LO' => :to_s,
209
+ 'LT' => :to_s,
210
+ 'PN' => :to_s,
211
+ 'SH' => :to_s,
212
+ 'ST' => :to_s,
213
+ 'TM' => :to_s,
214
+ 'UI' => :to_s,
215
+ 'UT' => :to_s
216
+ }
217
+
218
+ end
219
+