dcmjs 0.24.3 → 0.24.4
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/package.json +2 -2
- package/test/data-options.test.js +15 -52
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dcmjs",
|
|
3
|
-
"version": "0.24.
|
|
3
|
+
"version": "0.24.4",
|
|
4
4
|
"description": "Javascript implementation of DICOM manipulation",
|
|
5
5
|
"main": "build/dcmjs.js",
|
|
6
6
|
"module": "build/dcmjs.es.js",
|
|
@@ -32,6 +32,7 @@
|
|
|
32
32
|
"acorn": "^7.1.0",
|
|
33
33
|
"acorn-jsx": "^5.2.0",
|
|
34
34
|
"eslint": "^8.17.0",
|
|
35
|
+
"eslint-config-prettier": "^8.5.0",
|
|
35
36
|
"follow-redirects": "^1.10.0",
|
|
36
37
|
"husky": "^1.3.1",
|
|
37
38
|
"jest": "^27.5.1",
|
|
@@ -49,7 +50,6 @@
|
|
|
49
50
|
},
|
|
50
51
|
"dependencies": {
|
|
51
52
|
"@babel/runtime-corejs2": "^7.17.8",
|
|
52
|
-
"eslint-config-prettier": "^8.5.0",
|
|
53
53
|
"gl-matrix": "^3.1.0",
|
|
54
54
|
"lodash.clonedeep": "^4.5.0",
|
|
55
55
|
"loglevelnext": "^3.0.1",
|
|
@@ -4,11 +4,9 @@ import dcmjs from "../src/index.js";
|
|
|
4
4
|
import fs from "fs";
|
|
5
5
|
import path from "path";
|
|
6
6
|
import os from "os";
|
|
7
|
-
import followRedirects from "follow-redirects";
|
|
8
|
-
const { https } = followRedirects;
|
|
9
7
|
import { promisify } from "util";
|
|
10
|
-
import unzipper from "unzipper";
|
|
11
8
|
import fsPromises from "fs/promises";
|
|
9
|
+
import { getZippedTestDataset, getTestDataset } from "./testUtils.js";
|
|
12
10
|
|
|
13
11
|
const {
|
|
14
12
|
DicomMetaDictionary,
|
|
@@ -17,20 +15,6 @@ const {
|
|
|
17
15
|
ReadBufferStream
|
|
18
16
|
} = dcmjs.data;
|
|
19
17
|
|
|
20
|
-
function downloadToFile(url, filePath) {
|
|
21
|
-
return new Promise((resolve, reject) => {
|
|
22
|
-
const fileStream = fs.createWriteStream(filePath);
|
|
23
|
-
https
|
|
24
|
-
.get(url, response => {
|
|
25
|
-
response.pipe(fileStream);
|
|
26
|
-
fileStream.on("finish", () => {
|
|
27
|
-
resolve(filePath);
|
|
28
|
-
});
|
|
29
|
-
})
|
|
30
|
-
.on("error", reject);
|
|
31
|
-
});
|
|
32
|
-
}
|
|
33
|
-
|
|
34
18
|
const areEqual = (first, second) =>
|
|
35
19
|
first.byteLength === second.byteLength &&
|
|
36
20
|
first.every((value, index) => value === second[index]);
|
|
@@ -69,20 +53,17 @@ it("test_untilTag", () => {
|
|
|
69
53
|
});
|
|
70
54
|
|
|
71
55
|
it("noCopy multiframe DICOM which has trailing padding", async () => {
|
|
72
|
-
const
|
|
56
|
+
const url =
|
|
73
57
|
"https://github.com/dcmjs-org/data/releases/download/binary-parsing-stressors/multiframe-ultrasound.dcm";
|
|
74
|
-
const
|
|
75
|
-
|
|
76
|
-
await downloadToFile(dicomUrl, dicomPath);
|
|
77
|
-
|
|
58
|
+
const dcmPath = await getTestDataset(url, "multiframe-ultrasound.dcm")
|
|
78
59
|
const dicomDictNoCopy = DicomMessage.readFile(
|
|
79
|
-
fs.readFileSync(
|
|
60
|
+
fs.readFileSync(dcmPath).buffer,
|
|
80
61
|
{
|
|
81
62
|
noCopy: true
|
|
82
63
|
}
|
|
83
64
|
);
|
|
84
65
|
|
|
85
|
-
const dicomDict = DicomMessage.readFile(fs.readFileSync(
|
|
66
|
+
const dicomDict = DicomMessage.readFile(fs.readFileSync(dcmPath).buffer, {
|
|
86
67
|
noCopy: false
|
|
87
68
|
});
|
|
88
69
|
|
|
@@ -99,20 +80,18 @@ it("noCopy multiframe DICOM which has trailing padding", async () => {
|
|
|
99
80
|
});
|
|
100
81
|
|
|
101
82
|
it("noCopy multiframe DICOM with large private tags before and after the image data", async () => {
|
|
102
|
-
const
|
|
83
|
+
const url =
|
|
103
84
|
"https://github.com/dcmjs-org/data/releases/download/binary-parsing-stressors/large-private-tags.dcm";
|
|
104
|
-
const
|
|
105
|
-
|
|
106
|
-
await downloadToFile(dicomUrl, dicomPath);
|
|
85
|
+
const dcmPath = await getTestDataset(url, "large-private-tags.dcm")
|
|
107
86
|
|
|
108
87
|
const dicomDictNoCopy = DicomMessage.readFile(
|
|
109
|
-
fs.readFileSync(
|
|
88
|
+
fs.readFileSync(dcmPath).buffer,
|
|
110
89
|
{
|
|
111
90
|
noCopy: true
|
|
112
91
|
}
|
|
113
92
|
);
|
|
114
93
|
|
|
115
|
-
const dicomDict = DicomMessage.readFile(fs.readFileSync(
|
|
94
|
+
const dicomDict = DicomMessage.readFile(fs.readFileSync(dcmPath).buffer, {
|
|
116
95
|
noCopy: false
|
|
117
96
|
});
|
|
118
97
|
|
|
@@ -129,12 +108,10 @@ it("noCopy multiframe DICOM with large private tags before and after the image d
|
|
|
129
108
|
});
|
|
130
109
|
|
|
131
110
|
it("noCopy binary data into an ArrayBuffer", async () => {
|
|
132
|
-
const
|
|
111
|
+
const url =
|
|
133
112
|
"https://github.com/dcmjs-org/data/releases/download/binary-tag/binary-tag.dcm";
|
|
134
|
-
const
|
|
135
|
-
|
|
136
|
-
await downloadToFile(dicomUrl, dicomPath);
|
|
137
|
-
const fileData = await promisify(fs.readFile)(dicomPath);
|
|
113
|
+
const dcmPath = await getTestDataset(url, "binary-tag.dcm")
|
|
114
|
+
const fileData = await promisify(fs.readFile)(dcmPath);
|
|
138
115
|
|
|
139
116
|
const dicomDictNoCopy = DicomMessage.readFile(fileData.buffer, {
|
|
140
117
|
noCopy: true
|
|
@@ -159,17 +136,8 @@ it("noCopy binary data into an ArrayBuffer", async () => {
|
|
|
159
136
|
it("noCopy test_multiframe_1", async () => {
|
|
160
137
|
const url =
|
|
161
138
|
"https://github.com/dcmjs-org/data/releases/download/MRHead/MRHead.zip";
|
|
162
|
-
|
|
163
|
-
const unzipPath =
|
|
164
|
-
|
|
165
|
-
await downloadToFile(url, zipFilePath);
|
|
166
|
-
|
|
167
|
-
await new Promise(resolve => {
|
|
168
|
-
fs.createReadStream(zipFilePath).pipe(
|
|
169
|
-
unzipper.Extract({ path: unzipPath }).on("close", resolve)
|
|
170
|
-
);
|
|
171
|
-
});
|
|
172
|
-
|
|
139
|
+
|
|
140
|
+
const unzipPath = await getZippedTestDataset(url, "MRHead.zip", "test_multiframe_1");
|
|
173
141
|
const mrHeadPath = path.join(unzipPath, "MRHead");
|
|
174
142
|
const fileNames = await fsPromises.readdir(mrHeadPath);
|
|
175
143
|
|
|
@@ -200,12 +168,7 @@ it("noCopy test_multiframe_1", async () => {
|
|
|
200
168
|
it("noCopy test_fragment_multiframe", async () => {
|
|
201
169
|
const url =
|
|
202
170
|
"https://github.com/dcmjs-org/data/releases/download/encapsulation/encapsulation-fragment-multiframe.dcm";
|
|
203
|
-
const dcmPath =
|
|
204
|
-
os.tmpdir(),
|
|
205
|
-
"encapsulation-fragment-multiframe.dcm"
|
|
206
|
-
);
|
|
207
|
-
|
|
208
|
-
await downloadToFile(url, dcmPath);
|
|
171
|
+
const dcmPath = await getTestDataset(url, "encapsulation-fragment-multiframe.dcm")
|
|
209
172
|
const file = fs.readFileSync(dcmPath);
|
|
210
173
|
|
|
211
174
|
const dicomDict = dcmjs.data.DicomMessage.readFile(file.buffer, {
|