dcm_dict 0.25.0 → 0.30.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +38 -0
- data/LICENSE +1 -1
- data/README.md +80 -65
- data/bin/dcm_dict_converter.rb +3 -3
- data/lib/dcm_dict.rb +1 -1
- data/lib/dcm_dict/dictionary/base_dictionary.rb +1 -1
- data/lib/dcm_dict/dictionary/base_record.rb +1 -1
- data/lib/dcm_dict/dictionary/data_element_dictionary.rb +1 -1
- data/lib/dcm_dict/dictionary/data_element_record.rb +1 -1
- data/lib/dcm_dict/dictionary/uid_dictionary.rb +2 -4
- data/lib/dcm_dict/dictionary/uid_record.rb +6 -1
- data/lib/dcm_dict/encoder/data_to_code.rb +2 -2
- data/lib/dcm_dict/error/dictionary_error.rb +1 -1
- data/lib/dcm_dict/ext/object_extension.rb +1 -1
- data/lib/dcm_dict/refine/array_refine.rb +1 -1
- data/lib/dcm_dict/refine/data_element_refine.rb +1 -1
- data/lib/dcm_dict/refine/internal/array_refine_internal.rb +1 -1
- data/lib/dcm_dict/refine/internal/hash_refine_internal.rb +14 -1
- data/lib/dcm_dict/refine/internal/string_refine_internal.rb +1 -1
- data/lib/dcm_dict/refine/string_refine.rb +1 -1
- data/lib/dcm_dict/refine/symbol_refine.rb +2 -1
- data/lib/dcm_dict/refine/uid_refine.rb +1 -1
- data/lib/dcm_dict/rubies/rb_ext.rb +1 -1
- data/lib/dcm_dict/source_data/data_elements_data.rb +75 -3
- data/lib/dcm_dict/source_data/detached_data.rb +1 -1
- data/lib/dcm_dict/source_data/uid_values_data.rb +444 -420
- data/lib/dcm_dict/version.rb +3 -3
- data/lib/dcm_dict/xml/constant.rb +3 -2
- data/lib/dcm_dict/xml/field_data.rb +1 -1
- data/lib/dcm_dict/xml/nokogiri_tool.rb +1 -1
- data/lib/dcm_dict/xml/rexml_tool.rb +1 -1
- data/lib/dcm_dict/xml/tag_field_data.rb +1 -1
- data/lib/dcm_dict/xml/uid_field_data.rb +14 -4
- data/lib/dcm_dict/xml/xml_tool.rb +1 -1
- data/spec/data_element_sample_spec_helper.rb +10 -2
- data/spec/data_element_shared_example_spec_helper.rb +1 -1
- data/spec/dcm_dict/dictionary/data_element_dictionary_spec.rb +1 -1
- data/spec/dcm_dict/dictionary/data_element_record_spec.rb +1 -1
- data/spec/dcm_dict/dictionary/uid_dictionary_spec.rb +62 -14
- data/spec/dcm_dict/dictionary/uid_record_spec.rb +8 -4
- data/spec/dcm_dict/encoder/data_to_code_spec.rb +2 -2
- data/spec/dcm_dict/ext/object_extension_spec.rb +1 -1
- data/spec/dcm_dict/refine/array_refine_spec.rb +1 -1
- data/spec/dcm_dict/refine/internal/array_refine_internal_spec.rb +1 -1
- data/spec/dcm_dict/refine/internal/hash_refine_internal_spec.rb +19 -1
- data/spec/dcm_dict/refine/internal/string_refine_internal_spec.rb +1 -1
- data/spec/dcm_dict/refine/string_refine_spec.rb +4 -4
- data/spec/dcm_dict/refine/symbol_refine_spec.rb +26 -1
- data/spec/dcm_dict/rubies/rb_ext_spec.rb +1 -1
- data/spec/dcm_dict/source_data/data_elements_data_spec.rb +1 -1
- data/spec/dcm_dict/source_data/detached_data_spec.rb +1 -1
- data/spec/dcm_dict/source_data/uid_values_data_spec.rb +1 -1
- data/spec/dcm_dict/version_spec.rb +1 -1
- data/spec/dcm_dict/xml/tag_field_data_spec.rb +1 -1
- data/spec/dcm_dict/xml/uid_field_data_spec.rb +1 -1
- data/spec/dictionary_shared_example_spec_helper.rb +3 -3
- data/spec/refine_shared_example_spec_helper.rb +1 -1
- data/spec/spec_helper.rb +1 -1
- data/spec/xml_sample_spec_helper.rb +80 -32
- metadata +8 -9
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0eeae5a7505188a36e7338519c3513da23a6b00f2c70fee8c6f41dd707a82729
|
4
|
+
data.tar.gz: 85051f9f6a98d72d822fb9836e98bd2d074e2a9343258d320478e355b3c61a82
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c54c7096faffa01d3f047ef516d044d4d507a83f4624a0212e1e8129acec314708c4c45d857a6c834093cbf6403ff80f9dbbf80c20803a3a56502c8eeca23b55
|
7
|
+
data.tar.gz: 24a8ba4492daebd8576470d3b02c81d937ef3564858f54ded2a0db6e674756a80cdbb6155ddb9510901d26fd9742aeccfeaad689aad59784f7d70a1c61882162
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,43 @@
|
|
1
1
|
# DcmDict project Changelog
|
2
2
|
|
3
|
+
## v0.30.0 (2020-10-03)
|
4
|
+
* Update to 2020d Base Standard
|
5
|
+
* Add keywords support for standard UIDs
|
6
|
+
___
|
7
|
+
## v0.29.0 (2020-07-21)
|
8
|
+
* Update to 2020c Base Standard
|
9
|
+
___
|
10
|
+
## v0.28.1 (2020-03-18)
|
11
|
+
* Updated dcm_dict.gemspec due to a security vulnerabilities into the Rake gem as defined into gemspec (>=10.3 to >=12.3.3)
|
12
|
+
#### Note for gemspec security report:
|
13
|
+
>rake vulnerability found in dcm_dict.gemspec:
|
14
|
+
>CVE-2020-8130 (moderate severity)
|
15
|
+
>Vulnerable versions: <= 12.3.2
|
16
|
+
>Patched version: 12.3.3
|
17
|
+
>There is an OS command injection vulnerability in Ruby Rake before 12.3.3 in Rake::FileList when supplying a filename that begins with the pipe character |.
|
18
|
+
>
|
19
|
+
>Remediation:
|
20
|
+
>Upgrade rake to version 12.3.3 or later.
|
21
|
+
>
|
22
|
+
>["OS Command Injection in Rake"](https://github.com/advisories/GHSA-jppv-gw3r-w3q8)
|
23
|
+
>["CVE-2020-8130 Detail"](https://nvd.nist.gov/vuln/detail/CVE-2020-8130)
|
24
|
+
___
|
25
|
+
## v0.28.0 (2020-03-18)
|
26
|
+
* Update to 2020b Base Standard
|
27
|
+
* Remove warning for deprecated method 'Kernel#open'
|
28
|
+
___
|
29
|
+
## v0.27.0 (2020-02-05)
|
30
|
+
* Update to 2020a Base Standard
|
31
|
+
___
|
32
|
+
## v0.26.2 (2020-02-05)
|
33
|
+
* Update copyright year
|
34
|
+
___
|
35
|
+
## v0.26.1 (2020-01-03)
|
36
|
+
* Fix test to be compatible with ruby 2.7
|
37
|
+
* (No Dictionary Change from 2019e)
|
38
|
+
___
|
39
|
+
## v0.26.0 (2019-11-20)
|
40
|
+
* Update to 2019e Base Standard
|
3
41
|
___
|
4
42
|
## v0.25.0 (2019-10-04)
|
5
43
|
* Update to 2019d Base Standard
|
data/LICENSE
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
DcmDict is a Ruby gem (dcm_dict) to handle
|
2
2
|
in a simple way the Data defined within the DICOM Standard.
|
3
3
|
|
4
|
-
Copyright (C) 2014-
|
4
|
+
Copyright (C) 2014-2020 Enrico Rivarola
|
5
5
|
|
6
6
|
DcmDict is free software: you can redistribute it and/or modify
|
7
7
|
it under the terms of the GNU General Public License as published by
|
data/README.md
CHANGED
@@ -4,11 +4,8 @@
|
|
4
4
|
# Why *DcmDict*
|
5
5
|
With the new releases from year 2014 DICOM documents are available in different format including one particularly interesting, the *DocBook* XML version.
|
6
6
|
|
7
|
-
As
|
8
|
-
>
|
9
|
-
|
10
|
-
This is confirmed in the DICOM<sup>®</sup> Standard [web site][10] where each part is published in [multiple formats][11] and the XML format is defined:
|
11
|
-
>"... good for machine readability, e.g. self-updating validators ..."
|
7
|
+
As confirmed in the DICOM<sup>®</sup> Standard [web site][10] where each part is published in [multiple formats][11] and XML format is defined by:
|
8
|
+
>"... XML – good for machine readability, e.g. self-updating validators ..."
|
12
9
|
|
13
10
|
This is great news for anyone involved in the study of the standard !
|
14
11
|
|
@@ -49,6 +46,14 @@ as well for UIDs
|
|
49
46
|
=> :transfer_syntax
|
50
47
|
> "Implicit VR Little Endian: Default Transfer Syntax for DICOM".uid_value
|
51
48
|
=> "1.2.840.10008.1.2"
|
49
|
+
> "Verification SOP Class".uid_value
|
50
|
+
=> "1.2.840.10008.1.1"
|
51
|
+
> "1.2.840.10008.1.1".uid_type
|
52
|
+
=> :sop_class
|
53
|
+
> "Verification".uid
|
54
|
+
=> "1.2.840.10008.1.1"
|
55
|
+
> :verification.uid
|
56
|
+
=> "1.2.840.10008.1.1"
|
52
57
|
```
|
53
58
|
|
54
59
|
let see all features in detail:
|
@@ -95,33 +100,33 @@ For these objects is possible to access to Tag (group/element), Name, Keyword, V
|
|
95
100
|
|
96
101
|
The main methods supported are:
|
97
102
|
|
98
|
-
|Method
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
103
|
+
| Method | Note | Type | |
|
104
|
+
|:------------------|:---------------------------------:|:-------------------:|:----------------------------------:|
|
105
|
+
| **tag** | tag as Array | Array of two Fixnum | (alias of *tag_ary*) |
|
106
|
+
| **tag_name** | name of tag | String | |
|
107
|
+
| **tag_keyword** | keyword | String | |
|
108
|
+
| **tag_key** | keyword | String | |
|
109
|
+
| **tag_vr** | Value Representation | Array of Symbol | |
|
110
|
+
| **tag_vm** | Value Multiplicity | Array of Symbol | |
|
111
|
+
| **tag_ps** | tag as string (as standard doc) | String | |
|
112
|
+
| **tag_ary** | tag as Array | Array of two Fixnum | |
|
113
|
+
| **tag_sym** | tag as Symbol | Symbol | |
|
114
|
+
| **tag_ndm** | tag as in Native DICOM Model | String | |
|
115
|
+
| **tag_str** | tag as string (similar to tag_ps) | String | |
|
116
|
+
| **tag_note** | tag note | String | |
|
117
|
+
| **tag_multiple?** | is a multiple tag ? | boolean | (useful for 'multi tag' attribute) |
|
113
118
|
|
114
119
|
each data element is indexed by these fields:
|
115
120
|
|
116
|
-
|Field|Type|
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
121
|
+
| Field | Type |
|
122
|
+
|:-------------|:------:|
|
123
|
+
| **tag_key** | String |
|
124
|
+
| **tag_ps** | String |
|
125
|
+
| **tag_ary** | Array |
|
126
|
+
| **tag_sym** | Symbol |
|
127
|
+
| **tag_ndm** | String |
|
128
|
+
| **tag_str** | String |
|
129
|
+
| **tag_name** | String |
|
125
130
|
|
126
131
|
By these fields is possible to access to data element informations.
|
127
132
|
Consider the case of the tag (0010,1005) (*Patient's Birth Name*), the primary fields are:
|
@@ -173,21 +178,21 @@ will produce
|
|
173
178
|
The library also manage 'multiple tags' such as *(0020,31XX)* (*Source Image IDs*).
|
174
179
|
As an example for this data element the default tag in array form is [0x0020,0x3122] and all fields are expressed as:
|
175
180
|
|
176
|
-
|Method/field
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
|
181
|
+
| Method/field | Value |
|
182
|
+
|:------------------|:------------------:|
|
183
|
+
| **tag** | [0x0020,0x3122] |
|
184
|
+
| **tag_name** | "Source Image IDs" |
|
185
|
+
| **tag_keyword** | 'SourceImageIDs' |
|
186
|
+
| **tag_key** | 'SourceImageIDs' |
|
187
|
+
| **tag_vr** | [:CS] |
|
188
|
+
| **tag_vm** | ["1-n"] |
|
189
|
+
| **tag_ps** | '(0020,31XX)' |
|
190
|
+
| **tag_ary** | [0x0020,0x3122] |
|
191
|
+
| **tag_sym** | :source_image_ids |
|
192
|
+
| **tag_ndm** | '00203122' |
|
193
|
+
| **tag_str** | '(0020,3122)' |
|
194
|
+
| **tag_note** | 'RET' |
|
195
|
+
| **tag_multiple?** | true |
|
191
196
|
|
192
197
|
[0x0020,0x3122] is the default value for group/element pair (*[32, 12578]*), but any valid pair of numbers for this tag will be refers that information:
|
193
198
|
|
@@ -213,38 +218,44 @@ As an example for this data element the default tag in array form is [0x0020,0x3
|
|
213
218
|
and so on.
|
214
219
|
|
215
220
|
## UID data in detail
|
216
|
-
Any UID features can be accessed from a *String* object.
|
221
|
+
Any UID features can be accessed from a *String* or a *Symbol* object.
|
217
222
|
|
218
223
|
### UID Values
|
219
224
|
For these objects is possible to access to value, name and type values for any single uid.
|
220
225
|
Main methods supported are:
|
221
226
|
|
222
|
-
|Method
|
223
|
-
|
224
|
-
|
225
|
-
|
226
|
-
|
227
|
-
|
227
|
+
| Method | Note | Type | |
|
228
|
+
|:--------------|:------------------------:|:------:|:----------------------:|
|
229
|
+
| **uid** | value of uid | String | (alias of *uid_value*) |
|
230
|
+
| **uid_value** | value of uid | String | |
|
231
|
+
| **uid_name** | name of uid | String | |
|
232
|
+
| **uid_key** | keyword of uid | String | |
|
233
|
+
| **uid_sym** | keyword as symbol of uid | Symbol | |
|
234
|
+
| **uid_type** | type of uid | Symbol | |
|
228
235
|
|
229
236
|
each uid is indexed by:
|
230
237
|
|
231
|
-
|Field|Type|
|
232
|
-
|
233
|
-
|
234
|
-
|
238
|
+
| Field | Type |
|
239
|
+
|:--------------|:-------|
|
240
|
+
| **uid_value** | String |
|
241
|
+
| **uid_name** | String |
|
242
|
+
| **uid_key** | String |
|
243
|
+
| **uid_sym** | Symbol |
|
235
244
|
|
236
245
|
From these fields is possible to access to all uid informations.
|
237
|
-
Consider the case of the uid *1.2.840.10008.1.1* (*Verification SOP Class*), the primary fields are the strings **'1.2.840.10008.1.1'
|
238
|
-
- As
|
246
|
+
Consider the case of the uid *1.2.840.10008.1.1* (*Verification SOP Class*), the primary fields are the strings **'1.2.840.10008.1.1'**, **"Verification SOP Class"**, **"Verification"**.
|
247
|
+
- As key you may use the standard value **'1.2.840.10008.1.1'**, the uid name **"Verification SOP Class"**, the uid keyword **"Verification"** and the symbol **:verification**
|
239
248
|
|
240
249
|
For this uid all fields are expressed as:
|
241
250
|
|
242
|
-
|Method/field | Value|
|
243
|
-
|
244
|
-
|
245
|
-
|
246
|
-
|
247
|
-
|
251
|
+
| Method/field | Value |
|
252
|
+
|:--------------|:------------------------:|
|
253
|
+
| **uid** | '1.2.840.10008.1.1' |
|
254
|
+
| **uid_value** | '1.2.840.10008.1.1' |
|
255
|
+
| **uid_name** | "Verification SOP Class" |
|
256
|
+
| **uid_key** | "Verification" |
|
257
|
+
| **uid_sym** | :verification |
|
258
|
+
| **uid_type** | :sop_class |
|
248
259
|
|
249
260
|
### example:
|
250
261
|
|
@@ -257,6 +268,10 @@ For this uid all fields are expressed as:
|
|
257
268
|
=> "Verification SOP Class"
|
258
269
|
> "Verification SOP Class".uid
|
259
270
|
=> "1.2.840.10008.1.1"
|
271
|
+
> "Verification".uid
|
272
|
+
=> "1.2.840.10008.1.1"
|
273
|
+
> :verification.uid
|
274
|
+
=> "1.2.840.10008.1.1"
|
260
275
|
```
|
261
276
|
|
262
277
|
## How data is extracted
|
@@ -272,7 +287,7 @@ Note: the script use the [Nokogiri][3] as XML parser if installed as gem, otherw
|
|
272
287
|
Check the file for other details.
|
273
288
|
|
274
289
|
## Note
|
275
|
-
Current library version is aligned to *DICOM Base Standard* **
|
290
|
+
Current library version is aligned to *DICOM Base Standard* **2020d**
|
276
291
|
|
277
292
|
## Install
|
278
293
|
|
@@ -295,7 +310,7 @@ There are many possible *candidates* for inclusion in the *dictionary*, here are
|
|
295
310
|
TBD
|
296
311
|
|
297
312
|
## License
|
298
|
-
Copyright (C) 2014-
|
313
|
+
Copyright (C) 2014-2020 Enrico Rivarola.
|
299
314
|
See the `LICENSE` and `COPYING` files for license details.
|
300
315
|
|
301
316
|
## Ruby Gem
|
data/bin/dcm_dict_converter.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
# -*- ruby -*-
|
3
3
|
#
|
4
|
-
# Copyright (C) 2014-
|
4
|
+
# Copyright (C) 2014-2020 Enrico Rivarola
|
5
5
|
#
|
6
6
|
# This file is part of DcmDict gem (dcm_dict).
|
7
7
|
#
|
@@ -29,7 +29,7 @@ require 'dcm_dict'
|
|
29
29
|
require 'dcm_dict/xml/xml_tool'
|
30
30
|
|
31
31
|
LICENSE_TEXT=<<END_LICENSE
|
32
|
-
Copyright (C) 2014-
|
32
|
+
Copyright (C) 2014-2020 Enrico Rivarola
|
33
33
|
|
34
34
|
This file is part of DcmDict gem (dcm_dict).
|
35
35
|
|
@@ -89,7 +89,7 @@ class DcmDictConverter
|
|
89
89
|
def pull_standard_draft(url, output)
|
90
90
|
buffer_size = 256 * 1_024
|
91
91
|
trace("Downloading #{url}\n")
|
92
|
-
open(url, "r",
|
92
|
+
URI.open(url, "r",
|
93
93
|
:content_length_proc => lambda {|content_length| trace("Content Length: #{content_length} bytes\n.") },
|
94
94
|
:progress_proc => lambda { |size| trace(".") }) do |src|
|
95
95
|
while (buffer = src.read(buffer_size))
|
data/lib/dcm_dict.rb
CHANGED
@@ -25,7 +25,7 @@ module DcmDict
|
|
25
25
|
module Dictionary
|
26
26
|
using DcmDict::Refine::Internal::StringRefineInternal
|
27
27
|
|
28
|
-
UidIndexKey = [:uid_value, :uid_name]
|
28
|
+
UidIndexKey = [:uid_value, :uid_name, :uid_key, :uid_sym]
|
29
29
|
|
30
30
|
# Main class to handle uid data as dictionary
|
31
31
|
class UidDictionary < BaseDictionary
|
@@ -70,9 +70,7 @@ module DcmDict
|
|
70
70
|
|
71
71
|
def try_to_find_unknown_uid(uid)
|
72
72
|
raise "Unknown UID value" unless uid.uid_value?
|
73
|
-
UidRecord.new({ uid_value: uid
|
74
|
-
uid_name: 'Unknown UID',
|
75
|
-
uid_type: :unknown })
|
73
|
+
UidRecord.new({ uid_value: uid })
|
76
74
|
end
|
77
75
|
end
|
78
76
|
|
@@ -1,5 +1,5 @@
|
|
1
1
|
#
|
2
|
-
# Copyright (C) 2014-
|
2
|
+
# Copyright (C) 2014-2020 Enrico Rivarola
|
3
3
|
#
|
4
4
|
# This file is part of DcmDict gem (dcm_dict).
|
5
5
|
#
|
@@ -25,8 +25,12 @@ require_relative 'base_record'
|
|
25
25
|
|
26
26
|
module DcmDict
|
27
27
|
module Dictionary
|
28
|
+
using DcmDict::Refine::Internal::HashRefineInternal
|
29
|
+
|
28
30
|
UidMethodMap = {uid_value: :uid_value,
|
29
31
|
uid: :uid_value,
|
32
|
+
uid_key: :uid_key,
|
33
|
+
uid_sym: :uid_sym,
|
30
34
|
uid_name: :uid_name,
|
31
35
|
uid_type: :uid_type }.freeze
|
32
36
|
|
@@ -35,6 +39,7 @@ module DcmDict
|
|
35
39
|
# Class to handle uid record from source dictionary data
|
36
40
|
class UidRecord < BaseRecord
|
37
41
|
def initialize(data)
|
42
|
+
data.check_base_data_uid_field!
|
38
43
|
super
|
39
44
|
end
|
40
45
|
|
@@ -1,5 +1,5 @@
|
|
1
1
|
#
|
2
|
-
# Copyright (C) 2014-
|
2
|
+
# Copyright (C) 2014-2020 Enrico Rivarola
|
3
3
|
#
|
4
4
|
# This file is part of DcmDict gem (dcm_dict).
|
5
5
|
#
|
@@ -72,7 +72,7 @@ END
|
|
72
72
|
# Convert uid +data+ to Ruby code using +indent+ spaces indentation
|
73
73
|
def self.uid_data_to_code(data, indent=4)
|
74
74
|
indent = 4 unless indent
|
75
|
-
"#{' '*indent}{ uid_value: '#{data[:uid_value]}', uid_name:
|
75
|
+
"#{' '*indent}{ uid_value: '#{data[:uid_value]}', uid_name: '#{data[:uid_name]}', uid_key: '#{data[:uid_key]}', uid_sym: #{data[:uid_sym].inspect}, uid_type: #{data[:uid_type].inspect}},"
|
76
76
|
end
|
77
77
|
end
|
78
78
|
end
|