@radicalimaging/static-wado-creator 1.3.2 → 1.5.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.
|
@@ -110,10 +110,6 @@ class ThumbnailService {
|
|
|
110
110
|
async generateThumbnails(itemId, dataSet, metadata, callback, options) {
|
|
111
111
|
const { imageFrame, id } = this.favoriteThumbnailObj;
|
|
112
112
|
|
|
113
|
-
if (!options.thumb) {
|
|
114
|
-
return null;
|
|
115
|
-
}
|
|
116
|
-
|
|
117
113
|
// There are various reasons no thumbnails might be generated, so just return
|
|
118
114
|
if (!id) {
|
|
119
115
|
const pixelData = metadata[Tags.PixelData];
|
|
@@ -133,6 +129,11 @@ class ThumbnailService {
|
|
|
133
129
|
}
|
|
134
130
|
return null;
|
|
135
131
|
}
|
|
132
|
+
|
|
133
|
+
if (!options.thumb) {
|
|
134
|
+
return null;
|
|
135
|
+
}
|
|
136
|
+
|
|
136
137
|
if (options.dcm2jpg) {
|
|
137
138
|
return this.dcm2jpg(id.filename, id.imageFrameRootPath.replace(/frames/, "thumbnail"), {});
|
|
138
139
|
}
|
|
@@ -286,6 +286,10 @@ async function generateLossyImage(id, decoded, options) {
|
|
|
286
286
|
}
|
|
287
287
|
}
|
|
288
288
|
|
|
289
|
+
function isPalette(dataSet) {
|
|
290
|
+
return dataSet.string(Tags.RawPhotometricInterpretation) === "PALETTE COLOR";
|
|
291
|
+
}
|
|
292
|
+
|
|
289
293
|
/**
|
|
290
294
|
* Transcode imageFrame. It uses transcodeMap to define the target encoding based on source encoding.
|
|
291
295
|
*
|
|
@@ -302,7 +306,7 @@ async function transcodeImageFrame(id, targetIdSrc, imageFrame, dataSet, options
|
|
|
302
306
|
|
|
303
307
|
const samplesPerPixel = dataSet.uint16(Tags.RawSamplesPerPixel);
|
|
304
308
|
const planarConfiguration = dataSet.uint16("x00280006");
|
|
305
|
-
if (!shouldTranscodeImageFrame(id, options, samplesPerPixel) || planarConfiguration === 1) {
|
|
309
|
+
if (!shouldTranscodeImageFrame(id, options, samplesPerPixel) || planarConfiguration === 1 || isPalette(dataSet)) {
|
|
306
310
|
console.verbose("Shouldn't transcode");
|
|
307
311
|
return {
|
|
308
312
|
id,
|
|
@@ -8,7 +8,9 @@ function decodeUtf8(s, options) {
|
|
|
8
8
|
}
|
|
9
9
|
|
|
10
10
|
/** Gets a value as a UTF-8 string - todo, make UTF-8 decode optional. */
|
|
11
|
-
const getValueInlineString = (dataSet, attr, options) => [
|
|
11
|
+
const getValueInlineString = (dataSet, attr, options) => [
|
|
12
|
+
decodeUtf8(dataSet.string(attr.tag), options),
|
|
13
|
+
];
|
|
12
14
|
|
|
13
15
|
const getStrings = (dataSet, attr, options) => {
|
|
14
16
|
const ret = dataSet.string(attr.tag);
|
|
@@ -20,21 +22,27 @@ const getStrings = (dataSet, attr, options) => {
|
|
|
20
22
|
|
|
21
23
|
const getValuePatientName = (dataSet, attr) => {
|
|
22
24
|
const strings = getStrings(dataSet, attr);
|
|
23
|
-
return (
|
|
25
|
+
return (
|
|
26
|
+
(strings && strings.map((item) => ({ Alphabetic: item }))) || undefined
|
|
27
|
+
);
|
|
24
28
|
};
|
|
25
29
|
|
|
26
30
|
/** Gets either InlineBinary or BulkDataURI, if already defined */
|
|
27
31
|
const getValueInlineBinary = (dataSet, attr) => {
|
|
28
32
|
if (attr.BulkDataURI) return { BulkDataURI: attr.BulkDataURI };
|
|
29
|
-
const binaryValue = dataSet.byteArray.slice(
|
|
33
|
+
const binaryValue = dataSet.byteArray.slice(
|
|
34
|
+
attr.dataOffset,
|
|
35
|
+
attr.dataOffset + attr.length
|
|
36
|
+
);
|
|
30
37
|
return { InlineBinary: binaryValue.toString("base64") };
|
|
31
38
|
};
|
|
32
39
|
|
|
33
40
|
const getValueInlineSignedShort = (dataSet, attr) => {
|
|
34
|
-
|
|
35
|
-
|
|
41
|
+
const ret = [];
|
|
42
|
+
for (let i = 0; i < attr.length / 2; i++) {
|
|
43
|
+
ret.push(dataSet.int16(attr.tag, i));
|
|
36
44
|
}
|
|
37
|
-
return
|
|
45
|
+
return ret;
|
|
38
46
|
};
|
|
39
47
|
|
|
40
48
|
const getValueInlineUnsignedShort = (dataSet, attr) => {
|
|
@@ -70,9 +78,11 @@ const getValueInlineFloat = (dataSet, attr) => {
|
|
|
70
78
|
return ret;
|
|
71
79
|
};
|
|
72
80
|
|
|
73
|
-
const getValueInlineIntString = (dataSet, attr) =>
|
|
81
|
+
const getValueInlineIntString = (dataSet, attr) =>
|
|
82
|
+
getStrings(dataSet, attr).map((val) => parseInt(val));
|
|
74
83
|
|
|
75
|
-
const getValueInlineFloatString = (dataSet, attr) =>
|
|
84
|
+
const getValueInlineFloatString = (dataSet, attr) =>
|
|
85
|
+
getStrings(dataSet, attr).map((val) => parseFloat(val));
|
|
76
86
|
|
|
77
87
|
const getValueInlineFloatDouble = (dataSet, attr) => {
|
|
78
88
|
if (attr.length > 8) {
|
|
@@ -177,15 +187,30 @@ const isValueInline = (attr, options) => {
|
|
|
177
187
|
* @param {*} parentAttr attr's parent. If not present means attr is at root level.
|
|
178
188
|
* @returns
|
|
179
189
|
*/
|
|
180
|
-
const getValue = async (
|
|
190
|
+
const getValue = async (
|
|
191
|
+
dataSet,
|
|
192
|
+
attr,
|
|
193
|
+
vr,
|
|
194
|
+
getDataSet,
|
|
195
|
+
callback,
|
|
196
|
+
options,
|
|
197
|
+
parentAttr
|
|
198
|
+
) => {
|
|
181
199
|
// It will only process pixelData tag if on metadata root. Otherwise it will be skiped.
|
|
182
200
|
if (attr.tag === "x7fe00010" && !parentAttr) {
|
|
183
|
-
const BulkDataURI = await extractImageFrames(
|
|
201
|
+
const BulkDataURI = await extractImageFrames(
|
|
202
|
+
dataSet,
|
|
203
|
+
attr,
|
|
204
|
+
vr,
|
|
205
|
+
callback,
|
|
206
|
+
options
|
|
207
|
+
);
|
|
184
208
|
return { BulkDataURI };
|
|
185
209
|
}
|
|
186
210
|
if (attr.tag === "xfffee00d") return undefined;
|
|
187
211
|
// Group length
|
|
188
|
-
if (attr.tag.length == 9 && attr.tag.substring(5, 9) === "0000")
|
|
212
|
+
if (attr.tag.length == 9 && attr.tag.substring(5, 9) === "0000")
|
|
213
|
+
return undefined;
|
|
189
214
|
if (attr.items) {
|
|
190
215
|
// sequences
|
|
191
216
|
const result = [];
|
|
@@ -202,7 +227,10 @@ const getValue = async (dataSet, attr, vr, getDataSet, callback, options, parent
|
|
|
202
227
|
if (isValueInline(attr, options)) {
|
|
203
228
|
return getValueInline(dataSet, attr, vr, options);
|
|
204
229
|
}
|
|
205
|
-
const binaryValue = dataSet.byteArray.slice(
|
|
230
|
+
const binaryValue = dataSet.byteArray.slice(
|
|
231
|
+
attr.dataOffset,
|
|
232
|
+
attr.dataOffset + attr.length
|
|
233
|
+
);
|
|
206
234
|
const mimeType = attr.tag == "x00420011" && dataSet.string("x00420012");
|
|
207
235
|
|
|
208
236
|
const BulkDataURI = await callback.bulkdata(binaryValue, { mimeType });
|
|
@@ -19,16 +19,23 @@ const VIDEO_TYPES = {
|
|
|
19
19
|
// TODO - add the new multi-segment MPEG2 and H264 variants
|
|
20
20
|
};
|
|
21
21
|
|
|
22
|
-
const isVideo = (value) =>
|
|
22
|
+
const isVideo = (value) =>
|
|
23
|
+
VIDEO_TYPES[
|
|
24
|
+
value && value.string ? value.string(Tags.RawTransferSyntaxUID) : value
|
|
25
|
+
];
|
|
23
26
|
|
|
24
27
|
const VideoWriter = () =>
|
|
25
28
|
async function run(id, dataSet) {
|
|
26
29
|
console.log(`Writing video ${id.sopInstanceUid}`);
|
|
27
30
|
const extension = VIDEO_TYPES[dataSet.string(Tags.RawTransferSyntaxUID)];
|
|
28
31
|
const filename = `index.${extension}`;
|
|
29
|
-
const writeStream = WriteStream(
|
|
30
|
-
|
|
31
|
-
|
|
32
|
+
const writeStream = WriteStream(
|
|
33
|
+
`${id.sopInstanceRootPath}/rendered`,
|
|
34
|
+
filename,
|
|
35
|
+
{
|
|
36
|
+
mkdir: true,
|
|
37
|
+
}
|
|
38
|
+
);
|
|
32
39
|
let length = 0;
|
|
33
40
|
const { fragments } = dataSet.elements.x7fe00010;
|
|
34
41
|
|
|
@@ -39,13 +46,18 @@ const VideoWriter = () =>
|
|
|
39
46
|
// The zero position fragment isn't available, even though present in the original data
|
|
40
47
|
for (let i = 0; i < fragments.length; i++) {
|
|
41
48
|
const fragment = fragments[i];
|
|
42
|
-
const blob = dataSet.byteArray.slice(
|
|
49
|
+
const blob = dataSet.byteArray.slice(
|
|
50
|
+
fragment.position,
|
|
51
|
+
fragment.position + fragment.length
|
|
52
|
+
);
|
|
43
53
|
length += blob.length;
|
|
44
54
|
await writeStream.write(blob);
|
|
45
55
|
}
|
|
46
56
|
await writeStream.close();
|
|
47
|
-
console.log(
|
|
48
|
-
|
|
57
|
+
console.log(
|
|
58
|
+
`Done video ${id.sopInstanceRootPath}\\${filename} of length ${length}`
|
|
59
|
+
);
|
|
60
|
+
return `series/${id.seriesInstanceUid}/instances/${id.sopInstanceUid}/rendered?length=${length}&offset=0&accept=video/mp4`;
|
|
49
61
|
};
|
|
50
62
|
|
|
51
63
|
module.exports = VideoWriter;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@radicalimaging/static-wado-creator",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.5.0",
|
|
4
4
|
"description": "Library to convert DICOMP10 to DICOMweb format. Original upstream: https://github.com/chafey/dicomp10-to-dicomweb-js",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public"
|
|
@@ -56,18 +56,18 @@
|
|
|
56
56
|
},
|
|
57
57
|
"dependencies": {
|
|
58
58
|
"@cornerstonejs/dicom-codec": ">=1.0.5",
|
|
59
|
-
"@radicalimaging/static-cs-lite": "^1.
|
|
60
|
-
"@radicalimaging/static-wado-util": "^1.
|
|
59
|
+
"@radicalimaging/static-cs-lite": "^1.5.0",
|
|
60
|
+
"@radicalimaging/static-wado-util": "^1.5.0",
|
|
61
61
|
"canvas": "^2.11.1",
|
|
62
62
|
"config-point": ">=0.5.1",
|
|
63
63
|
"dcmjs": "^0.29.5",
|
|
64
64
|
"dicom-parser": "^1.8.13",
|
|
65
65
|
"glob": "^7.2.0",
|
|
66
66
|
"node-object-hash": "^3.0.0",
|
|
67
|
+
"npmjs": "npm publish",
|
|
67
68
|
"uuid": "^8.3.2"
|
|
68
69
|
},
|
|
69
70
|
"devDependencies": {
|
|
70
71
|
"must": "^0.13.4"
|
|
71
|
-
}
|
|
72
|
-
"gitHead": "202e8673a2c9618f441023c8382187ae7fdf5b1a"
|
|
72
|
+
}
|
|
73
73
|
}
|
package/license.md
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
MIT License
|
|
2
|
-
|
|
3
|
-
Copyright (c) 2024 Radical Imaging Inc
|
|
4
|
-
|
|
5
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
-
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
-
in the Software without restriction, including without limitation the rights
|
|
8
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
-
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
-
furnished to do so, subject to the following conditions:
|
|
11
|
-
|
|
12
|
-
The above copyright notice and this permission notice shall be included in all
|
|
13
|
-
copies or substantial portions of the Software.
|
|
14
|
-
|
|
15
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
-
SOFTWARE.
|