dcm_dict 0.1.0
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.
- checksums.yaml +7 -0
- data/COPYING +674 -0
- data/LICENSE +22 -0
- data/README.md +296 -0
- data/Rakefile +36 -0
- data/bin/dcm_dict_converter.rb +194 -0
- data/lib/dcm_dict.rb +46 -0
- data/lib/dcm_dict/dictionary/base_dictionary.rb +47 -0
- data/lib/dcm_dict/dictionary/base_record.rb +62 -0
- data/lib/dcm_dict/dictionary/data_element_dictionary.rb +117 -0
- data/lib/dcm_dict/dictionary/data_element_record.rb +93 -0
- data/lib/dcm_dict/dictionary/uid_dictionary.rb +82 -0
- data/lib/dcm_dict/dictionary/uid_record.rb +48 -0
- data/lib/dcm_dict/encoder/data_to_code.rb +79 -0
- data/lib/dcm_dict/error/dictionary_error.rb +30 -0
- data/lib/dcm_dict/ext/object_extension.rb +38 -0
- data/lib/dcm_dict/refine/array_refine.rb +34 -0
- data/lib/dcm_dict/refine/data_element_refine.rb +37 -0
- data/lib/dcm_dict/refine/internal/array_refine_internal.rb +97 -0
- data/lib/dcm_dict/refine/internal/hash_refine_internal.rb +71 -0
- data/lib/dcm_dict/refine/internal/string_refine_internal.rb +119 -0
- data/lib/dcm_dict/refine/string_refine.rb +35 -0
- data/lib/dcm_dict/refine/symbol_refine.rb +34 -0
- data/lib/dcm_dict/refine/uid_refine.rb +36 -0
- data/lib/dcm_dict/rubies/rb_ext.rb +32 -0
- data/lib/dcm_dict/source_data/data_elements_data.rb +3937 -0
- data/lib/dcm_dict/source_data/detached_data.rb +67 -0
- data/lib/dcm_dict/source_data/uid_values_data.rb +382 -0
- data/lib/dcm_dict/version.rb +27 -0
- data/lib/dcm_dict/xml/constant.rb +38 -0
- data/lib/dcm_dict/xml/field_data.rb +47 -0
- data/lib/dcm_dict/xml/nokogiri_tool.rb +108 -0
- data/lib/dcm_dict/xml/rexml_tool.rb +105 -0
- data/lib/dcm_dict/xml/tag_field_data.rb +96 -0
- data/lib/dcm_dict/xml/uid_field_data.rb +49 -0
- data/lib/dcm_dict/xml/xml_tool.rb +47 -0
- data/spec/data_element_sample_spec_helper.rb +110 -0
- data/spec/data_element_shared_example_spec_helper.rb +57 -0
- data/spec/dcm_dict/dictionary/data_element_dictionary_spec.rb +75 -0
- data/spec/dcm_dict/dictionary/data_element_record_spec.rb +117 -0
- data/spec/dcm_dict/dictionary/uid_dictionary_spec.rb +60 -0
- data/spec/dcm_dict/dictionary/uid_record_spec.rb +53 -0
- data/spec/dcm_dict/encoder/data_to_code_spec.rb +109 -0
- data/spec/dcm_dict/ext/object_extension_spec.rb +53 -0
- data/spec/dcm_dict/refine/array_refine_spec.rb +61 -0
- data/spec/dcm_dict/refine/internal/array_refine_internal_spec.rb +98 -0
- data/spec/dcm_dict/refine/internal/hash_refine_internal_spec.rb +64 -0
- data/spec/dcm_dict/refine/internal/string_refine_internal_spec.rb +214 -0
- data/spec/dcm_dict/refine/string_refine_spec.rb +87 -0
- data/spec/dcm_dict/refine/symbol_refine_spec.rb +41 -0
- data/spec/dcm_dict/rubies/rb_ext_spec.rb +46 -0
- data/spec/dcm_dict/source_data/data_elements_data_spec.rb +40 -0
- data/spec/dcm_dict/source_data/detached_data_spec.rb +55 -0
- data/spec/dcm_dict/source_data/uid_values_data_spec.rb +37 -0
- data/spec/dcm_dict/version_spec.rb +30 -0
- data/spec/dcm_dict/xml/tag_field_data_spec.rb +62 -0
- data/spec/dcm_dict/xml/uid_field_data_spec.rb +60 -0
- data/spec/dictionary_shared_example_spec_helper.rb +118 -0
- data/spec/refine_shared_example_spec_helper.rb +54 -0
- data/spec/spec_helper.rb +42 -0
- data/spec/xml_sample_spec_helper.rb +533 -0
- metadata +212 -0
@@ -0,0 +1,47 @@
|
|
1
|
+
#
|
2
|
+
# Copyright (C) 2014 Enrico Rivarola
|
3
|
+
#
|
4
|
+
# This file is part of DcmDict gem (dcm_dict).
|
5
|
+
#
|
6
|
+
# DcmDict is free software: you can redistribute it and/or modify
|
7
|
+
# it under the terms of the GNU General Public License as published by
|
8
|
+
# the Free Software Foundation, either version 3 of the License, or
|
9
|
+
# (at your option) any later version.
|
10
|
+
#
|
11
|
+
# DcmDict is distributed in the hope that it will be useful,
|
12
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
13
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
14
|
+
# GNU General Public License for more details.
|
15
|
+
#
|
16
|
+
# You should have received a copy of the GNU General Public License
|
17
|
+
# along with DcmDict. If not, see <http://www.gnu.org/licenses/>.
|
18
|
+
#
|
19
|
+
# This software has neither been tested nor approved for clinical use
|
20
|
+
# or for incorporation in a medical device.
|
21
|
+
# It is the redistributor's or user's responsibility to comply with any
|
22
|
+
# applicable local, state, national or international regulations.
|
23
|
+
#
|
24
|
+
#require_relative 'constant'
|
25
|
+
require_relative 'rexml_tool'
|
26
|
+
require_relative 'nokogiri_tool'
|
27
|
+
|
28
|
+
module DcmDict
|
29
|
+
module XML
|
30
|
+
|
31
|
+
# Main tool to handle xml data for uid and data element
|
32
|
+
module XmlTool
|
33
|
+
class << self
|
34
|
+
private
|
35
|
+
def xml_tool
|
36
|
+
XML.nokogiri_enable? ? NokogiriTool : RexmlTool
|
37
|
+
end
|
38
|
+
|
39
|
+
def method_missing(*args, &block)
|
40
|
+
m = args.shift
|
41
|
+
xml_tool.send(m, *args, &block)
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
end
|
47
|
+
end
|
@@ -0,0 +1,110 @@
|
|
1
|
+
#
|
2
|
+
# Copyright (C) 2014 Enrico Rivarola
|
3
|
+
#
|
4
|
+
# This file is part of DcmDict gem (dcm_dict).
|
5
|
+
#
|
6
|
+
# DcmDict is free software: you can redistribute it and/or modify
|
7
|
+
# it under the terms of the GNU General Public License as published by
|
8
|
+
# the Free Software Foundation, either version 3 of the License, or
|
9
|
+
# (at your option) any later version.
|
10
|
+
#
|
11
|
+
# DcmDict is distributed in the hope that it will be useful,
|
12
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
13
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
14
|
+
# GNU General Public License for more details.
|
15
|
+
#
|
16
|
+
# You should have received a copy of the GNU General Public License
|
17
|
+
# along with DcmDict. If not, see <http://www.gnu.org/licenses/>.
|
18
|
+
#
|
19
|
+
# This software has neither been tested nor approved for clinical use
|
20
|
+
# or for incorporation in a medical device.
|
21
|
+
# It is the redistributor's or user's responsibility to comply with any
|
22
|
+
# applicable local, state, national or international regulations.
|
23
|
+
#
|
24
|
+
require 'spec_helper'
|
25
|
+
module DataElementSampleSpecHelper
|
26
|
+
def self.private_creator_sample
|
27
|
+
{
|
28
|
+
[17,5] => {tag_ps: '(0011,0005)', tag_str: '(0011,0005)', tag_ary: [0x0011,0x0005],
|
29
|
+
tag_sym: :private_creator, tag_ndm: '00110005', tag_name: 'Private Creator',
|
30
|
+
tag_key: 'PrivateCreator', tag_vr: [:LO], tag_vm: ['1'], tag_note: 'Dummy Record',
|
31
|
+
tag_multiple: false},
|
32
|
+
'(0011,0005)' => {tag_ps: '(0011,0005)', tag_str: '(0011,0005)', tag_ary: [0x0011,0x0005],
|
33
|
+
tag_sym: :private_creator, tag_ndm: '00110005', tag_name: 'Private Creator',
|
34
|
+
tag_key: 'PrivateCreator', tag_vr: [:LO], tag_vm: ['1'], tag_note: 'Dummy Record',
|
35
|
+
tag_multiple: false},
|
36
|
+
'00110005' => {tag_ps: '(0011,0005)', tag_str: '(0011,0005)', tag_ary: [0x0011,0x0005],
|
37
|
+
tag_sym: :private_creator, tag_ndm: '00110005', tag_name: 'Private Creator',
|
38
|
+
tag_key: 'PrivateCreator', tag_vr: [:LO], tag_vm: ['1'], tag_note: 'Dummy Record',
|
39
|
+
tag_multiple: false}
|
40
|
+
}
|
41
|
+
end
|
42
|
+
|
43
|
+
def self.unknown_sample
|
44
|
+
{
|
45
|
+
[17,512] => {tag_ps: '(0011,0200)', tag_str: '(0011,0200)', tag_ary: [0x0011,0x0200],
|
46
|
+
tag_sym: :unknown_tag, tag_ndm: '00110200', tag_name: 'Unknown Tag',
|
47
|
+
tag_key: 'UnknownTag', tag_vr: [:UN], tag_vm: ['1'], tag_note: 'Dummy Record', tag_multiple: false},
|
48
|
+
[0x4444,0x1234] => {tag_ps: '(4444,1234)', tag_str: '(4444,1234)', tag_ary: [0x4444,0x1234],
|
49
|
+
tag_sym: :unknown_tag, tag_ndm: '44441234', tag_name: 'Unknown Tag',
|
50
|
+
tag_key: 'UnknownTag', tag_vr: [:UN], tag_vm: ['1'], tag_note: 'Dummy Record', tag_multiple: false},
|
51
|
+
'(4444,1234)' => {tag_ps: '(4444,1234)', tag_str: '(4444,1234)', tag_ary: [0x4444,0x1234],
|
52
|
+
tag_sym: :unknown_tag, tag_ndm: '44441234', tag_name: 'Unknown Tag',
|
53
|
+
tag_key: 'UnknownTag', tag_vr: [:UN], tag_vm: ['1'], tag_note: 'Dummy Record', tag_multiple: false},
|
54
|
+
'44441234' => {tag_ps: '(4444,1234)', tag_str: '(4444,1234)', tag_ary: [0x4444,0x1234],
|
55
|
+
tag_sym: :unknown_tag, tag_ndm: '44441234', tag_name: 'Unknown Tag',
|
56
|
+
tag_key: 'UnknownTag', tag_vr: [:UN], tag_vm: ['1'], tag_note: 'Dummy Record', tag_multiple: false},
|
57
|
+
}
|
58
|
+
end
|
59
|
+
|
60
|
+
def self.known_group_length_sample
|
61
|
+
{
|
62
|
+
[0,0] => { tag_ps: '(0000,0000)', tag_name: "Command Group Length", tag_key: 'CommandGroupLength',
|
63
|
+
tag_vr: [:UL], tag_vm: ["1"], tag_str: '(0000,0000)', tag_sym: :command_group_length,
|
64
|
+
tag_ndm: '00000000', tag_ary: [0, 0], tag_multiple: false,
|
65
|
+
tag_note: 'The even number of bytes from the end of the value field to the beginning of the next group.'}
|
66
|
+
}
|
67
|
+
end
|
68
|
+
|
69
|
+
def self.unknown_group_length_sample
|
70
|
+
{
|
71
|
+
[16,0] => {tag_ps: '(0010,0000)', tag_str: '(0010,0000)', tag_ary: [0x0010,0x0000],
|
72
|
+
tag_sym: :group_length, tag_ndm: '00100000', tag_name: 'Group Length',
|
73
|
+
tag_key: 'GroupLength', tag_vr: [:UL], tag_vm: ['1'], tag_note: 'Dummy Record',
|
74
|
+
tag_multiple: false},
|
75
|
+
[17,0] => {tag_ps: '(0011,0000)', tag_str: '(0011,0000)', tag_ary: [0x0011,0x0000],
|
76
|
+
tag_sym: :group_length, tag_ndm: '00110000', tag_name: 'Group Length',
|
77
|
+
tag_key: 'GroupLength', tag_vr: [:UL], tag_vm: ['1'], tag_note: 'Dummy Record',},
|
78
|
+
[0x4444,0x0000] => {tag_ps: '(4444,0000)', tag_str: '(4444,0000)', tag_ary: [0x4444,0x0000],
|
79
|
+
tag_sym: :group_length, tag_ndm: '44440000', tag_name: 'Group Length',
|
80
|
+
tag_key: 'GroupLength', tag_vr: [:UL], tag_vm: ['1'], tag_note: 'Dummy Record',
|
81
|
+
tag_multiple: false},
|
82
|
+
'44440000' => {tag_ps: '(4444,0000)', tag_str: '(4444,0000)', tag_ary: [0x4444,0x0000],
|
83
|
+
tag_sym: :group_length, tag_ndm: '44440000', tag_name: 'Group Length',
|
84
|
+
tag_key: 'GroupLength', tag_vr: [:UL], tag_vm: ['1'], tag_note: 'Dummy Record',
|
85
|
+
tag_multiple: false},
|
86
|
+
'(4444,0000)' => {tag_ps: '(4444,0000)', tag_str: '(4444,0000)', tag_ary: [0x4444,0x0000],
|
87
|
+
tag_sym: :group_length, tag_ndm: '44440000', tag_name: 'Group Length',
|
88
|
+
tag_key: 'GroupLength', tag_vr: [:UL], tag_vm: ['1'], tag_note: 'Dummy Record',
|
89
|
+
tag_multiple: false}
|
90
|
+
|
91
|
+
}
|
92
|
+
end
|
93
|
+
|
94
|
+
def self.multiple_tag_sample
|
95
|
+
{
|
96
|
+
# (60xx,0010) -> "Overlay Rows"
|
97
|
+
[0x60A2,0x0010] => { tag_ps: '(60XX,0010)', tag_name: "Overlay Rows", tag_key: 'OverlayRows', tag_vr: [:US], tag_vm: ["1"], tag_str: '(60A2,0010)', tag_sym: :overlay_rows, tag_ndm: '60A20010', tag_ary: [0x60a2,0x0010], tag_multiple: true, tag_note: ''},
|
98
|
+
'60A20010' => { tag_ps: '(60XX,0010)', tag_name: "Overlay Rows", tag_key: 'OverlayRows', tag_vr: [:US], tag_vm: ["1"], tag_str: '(60A2,0010)', tag_sym: :overlay_rows, tag_ndm: '60A20010', tag_ary: [0x60a2,0x0010], tag_multiple: true, tag_note: ''},
|
99
|
+
'(60A2,0010)' => { tag_ps: '(60XX,0010)', tag_name: "Overlay Rows", tag_key: 'OverlayRows', tag_vr: [:US], tag_vm: ["1"], tag_str: '(60A2,0010)', tag_sym: :overlay_rows, tag_ndm: '60A20010', tag_ary: [0x60a2,0x0010], tag_multiple: true, tag_note: ''},
|
100
|
+
'(6022,0010)' => { tag_ps: '(60XX,0010)', tag_name: "Overlay Rows", tag_key: 'OverlayRows', tag_vr: [:US], tag_vm: ["1"], tag_str: '(6022,0010)', tag_sym: :overlay_rows, tag_ndm: '60220010', tag_ary: [24610, 16], tag_multiple: true, tag_note: ''},
|
101
|
+
'OverlayRows' => { tag_ps: '(60XX,0010)', tag_name: "Overlay Rows", tag_key: 'OverlayRows', tag_vr: [:US], tag_vm: ["1"], tag_str: '(6022,0010)', tag_sym: :overlay_rows, tag_ndm: '60220010', tag_ary: [24610, 16], tag_multiple: true, tag_note: ''},
|
102
|
+
[0x6022,0x0010] => { tag_ps: '(60XX,0010)', tag_name: "Overlay Rows", tag_key: 'OverlayRows', tag_vr: [:US], tag_vm: ["1"], tag_str: '(6022,0010)', tag_sym: :overlay_rows, tag_ndm: '60220010', tag_ary: [24610, 16], tag_multiple: true, tag_note: ''},
|
103
|
+
[0x1010,0xa1b2] => { tag_ps: '(1010,XXXX)', tag_name: "Zonal Map", tag_key: 'ZonalMap', tag_vr: [:US], tag_vm: ["1-n"], tag_str: '(1010,A1B2)', tag_sym: :zonal_map, tag_ndm: '1010A1B2', tag_ary: [0x1010, 0xa1b2], tag_multiple: true, tag_note: 'RET'},
|
104
|
+
'(1010,A1B2)' => { tag_ps: '(1010,XXXX)', tag_name: "Zonal Map", tag_key: 'ZonalMap', tag_vr: [:US], tag_vm: ["1-n"], tag_str: '(1010,A1B2)', tag_sym: :zonal_map, tag_ndm: '1010A1B2', tag_ary: [0x1010, 0xa1b2], tag_multiple: true, tag_note: 'RET'},
|
105
|
+
'1010A1B2' => { tag_ps: '(1010,XXXX)', tag_name: "Zonal Map", tag_key: 'ZonalMap', tag_vr: [:US], tag_vm: ["1-n"], tag_str: '(1010,A1B2)', tag_sym: :zonal_map, tag_ndm: '1010A1B2', tag_ary: [0x1010, 0xa1b2], tag_multiple: true, tag_note: 'RET'},
|
106
|
+
'10100000' => { tag_ps: '(1010,0000)', tag_name: 'Group Length', tag_key: 'GroupLength', tag_vr: [:UL], tag_vm: ["1"], tag_str: '(1010,0000)', tag_sym: :group_length, tag_ndm: '10100000', tag_ary: [0x1010, 0x0000], tag_multiple: false, tag_note: 'Dummy Record'},
|
107
|
+
}
|
108
|
+
end
|
109
|
+
|
110
|
+
end
|
@@ -0,0 +1,57 @@
|
|
1
|
+
#
|
2
|
+
# Copyright (C) 2014 Enrico Rivarola
|
3
|
+
#
|
4
|
+
# This file is part of DcmDict gem (dcm_dict).
|
5
|
+
#
|
6
|
+
# DcmDict is free software: you can redistribute it and/or modify
|
7
|
+
# it under the terms of the GNU General Public License as published by
|
8
|
+
# the Free Software Foundation, either version 3 of the License, or
|
9
|
+
# (at your option) any later version.
|
10
|
+
#
|
11
|
+
# DcmDict is distributed in the hope that it will be useful,
|
12
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
13
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
14
|
+
# GNU General Public License for more details.
|
15
|
+
#
|
16
|
+
# You should have received a copy of the GNU General Public License
|
17
|
+
# along with DcmDict. If not, see <http://www.gnu.org/licenses/>.
|
18
|
+
#
|
19
|
+
# This software has neither been tested nor approved for clinical use
|
20
|
+
# or for incorporation in a medical device.
|
21
|
+
# It is the redistributor's or user's responsibility to comply with any
|
22
|
+
# applicable local, state, national or international regulations.
|
23
|
+
#
|
24
|
+
using DcmDict::Refine::ArrayRefine
|
25
|
+
using DcmDict::Refine::StringRefine
|
26
|
+
using DcmDict::Refine::SymbolRefine
|
27
|
+
|
28
|
+
RSpec.shared_examples "refinement for standard tag" do |tags, tag_proc|
|
29
|
+
describe "for standard tag" do
|
30
|
+
tags.each do |tag|
|
31
|
+
describe "as #{tag_proc.call(tag)}" do
|
32
|
+
obj = DcmDict::Dictionary::TheDataElementDictionary.record_at(tag)
|
33
|
+
DcmDict::Dictionary::DataElementMethod.each do |method|
|
34
|
+
expr = "#{tag_proc.call(tag)}.#{method.to_s}"
|
35
|
+
it "with #{expr} > #{obj.send(method).inspect}" do
|
36
|
+
value = eval(expr)
|
37
|
+
expect(value).to eq(obj.send(method))
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
RSpec.shared_examples "refinement for multiple tag" do |tag_data, tag_proc|
|
46
|
+
describe "for multiple tag" do
|
47
|
+
tag_data.each do |tag, data|
|
48
|
+
data.each do |key, exp_value|
|
49
|
+
expr = "#{tag_proc.call(tag)}.#{key}"
|
50
|
+
it "as #{expr} > #{exp_value.inspect}" do
|
51
|
+
value = eval(expr)
|
52
|
+
expect(value).to eq(exp_value)
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
@@ -0,0 +1,75 @@
|
|
1
|
+
#
|
2
|
+
# Copyright (C) 2014 Enrico Rivarola
|
3
|
+
#
|
4
|
+
# This file is part of DcmDict gem (dcm_dict).
|
5
|
+
#
|
6
|
+
# DcmDict is free software: you can redistribute it and/or modify
|
7
|
+
# it under the terms of the GNU General Public License as published by
|
8
|
+
# the Free Software Foundation, either version 3 of the License, or
|
9
|
+
# (at your option) any later version.
|
10
|
+
#
|
11
|
+
# DcmDict is distributed in the hope that it will be useful,
|
12
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
13
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
14
|
+
# GNU General Public License for more details.
|
15
|
+
#
|
16
|
+
# You should have received a copy of the GNU General Public License
|
17
|
+
# along with DcmDict. If not, see <http://www.gnu.org/licenses/>.
|
18
|
+
#
|
19
|
+
# This software has neither been tested nor approved for clinical use
|
20
|
+
# or for incorporation in a medical device.
|
21
|
+
# It is the redistributor's or user's responsibility to comply with any
|
22
|
+
# applicable local, state, national or international regulations.
|
23
|
+
#
|
24
|
+
require 'spec_helper'
|
25
|
+
require 'data_element_sample_spec_helper'
|
26
|
+
|
27
|
+
describe DcmDict::Dictionary::DataElementDictionary do
|
28
|
+
|
29
|
+
include_examples "Map all source data",
|
30
|
+
[:tag_ps, :tag_name, :tag_key, :tag_str, :tag_sym, :tag_ndm, :tag_ary],
|
31
|
+
DcmDict::SourceData::DataElementsData,
|
32
|
+
DcmDict::Dictionary::TheDataElementDictionary,
|
33
|
+
DcmDict::Dictionary::DataElementRecord,
|
34
|
+
[:tag_ps, :tag_name, :tag_key, :tag_vr, :tag_vm, :tag_str, :tag_sym,
|
35
|
+
:tag_ndm, :tag_ary, :tag_multiple, :tag_note]
|
36
|
+
|
37
|
+
DataElementSampleSpecHelper.unknown_group_length_sample.
|
38
|
+
merge(DataElementSampleSpecHelper.known_group_length_sample).
|
39
|
+
merge(DataElementSampleSpecHelper.private_creator_sample).
|
40
|
+
merge(DataElementSampleSpecHelper.unknown_sample).each do |tag, data|
|
41
|
+
include_examples "Handle specific record", "single tag",
|
42
|
+
tag, data, DcmDict::Dictionary::TheDataElementDictionary
|
43
|
+
end
|
44
|
+
|
45
|
+
DataElementSampleSpecHelper.multiple_tag_sample.each do |tag, data|
|
46
|
+
include_examples "Handle specific record", "multiple tag",
|
47
|
+
tag, data, DcmDict::Dictionary::TheDataElementDictionary
|
48
|
+
end
|
49
|
+
|
50
|
+
[nil,
|
51
|
+
123455,
|
52
|
+
'abracadabra',
|
53
|
+
Time.now,
|
54
|
+
[1234.5678, 1234]
|
55
|
+
].each do |wrong_tag|
|
56
|
+
include_examples "Dictionary with wrong key",
|
57
|
+
wrong_tag,
|
58
|
+
[:tag_ps, :tag_name, :tag_key, :tag_vr, :tag_vm, :tag_str,
|
59
|
+
:tag_sym, :tag_ndm, :tag_ary, :tag_multiple, :tag_note],
|
60
|
+
DcmDict::Dictionary::TheDataElementDictionary
|
61
|
+
end
|
62
|
+
|
63
|
+
include_examples "Dictionary Data not modifiable",
|
64
|
+
'(0002,0010)', :tag_ps, DcmDict::Dictionary::TheDataElementDictionary
|
65
|
+
|
66
|
+
include_examples "Concurrency support",
|
67
|
+
'(0002,0010)',
|
68
|
+
DcmDict::Dictionary::TheDataElementDictionary,
|
69
|
+
{ tag_ps: '(0002,0010)', tag_name: "Transfer Syntax UID",
|
70
|
+
tag_key: 'TransferSyntaxUID', tag_vr: [:UI], tag_vm: ["1"],
|
71
|
+
tag_str: '(0002,0010)', tag_sym: :transfer_syntax_uid,
|
72
|
+
tag_ndm: '00020010', tag_ary: [0x0002,0x0010],
|
73
|
+
tag_multiple: false, tag_note: ''}
|
74
|
+
|
75
|
+
end
|
@@ -0,0 +1,117 @@
|
|
1
|
+
#
|
2
|
+
# Copyright (C) 2014 Enrico Rivarola
|
3
|
+
#
|
4
|
+
# This file is part of DcmDict gem (dcm_dict).
|
5
|
+
#
|
6
|
+
# DcmDict is free software: you can redistribute it and/or modify
|
7
|
+
# it under the terms of the GNU General Public License as published by
|
8
|
+
# the Free Software Foundation, either version 3 of the License, or
|
9
|
+
# (at your option) any later version.
|
10
|
+
#
|
11
|
+
# DcmDict is distributed in the hope that it will be useful,
|
12
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
13
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
14
|
+
# GNU General Public License for more details.
|
15
|
+
#
|
16
|
+
# You should have received a copy of the GNU General Public License
|
17
|
+
# along with DcmDict. If not, see <http://www.gnu.org/licenses/>.
|
18
|
+
#
|
19
|
+
# This software has neither been tested nor approved for clinical use
|
20
|
+
# or for incorporation in a medical device.
|
21
|
+
# It is the redistributor's or user's responsibility to comply with any
|
22
|
+
# applicable local, state, national or international regulations.
|
23
|
+
#
|
24
|
+
require 'spec_helper'
|
25
|
+
|
26
|
+
|
27
|
+
|
28
|
+
describe DcmDict::Dictionary::DataElementRecord do
|
29
|
+
using DcmDict::Refine::Internal::ArrayRefineInternal
|
30
|
+
|
31
|
+
[
|
32
|
+
{tag_ps: '(0008,0010)',
|
33
|
+
tag_name: 'Recognition Code',
|
34
|
+
tag_key: 'RecognitionCode',
|
35
|
+
tag_vr: [:SH],
|
36
|
+
tag_vm: ['1'],
|
37
|
+
tag_note: 'RET',
|
38
|
+
tag_ary: [0x0008,0x0010],
|
39
|
+
tag_sym: :recognition_code,
|
40
|
+
tag_ndm: '00080010',
|
41
|
+
tag_str: '(0008,0010)',
|
42
|
+
tag_multiple: false
|
43
|
+
},
|
44
|
+
].each do |data|
|
45
|
+
it "Handle Data Element Data correctly" do
|
46
|
+
der = DcmDict::Dictionary::DataElementRecord.new(data)
|
47
|
+
expect(der.tag_ps).to eq(data[:tag_ps])
|
48
|
+
expect(der.tag_name).to eq(data[:tag_name])
|
49
|
+
expect(der.tag_keyword).to eq(data[:tag_key])
|
50
|
+
expect(der.tag_vr).to eq(data[:tag_vr])
|
51
|
+
expect(der.tag_vm).to eq(data[:tag_vm])
|
52
|
+
expect(der.tag_note).to eq(data[:tag_note])
|
53
|
+
expect(der.tag_ary).to eq(data[:tag_ary])
|
54
|
+
expect(der.tag).to eq(data[:tag_ary])
|
55
|
+
expect(der.tag_sym).to eq(data[:tag_sym])
|
56
|
+
expect(der.tag_ndm).to eq(data[:tag_ndm])
|
57
|
+
expect(der.tag_str).to eq(data[:tag_str])
|
58
|
+
expect(der.tag_multiple?).to eq(data[:tag_multiple])
|
59
|
+
|
60
|
+
data.each do |key, expected_val|
|
61
|
+
expect(der.send(key)).to eq(expected_val)
|
62
|
+
end
|
63
|
+
|
64
|
+
end
|
65
|
+
|
66
|
+
include_examples "Record handle methods correctly",
|
67
|
+
DcmDict::Dictionary::DataElementRecord.new(data),
|
68
|
+
data
|
69
|
+
|
70
|
+
|
71
|
+
it "Handle group and element with explicit method" do
|
72
|
+
der = DcmDict::Dictionary::DataElementRecord.new(data)
|
73
|
+
expect(der.tag_group).to eq(data[:tag_ary].tag_group_num)
|
74
|
+
expect(der.tag_element).to eq(data[:tag_ary].tag_element_num)
|
75
|
+
end
|
76
|
+
|
77
|
+
it "data should be not modifiable" do
|
78
|
+
der = DcmDict::Dictionary::DataElementRecord.new(data)
|
79
|
+
old_ps = der.tag_ps.dup
|
80
|
+
expect{der.tag_ps << 'aaa'}.to raise_error
|
81
|
+
expect(der.tag_ps).to eq(old_ps)
|
82
|
+
end
|
83
|
+
|
84
|
+
it "should extract multiple tag record only for specific tag" do
|
85
|
+
der = DcmDict::Dictionary::DataElementRecord.new(data)
|
86
|
+
mrec = der.extract_multiple_tag_record(data[:tag_ary])
|
87
|
+
expect(mrec).to be_nil
|
88
|
+
end
|
89
|
+
|
90
|
+
end
|
91
|
+
|
92
|
+
{
|
93
|
+
# { tag_ps: '(60xx,0010)', tag_name: "Overlay Rows", tag_key: 'OverlayRows', tag_vr: [:US], tag_vm: ["1"], tag_str: '(6022,0010)', tag_sym: :overlay_rows, tag_ndm: '60220010', tag_ary: [24610, 16], tag_multiple: true, tag_note: ''},
|
94
|
+
[
|
95
|
+
'(6068,0010)', '60680010', [0x6068,0x0010]
|
96
|
+
] => {
|
97
|
+
:source_data => { tag_ps: '(60XX,0010)', tag_name: "Overlay Rows", tag_key: 'OverlayRows', tag_vr: [:US], tag_vm: ["1"], tag_str: '(6022,0010)', tag_sym: :overlay_rows, tag_ndm: '60220010', tag_ary: [24610, 16], tag_multiple: true, tag_note: ''},
|
98
|
+
:specific_data => { tag_ps: '(60XX,0010)', tag_name: "Overlay Rows", tag_key: 'OverlayRows', tag_vr: [:US], tag_vm: ["1"], tag_str: '(6068,0010)', tag_sym: :overlay_rows, tag_ndm: '60680010', tag_ary: [0x6068,0x0010], tag_multiple: true, tag_note: ''} }
|
99
|
+
}.each do |keys, multi_data|
|
100
|
+
it "check match for multiple tag definition from #{keys[0].inspect}" do
|
101
|
+
der = DcmDict::Dictionary::DataElementRecord.new(multi_data[:source_data])
|
102
|
+
keys.each do |key|
|
103
|
+
expect(der.send(:match_tag?, key)).to be_truthy
|
104
|
+
end
|
105
|
+
end
|
106
|
+
|
107
|
+
it "generate equivalent record for specific tag from #{keys[0].inspect}" do
|
108
|
+
der_multi = DcmDict::Dictionary::DataElementRecord.new(multi_data[:source_data])
|
109
|
+
der = der_multi.extract_multiple_tag_record(multi_data[:specific_data][:tag_ary])
|
110
|
+
multi_data[:specific_data].each do |key, val|
|
111
|
+
expect(der.send(key)).to eq(val)
|
112
|
+
end
|
113
|
+
|
114
|
+
end
|
115
|
+
end
|
116
|
+
|
117
|
+
end
|
@@ -0,0 +1,60 @@
|
|
1
|
+
#
|
2
|
+
# This file is part of DcmDict gem (dcm_dict).
|
3
|
+
#
|
4
|
+
# DcmDict is free software: you can redistribute it and/or modify
|
5
|
+
# it under the terms of the GNU General Public License as published by
|
6
|
+
# the Free Software Foundation, either version 3 of the License, or
|
7
|
+
# (at your option) any later version.
|
8
|
+
#
|
9
|
+
# DcmDict is distributed in the hope that it will be useful,
|
10
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
11
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
12
|
+
# GNU General Public License for more details.
|
13
|
+
#
|
14
|
+
# You should have received a copy of the GNU General Public License
|
15
|
+
# along with DcmDict. If not, see <http://www.gnu.org/licenses/>.
|
16
|
+
#
|
17
|
+
# This software has neither been tested nor approved for clinical use
|
18
|
+
# or for incorporation in a medical device.
|
19
|
+
# It is the redistributor's or user's responsibility to comply with any
|
20
|
+
# applicable local, state, national or international regulations.
|
21
|
+
#
|
22
|
+
require 'spec_helper'
|
23
|
+
|
24
|
+
describe DcmDict::Dictionary::UidDictionary do
|
25
|
+
|
26
|
+
include_examples "Map all source data",
|
27
|
+
[:uid_value, :uid_name],
|
28
|
+
DcmDict::SourceData::UidValuesData,
|
29
|
+
DcmDict::Dictionary::TheUidDictionary,
|
30
|
+
DcmDict::Dictionary::UidRecord,
|
31
|
+
[:uid_value, :uid_name, :uid_type]
|
32
|
+
|
33
|
+
{
|
34
|
+
'1.2.3.4.5.6' => { :uid_value => '1.2.3.4.5.6',
|
35
|
+
:uid_name => 'Unknown UID',
|
36
|
+
:uid_type => :unknown }
|
37
|
+
}.each do |uid, data|
|
38
|
+
include_examples "Handle specific record", "unknown uid",
|
39
|
+
uid, data, DcmDict::Dictionary::TheUidDictionary
|
40
|
+
end
|
41
|
+
|
42
|
+
[
|
43
|
+
'1.2.abc.3.4', 'this string is not a valid uid', '1.2.3.04.5'
|
44
|
+
].each do |uid|
|
45
|
+
include_examples "Dictionary with wrong key",
|
46
|
+
uid, [:uid_value, :uid_name, :uid_type],
|
47
|
+
DcmDict::Dictionary::TheUidDictionary
|
48
|
+
end
|
49
|
+
|
50
|
+
include_examples "Dictionary Data not modifiable",
|
51
|
+
'1.2.840.10008.1.2', :uid_value, DcmDict::Dictionary::TheUidDictionary
|
52
|
+
|
53
|
+
|
54
|
+
include_examples "Concurrency support",
|
55
|
+
'1.2.840.10008.1.2',
|
56
|
+
DcmDict::Dictionary::TheUidDictionary,
|
57
|
+
{uid_value: '1.2.840.10008.1.2',
|
58
|
+
uid_name: "Implicit VR Little Endian: Default Transfer Syntax for DICOM",
|
59
|
+
uid_type: :transfer_syntax}
|
60
|
+
end
|