@exini/dicom-streams-js 3.0.9 → 3.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.
Files changed (162) hide show
  1. package/RELEASE-NOTES.md +10 -0
  2. package/coverage/base.css +224 -0
  3. package/coverage/block-navigation.js +87 -0
  4. package/coverage/dicom-streams-js/index.html +116 -0
  5. package/coverage/favicon.png +0 -0
  6. package/coverage/index.html +146 -0
  7. package/coverage/prettify.css +1 -0
  8. package/coverage/prettify.js +2 -0
  9. package/coverage/sort-arrow-sprite.png +0 -0
  10. package/coverage/sorter.js +196 -0
  11. package/dist/LICENSE +201 -0
  12. package/dist/README.md +157 -0
  13. package/{lib → dist/lib}/base.d.ts +0 -1
  14. package/{lib → dist/lib}/base.js +64 -65
  15. package/dist/lib/base.js.map +1 -0
  16. package/{lib → dist/lib}/byte-parser.d.ts +0 -1
  17. package/dist/lib/byte-parser.js.map +1 -0
  18. package/{lib → dist/lib}/character-sets.d.ts +0 -1
  19. package/{lib → dist/lib}/character-sets.js.map +1 -1
  20. package/{lib → dist/lib}/collect-flow.d.ts +0 -1
  21. package/{lib → dist/lib}/collect-flow.js +5 -6
  22. package/dist/lib/collect-flow.js.map +1 -0
  23. package/{lib → dist/lib}/detour.d.ts +0 -1
  24. package/dist/lib/detour.js.map +1 -0
  25. package/{lib → dist/lib}/dicom-elements.d.ts +0 -1
  26. package/dist/lib/dicom-elements.js.map +1 -0
  27. package/{lib → dist/lib}/dicom-flow.d.ts +5 -9
  28. package/{lib → dist/lib}/dicom-flow.js +20 -21
  29. package/dist/lib/dicom-flow.js.map +1 -0
  30. package/{lib → dist/lib}/dicom-flows.d.ts +0 -1
  31. package/{lib → dist/lib}/dicom-flows.js +14 -14
  32. package/dist/lib/dicom-flows.js.map +1 -0
  33. package/{lib → dist/lib}/dicom-parts.d.ts +0 -1
  34. package/dist/lib/dicom-parts.js.map +1 -0
  35. package/{lib → dist/lib}/element-flows.js +1 -2
  36. package/dist/lib/element-flows.js.map +1 -0
  37. package/{lib → dist/lib}/element-sink.d.ts +0 -1
  38. package/{lib → dist/lib}/element-sink.js +1 -2
  39. package/dist/lib/element-sink.js.map +1 -0
  40. package/dist/lib/elements-builder.js.map +1 -0
  41. package/{lib → dist/lib}/elements.d.ts +0 -1
  42. package/{lib → dist/lib}/elements.js +2 -2
  43. package/dist/lib/elements.js.map +1 -0
  44. package/{lib → dist/lib}/flows.d.ts +0 -1
  45. package/{lib → dist/lib}/flows.js +8 -9
  46. package/dist/lib/flows.js.map +1 -0
  47. package/{lib → dist/lib}/lookup.js +1 -1
  48. package/dist/lib/lookup.js.map +1 -0
  49. package/{lib → dist/lib}/modify-flow.d.ts +0 -1
  50. package/{lib → dist/lib}/modify-flow.js +2 -2
  51. package/dist/lib/modify-flow.js.map +1 -0
  52. package/{lib → dist/lib}/parse-flow.js +1 -2
  53. package/dist/lib/parse-flow.js.map +1 -0
  54. package/{lib → dist/lib}/parser.d.ts +0 -1
  55. package/{lib → dist/lib}/parser.js +36 -4
  56. package/dist/lib/parser.js.map +1 -0
  57. package/{lib → dist/lib}/parsing.d.ts +0 -1
  58. package/{lib → dist/lib}/parsing.js +9 -9
  59. package/dist/lib/parsing.js.map +1 -0
  60. package/{lib → dist/lib}/sinks.d.ts +0 -2
  61. package/{lib → dist/lib}/sinks.js +3 -4
  62. package/dist/lib/sinks.js.map +1 -0
  63. package/{lib → dist/lib}/sources.d.ts +0 -1
  64. package/{lib → dist/lib}/sources.js +2 -3
  65. package/dist/lib/sources.js.map +1 -0
  66. package/dist/lib/tag-path-like.js.map +1 -0
  67. package/dist/lib/tag-path.js.map +1 -0
  68. package/{lib → dist/lib}/tag-to-vr.js +1 -1
  69. package/dist/lib/tag-to-vr.js.map +1 -0
  70. package/dist/lib/tag-tree.js.map +1 -0
  71. package/{lib → dist/lib}/tag.js +448 -448
  72. package/dist/lib/tag.js.map +1 -0
  73. package/{lib → dist/lib}/uid-to-name.js +1 -1
  74. package/dist/lib/uid-to-name.js.map +1 -0
  75. package/{lib → dist/lib}/uid.js +71 -71
  76. package/dist/lib/uid.js.map +1 -0
  77. package/{lib → dist/lib}/value.d.ts +0 -1
  78. package/{lib → dist/lib}/value.js +2 -2
  79. package/dist/lib/value.js.map +1 -0
  80. package/{lib → dist/lib}/vr.js +1 -1
  81. package/dist/lib/vr.js.map +1 -0
  82. package/{node → dist/node}/index.js +693 -670
  83. package/dist/node/index.js.map +1 -0
  84. package/dist/node/index.min.js +1 -0
  85. package/dist/package.json +92 -0
  86. package/{web → dist/web}/index.js +706 -683
  87. package/dist/web/index.js.map +1 -0
  88. package/dist/web/index.min.js +2 -0
  89. package/{web → dist/web}/index.min.js.LICENSE.txt +1 -1
  90. package/example/data-model.png +0 -0
  91. package/example/detour-example.js +52 -0
  92. package/example/image/example-eb.dcm +0 -0
  93. package/example/image/example-ed.dcm +0 -0
  94. package/example/image/example-el-delimited.dcm +0 -0
  95. package/example/image/example-el.dcm +0 -0
  96. package/example/image/example-il.dcm +0 -0
  97. package/example/parse-log.js +13 -0
  98. package/example/parse-modify-log.js +43 -0
  99. package/example/parse-modify-write.js +40 -0
  100. package/package.json +11 -11
  101. package/typings/dicom-character-set/index.d.ts +5 -0
  102. package/typings/multipipe/index.d.ts +4 -0
  103. package/lib/base.js.map +0 -1
  104. package/lib/byte-parser.js.map +0 -1
  105. package/lib/collect-flow.js.map +0 -1
  106. package/lib/detour.js.map +0 -1
  107. package/lib/dicom-elements.js.map +0 -1
  108. package/lib/dicom-flow.js.map +0 -1
  109. package/lib/dicom-flows.js.map +0 -1
  110. package/lib/dicom-parts.js.map +0 -1
  111. package/lib/element-flows.js.map +0 -1
  112. package/lib/element-sink.js.map +0 -1
  113. package/lib/elements-builder.js.map +0 -1
  114. package/lib/elements.js.map +0 -1
  115. package/lib/flows.js.map +0 -1
  116. package/lib/lookup.js.map +0 -1
  117. package/lib/modify-flow.js.map +0 -1
  118. package/lib/parse-flow.js.map +0 -1
  119. package/lib/parser.js.map +0 -1
  120. package/lib/parsing.js.map +0 -1
  121. package/lib/sinks.js.map +0 -1
  122. package/lib/sources.js.map +0 -1
  123. package/lib/tag-path-like.js.map +0 -1
  124. package/lib/tag-path.js.map +0 -1
  125. package/lib/tag-to-vr.js.map +0 -1
  126. package/lib/tag-tree.js.map +0 -1
  127. package/lib/tag.js.map +0 -1
  128. package/lib/uid-to-name.js.map +0 -1
  129. package/lib/uid.js.map +0 -1
  130. package/lib/value.js.map +0 -1
  131. package/lib/vr.js.map +0 -1
  132. package/node/index.js.map +0 -1
  133. package/node/index.min.js +0 -1
  134. package/web/index.js.map +0 -1
  135. package/web/index.min.js +0 -2
  136. /package/{lib → dist/lib}/byte-parser.js +0 -0
  137. /package/{lib → dist/lib}/character-sets.js +0 -0
  138. /package/{lib → dist/lib}/detour.js +0 -0
  139. /package/{lib → dist/lib}/dicom-elements.js +0 -0
  140. /package/{lib → dist/lib}/dicom-parts.js +0 -0
  141. /package/{lib → dist/lib}/element-flows.d.ts +0 -0
  142. /package/{lib → dist/lib}/elements-builder.d.ts +0 -0
  143. /package/{lib → dist/lib}/elements-builder.js +0 -0
  144. /package/{lib → dist/lib}/index.d.ts +0 -0
  145. /package/{lib → dist/lib}/index.js +0 -0
  146. /package/{lib → dist/lib}/index.js.map +0 -0
  147. /package/{lib → dist/lib}/lookup.d.ts +0 -0
  148. /package/{lib → dist/lib}/parse-flow.d.ts +0 -0
  149. /package/{lib → dist/lib}/person-name.d.ts +0 -0
  150. /package/{lib → dist/lib}/person-name.js +0 -0
  151. /package/{lib → dist/lib}/person-name.js.map +0 -0
  152. /package/{lib → dist/lib}/tag-path-like.d.ts +0 -0
  153. /package/{lib → dist/lib}/tag-path-like.js +0 -0
  154. /package/{lib → dist/lib}/tag-path.d.ts +0 -0
  155. /package/{lib → dist/lib}/tag-path.js +0 -0
  156. /package/{lib → dist/lib}/tag-to-vr.d.ts +0 -0
  157. /package/{lib → dist/lib}/tag-tree.d.ts +0 -0
  158. /package/{lib → dist/lib}/tag-tree.js +0 -0
  159. /package/{lib → dist/lib}/tag.d.ts +0 -0
  160. /package/{lib → dist/lib}/uid-to-name.d.ts +0 -0
  161. /package/{lib → dist/lib}/uid.d.ts +0 -0
  162. /package/{lib → dist/lib}/vr.d.ts +0 -0
@@ -0,0 +1,196 @@
1
+ /* eslint-disable */
2
+ var addSorting = (function() {
3
+ 'use strict';
4
+ var cols,
5
+ currentSort = {
6
+ index: 0,
7
+ desc: false
8
+ };
9
+
10
+ // returns the summary table element
11
+ function getTable() {
12
+ return document.querySelector('.coverage-summary');
13
+ }
14
+ // returns the thead element of the summary table
15
+ function getTableHeader() {
16
+ return getTable().querySelector('thead tr');
17
+ }
18
+ // returns the tbody element of the summary table
19
+ function getTableBody() {
20
+ return getTable().querySelector('tbody');
21
+ }
22
+ // returns the th element for nth column
23
+ function getNthColumn(n) {
24
+ return getTableHeader().querySelectorAll('th')[n];
25
+ }
26
+
27
+ function onFilterInput() {
28
+ const searchValue = document.getElementById('fileSearch').value;
29
+ const rows = document.getElementsByTagName('tbody')[0].children;
30
+ for (let i = 0; i < rows.length; i++) {
31
+ const row = rows[i];
32
+ if (
33
+ row.textContent
34
+ .toLowerCase()
35
+ .includes(searchValue.toLowerCase())
36
+ ) {
37
+ row.style.display = '';
38
+ } else {
39
+ row.style.display = 'none';
40
+ }
41
+ }
42
+ }
43
+
44
+ // loads the search box
45
+ function addSearchBox() {
46
+ var template = document.getElementById('filterTemplate');
47
+ var templateClone = template.content.cloneNode(true);
48
+ templateClone.getElementById('fileSearch').oninput = onFilterInput;
49
+ template.parentElement.appendChild(templateClone);
50
+ }
51
+
52
+ // loads all columns
53
+ function loadColumns() {
54
+ var colNodes = getTableHeader().querySelectorAll('th'),
55
+ colNode,
56
+ cols = [],
57
+ col,
58
+ i;
59
+
60
+ for (i = 0; i < colNodes.length; i += 1) {
61
+ colNode = colNodes[i];
62
+ col = {
63
+ key: colNode.getAttribute('data-col'),
64
+ sortable: !colNode.getAttribute('data-nosort'),
65
+ type: colNode.getAttribute('data-type') || 'string'
66
+ };
67
+ cols.push(col);
68
+ if (col.sortable) {
69
+ col.defaultDescSort = col.type === 'number';
70
+ colNode.innerHTML =
71
+ colNode.innerHTML + '<span class="sorter"></span>';
72
+ }
73
+ }
74
+ return cols;
75
+ }
76
+ // attaches a data attribute to every tr element with an object
77
+ // of data values keyed by column name
78
+ function loadRowData(tableRow) {
79
+ var tableCols = tableRow.querySelectorAll('td'),
80
+ colNode,
81
+ col,
82
+ data = {},
83
+ i,
84
+ val;
85
+ for (i = 0; i < tableCols.length; i += 1) {
86
+ colNode = tableCols[i];
87
+ col = cols[i];
88
+ val = colNode.getAttribute('data-value');
89
+ if (col.type === 'number') {
90
+ val = Number(val);
91
+ }
92
+ data[col.key] = val;
93
+ }
94
+ return data;
95
+ }
96
+ // loads all row data
97
+ function loadData() {
98
+ var rows = getTableBody().querySelectorAll('tr'),
99
+ i;
100
+
101
+ for (i = 0; i < rows.length; i += 1) {
102
+ rows[i].data = loadRowData(rows[i]);
103
+ }
104
+ }
105
+ // sorts the table using the data for the ith column
106
+ function sortByIndex(index, desc) {
107
+ var key = cols[index].key,
108
+ sorter = function(a, b) {
109
+ a = a.data[key];
110
+ b = b.data[key];
111
+ return a < b ? -1 : a > b ? 1 : 0;
112
+ },
113
+ finalSorter = sorter,
114
+ tableBody = document.querySelector('.coverage-summary tbody'),
115
+ rowNodes = tableBody.querySelectorAll('tr'),
116
+ rows = [],
117
+ i;
118
+
119
+ if (desc) {
120
+ finalSorter = function(a, b) {
121
+ return -1 * sorter(a, b);
122
+ };
123
+ }
124
+
125
+ for (i = 0; i < rowNodes.length; i += 1) {
126
+ rows.push(rowNodes[i]);
127
+ tableBody.removeChild(rowNodes[i]);
128
+ }
129
+
130
+ rows.sort(finalSorter);
131
+
132
+ for (i = 0; i < rows.length; i += 1) {
133
+ tableBody.appendChild(rows[i]);
134
+ }
135
+ }
136
+ // removes sort indicators for current column being sorted
137
+ function removeSortIndicators() {
138
+ var col = getNthColumn(currentSort.index),
139
+ cls = col.className;
140
+
141
+ cls = cls.replace(/ sorted$/, '').replace(/ sorted-desc$/, '');
142
+ col.className = cls;
143
+ }
144
+ // adds sort indicators for current column being sorted
145
+ function addSortIndicators() {
146
+ getNthColumn(currentSort.index).className += currentSort.desc
147
+ ? ' sorted-desc'
148
+ : ' sorted';
149
+ }
150
+ // adds event listeners for all sorter widgets
151
+ function enableUI() {
152
+ var i,
153
+ el,
154
+ ithSorter = function ithSorter(i) {
155
+ var col = cols[i];
156
+
157
+ return function() {
158
+ var desc = col.defaultDescSort;
159
+
160
+ if (currentSort.index === i) {
161
+ desc = !currentSort.desc;
162
+ }
163
+ sortByIndex(i, desc);
164
+ removeSortIndicators();
165
+ currentSort.index = i;
166
+ currentSort.desc = desc;
167
+ addSortIndicators();
168
+ };
169
+ };
170
+ for (i = 0; i < cols.length; i += 1) {
171
+ if (cols[i].sortable) {
172
+ // add the click event handler on the th so users
173
+ // dont have to click on those tiny arrows
174
+ el = getNthColumn(i).querySelector('.sorter').parentElement;
175
+ if (el.addEventListener) {
176
+ el.addEventListener('click', ithSorter(i));
177
+ } else {
178
+ el.attachEvent('onclick', ithSorter(i));
179
+ }
180
+ }
181
+ }
182
+ }
183
+ // adds sorting functionality to the UI
184
+ return function() {
185
+ if (!getTable()) {
186
+ return;
187
+ }
188
+ cols = loadColumns();
189
+ loadData();
190
+ addSearchBox();
191
+ addSortIndicators();
192
+ enableUI();
193
+ };
194
+ })();
195
+
196
+ window.addEventListener('load', addSorting);
package/dist/LICENSE ADDED
@@ -0,0 +1,201 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ APPENDIX: How to apply the Apache License to your work.
179
+
180
+ To apply the Apache License to your work, attach the following
181
+ boilerplate notice, with the fields enclosed by brackets "[]"
182
+ replaced with your own identifying information. (Don't include
183
+ the brackets!) The text should be enclosed in the appropriate
184
+ comment syntax for the file format. We also recommend that a
185
+ file or class name and description of purpose be included on the
186
+ same "printed page" as the copyright notice for easier
187
+ identification within third-party archives.
188
+
189
+ Copyright [yyyy] [name of copyright owner]
190
+
191
+ Licensed under the Apache License, Version 2.0 (the "License");
192
+ you may not use this file except in compliance with the License.
193
+ You may obtain a copy of the License at
194
+
195
+ http://www.apache.org/licenses/LICENSE-2.0
196
+
197
+ Unless required by applicable law or agreed to in writing, software
198
+ distributed under the License is distributed on an "AS IS" BASIS,
199
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200
+ See the License for the specific language governing permissions and
201
+ limitations under the License.
package/dist/README.md ADDED
@@ -0,0 +1,157 @@
1
+ # dicom-streams-js
2
+
3
+ [![Build Status](https://travis-ci.org/exini/dicom-streams-js.svg?branch=develop)](https://travis-ci.org/exini/dicom-streams-js)
4
+ [![Coverage Status](https://coveralls.io/repos/exini/dicom-streams-js/badge.svg)](https://coveralls.io/r/exini/dicom-streams-js)
5
+
6
+ The purpose of this project is to create a streaming API for reading and processing DICOM data using [node-streams](https://nodejs.org/api/stream.html). It can be used both on the backend using Node, as well as on the frontend. Advantages of streaming DICOM data include better control over resource allocation such as memory via strict bounds on DICOM data chunk size and network utilization using back-pressure.
7
+
8
+ This project is a port of the [dicom-streams](https://github.com/exini/dicom-streams) project which is written in Scala using Akka-streams.
9
+
10
+ ### Setup
11
+
12
+ The dicom-streams-js library is deployed to NPM. Install it using `npm install -s @exini/dicom-streams-js`. Time and date handling using `js-joda` is marked as an external dependency in dicom-streams-js. If you want to read and modify times and dates, install this using `npm install -s js-joda`.
13
+
14
+ ### Data Model
15
+
16
+ Streaming binary DICOM data may originate from many different sources such as files, a HTTP POST request (on the server side), or a read from a database. Streaming data arrives in chunks (`Buffer`s). In the Node Streams nomenclature, chunks originate from _readables_, they are processed in _transforms_ and and folded into a non-streaming plain objects using _writables_. Synonyms for these terms are _sources_, _flows_ and _sinks_. These latter terms are used in the docs and throughout the code.
17
+
18
+ This library provides flows for parsing binary DICOM data into DICOM parts (represented by the `DicomPart` abstraction) - small objects representing a part of a data element. These DICOM parts are bounded in size by a user specified chunk size parameter. Flows of DICOM parts can be processed using a series of flows in this library. There are flows for filtering based on tag path conditions, flows for converting between transfer syntaxes, flows for re-encoding sequences and items, etc.
19
+
20
+ The `Element` interface provides a set of higher level data classes, each roughly corresponding to one row in a textual dump of a DICOM files. Here, chunks are aggregated into complete data elements. There are representations for standard tag-value elements, sequence and item start elements, sequence and item delimitation elements, fragments start elements, etc. A `DicomPart` stream is transformed into an `Element` stream via the `elementFlow` flow.
21
+
22
+ A flow of `Element`s can be materialized into a representation of a dataset called an `Elements` using the `elementSink` sink. For processing of large sets of data, one should strive for a fully streaming DICOM pipeline, however, in some cases it can be convenient to work with a plain dataset; `Elements` serves this purpose. Internally, the sink aggregates
23
+ `Element`s into `ElementSet`s, each with an asssociated tag number (value elements, sequences and fragments). `Elements` implements a straight-forward data hierarchy:
24
+
25
+ - An `Elements` holds a list of `ElementSet`s (`ValueElement`, `Sequence` and `Fragments`)
26
+ - A `ValueElement` is a standard attribute with tag number and binary value
27
+ - A `Sequence` holds a list of `Item`s
28
+ - An `Item` contains zero or one `Elements` (note the recursion)
29
+ - A `Fragments` holds a list of `Fragment`s
30
+ - A `Fragment` holds a binary value.
31
+
32
+ The following diagram shows an overview of the data model at the `DicomPart`, `Element` and `ElementSet` levels.
33
+
34
+ ![Data model](example/data-model.png)
35
+
36
+ As seen, a standard attribute, represented by the `ValueElement` class is composed by one `HeaderPart` followed by zero,
37
+ one or more `ValueChunk`s of data. Likewise, ecapsulated data such as a jpeg image is composed by one `FragmentsPart`
38
+ followed by, for each fragment, one `ItemPart` followed by `ValueChunk`s of data, and ends with a
39
+ `SequenceDelimitationPart`.
40
+
41
+ ### Examples
42
+
43
+ The following example reads the DICOM file provided as input argument, folds its contents first into a stream of `Element`s, and then into a concrete `Elements` object and logs the result to the console
44
+
45
+ ```javascript
46
+ const fs = require('fs');
47
+ const { parseFlow, elementFlow, elementSink, pipe, VR } = require('@exini/dicom-streams-js');
48
+
49
+ const src = fs.createReadStream(process.argv[2]);
50
+
51
+ pipe(
52
+ src,
53
+ parseFlow(),
54
+ elementFlow(),
55
+ elementSink((elements) => {
56
+ console.log(elements.toString());
57
+ }),
58
+ );
59
+ ```
60
+
61
+ The next, longer, example reads the file specified by the first input argument then passes the data through the following flows:
62
+
63
+ 1. Parsing the binary data into `DicomPart`s for further processing
64
+ 2. Re-encoding the data to always use indeterminate length sequences and items with explicit sequence and item delimitations
65
+ 3. Re-encoding the data to use the UTF-8 character set
66
+ 4. Filtering of the elements to preserve only those on a allow list specified as an array of `TagTree`s (trees of pointers into a dataset)
67
+ 5. Filtering of the remaining elements according to a deny list of tag trees
68
+ 6. Modification of the remaining elements to set Patient Name to `Anon 001`, add or modifiy the attribute Patient Identity Removed to `YES`, and leave other elements unmodified
69
+ 7. Map the resulting elements to their corresponding byte representations
70
+ 8. Write the results to disk using the file name specified by the second input argument.
71
+
72
+ ```javascript
73
+ const fs = require('fs');
74
+ const {
75
+ TagPath,
76
+ TagTree,
77
+ parseFlow,
78
+ toBytesFlow,
79
+ allowFilter,
80
+ denyFilter,
81
+ toUtf8Flow,
82
+ toIndeterminateLengthSequences,
83
+ modifyFlow,
84
+ TagModification,
85
+ TagInsertion,
86
+ pipe,
87
+ } = require('@exini/dicom-streams-js');
88
+
89
+ const src = fs.createReadStream(process.argv[2]);
90
+ const dest = fs.createWriteStream(process.argv[3]);
91
+
92
+ pipe(
93
+ src,
94
+ parseFlow(),
95
+ toIndeterminateLengthSequences(),
96
+ toUtf8Flow(),
97
+ allowFilter([
98
+ TagTree.fromTag(Tag.SpecificCharacterSet),
99
+ TagTree.fromTag(Tag.PatientName),
100
+ TagTree.fromTag(Tag.PatientName),
101
+ TagTree.fromTag(Tag.StudyDescription),
102
+ TagTree.fromTag(Tag.SeriesDate),
103
+ TagTree.fromAnyItem(Tag.MACParametersSequence),
104
+ ]),
105
+ denyFilter([TagTree.fromAnyItem(Tag.MACParametersSequence).thenTag(Tag.DataElementsSigned)]),
106
+ modifyFlow(
107
+ [TagModification.equals(TagPath.fromTag(Tag.PatientName), () => Buffer.from('Anon 001'))],
108
+ [new TagInsertion(TagPath.fromTag(Tag.PatientIdentityRemoved), () => Buffer.from('YES'))],
109
+ ),
110
+ toBytesFlow(),
111
+ dest,
112
+ );
113
+ ```
114
+
115
+ ### Custom Processing
116
+
117
+ New non-trivial DICOM flows can be built using a modular system of capabilities that are mixed in as appropriate with a core class implementing a common base interface. The base abstraction for DICOM flows is `DicomFlow` and new flows are created using the `DicomFlow.createFlow` method. The `DicomFlow` interface defines a series of events, one for each type of `DicomPart` that is produced when parsing DICOM data with `DicomParseFlow`. The core events are:
118
+
119
+ ```javascript
120
+ public onPreamble(part: PreamblePart): DicomPart[]
121
+ public onHeader(part: HeaderPart): DicomPart[]
122
+ public onValueChunk(part: ValueChunk): DicomPart[]
123
+ public onSequence(part: SequencePart): DicomPart[]
124
+ public onSequenceDelimitation(part: SequenceDelimitationPart): DicomPart[]
125
+ public onFragments(part: FragmentsPart): DicomPart[]
126
+ public onItem(part: ItemPart): DicomPart[]
127
+ public onItemDelimitation(part: ItemDelimitationPart): DicomPart[]
128
+ public onDeflatedChunk(part: DeflatedChunk): DicomPart[]
129
+ public onUnknown(part: UnknownPart): DicomPart[]
130
+ public onPart(part: DicomPart): DicomPart[]
131
+ ```
132
+
133
+ Default behavior to these events are implemented in core classes. The most natural behavior is to simply pass parts on
134
+ down the stream, e.g.
135
+
136
+ ```javascript
137
+ public onPreamble(part: PreamblePart): DicomPart[] { return [part]; }
138
+ public onHeader(part: HeaderPart): DicomPart[] { return [part]; }
139
+ ...
140
+ ```
141
+
142
+ This behavior is implemented in the `IdentityFlow` core class. Another option is to defer handling to the `onPart` method which is implemented in the `DeferToPartFlow` core class. This is appropriate for flows which define a common behavior for all part types.
143
+
144
+ To give an example of a custom flow, here is the implementation of a filter that removes nested sequences from a dataset. We define a nested dataset as a sequence with `depth > 1` given that the root dataset
145
+ has `depth = 0`.
146
+
147
+ ```javascript
148
+ public nestedSequencesFilter() = createFlow(new class extends TagPathTracking(GuaranteedValueEvent(GuaranteedDelimitationEvents(InFragments(DeferToPartFlow)))) {
149
+ public onPart(part: DicomPart): DicomPart[] { return this.tagPath.depth() > 1 ? [] : [part];
150
+ }());
151
+ ```
152
+
153
+ In this example, we chose to use `DeferToPartFlow` as the core class and mixed in the `TagPathTracking` capability (along with its dependencies `GuaranteedValueEvent`, `GuaranteedDelimitationEvents` and `InFragments`) which gives access to a `tagPath: TagPath` variable at all times which is automatically updated as the flow progresses.
154
+
155
+ ### License
156
+
157
+ This project is released under the [Apache License, version 2.0](./LICENSE).
@@ -1,4 +1,3 @@
1
- /// <reference types="node" />
2
1
  import { ZoneId } from 'js-joda';
3
2
  import * as CS from './character-sets';
4
3
  import { VR } from './vr';