@radicalimaging/static-wado-creator 0.6.4 → 1.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.
- package/CHANGELOG.md +67 -0
- package/README.md +3 -1
- package/lib/DeleteStudy.js +3 -3
- package/lib/StaticWado.js +24 -2
- package/lib/index.js +1 -0
- package/lib/indexMain.js +10 -0
- package/lib/mkdicomwebConfig.js +19 -4
- package/lib/model/TagLists.js +7 -7
- package/lib/model/uids.js +9 -10
- package/lib/operation/InstanceDeduplicate.js +8 -8
- package/lib/operation/StudyData.js +24 -23
- package/lib/operation/ThumbnailService.js +1 -1
- package/lib/operation/adapter/transcodeImage.js +33 -16
- package/lib/operation/getDataSet.js +1 -1
- package/lib/operation/getVR.js +1 -1
- package/lib/util/adaptProgramOpts.js +2 -0
- package/lib/util/compressionOptionParser.js +3 -3
- package/lib/writer/CompleteStudyWriter.js +4 -6
- package/lib/writer/DeduplicateWriter.js +2 -2
- package/lib/writer/HashDataWriter.js +2 -2
- package/lib/writer/ImageFrameWriter.js +27 -8
- package/lib/writer/RawDicomWriter.js +36 -0
- package/lib/writer/VideoWriter.js +1 -1
- package/package.json +8 -7
- package/lib/dictionary/Tags.js +0 -111
- package/lib/dictionary/dataDictionary.js +0 -22268
- package/lib/operation/adapter/asyncIterableToBuffer.js +0 -112
- package/lib/writer/JSONWriter.js +0 -18
|
@@ -1,112 +0,0 @@
|
|
|
1
|
-
const { Stats } = require("@radicalimaging/static-wado-util");
|
|
2
|
-
/* eslint "no-param-reassign": "off" */
|
|
3
|
-
|
|
4
|
-
const handler = {
|
|
5
|
-
get(obj, key) {
|
|
6
|
-
const ikey = parseInt(key);
|
|
7
|
-
if (ikey == key) return obj.index_get(ikey);
|
|
8
|
-
const handlerFunc = handler[key];
|
|
9
|
-
if (handlerFunc && key != "get") return handlerFunc(obj, key);
|
|
10
|
-
if (!obj._keys[key]) {
|
|
11
|
-
console.log("New call to", key);
|
|
12
|
-
obj._keys[key] = true;
|
|
13
|
-
}
|
|
14
|
-
return obj[key];
|
|
15
|
-
},
|
|
16
|
-
|
|
17
|
-
length: (obj) => obj.combinedLength,
|
|
18
|
-
};
|
|
19
|
-
|
|
20
|
-
const StreamingFunctions = {
|
|
21
|
-
addChunks(chunks) {
|
|
22
|
-
if (!this.chunks) this.chunks = [];
|
|
23
|
-
chunks.forEach((chunk) => this.chunks.push(chunk));
|
|
24
|
-
this.combinedLength = 0;
|
|
25
|
-
let i = 0;
|
|
26
|
-
this.chunks.forEach((chunk) => {
|
|
27
|
-
chunk.start = this.combinedLength;
|
|
28
|
-
chunk.i = i;
|
|
29
|
-
i += 1;
|
|
30
|
-
this.combinedLength += chunk.length;
|
|
31
|
-
});
|
|
32
|
-
this.lastChunk = this.chunks[0];
|
|
33
|
-
},
|
|
34
|
-
|
|
35
|
-
index_get(ikey) {
|
|
36
|
-
const found = this.findChunk(ikey);
|
|
37
|
-
if (!found) throw Error(`index ${ikey} not found between 0..${this.combinedLength}`);
|
|
38
|
-
return found[ikey - found.start];
|
|
39
|
-
},
|
|
40
|
-
|
|
41
|
-
findChunk(ikey) {
|
|
42
|
-
let i = (this.lastChunk.start <= ikey && this.lastChunk.i) || 0;
|
|
43
|
-
while (i < this.chunks.length) {
|
|
44
|
-
const chunk = this.chunks[i];
|
|
45
|
-
if (ikey >= chunk.start && ikey < chunk.start + chunk.length) {
|
|
46
|
-
this.lastChunk = chunk;
|
|
47
|
-
return chunk;
|
|
48
|
-
}
|
|
49
|
-
i += 1;
|
|
50
|
-
}
|
|
51
|
-
return undefined;
|
|
52
|
-
},
|
|
53
|
-
|
|
54
|
-
slice(start, end) {
|
|
55
|
-
const buflen = end - start;
|
|
56
|
-
const ret = Buffer.alloc(buflen);
|
|
57
|
-
let i = 0;
|
|
58
|
-
while (i < buflen) {
|
|
59
|
-
const chunk = this.findChunk(start + i);
|
|
60
|
-
const chunkI = start + i - chunk.start;
|
|
61
|
-
const useLen = Math.min(buflen, chunk.length - chunkI);
|
|
62
|
-
chunk.copy(ret, i, chunkI, chunkI + useLen);
|
|
63
|
-
i += useLen;
|
|
64
|
-
}
|
|
65
|
-
return ret;
|
|
66
|
-
},
|
|
67
|
-
|
|
68
|
-
hexSlice(start, end) {
|
|
69
|
-
return this.slice(start, end).hexSlice();
|
|
70
|
-
},
|
|
71
|
-
|
|
72
|
-
/** The internal node copy function is a native that directly accesses internal class details, so over-ride it.
|
|
73
|
-
* TODO: Make this efficient by using the internal copy function when available rather than copy one at a time.
|
|
74
|
-
*/
|
|
75
|
-
copy(target, targetStart = 0, srcStart = 0, srcEnd = 0) {
|
|
76
|
-
const { length } = target;
|
|
77
|
-
const srcLength = (srcEnd === undefined && Math.min(this.length, srcEnd)) || this.length;
|
|
78
|
-
const copied = 0;
|
|
79
|
-
while (targetStart < length && srcStart < srcLength) {
|
|
80
|
-
target[targetStart] = this[srcStart];
|
|
81
|
-
targetStart += 1;
|
|
82
|
-
srcStart += 1;
|
|
83
|
-
}
|
|
84
|
-
return copied;
|
|
85
|
-
},
|
|
86
|
-
|
|
87
|
-
_keys: { then: true, lastChunk: true, chunks: true },
|
|
88
|
-
};
|
|
89
|
-
|
|
90
|
-
Object.keys(StreamingFunctions).forEach((key) => {
|
|
91
|
-
StreamingFunctions._keys[key] = true;
|
|
92
|
-
});
|
|
93
|
-
|
|
94
|
-
const StreamingBuffer = (chunks) => {
|
|
95
|
-
const buf = Buffer.from("NotUsed");
|
|
96
|
-
Object.assign(buf, StreamingFunctions);
|
|
97
|
-
buf.addChunks(chunks);
|
|
98
|
-
return new Proxy(buf, handler);
|
|
99
|
-
};
|
|
100
|
-
|
|
101
|
-
const asyncIteratorToBuffer = async (readable) => {
|
|
102
|
-
if (ArrayBuffer.isView(readable)) return readable;
|
|
103
|
-
const chunks = [];
|
|
104
|
-
for await (const chunk of readable) {
|
|
105
|
-
chunks.push(chunk);
|
|
106
|
-
Stats.BufferStats.add("Read Async", `Read async buffer ${chunks.length}`, 1024);
|
|
107
|
-
}
|
|
108
|
-
Stats.BufferStats.reset();
|
|
109
|
-
return StreamingBuffer(chunks);
|
|
110
|
-
};
|
|
111
|
-
|
|
112
|
-
module.exports = asyncIteratorToBuffer;
|
package/lib/writer/JSONWriter.js
DELETED
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
const { Stats } = require("@radicalimaging/static-wado-util");
|
|
2
|
-
const path = require("path");
|
|
3
|
-
const WriteStream = require("./WriteStream");
|
|
4
|
-
|
|
5
|
-
/** Writes out JSON files to the given file name. Automatically GZips them, and adds the extension */
|
|
6
|
-
const JSONWriter = async (dir, name, data, options = { gzip: true, brotli: false, index: true }) => {
|
|
7
|
-
const fileName = options.index ? "index.json.gz" : name + ((options.gzip && ".gz") || (options.brotli && ".br") || "");
|
|
8
|
-
const dirName = options.index ? path.join(dir, name) : dir;
|
|
9
|
-
const writeStream = WriteStream(dirName, fileName, {
|
|
10
|
-
...options,
|
|
11
|
-
mkdir: true,
|
|
12
|
-
});
|
|
13
|
-
await writeStream.write(JSON.stringify(data));
|
|
14
|
-
await writeStream.close();
|
|
15
|
-
Stats.StudyStats.add("Write JSON", `Write JSON file ${name}`, 1000);
|
|
16
|
-
};
|
|
17
|
-
|
|
18
|
-
module.exports = JSONWriter;
|