dcmjs 0.49.3 → 0.50.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.
- package/README.md +50 -0
- package/build/dcmjs.es.js +1071 -112
- package/build/dcmjs.es.js.map +1 -1
- package/build/dcmjs.js +1071 -112
- package/build/dcmjs.js.map +1 -1
- package/build/dcmjs.min.js +2 -2
- package/build/dcmjs.min.js.map +1 -1
- package/generate/dictionary.mjs +56029 -0
- package/package.json +18 -2
- package/.babelrc +0 -9
- package/.github/workflows/lint-and-format.yml +0 -27
- package/.github/workflows/publish-package.yml +0 -45
- package/.github/workflows/tests.yml +0 -24
- package/.prettierrc +0 -5
- package/.vscode/extensions.json +0 -7
- package/.vscode/settings.json +0 -8
- package/changelog.md +0 -31
- package/docs/ArrayBufferExpanderListener.md +0 -303
- package/docs/AsyncDicomReader-skill.md +0 -730
- package/eslint.config.mjs +0 -30
- package/generate-dictionary.js +0 -145
- package/jest.setup.js +0 -39
- package/netlify.toml +0 -22
- package/rollup.config.mjs +0 -57
- package/test/ArrayBufferExpanderListener.test.js +0 -365
- package/test/DICOMWEB.test.js +0 -1
- package/test/DicomMetaDictionary.test.js +0 -73
- package/test/SequenceOfItems.test.js +0 -86
- package/test/adapters.test.js +0 -43
- package/test/anonymizer.test.js +0 -176
- package/test/arrayItem.json +0 -351
- package/test/async-data.test.js +0 -575
- package/test/data-encoding.test.js +0 -59
- package/test/data-options.test.js +0 -199
- package/test/data.test.js +0 -1776
- package/test/derivations.test.js +0 -1
- package/test/helper/DicomDataReadBufferStreamBuilder.js +0 -89
- package/test/information-filter.test.js +0 -165
- package/test/integration/DicomMessage.readFile.test.js +0 -50
- package/test/lossless-read-write.test.js +0 -1407
- package/test/mocks/minimal_fields_dataset.json +0 -17
- package/test/mocks/null_number_vrs_dataset.json +0 -102
- package/test/normalizers.test.js +0 -38
- package/test/odd-frame-bit-data.js +0 -138
- package/test/rawTags.js +0 -170
- package/test/readBufferStream.test.js +0 -158
- package/test/sample-dicom.json +0 -904
- package/test/sample-op.lei +0 -0
- package/test/sample-sr.json +0 -997
- package/test/sr-tid.test.js +0 -251
- package/test/testUtils.js +0 -85
- package/test/utilities/deepEqual.test.js +0 -87
- package/test/utilities.test.js +0 -205
- package/test/video-test-dict.js +0 -40
- package/test/writeBufferStream.test.js +0 -149
|
@@ -1,199 +0,0 @@
|
|
|
1
|
-
import dcmjs from "../src/index.js";
|
|
2
|
-
import fs from "fs";
|
|
3
|
-
import path from "path";
|
|
4
|
-
import { promisify } from "util";
|
|
5
|
-
import fsPromises from "fs/promises";
|
|
6
|
-
import { getZippedTestDataset, getTestDataset } from "./testUtils.js";
|
|
7
|
-
|
|
8
|
-
const { DicomMetaDictionary, DicomMessage } = dcmjs.data;
|
|
9
|
-
|
|
10
|
-
const areEqual = (first, second) =>
|
|
11
|
-
first.byteLength === second.byteLength &&
|
|
12
|
-
first.every((value, index) => value === second[index]);
|
|
13
|
-
|
|
14
|
-
it("test_untilTag", () => {
|
|
15
|
-
const buffer = fs.readFileSync("test/sample-dicom.dcm");
|
|
16
|
-
console.time("readFile");
|
|
17
|
-
const fullData = DicomMessage.readFile(buffer.buffer);
|
|
18
|
-
console.timeEnd("readFile");
|
|
19
|
-
|
|
20
|
-
console.time("readFile without untilTag");
|
|
21
|
-
const dicomData = DicomMessage.readFile(buffer.buffer, {
|
|
22
|
-
untilTag: "7FE00010",
|
|
23
|
-
includeUntilTagValue: false
|
|
24
|
-
});
|
|
25
|
-
console.timeEnd("readFile without untilTag");
|
|
26
|
-
|
|
27
|
-
console.time("readFile with untilTag");
|
|
28
|
-
const dicomData2 = DicomMessage.readFile(buffer.buffer, {
|
|
29
|
-
untilTag: "7FE00010",
|
|
30
|
-
includeUntilTagValue: true
|
|
31
|
-
});
|
|
32
|
-
console.timeEnd("readFile with untilTag");
|
|
33
|
-
|
|
34
|
-
const full_dataset = DicomMetaDictionary.naturalizeDataset(fullData.dict);
|
|
35
|
-
full_dataset._meta = DicomMetaDictionary.namifyDataset(fullData.meta);
|
|
36
|
-
|
|
37
|
-
const dataset = DicomMetaDictionary.naturalizeDataset(dicomData.dict);
|
|
38
|
-
dataset._meta = DicomMetaDictionary.namifyDataset(dicomData.meta);
|
|
39
|
-
|
|
40
|
-
const dataset2 = DicomMetaDictionary.naturalizeDataset(dicomData2.dict);
|
|
41
|
-
dataset2._meta = DicomMetaDictionary.namifyDataset(dicomData2.meta);
|
|
42
|
-
|
|
43
|
-
expect(full_dataset.PixelData).toEqual(dataset2.PixelData);
|
|
44
|
-
expect(dataset.PixelData).toEqual(0);
|
|
45
|
-
});
|
|
46
|
-
|
|
47
|
-
it("noCopy multiframe DICOM which has trailing padding", async () => {
|
|
48
|
-
const url =
|
|
49
|
-
"https://github.com/dcmjs-org/data/releases/download/binary-parsing-stressors/multiframe-ultrasound.dcm";
|
|
50
|
-
const dcmPath = await getTestDataset(url, "multiframe-ultrasound.dcm");
|
|
51
|
-
const dicomDictNoCopy = DicomMessage.readFile(
|
|
52
|
-
fs.readFileSync(dcmPath).buffer,
|
|
53
|
-
{
|
|
54
|
-
noCopy: true
|
|
55
|
-
}
|
|
56
|
-
);
|
|
57
|
-
|
|
58
|
-
const dicomDict = DicomMessage.readFile(fs.readFileSync(dcmPath).buffer, {
|
|
59
|
-
noCopy: false
|
|
60
|
-
});
|
|
61
|
-
|
|
62
|
-
Object.keys(dicomDict.dict).map(key => {
|
|
63
|
-
const value = dicomDict.dict[key].Value;
|
|
64
|
-
if (value[0] instanceof ArrayBuffer) {
|
|
65
|
-
value.map((e, idx) => {
|
|
66
|
-
const noCopyValue = dicomDictNoCopy.dict[key].Value[idx];
|
|
67
|
-
const copyValue = new Uint8Array(e);
|
|
68
|
-
expect(areEqual(noCopyValue, copyValue)).toEqual(true);
|
|
69
|
-
});
|
|
70
|
-
}
|
|
71
|
-
});
|
|
72
|
-
});
|
|
73
|
-
|
|
74
|
-
it("noCopy multiframe DICOM with large private tags before and after the image data", async () => {
|
|
75
|
-
const url =
|
|
76
|
-
"https://github.com/dcmjs-org/data/releases/download/binary-parsing-stressors/large-private-tags.dcm";
|
|
77
|
-
const dcmPath = await getTestDataset(url, "large-private-tags.dcm");
|
|
78
|
-
|
|
79
|
-
const dicomDictNoCopy = DicomMessage.readFile(
|
|
80
|
-
fs.readFileSync(dcmPath).buffer,
|
|
81
|
-
{
|
|
82
|
-
noCopy: true
|
|
83
|
-
}
|
|
84
|
-
);
|
|
85
|
-
|
|
86
|
-
const dicomDict = DicomMessage.readFile(fs.readFileSync(dcmPath).buffer, {
|
|
87
|
-
noCopy: false
|
|
88
|
-
});
|
|
89
|
-
|
|
90
|
-
Object.keys(dicomDict.dict).map(key => {
|
|
91
|
-
const value = dicomDict.dict[key].Value;
|
|
92
|
-
if (value[0] instanceof ArrayBuffer) {
|
|
93
|
-
value.map((e, idx) => {
|
|
94
|
-
const noCopyValue = dicomDictNoCopy.dict[key].Value[idx];
|
|
95
|
-
const copyValue = new Uint8Array(e);
|
|
96
|
-
expect(areEqual(noCopyValue, copyValue)).toEqual(true);
|
|
97
|
-
});
|
|
98
|
-
}
|
|
99
|
-
});
|
|
100
|
-
});
|
|
101
|
-
|
|
102
|
-
it("noCopy binary data into an ArrayBuffer", async () => {
|
|
103
|
-
const url =
|
|
104
|
-
"https://github.com/dcmjs-org/data/releases/download/binary-tag/binary-tag.dcm";
|
|
105
|
-
const dcmPath = await getTestDataset(url, "binary-tag.dcm");
|
|
106
|
-
const fileData = await promisify(fs.readFile)(dcmPath);
|
|
107
|
-
|
|
108
|
-
const dicomDictNoCopy = DicomMessage.readFile(fileData.buffer, {
|
|
109
|
-
noCopy: true
|
|
110
|
-
});
|
|
111
|
-
|
|
112
|
-
const dicomDict = DicomMessage.readFile(fileData.buffer, {
|
|
113
|
-
noCopy: false
|
|
114
|
-
});
|
|
115
|
-
|
|
116
|
-
Object.keys(dicomDict.dict).map(key => {
|
|
117
|
-
const value = dicomDict.dict[key].Value;
|
|
118
|
-
if (value[0] instanceof ArrayBuffer) {
|
|
119
|
-
value.map((e, idx) => {
|
|
120
|
-
const noCopyValue = dicomDictNoCopy.dict[key].Value[idx];
|
|
121
|
-
const copyValue = new Uint8Array(e);
|
|
122
|
-
expect(areEqual(noCopyValue, copyValue)).toEqual(true);
|
|
123
|
-
});
|
|
124
|
-
}
|
|
125
|
-
});
|
|
126
|
-
});
|
|
127
|
-
|
|
128
|
-
it("noCopy test_multiframe_1", async () => {
|
|
129
|
-
const url =
|
|
130
|
-
"https://github.com/dcmjs-org/data/releases/download/MRHead/MRHead.zip";
|
|
131
|
-
|
|
132
|
-
const unzipPath = await getZippedTestDataset(
|
|
133
|
-
url,
|
|
134
|
-
"MRHead.zip",
|
|
135
|
-
"test_multiframe_1"
|
|
136
|
-
);
|
|
137
|
-
const mrHeadPath = path.join(unzipPath, "MRHead");
|
|
138
|
-
const fileNames = await fsPromises.readdir(mrHeadPath);
|
|
139
|
-
|
|
140
|
-
fileNames.forEach(fileName => {
|
|
141
|
-
const arrayBuffer = fs.readFileSync(
|
|
142
|
-
path.join(mrHeadPath, fileName)
|
|
143
|
-
).buffer;
|
|
144
|
-
const dicomDictNoCopy = DicomMessage.readFile(arrayBuffer, {
|
|
145
|
-
noCopy: true
|
|
146
|
-
});
|
|
147
|
-
const dicomDict = DicomMessage.readFile(arrayBuffer, {
|
|
148
|
-
noCopy: false
|
|
149
|
-
});
|
|
150
|
-
|
|
151
|
-
Object.keys(dicomDict.dict).map(key => {
|
|
152
|
-
const value = dicomDict.dict[key].Value;
|
|
153
|
-
if (value[0] instanceof ArrayBuffer) {
|
|
154
|
-
value.map((e, idx) => {
|
|
155
|
-
const noCopyValue = dicomDictNoCopy.dict[key].Value[idx];
|
|
156
|
-
const copyValue = new Uint8Array(e);
|
|
157
|
-
expect(areEqual(noCopyValue, copyValue)).toEqual(true);
|
|
158
|
-
});
|
|
159
|
-
}
|
|
160
|
-
});
|
|
161
|
-
});
|
|
162
|
-
});
|
|
163
|
-
|
|
164
|
-
it("noCopy test_fragment_multiframe", async () => {
|
|
165
|
-
const url =
|
|
166
|
-
"https://github.com/dcmjs-org/data/releases/download/encapsulation/encapsulation-fragment-multiframe.dcm";
|
|
167
|
-
const dcmPath = await getTestDataset(
|
|
168
|
-
url,
|
|
169
|
-
"encapsulation-fragment-multiframe-b.dcm"
|
|
170
|
-
);
|
|
171
|
-
const file = fs.readFileSync(dcmPath);
|
|
172
|
-
|
|
173
|
-
const dicomDict = dcmjs.data.DicomMessage.readFile(file.buffer, {
|
|
174
|
-
// ignoreErrors: true,
|
|
175
|
-
});
|
|
176
|
-
|
|
177
|
-
const dicomDictNoCopy = DicomMessage.readFile(file.buffer, {
|
|
178
|
-
noCopy: true
|
|
179
|
-
});
|
|
180
|
-
|
|
181
|
-
Object.keys(dicomDict.dict).map(key => {
|
|
182
|
-
const value = dicomDict.dict[key].Value;
|
|
183
|
-
if (value[0] instanceof ArrayBuffer) {
|
|
184
|
-
value.map((e, idx) => {
|
|
185
|
-
const noCopyValue = dicomDictNoCopy.dict[key].Value[idx];
|
|
186
|
-
const copyValue = new Uint8Array(e);
|
|
187
|
-
const areEqual = (first, second) =>
|
|
188
|
-
first.every((value, index) => value === second[index]);
|
|
189
|
-
|
|
190
|
-
const totalSize = noCopyValue.reduce(
|
|
191
|
-
(sum, arr) => sum + arr.byteLength,
|
|
192
|
-
0
|
|
193
|
-
);
|
|
194
|
-
expect(totalSize).toEqual(copyValue.length);
|
|
195
|
-
expect(areEqual(noCopyValue[0], copyValue)).toEqual(true);
|
|
196
|
-
});
|
|
197
|
-
}
|
|
198
|
-
});
|
|
199
|
-
});
|