dcmjs 0.49.4 → 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 +1059 -105
- package/build/dcmjs.es.js.map +1 -1
- package/build/dcmjs.js +1059 -105
- 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
package/test/sr-tid.test.js
DELETED
|
@@ -1,251 +0,0 @@
|
|
|
1
|
-
import { utilities } from "../src";
|
|
2
|
-
|
|
3
|
-
const {
|
|
4
|
-
Length,
|
|
5
|
-
Circle,
|
|
6
|
-
Polygon,
|
|
7
|
-
Polyline,
|
|
8
|
-
Ellipse,
|
|
9
|
-
Bidirectional,
|
|
10
|
-
Calibration
|
|
11
|
-
} = utilities.TID300;
|
|
12
|
-
|
|
13
|
-
describe("DICOM SR TID 300/1500 tests", () => {
|
|
14
|
-
describe("TID300 Creation", () => {
|
|
15
|
-
it("Polygon Create", () => {
|
|
16
|
-
const props = {
|
|
17
|
-
points: [
|
|
18
|
-
{ x: 3, y: 5 },
|
|
19
|
-
{ x: 6, y: 1 }
|
|
20
|
-
],
|
|
21
|
-
unit: "mm",
|
|
22
|
-
areaUnit: "mm2",
|
|
23
|
-
area: 3.14,
|
|
24
|
-
perimeter: 25
|
|
25
|
-
};
|
|
26
|
-
const polyline = new Polygon(props);
|
|
27
|
-
const value = polyline.contentItem();
|
|
28
|
-
expect(value.length).toBe(4);
|
|
29
|
-
const measured = value[2].MeasuredValueSequence;
|
|
30
|
-
expect(measured.NumericValue).toBe(props.perimeter);
|
|
31
|
-
expect(value[3].MeasuredValueSequence.NumericValue).toBe(
|
|
32
|
-
props.area
|
|
33
|
-
);
|
|
34
|
-
const units = measured.MeasurementUnitsCodeSequence;
|
|
35
|
-
expect(units.CodeValue).toBe("mm");
|
|
36
|
-
});
|
|
37
|
-
|
|
38
|
-
it("Polyline Create", () => {
|
|
39
|
-
const props = {
|
|
40
|
-
points: [
|
|
41
|
-
{ x: 3, y: 5 },
|
|
42
|
-
{ x: 6, y: 1 }
|
|
43
|
-
],
|
|
44
|
-
unit: "mm",
|
|
45
|
-
areaUnit: "mm2",
|
|
46
|
-
area: 3.14,
|
|
47
|
-
perimeter: 25
|
|
48
|
-
};
|
|
49
|
-
const polyline = new Polyline(props);
|
|
50
|
-
const value = polyline.contentItem();
|
|
51
|
-
expect(value.length).toBe(4);
|
|
52
|
-
const measured = value[2].MeasuredValueSequence;
|
|
53
|
-
expect(measured.NumericValue).toBe(props.perimeter);
|
|
54
|
-
expect(value[3].MeasuredValueSequence.NumericValue).toBe(
|
|
55
|
-
props.area
|
|
56
|
-
);
|
|
57
|
-
const units = measured.MeasurementUnitsCodeSequence;
|
|
58
|
-
expect(units.CodeValue).toBe("mm");
|
|
59
|
-
});
|
|
60
|
-
|
|
61
|
-
it("Ellipse Create", () => {
|
|
62
|
-
const r = 10;
|
|
63
|
-
const props = {
|
|
64
|
-
points: [
|
|
65
|
-
{ x: 3, y: 5 },
|
|
66
|
-
{ x: 6, y: 1 }
|
|
67
|
-
],
|
|
68
|
-
areaUnit: "mm\xB2",
|
|
69
|
-
area: 3.141592 * r * r
|
|
70
|
-
};
|
|
71
|
-
const circle = new Ellipse(props);
|
|
72
|
-
const value = circle.contentItem();
|
|
73
|
-
expect(value.length).toBe(3);
|
|
74
|
-
const measured = value[2].MeasuredValueSequence;
|
|
75
|
-
expect(measured.NumericValue).toBe(props.area);
|
|
76
|
-
const units = measured.MeasurementUnitsCodeSequence;
|
|
77
|
-
expect(units.CodeValue).toBe("mm2");
|
|
78
|
-
});
|
|
79
|
-
|
|
80
|
-
it("Bidirectional Create", () => {
|
|
81
|
-
const bidir = new Bidirectional({
|
|
82
|
-
longAxis: {
|
|
83
|
-
point1: { x: 3, y: 5 },
|
|
84
|
-
point2: { x: 6, y: 1 }
|
|
85
|
-
},
|
|
86
|
-
shortAxis: {
|
|
87
|
-
point1: { x: 3, y: 5 },
|
|
88
|
-
point2: { x: 6, y: 1 }
|
|
89
|
-
},
|
|
90
|
-
unit: "mm",
|
|
91
|
-
longAxisLength: 3.14,
|
|
92
|
-
shortAxisLenght: 1.5
|
|
93
|
-
});
|
|
94
|
-
const value = bidir.contentItem();
|
|
95
|
-
expect(value.length).toBe(4);
|
|
96
|
-
const measured = value[2].MeasuredValueSequence;
|
|
97
|
-
expect(measured.NumericValue).toBe(3.14);
|
|
98
|
-
const units = measured.MeasurementUnitsCodeSequence;
|
|
99
|
-
expect(units.CodeValue).toBe("mm");
|
|
100
|
-
});
|
|
101
|
-
|
|
102
|
-
it("Length Create", () => {
|
|
103
|
-
const length = new Length({
|
|
104
|
-
point1: { x: 3, y: 5 },
|
|
105
|
-
point2: { x: 6, y: 1 },
|
|
106
|
-
unit: "mm",
|
|
107
|
-
distance: 3.14
|
|
108
|
-
});
|
|
109
|
-
const value = length.contentItem();
|
|
110
|
-
expect(value.length).toBe(3);
|
|
111
|
-
const measured = value[2].MeasuredValueSequence;
|
|
112
|
-
expect(measured.NumericValue).toBe(3.14);
|
|
113
|
-
const units = measured.MeasurementUnitsCodeSequence;
|
|
114
|
-
expect(units.CodeValue).toBe("mm");
|
|
115
|
-
});
|
|
116
|
-
|
|
117
|
-
it("Circle Create", () => {
|
|
118
|
-
const r = 10;
|
|
119
|
-
const props = {
|
|
120
|
-
points: [
|
|
121
|
-
{ x: 3, y: 5 },
|
|
122
|
-
{ x: 6, y: 1 }
|
|
123
|
-
],
|
|
124
|
-
unit: "mm",
|
|
125
|
-
areaUnit: "mm\xB2",
|
|
126
|
-
perimeter: 2 * 3.141592 * r,
|
|
127
|
-
area: 3.141592 * r * r
|
|
128
|
-
};
|
|
129
|
-
const circle = new Circle(props);
|
|
130
|
-
const value = circle.contentItem();
|
|
131
|
-
expect(value.length).toBe(4);
|
|
132
|
-
const measured = value[3].MeasuredValueSequence;
|
|
133
|
-
expect(measured.NumericValue).toBe(props.area);
|
|
134
|
-
const units = measured.MeasurementUnitsCodeSequence;
|
|
135
|
-
expect(units.CodeValue).toBe("mm2");
|
|
136
|
-
});
|
|
137
|
-
|
|
138
|
-
it("Calibration Create", () => {
|
|
139
|
-
const calibration = new Calibration({
|
|
140
|
-
point1: { x: 3, y: 5 },
|
|
141
|
-
point2: { x: 6, y: 1 },
|
|
142
|
-
unit: "mm",
|
|
143
|
-
distance: 3.14
|
|
144
|
-
});
|
|
145
|
-
const value = calibration.contentItem();
|
|
146
|
-
expect(value.length).toBe(3);
|
|
147
|
-
const measured = value[2].MeasuredValueSequence;
|
|
148
|
-
expect(measured.NumericValue).toBe(3.14);
|
|
149
|
-
const units = measured.MeasurementUnitsCodeSequence;
|
|
150
|
-
expect(units.CodeValue).toBe("mm");
|
|
151
|
-
});
|
|
152
|
-
});
|
|
153
|
-
|
|
154
|
-
describe("Use Units", () => {
|
|
155
|
-
it("Length Units", () => {
|
|
156
|
-
const length = new Length({
|
|
157
|
-
point1: { x: 3, y: 5 },
|
|
158
|
-
point2: { x: 6, y: 1 },
|
|
159
|
-
unit: "px",
|
|
160
|
-
distance: 3.14
|
|
161
|
-
});
|
|
162
|
-
const value = length.contentItem();
|
|
163
|
-
expect(value.length).toBe(3);
|
|
164
|
-
const measured = value[2].MeasuredValueSequence;
|
|
165
|
-
expect(measured.NumericValue).toBe(3.14);
|
|
166
|
-
const units = measured.MeasurementUnitsCodeSequence;
|
|
167
|
-
expect(units.CodeValue).toBe("1");
|
|
168
|
-
});
|
|
169
|
-
|
|
170
|
-
it("Polygon Units", () => {
|
|
171
|
-
const props = {
|
|
172
|
-
points: [
|
|
173
|
-
{ x: 3, y: 5 },
|
|
174
|
-
{ x: 6, y: 1 }
|
|
175
|
-
],
|
|
176
|
-
unit: "px",
|
|
177
|
-
areaUnit: "px\xB2",
|
|
178
|
-
area: 3.14,
|
|
179
|
-
perimeter: 25
|
|
180
|
-
};
|
|
181
|
-
const polyline = new Polygon(props);
|
|
182
|
-
const value = polyline.contentItem();
|
|
183
|
-
expect(value.length).toBe(4);
|
|
184
|
-
const measured = value[2].MeasuredValueSequence;
|
|
185
|
-
expect(measured.NumericValue).toBe(props.perimeter);
|
|
186
|
-
const units = measured.MeasurementUnitsCodeSequence;
|
|
187
|
-
expect(units.CodeValue).toBe("1");
|
|
188
|
-
});
|
|
189
|
-
|
|
190
|
-
it("Polyline Units", () => {
|
|
191
|
-
const props = {
|
|
192
|
-
points: [
|
|
193
|
-
{ x: 3, y: 5 },
|
|
194
|
-
{ x: 6, y: 1 }
|
|
195
|
-
],
|
|
196
|
-
unit: "px",
|
|
197
|
-
areaUnit: "px\xB2",
|
|
198
|
-
area: 3.14,
|
|
199
|
-
perimeter: 25
|
|
200
|
-
};
|
|
201
|
-
const polyline = new Polyline(props);
|
|
202
|
-
const value = polyline.contentItem();
|
|
203
|
-
expect(value.length).toBe(4);
|
|
204
|
-
const measured = value[2].MeasuredValueSequence;
|
|
205
|
-
expect(measured.NumericValue).toBe(props.perimeter);
|
|
206
|
-
const units = measured.MeasurementUnitsCodeSequence;
|
|
207
|
-
expect(units.CodeValue).toBe("1");
|
|
208
|
-
});
|
|
209
|
-
|
|
210
|
-
it("Ellipse Unit", () => {
|
|
211
|
-
const r = 10;
|
|
212
|
-
const props = {
|
|
213
|
-
points: [
|
|
214
|
-
{ x: 3, y: 5 },
|
|
215
|
-
{ x: 6, y: 1 }
|
|
216
|
-
],
|
|
217
|
-
areaUnit: "px\xB2",
|
|
218
|
-
area: 3.141592 * r * r
|
|
219
|
-
};
|
|
220
|
-
const circle = new Ellipse(props);
|
|
221
|
-
const value = circle.contentItem();
|
|
222
|
-
expect(value.length).toBe(3);
|
|
223
|
-
const measured = value[2].MeasuredValueSequence;
|
|
224
|
-
expect(measured.NumericValue).toBe(props.area);
|
|
225
|
-
const units = measured.MeasurementUnitsCodeSequence;
|
|
226
|
-
expect(units.CodeValue).toBe("1");
|
|
227
|
-
});
|
|
228
|
-
|
|
229
|
-
it("Bidirectional Create", () => {
|
|
230
|
-
const bidir = new Bidirectional({
|
|
231
|
-
longAxis: {
|
|
232
|
-
point1: { x: 3, y: 5 },
|
|
233
|
-
point2: { x: 6, y: 1 }
|
|
234
|
-
},
|
|
235
|
-
shortAxis: {
|
|
236
|
-
point1: { x: 3, y: 5 },
|
|
237
|
-
point2: { x: 6, y: 1 }
|
|
238
|
-
},
|
|
239
|
-
unit: "px",
|
|
240
|
-
longAxisLength: 3.14,
|
|
241
|
-
shortAxisLenght: 1.5
|
|
242
|
-
});
|
|
243
|
-
const value = bidir.contentItem();
|
|
244
|
-
expect(value.length).toBe(4);
|
|
245
|
-
const measured = value[2].MeasuredValueSequence;
|
|
246
|
-
expect(measured.NumericValue).toBe(3.14);
|
|
247
|
-
const units = measured.MeasurementUnitsCodeSequence;
|
|
248
|
-
expect(units.CodeValue).toBe("1");
|
|
249
|
-
});
|
|
250
|
-
});
|
|
251
|
-
});
|
package/test/testUtils.js
DELETED
|
@@ -1,85 +0,0 @@
|
|
|
1
|
-
import fs from "fs";
|
|
2
|
-
import os from "os";
|
|
3
|
-
import path from "path";
|
|
4
|
-
import followRedirects from "follow-redirects";
|
|
5
|
-
import AdmZip from "adm-zip";
|
|
6
|
-
import { validationLog } from "./../src/log.js";
|
|
7
|
-
|
|
8
|
-
const { https } = followRedirects;
|
|
9
|
-
|
|
10
|
-
// Don't show validation errors, as those are normally tested
|
|
11
|
-
validationLog.setLevel(5);
|
|
12
|
-
|
|
13
|
-
function downloadToFile(url, filePath) {
|
|
14
|
-
return new Promise((resolve, reject) => {
|
|
15
|
-
const fileStream = fs.createWriteStream(filePath);
|
|
16
|
-
https
|
|
17
|
-
.get(url, response => {
|
|
18
|
-
response.pipe(fileStream);
|
|
19
|
-
fileStream.on("finish", () => {
|
|
20
|
-
resolve(filePath);
|
|
21
|
-
});
|
|
22
|
-
})
|
|
23
|
-
.on("error", reject);
|
|
24
|
-
});
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
function unzip(zipFilePath, targetPath) {
|
|
28
|
-
return new Promise((resolve, reject) => {
|
|
29
|
-
try {
|
|
30
|
-
// reading archives
|
|
31
|
-
var zip = new AdmZip(zipFilePath);
|
|
32
|
-
// extracts everything
|
|
33
|
-
zip.extractAllTo(targetPath, true);
|
|
34
|
-
resolve();
|
|
35
|
-
} catch (e) {
|
|
36
|
-
reject(e);
|
|
37
|
-
}
|
|
38
|
-
});
|
|
39
|
-
|
|
40
|
-
// This code is broken in Node 18+, creating garbage output
|
|
41
|
-
// return new Promise(resolve => {
|
|
42
|
-
// fs.createReadStream(zipFilePath).pipe(
|
|
43
|
-
// unzipper.Extract({ path: targetPath }).on("close", resolve)
|
|
44
|
-
// );
|
|
45
|
-
// });
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
function ensureTestDataDir() {
|
|
49
|
-
var targetPath = path.join(os.tmpdir(), "dcmjs-test");
|
|
50
|
-
if (!fs.existsSync(targetPath)) {
|
|
51
|
-
fs.mkdirSync(targetPath);
|
|
52
|
-
}
|
|
53
|
-
return targetPath;
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
async function getZippedTestDataset(url, filename, unpackDirectory) {
|
|
57
|
-
const dir = ensureTestDataDir();
|
|
58
|
-
const targetPath = path.join(dir, filename);
|
|
59
|
-
const unpackPath = path.join(dir, unpackDirectory);
|
|
60
|
-
if (!fs.existsSync(unpackPath)) {
|
|
61
|
-
await downloadToFile(url, targetPath);
|
|
62
|
-
await unzip(targetPath, unpackPath);
|
|
63
|
-
}
|
|
64
|
-
return unpackPath;
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
/**
|
|
68
|
-
* Stores the required downloads to prevent async reading before download completed.
|
|
69
|
-
*/
|
|
70
|
-
const asyncDownloadMap = new Map();
|
|
71
|
-
|
|
72
|
-
async function getTestDataset(url, filename) {
|
|
73
|
-
const dir = ensureTestDataDir();
|
|
74
|
-
const targetPath = path.join(dir, filename);
|
|
75
|
-
let filePromise = asyncDownloadMap.get(targetPath);
|
|
76
|
-
if (!filePromise && !fs.existsSync(targetPath)) {
|
|
77
|
-
filePromise = downloadToFile(url, targetPath);
|
|
78
|
-
asyncDownloadMap.set(targetPath, filePromise);
|
|
79
|
-
}
|
|
80
|
-
// This returns immediately if filePromise is undefined - eg if the file already downloaded.
|
|
81
|
-
await filePromise;
|
|
82
|
-
return targetPath;
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
export { getTestDataset, getZippedTestDataset };
|
|
@@ -1,87 +0,0 @@
|
|
|
1
|
-
import { deepEqual } from "../../src/utilities/deepEqual";
|
|
2
|
-
|
|
3
|
-
describe("deepEqual", () => {
|
|
4
|
-
test("returns true for identical primitives", () => {
|
|
5
|
-
expect(deepEqual(42, 42)).toBe(true);
|
|
6
|
-
expect(deepEqual("hello", "hello")).toBe(true);
|
|
7
|
-
expect(deepEqual(true, true)).toBe(true);
|
|
8
|
-
expect(deepEqual(null, null)).toBe(true);
|
|
9
|
-
});
|
|
10
|
-
|
|
11
|
-
test("returns false for different primitives", () => {
|
|
12
|
-
expect(deepEqual(42, 43)).toBe(false);
|
|
13
|
-
expect(deepEqual("hello", "world")).toBe(false);
|
|
14
|
-
expect(deepEqual(true, false)).toBe(false);
|
|
15
|
-
expect(deepEqual(null, undefined)).toBe(false);
|
|
16
|
-
});
|
|
17
|
-
|
|
18
|
-
test("returns same value check for signed zeros and special numbers", () => {
|
|
19
|
-
expect(deepEqual(Math.NaN, Math.NaN)).toBe(true);
|
|
20
|
-
expect(deepEqual(-0, 0)).toBe(false);
|
|
21
|
-
expect(deepEqual(-0, +0)).toBe(false);
|
|
22
|
-
});
|
|
23
|
-
|
|
24
|
-
test("returns true for deeply equal objects", () => {
|
|
25
|
-
const obj1 = { a: 1, b: { c: 2 } };
|
|
26
|
-
const obj2 = { a: 1, b: { c: 2 } };
|
|
27
|
-
expect(deepEqual(obj1, obj2)).toBe(true);
|
|
28
|
-
});
|
|
29
|
-
|
|
30
|
-
test("returns false for objects with different structures", () => {
|
|
31
|
-
const obj1 = { a: 1, b: { c: 2 } };
|
|
32
|
-
const obj2 = { a: 1, b: { d: 2 } };
|
|
33
|
-
expect(deepEqual(obj1, obj2)).toBe(false);
|
|
34
|
-
});
|
|
35
|
-
|
|
36
|
-
test("returns false for objects with different values", () => {
|
|
37
|
-
const obj1 = { a: 1, b: { c: 2 } };
|
|
38
|
-
const obj2 = { a: 1, b: { c: 3 } };
|
|
39
|
-
expect(deepEqual(obj1, obj2)).toBe(false);
|
|
40
|
-
});
|
|
41
|
-
|
|
42
|
-
test("returns true for deeply equal arrays", () => {
|
|
43
|
-
const arr1 = [1, 2, { a: 3 }];
|
|
44
|
-
const arr2 = [1, 2, { a: 3 }];
|
|
45
|
-
expect(deepEqual(arr1, arr2)).toBe(true);
|
|
46
|
-
});
|
|
47
|
-
|
|
48
|
-
test("returns false for arrays with different values", () => {
|
|
49
|
-
const arr1 = [1, 2, { a: 3 }];
|
|
50
|
-
const arr2 = [1, 2, { a: 4 }];
|
|
51
|
-
expect(deepEqual(arr1, arr2)).toBe(false);
|
|
52
|
-
});
|
|
53
|
-
|
|
54
|
-
test("returns false for objects compared with arrays", () => {
|
|
55
|
-
const obj = { a: 1, b: 2 };
|
|
56
|
-
const arr = [1, 2];
|
|
57
|
-
expect(deepEqual(obj, arr)).toBe(false);
|
|
58
|
-
});
|
|
59
|
-
|
|
60
|
-
test("returns false for different object types", () => {
|
|
61
|
-
const date1 = new Date(2024, 0, 1);
|
|
62
|
-
const obj1 = { a: 1, b: 2 };
|
|
63
|
-
expect(deepEqual(date1, obj1)).toBe(false);
|
|
64
|
-
});
|
|
65
|
-
|
|
66
|
-
test("returns true for nested objects with arrays", () => {
|
|
67
|
-
const obj1 = { a: 1, b: [1, 2, { c: 3 }] };
|
|
68
|
-
const obj2 = { a: 1, b: [1, 2, { c: 3 }] };
|
|
69
|
-
expect(deepEqual(obj1, obj2)).toBe(true);
|
|
70
|
-
});
|
|
71
|
-
|
|
72
|
-
test("returns false for functions, as they should not be equal", () => {
|
|
73
|
-
const obj1 = {
|
|
74
|
-
a: 1,
|
|
75
|
-
b: function () {
|
|
76
|
-
return 2;
|
|
77
|
-
}
|
|
78
|
-
};
|
|
79
|
-
const obj2 = {
|
|
80
|
-
a: 1,
|
|
81
|
-
b: function () {
|
|
82
|
-
return 2;
|
|
83
|
-
}
|
|
84
|
-
};
|
|
85
|
-
expect(deepEqual(obj1, obj2)).toBe(false);
|
|
86
|
-
});
|
|
87
|
-
});
|
package/test/utilities.test.js
DELETED
|
@@ -1,205 +0,0 @@
|
|
|
1
|
-
import dcmjs from "../src/index.js";
|
|
2
|
-
import dicomJson from "../src/utilities/dicomJson.js";
|
|
3
|
-
|
|
4
|
-
const { utilities } = dcmjs;
|
|
5
|
-
const { addAccessors } = utilities;
|
|
6
|
-
|
|
7
|
-
describe("dicomJson", () => {
|
|
8
|
-
describe("pnAddValueAccessors", () => {
|
|
9
|
-
it("recreates json object from string input", () => {
|
|
10
|
-
const value = new String("One\\Two");
|
|
11
|
-
const accessorValue = dicomJson.pnAddValueAccessors(value);
|
|
12
|
-
|
|
13
|
-
expect(value).toBe(accessorValue);
|
|
14
|
-
expect(JSON.stringify(value)).toEqual(
|
|
15
|
-
JSON.stringify([{ Alphabetic: "One" }, { Alphabetic: "Two" }])
|
|
16
|
-
);
|
|
17
|
-
expect(String(accessorValue)).toEqual("One\\Two");
|
|
18
|
-
});
|
|
19
|
-
|
|
20
|
-
it("recreates dicom string from json object", () => {
|
|
21
|
-
const value = [{ Alphabetic: "One" }, { Alphabetic: "Two" }];
|
|
22
|
-
const accessorValue = dicomJson.pnAddValueAccessors(value);
|
|
23
|
-
|
|
24
|
-
expect(value).toBe(accessorValue);
|
|
25
|
-
expect(JSON.stringify(value)).toEqual(
|
|
26
|
-
JSON.stringify([{ Alphabetic: "One" }, { Alphabetic: "Two" }])
|
|
27
|
-
);
|
|
28
|
-
expect(String(accessorValue)).toEqual("One\\Two");
|
|
29
|
-
});
|
|
30
|
-
});
|
|
31
|
-
|
|
32
|
-
describe("pnObjectToString", () => {
|
|
33
|
-
it("accepts undefined and empty", () => {
|
|
34
|
-
expect(dicomJson.pnObjectToString(undefined)).toEqual("");
|
|
35
|
-
expect(dicomJson.pnObjectToString(null)).toEqual("");
|
|
36
|
-
expect(dicomJson.pnObjectToString("")).toEqual("");
|
|
37
|
-
});
|
|
38
|
-
|
|
39
|
-
it("accepts json PNs", () => {
|
|
40
|
-
expect(dicomJson.pnObjectToString({ Alphabetic: "One" })).toEqual(
|
|
41
|
-
"One"
|
|
42
|
-
);
|
|
43
|
-
expect(dicomJson.pnObjectToString([{ Alphabetic: "One" }])).toEqual(
|
|
44
|
-
"One"
|
|
45
|
-
);
|
|
46
|
-
expect(
|
|
47
|
-
dicomJson.pnObjectToString([
|
|
48
|
-
{
|
|
49
|
-
Alphabetic: "One",
|
|
50
|
-
Ideographic: undefined,
|
|
51
|
-
Phonetic: undefined
|
|
52
|
-
}
|
|
53
|
-
])
|
|
54
|
-
).toEqual("One");
|
|
55
|
-
expect(
|
|
56
|
-
dicomJson.pnObjectToString([
|
|
57
|
-
{ Alphabetic: "One", Ideographic: "Two", Phonetic: "Three" }
|
|
58
|
-
])
|
|
59
|
-
).toEqual("One=Two=Three");
|
|
60
|
-
expect(
|
|
61
|
-
dicomJson.pnObjectToString([
|
|
62
|
-
{ Alphabetic: "One" },
|
|
63
|
-
{ Alphabetic: "Two" }
|
|
64
|
-
])
|
|
65
|
-
).toEqual("One\\Two");
|
|
66
|
-
});
|
|
67
|
-
|
|
68
|
-
it("accepts strings", () => {
|
|
69
|
-
expect(dicomJson.pnObjectToString("One")).toEqual("One");
|
|
70
|
-
expect(dicomJson.pnObjectToString(String("One"))).toEqual("One");
|
|
71
|
-
expect(dicomJson.pnObjectToString("One=Two\\Three\\Four")).toEqual(
|
|
72
|
-
"One=Two\\Three\\Four"
|
|
73
|
-
);
|
|
74
|
-
});
|
|
75
|
-
});
|
|
76
|
-
|
|
77
|
-
describe("pnConvertToJsonObject", () => {
|
|
78
|
-
it("accepts undefined", () => {
|
|
79
|
-
expect(dicomJson.pnConvertToJsonObject(undefined)).toEqual([]);
|
|
80
|
-
expect(dicomJson.pnConvertToJsonObject(undefined, false)).toEqual(
|
|
81
|
-
undefined
|
|
82
|
-
);
|
|
83
|
-
});
|
|
84
|
-
|
|
85
|
-
it("accepts a single name string", () => {
|
|
86
|
-
expect(dicomJson.pnConvertToJsonObject("One")).toEqual([
|
|
87
|
-
{ Alphabetic: "One" }
|
|
88
|
-
]);
|
|
89
|
-
expect(dicomJson.pnConvertToJsonObject("One==")).toEqual([
|
|
90
|
-
{ Alphabetic: "One" }
|
|
91
|
-
]);
|
|
92
|
-
expect(dicomJson.pnConvertToJsonObject("One=Two=")).toEqual([
|
|
93
|
-
{ Alphabetic: "One", Ideographic: "Two" }
|
|
94
|
-
]);
|
|
95
|
-
expect(dicomJson.pnConvertToJsonObject("One==Three")).toEqual([
|
|
96
|
-
{ Alphabetic: "One", Phonetic: "Three" }
|
|
97
|
-
]);
|
|
98
|
-
expect(dicomJson.pnConvertToJsonObject("One=Two=Three")).toEqual([
|
|
99
|
-
{ Alphabetic: "One", Ideographic: "Two", Phonetic: "Three" }
|
|
100
|
-
]);
|
|
101
|
-
expect(
|
|
102
|
-
dicomJson.pnConvertToJsonObject("One=Two=Three", false)
|
|
103
|
-
).toEqual({
|
|
104
|
-
Alphabetic: "One",
|
|
105
|
-
Ideographic: "Two",
|
|
106
|
-
Phonetic: "Three"
|
|
107
|
-
});
|
|
108
|
-
// Discard extraneous or empty values
|
|
109
|
-
expect(
|
|
110
|
-
dicomJson.pnConvertToJsonObject("One=Two=Three\\Four", false)
|
|
111
|
-
).toEqual({
|
|
112
|
-
Alphabetic: "One",
|
|
113
|
-
Ideographic: "Two",
|
|
114
|
-
Phonetic: "Three"
|
|
115
|
-
});
|
|
116
|
-
expect(dicomJson.pnConvertToJsonObject("\\One=Two=Three")).toEqual([
|
|
117
|
-
{
|
|
118
|
-
Alphabetic: "One",
|
|
119
|
-
Ideographic: "Two",
|
|
120
|
-
Phonetic: "Three"
|
|
121
|
-
}
|
|
122
|
-
]);
|
|
123
|
-
expect(
|
|
124
|
-
dicomJson.pnConvertToJsonObject("\\One=Two=Three", false)
|
|
125
|
-
).toEqual({
|
|
126
|
-
Alphabetic: "One",
|
|
127
|
-
Ideographic: "Two",
|
|
128
|
-
Phonetic: "Three"
|
|
129
|
-
});
|
|
130
|
-
});
|
|
131
|
-
|
|
132
|
-
it("accepts multiple name string", () => {
|
|
133
|
-
expect(
|
|
134
|
-
dicomJson.pnConvertToJsonObject("One=Two=Three\\Four=Five=Six")
|
|
135
|
-
).toEqual([
|
|
136
|
-
{ Alphabetic: "One", Ideographic: "Two", Phonetic: "Three" },
|
|
137
|
-
{ Alphabetic: "Four", Ideographic: "Five", Phonetic: "Six" }
|
|
138
|
-
]);
|
|
139
|
-
});
|
|
140
|
-
|
|
141
|
-
it("accepts objects", () => {
|
|
142
|
-
const jsonObj = {
|
|
143
|
-
Alphabetic: "One",
|
|
144
|
-
Ideographic: "Two",
|
|
145
|
-
Phonetic: "Three"
|
|
146
|
-
};
|
|
147
|
-
expect(dicomJson.pnConvertToJsonObject(jsonObj)).toEqual([jsonObj]);
|
|
148
|
-
expect(dicomJson.pnConvertToJsonObject(jsonObj, false)).toEqual(
|
|
149
|
-
jsonObj
|
|
150
|
-
);
|
|
151
|
-
expect(dicomJson.pnConvertToJsonObject([jsonObj])).toEqual([
|
|
152
|
-
jsonObj
|
|
153
|
-
]);
|
|
154
|
-
expect(dicomJson.pnConvertToJsonObject([jsonObj], false)).toEqual([
|
|
155
|
-
jsonObj
|
|
156
|
-
]);
|
|
157
|
-
});
|
|
158
|
-
});
|
|
159
|
-
});
|
|
160
|
-
|
|
161
|
-
describe("addAccessor", () => {
|
|
162
|
-
it("testAddAccessor", () => {
|
|
163
|
-
const baseValue = { a: 1, b: 2 };
|
|
164
|
-
const arrValue = [baseValue];
|
|
165
|
-
const val = addAccessors(arrValue);
|
|
166
|
-
expect(val.a).toEqual(1);
|
|
167
|
-
baseValue.a = 3;
|
|
168
|
-
expect(val.a).toEqual(3);
|
|
169
|
-
val.b = 4;
|
|
170
|
-
expect(baseValue.b).toEqual(4);
|
|
171
|
-
|
|
172
|
-
// Check that we can iterate as an array
|
|
173
|
-
const forArr = [];
|
|
174
|
-
val.forEach(item => forArr.push(item));
|
|
175
|
-
expect(forArr.length).toEqual(1);
|
|
176
|
-
expect(forArr[0]).toEqual(baseValue);
|
|
177
|
-
});
|
|
178
|
-
|
|
179
|
-
it("testAddAccessor-adds_children", () => {
|
|
180
|
-
const baseValue = { a: 1, b: 2 };
|
|
181
|
-
const arrValue = [baseValue];
|
|
182
|
-
const val = addAccessors(arrValue, baseValue);
|
|
183
|
-
val.push({ a: "two" });
|
|
184
|
-
expect(val.length).toBe(2);
|
|
185
|
-
expect(val[1].a).toBe("two");
|
|
186
|
-
expect(val.a).toBe(1);
|
|
187
|
-
expect(val[0].a).toBe(1);
|
|
188
|
-
});
|
|
189
|
-
|
|
190
|
-
it("Does not double proxy", () => {
|
|
191
|
-
const baseValue = { a: 1, b: 2 };
|
|
192
|
-
const arrValue = [baseValue];
|
|
193
|
-
const val = addAccessors(arrValue, baseValue);
|
|
194
|
-
expect(val).toEqual(addAccessors(val));
|
|
195
|
-
expect(val.__isProxy).toBe(true);
|
|
196
|
-
});
|
|
197
|
-
|
|
198
|
-
it("Handles non-array dest with no sqzero", () => {
|
|
199
|
-
const baseValue = { a: 1, b: 2 };
|
|
200
|
-
expect(Array.isArray(addAccessors(baseValue))).toBe(true);
|
|
201
|
-
expect(addAccessors("Hello")).toBe("Hello");
|
|
202
|
-
expect(addAccessors([baseValue])[0]).toBe(baseValue);
|
|
203
|
-
expect(addAccessors([baseValue, 2])[1]).toBe(2);
|
|
204
|
-
});
|
|
205
|
-
});
|
package/test/video-test-dict.js
DELETED
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
import { TagHex } from "../src/constants/dicom.js";
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* DICOM meta dict for video transfer syntax test
|
|
5
|
-
* This contains the file meta information (group 0002)
|
|
6
|
-
* Pixel data fragments are added separately in the test
|
|
7
|
-
*/
|
|
8
|
-
export const videoTestMeta = {
|
|
9
|
-
[TagHex.TransferSyntaxUID]: {
|
|
10
|
-
vr: "UI",
|
|
11
|
-
Value: ["1.2.840.10008.1.2.4.102"] // MPEG-4 AVC/H.264 High Profile / Level 4.1
|
|
12
|
-
},
|
|
13
|
-
[TagHex.MediaStorageSOPInstanceUID]: {
|
|
14
|
-
vr: "UI",
|
|
15
|
-
Value: ["1.2.3.4.5.6.7.8.9"]
|
|
16
|
-
},
|
|
17
|
-
[TagHex.MediaStorageSOPClassUID]: {
|
|
18
|
-
vr: "UI",
|
|
19
|
-
Value: ["1.2.840.10008.5.1.4.1.1.1"] // CR Image Storage
|
|
20
|
-
}
|
|
21
|
-
};
|
|
22
|
-
|
|
23
|
-
/**
|
|
24
|
-
* DICOM dataset dict for video transfer syntax test
|
|
25
|
-
* This contains the dataset elements (group 0008+)
|
|
26
|
-
*/
|
|
27
|
-
export const videoTestDict = {
|
|
28
|
-
[TagHex.Rows]: {
|
|
29
|
-
vr: "US",
|
|
30
|
-
Value: [512]
|
|
31
|
-
},
|
|
32
|
-
[TagHex.Columns]: {
|
|
33
|
-
vr: "US",
|
|
34
|
-
Value: [512]
|
|
35
|
-
},
|
|
36
|
-
[TagHex.NumberOfFrames]: {
|
|
37
|
-
vr: "IS",
|
|
38
|
-
Value: ["137"]
|
|
39
|
-
}
|
|
40
|
-
};
|