@radicalimaging/static-wado-creator 1.5.0 → 1.6.10
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 +234 -0
- package/README.md +1 -1
- package/bin/mkdicomweb.mjs +8 -0
- package/dist/canvas-xaqc8v6y.node +0 -0
- package/dist/index.js +481518 -0
- package/lib/DeleteStudy.js +9 -2
- package/lib/RejectInstance.js +15 -3
- package/lib/StaticWado.js +245 -41
- package/lib/createPart10.js +8 -4
- package/lib/createThumbnail.js +181 -0
- package/lib/index.js +2 -0
- package/lib/instanceMain.js +1 -0
- package/lib/mkdicomwebConfig.js +122 -19
- package/lib/model/TagLists.js +24 -3
- package/lib/model/uids.js +5 -1
- package/lib/operation/InstanceDeduplicate.js +14 -4
- package/lib/operation/ScanStudy.js +38 -5
- package/lib/operation/StudyData.js +158 -38
- package/lib/operation/ThumbnailService.js +60 -27
- package/lib/operation/adapter/decodeImage.js +5 -2
- package/lib/operation/adapter/getImageInfo.js +19 -1
- package/lib/operation/adapter/transcodeImage.js +170 -52
- package/lib/operation/extractImageFrames.js +19 -4
- package/lib/operation/getDataSet.js +41 -7
- package/lib/operation/getEncapsulatedImageFrame.js +30 -6
- package/lib/operation/getUncompressedImageFrame.js +10 -2
- package/lib/operation/getVR.js +10 -2
- package/lib/operation/getValue.js +4 -4
- package/lib/operation/validateMetadata.js +40 -0
- package/lib/program/index.js +5 -3
- package/lib/serverMain.js +27 -0
- package/lib/util/IdCreator.js +32 -6
- package/lib/util/adaptProgramOpts.js +1 -1
- package/lib/util/compressionOptionParser.js +12 -3
- package/lib/util/resultsReport.ts +88 -0
- package/lib/writer/CompleteStudyWriter.js +49 -13
- package/lib/writer/DeduplicateWriter.js +2 -1
- package/lib/writer/ExpandUriPath.js +4 -1
- package/lib/writer/HashDataWriter.js +5 -1
- package/lib/writer/ImageFrameWriter.js +38 -13
- package/lib/writer/RawDicomWriter.js +11 -2
- package/lib/writer/VideoWriter.js +3 -3
- package/lib/writer/WriteMultipart.js +3 -1
- package/lib/writer/WriteStream.js +12 -4
- package/lib/writer/static-dicomweb.code-workspace +8 -0
- package/package.json +22 -18
- package/bin/mkdicomweb.js +0 -9
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
const readline = require("node:readline");
|
|
2
|
+
const {
|
|
3
|
+
argv,
|
|
4
|
+
argv0,
|
|
5
|
+
exit,
|
|
6
|
+
stdin: input,
|
|
7
|
+
stdout: output,
|
|
8
|
+
} = require("node:process");
|
|
9
|
+
|
|
10
|
+
const StaticWado = require("./StaticWado");
|
|
11
|
+
const adaptProgramOpts = require("./util/adaptProgramOpts");
|
|
12
|
+
|
|
13
|
+
module.exports = async function createMain(options, program) {
|
|
14
|
+
const rl = readline.createInterface({ input, output });
|
|
15
|
+
for await (const line of rl) {
|
|
16
|
+
if (!line) continue;
|
|
17
|
+
if (line.startsWith("exit")) {
|
|
18
|
+
exit(0);
|
|
19
|
+
}
|
|
20
|
+
argv.splice(2, argv.length - 2, ...line.split(" "));
|
|
21
|
+
console.verbose("exec mkdicomweb", JSON.stringify(argv));
|
|
22
|
+
|
|
23
|
+
// Configure program commander
|
|
24
|
+
await StaticWado.configureProgram(StaticWado.mkdicomwebConfig);
|
|
25
|
+
output.write("mkdicomweb server -->\n");
|
|
26
|
+
}
|
|
27
|
+
};
|
package/lib/util/IdCreator.js
CHANGED
|
@@ -1,14 +1,40 @@
|
|
|
1
1
|
const path = require("path");
|
|
2
|
+
const {
|
|
3
|
+
getStudyUIDPathAndSubPath,
|
|
4
|
+
} = require("@radicalimaging/static-wado-util");
|
|
2
5
|
|
|
3
|
-
function IdCreator({
|
|
6
|
+
function IdCreator({
|
|
7
|
+
directoryName,
|
|
8
|
+
deduplicatedRoot,
|
|
9
|
+
deduplicatedInstancesRoot,
|
|
10
|
+
hashStudyUidPath,
|
|
11
|
+
}) {
|
|
4
12
|
return (uids, filename) => {
|
|
5
|
-
const
|
|
6
|
-
|
|
7
|
-
const
|
|
8
|
-
|
|
9
|
-
|
|
13
|
+
const { studyInstanceUid, seriesInstanceUid, sopInstanceUid } = uids;
|
|
14
|
+
|
|
15
|
+
const { path: hashPath = "", subpath: hashSubpath = "" } = hashStudyUidPath
|
|
16
|
+
? getStudyUIDPathAndSubPath(studyInstanceUid)
|
|
17
|
+
: {};
|
|
18
|
+
|
|
19
|
+
const studySubDir = hashStudyUidPath
|
|
20
|
+
? path.join(hashPath, hashSubpath, studyInstanceUid)
|
|
21
|
+
: studyInstanceUid;
|
|
22
|
+
|
|
23
|
+
const studyPath = path.join(directoryName, "studies", studySubDir);
|
|
24
|
+
const seriesRootPath = path.join(studyPath, "series", seriesInstanceUid);
|
|
25
|
+
const sopInstanceRootPath = path.join(
|
|
26
|
+
seriesRootPath,
|
|
27
|
+
"instances",
|
|
28
|
+
sopInstanceUid,
|
|
29
|
+
);
|
|
10
30
|
const imageFrameRootPath = path.join(sopInstanceRootPath, "frames");
|
|
11
31
|
|
|
32
|
+
const deduplicatedPath = path.join(deduplicatedRoot, studySubDir);
|
|
33
|
+
const deduplicatedInstancesPath = path.join(
|
|
34
|
+
deduplicatedInstancesRoot,
|
|
35
|
+
studySubDir,
|
|
36
|
+
);
|
|
37
|
+
|
|
12
38
|
return {
|
|
13
39
|
...uids,
|
|
14
40
|
studyPath,
|
|
@@ -1,13 +1,22 @@
|
|
|
1
1
|
const { program } = require("@radicalimaging/static-wado-util");
|
|
2
|
-
const {
|
|
2
|
+
const {
|
|
3
|
+
getDestinationTranscoder,
|
|
4
|
+
} = require("../operation/adapter/transcodeImage");
|
|
3
5
|
|
|
4
6
|
module.exports = function compressionOptionParser(value) {
|
|
5
7
|
const destination = getDestinationTranscoder(value);
|
|
6
8
|
if (destination) {
|
|
7
|
-
console.log(
|
|
9
|
+
console.log(
|
|
10
|
+
"Found destination transferSyntax ",
|
|
11
|
+
destination.transferSyntaxUid,
|
|
12
|
+
"for ",
|
|
13
|
+
value,
|
|
14
|
+
);
|
|
8
15
|
} else {
|
|
9
16
|
console.log("No transcoder destination for ", value);
|
|
10
|
-
throw new program.InvalidArgumentError(
|
|
17
|
+
throw new program.InvalidArgumentError(
|
|
18
|
+
`No transcoder destination for ${value}`,
|
|
19
|
+
);
|
|
11
20
|
}
|
|
12
21
|
return destination.transferSyntaxUid;
|
|
13
22
|
};
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
import fs from "fs";
|
|
2
|
+
|
|
3
|
+
const results = [];
|
|
4
|
+
let sopResponse = null;
|
|
5
|
+
|
|
6
|
+
function ensureSOPResponse(data) {
|
|
7
|
+
if( !data.ReferencedSOPSequence && !data.FailedSOPSequence ) {
|
|
8
|
+
return;
|
|
9
|
+
}
|
|
10
|
+
if( !sopResponse ) {
|
|
11
|
+
sopResponse = {
|
|
12
|
+
...data,
|
|
13
|
+
FailedSOPSequence: undefined,
|
|
14
|
+
ReferencedSOPSequence: undefined,
|
|
15
|
+
}
|
|
16
|
+
results.push(sopResponse);
|
|
17
|
+
}
|
|
18
|
+
if( data.ReferencedSOPSequence ) {
|
|
19
|
+
sopResponse.ReferencedSOPSequence ||= [];
|
|
20
|
+
sopResponse.ReferencedSOPSequence.push(...data.ReferencedSOPSequence);
|
|
21
|
+
}
|
|
22
|
+
if( data.FailedSOPSequence ) {
|
|
23
|
+
sopResponse.FailedSOPSequence ||= [];
|
|
24
|
+
sopResponse.FailedSOPSequence.push(...data.FailedSOPSequence);
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
}
|
|
28
|
+
export function Success(options) {
|
|
29
|
+
const { deleteInput = false } = options;
|
|
30
|
+
|
|
31
|
+
return (_action, data, file) => {
|
|
32
|
+
if( data.ReferencedSOPSequence ) {
|
|
33
|
+
ensureSOPResponse(data);
|
|
34
|
+
} else {
|
|
35
|
+
results.push(data);
|
|
36
|
+
}
|
|
37
|
+
if (file && deleteInput) {
|
|
38
|
+
console.noQuiet("Deleting", file);
|
|
39
|
+
fs.unlinkSync(file);
|
|
40
|
+
} else if( file ) {
|
|
41
|
+
console.verbose("Not deleting", file);
|
|
42
|
+
}
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
export function Failure(options) {
|
|
47
|
+
const { deleteFailed } = options;
|
|
48
|
+
|
|
49
|
+
return (_action, data, file) => {
|
|
50
|
+
if (data.FailedSOPSequence) {
|
|
51
|
+
ensureSOPResponse(data);
|
|
52
|
+
} else {
|
|
53
|
+
results.push(data);
|
|
54
|
+
}
|
|
55
|
+
if( file && deleteFailed ) {
|
|
56
|
+
console.noQuiet("Deleting failure", file);
|
|
57
|
+
fs.unlinkSync(file);
|
|
58
|
+
} else if( file ) {
|
|
59
|
+
console.verbose("Not deleting failure file", file);
|
|
60
|
+
}
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
export function clearResults() {
|
|
65
|
+
results.splice(0,results.length);
|
|
66
|
+
sopResponse = null;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
export function WriteResults(options) {
|
|
70
|
+
const { multipart } = options;
|
|
71
|
+
|
|
72
|
+
return function () {
|
|
73
|
+
if (multipart) {
|
|
74
|
+
const str =
|
|
75
|
+
results.length === 1
|
|
76
|
+
? JSON.stringify(results[0])
|
|
77
|
+
: `[\n${results.map((r) => JSON.stringify(r, null, 2)).join(",\n")}\n]`;
|
|
78
|
+
console.log(
|
|
79
|
+
"\r\n--boundary-response\r\n" +
|
|
80
|
+
"content-type: application/json\r\n\r\n" +
|
|
81
|
+
str +
|
|
82
|
+
"\r\n--boundary-response--\r\n"
|
|
83
|
+
);
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
clearResults();
|
|
87
|
+
};
|
|
88
|
+
}
|
|
@@ -1,4 +1,8 @@
|
|
|
1
|
-
const {
|
|
1
|
+
const {
|
|
2
|
+
JSONReader,
|
|
3
|
+
JSONWriter,
|
|
4
|
+
Stats,
|
|
5
|
+
} = require("@radicalimaging/static-wado-util");
|
|
2
6
|
const { Tags } = require("@radicalimaging/static-wado-util");
|
|
3
7
|
const StudyData = require("../operation/StudyData");
|
|
4
8
|
|
|
@@ -22,48 +26,77 @@ const CompleteStudyWriter = (options) => {
|
|
|
22
26
|
if (options.isGroup) {
|
|
23
27
|
if (studyData.dirty) {
|
|
24
28
|
await studyData.writeDeduplicatedGroup();
|
|
25
|
-
console.
|
|
29
|
+
console.noQuiet(
|
|
30
|
+
"Wrote updated deduplicated data for study",
|
|
31
|
+
studyData.studyInstanceUid,
|
|
32
|
+
);
|
|
26
33
|
} else {
|
|
27
|
-
console.
|
|
34
|
+
console.noQuiet(
|
|
35
|
+
"Not writing new deduplicated data because it is clean:",
|
|
36
|
+
studyData.studyInstanceUid,
|
|
37
|
+
);
|
|
38
|
+
const message = {
|
|
39
|
+
text: "Metadata clean, not updating",
|
|
40
|
+
status: 0,
|
|
41
|
+
studyInstanceUid: studyData.studyInstanceUid,
|
|
42
|
+
};
|
|
43
|
+
this.success("metadataClean", message);
|
|
28
44
|
}
|
|
29
45
|
await studyData.deleteInstancesReferenced();
|
|
30
46
|
}
|
|
31
47
|
|
|
32
48
|
if (!options.isStudyData) {
|
|
33
|
-
|
|
34
|
-
|
|
49
|
+
if (options.notifications)
|
|
50
|
+
this.notificationService.notifyStudy(studyData.studyInstanceUid);
|
|
35
51
|
delete this.studyData;
|
|
36
52
|
Stats.StudyStats.summarize();
|
|
37
53
|
return;
|
|
38
54
|
}
|
|
39
55
|
|
|
40
56
|
const isDirtyMetadata = await studyData.dirtyMetadata();
|
|
41
|
-
if (!isDirtyMetadata) {
|
|
57
|
+
if (!isDirtyMetadata && !options.force) {
|
|
42
58
|
console.log("Study metadata", studyData.studyInstanceUid, "is clean.");
|
|
43
59
|
delete this.studyData;
|
|
44
|
-
Stats.StudyStats.summarize(
|
|
60
|
+
Stats.StudyStats.summarize(
|
|
61
|
+
`Study metadata ${studyData.studyInstanceUid} has clean metadata, not writing`,
|
|
62
|
+
);
|
|
45
63
|
return;
|
|
46
64
|
}
|
|
47
|
-
console.
|
|
65
|
+
console.noQuiet("Writing study metadata", studyData.studyInstanceUid);
|
|
48
66
|
|
|
49
67
|
const studyQuery = await studyData.writeMetadata();
|
|
50
68
|
|
|
51
|
-
const allStudies = await JSONReader(
|
|
69
|
+
const allStudies = await JSONReader(
|
|
70
|
+
options.directoryName,
|
|
71
|
+
"studies/index.json.gz",
|
|
72
|
+
[],
|
|
73
|
+
);
|
|
52
74
|
const studyUID = Tags.getValue(studyQuery, Tags.StudyInstanceUID);
|
|
53
75
|
if (!studyUID) {
|
|
54
76
|
console.error("studyQuery=", studyQuery);
|
|
55
77
|
throw new Error("Study query has null studyUID");
|
|
56
78
|
}
|
|
57
|
-
const studyIndex = allStudies.findIndex(
|
|
79
|
+
const studyIndex = allStudies.findIndex(
|
|
80
|
+
(item) => Tags.getValue(item, Tags.StudyInstanceUID) == studyUID,
|
|
81
|
+
);
|
|
58
82
|
if (studyIndex == -1) {
|
|
59
83
|
allStudies.push(studyQuery);
|
|
60
84
|
} else {
|
|
61
85
|
allStudies[studyIndex] = studyQuery;
|
|
62
86
|
}
|
|
63
87
|
await JSONWriter(options.directoryName, "studies", allStudies);
|
|
64
|
-
if (options.notifications)
|
|
88
|
+
if (options.notifications)
|
|
89
|
+
this.notificationService.notifyStudy(studyData.studyInstanceUid);
|
|
90
|
+
const message = {
|
|
91
|
+
action: "metadata",
|
|
92
|
+
status: 0,
|
|
93
|
+
studyInstanceUid: studyData.studyInstanceUid,
|
|
94
|
+
};
|
|
95
|
+
this.success("completeStudyWriter", message);
|
|
65
96
|
delete this.studyData;
|
|
66
|
-
Stats.StudyStats.summarize(
|
|
97
|
+
Stats.StudyStats.summarize(
|
|
98
|
+
`Wrote study metadata/query files for ${studyData.studyInstanceUid}`,
|
|
99
|
+
);
|
|
67
100
|
}
|
|
68
101
|
|
|
69
102
|
/**
|
|
@@ -81,7 +114,10 @@ const CompleteStudyWriter = (options) => {
|
|
|
81
114
|
await callback.completeStudy(studyData);
|
|
82
115
|
}
|
|
83
116
|
callback.setStudyData(new StudyData(id, options));
|
|
84
|
-
|
|
117
|
+
if (!options.isSkipStudyScan) {
|
|
118
|
+
console.verbose("Initiate StudyData");
|
|
119
|
+
await callback.studyData.init(options);
|
|
120
|
+
}
|
|
85
121
|
return callback.studyData;
|
|
86
122
|
};
|
|
87
123
|
|
|
@@ -24,7 +24,8 @@ const DeduplicateWriter = (options) =>
|
|
|
24
24
|
const studyData = await this.completeStudy.getCurrentStudyData(this, id);
|
|
25
25
|
|
|
26
26
|
if (options.isDeduplicate) {
|
|
27
|
-
if (options.verbose)
|
|
27
|
+
if (options.verbose)
|
|
28
|
+
console.log("Writing single instance", id.studyInstanceUid);
|
|
28
29
|
await perInstanceWriter(id, data);
|
|
29
30
|
} else if (options.verbose) {
|
|
30
31
|
console.log("Not writing single instance deduplicated");
|
|
@@ -8,7 +8,10 @@ const ExpandUriPath = (id, path, options) => {
|
|
|
8
8
|
}
|
|
9
9
|
expandedRelative = `studies/${id.studyInstanceUid}/${expandedRelativeSeries}`;
|
|
10
10
|
}
|
|
11
|
-
if (options.verbose)
|
|
11
|
+
if (options.verbose)
|
|
12
|
+
console.log(
|
|
13
|
+
`Expanded path returned: ${prependBulkDataUri}${expandedRelative}${path}`,
|
|
14
|
+
);
|
|
12
15
|
return `${prependBulkDataUri}${expandedRelative}${path}`;
|
|
13
16
|
};
|
|
14
17
|
|
|
@@ -43,7 +43,11 @@ const HashDataWriter =
|
|
|
43
43
|
gzip,
|
|
44
44
|
});
|
|
45
45
|
if (isRaw) {
|
|
46
|
-
await WriteMultipart(
|
|
46
|
+
await WriteMultipart(
|
|
47
|
+
writeStream,
|
|
48
|
+
[new MultipartHeader("Content-Type", "application/octet-stream")],
|
|
49
|
+
rawData,
|
|
50
|
+
);
|
|
47
51
|
} else {
|
|
48
52
|
await writeStream.write(rawData);
|
|
49
53
|
}
|
|
@@ -18,29 +18,54 @@ const ImageFrameWriter = (options) => {
|
|
|
18
18
|
}
|
|
19
19
|
|
|
20
20
|
if (encapsulatedImage || !extension) {
|
|
21
|
-
const writeStream = WriteStream(
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
21
|
+
const writeStream = WriteStream(
|
|
22
|
+
id.imageFrameRootPath,
|
|
23
|
+
`${1 + index}.mht`,
|
|
24
|
+
{
|
|
25
|
+
gzip: type.gzip,
|
|
26
|
+
mkdir: true,
|
|
27
|
+
},
|
|
28
|
+
);
|
|
25
29
|
await WriteMultipart(
|
|
26
30
|
writeStream,
|
|
27
|
-
[
|
|
28
|
-
|
|
31
|
+
[
|
|
32
|
+
new MultipartHeader("Content-Type", type.contentType, [
|
|
33
|
+
new MultipartAttribute("transfer-syntax", transferSyntaxUid),
|
|
34
|
+
]),
|
|
35
|
+
],
|
|
36
|
+
content,
|
|
29
37
|
);
|
|
30
38
|
await writeStream.close();
|
|
31
|
-
console.verbose(
|
|
39
|
+
console.verbose(
|
|
40
|
+
"Wrote encapsulated image frame",
|
|
41
|
+
id.sopInstanceUid,
|
|
42
|
+
index + 1,
|
|
43
|
+
type.contentType,
|
|
44
|
+
);
|
|
32
45
|
}
|
|
33
46
|
if (extension && singlePartImage) {
|
|
34
|
-
const writeStreamSingle = WriteStream(
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
47
|
+
const writeStreamSingle = WriteStream(
|
|
48
|
+
id.imageFrameRootPath,
|
|
49
|
+
`${1 + index}${extension}`,
|
|
50
|
+
{
|
|
51
|
+
gzip: type.gzip,
|
|
52
|
+
mkdir: true,
|
|
53
|
+
},
|
|
54
|
+
);
|
|
38
55
|
await writeStreamSingle.write(content);
|
|
39
56
|
await writeStreamSingle.close();
|
|
40
|
-
console.verbose(
|
|
57
|
+
console.verbose(
|
|
58
|
+
"Wrote single part image frame",
|
|
59
|
+
id.sopInstanceUid,
|
|
60
|
+
index + 1,
|
|
61
|
+
extension,
|
|
62
|
+
);
|
|
41
63
|
}
|
|
42
64
|
const includeSeries = true;
|
|
43
|
-
return ExpandUriPath(id, `instances/${id.sopInstanceUid}/frames`, {
|
|
65
|
+
return ExpandUriPath(id, `instances/${id.sopInstanceUid}/frames`, {
|
|
66
|
+
includeSeries,
|
|
67
|
+
...options,
|
|
68
|
+
});
|
|
44
69
|
};
|
|
45
70
|
};
|
|
46
71
|
|
|
@@ -4,10 +4,15 @@ const WriteMultipart = require("./WriteMultipart");
|
|
|
4
4
|
const { MultipartHeader } = require("./MultipartHeader");
|
|
5
5
|
|
|
6
6
|
const modalitiesToRawWrite = ["SEG", "SR"];
|
|
7
|
+
const sopClassesToRawWrite = ["1.2.840.10008.5.1.4.1.1.30"];
|
|
7
8
|
|
|
8
9
|
const defaultSelector = (instance) => {
|
|
9
10
|
const modality = instance.metadata[Tags.Modality]?.Value?.[0];
|
|
10
|
-
|
|
11
|
+
const sopClass = instance.metadata[Tags.SOPClassUID]?.Value?.[0];
|
|
12
|
+
return (
|
|
13
|
+
modalitiesToRawWrite.indexOf(modality) !== -1 ||
|
|
14
|
+
sopClassesToRawWrite.indexOf(sopClass) !== -1
|
|
15
|
+
);
|
|
11
16
|
};
|
|
12
17
|
|
|
13
18
|
/** Writes out raw DICOM files, encapsulated in multipart and gzipped - currently just DICOM SR and SEG */
|
|
@@ -28,7 +33,11 @@ const RawDicomWriter =
|
|
|
28
33
|
});
|
|
29
34
|
const { length } = content;
|
|
30
35
|
const buffer = content.slice(0, length);
|
|
31
|
-
await WriteMultipart(
|
|
36
|
+
await WriteMultipart(
|
|
37
|
+
writeStream,
|
|
38
|
+
[new MultipartHeader("Content-Type", contentType, [])],
|
|
39
|
+
buffer,
|
|
40
|
+
);
|
|
32
41
|
await writeStream.close();
|
|
33
42
|
};
|
|
34
43
|
RawDicomWriter.defaultSelector = defaultSelector;
|
|
@@ -34,7 +34,7 @@ const VideoWriter = () =>
|
|
|
34
34
|
filename,
|
|
35
35
|
{
|
|
36
36
|
mkdir: true,
|
|
37
|
-
}
|
|
37
|
+
},
|
|
38
38
|
);
|
|
39
39
|
let length = 0;
|
|
40
40
|
const { fragments } = dataSet.elements.x7fe00010;
|
|
@@ -48,14 +48,14 @@ const VideoWriter = () =>
|
|
|
48
48
|
const fragment = fragments[i];
|
|
49
49
|
const blob = dataSet.byteArray.slice(
|
|
50
50
|
fragment.position,
|
|
51
|
-
fragment.position + fragment.length
|
|
51
|
+
fragment.position + fragment.length,
|
|
52
52
|
);
|
|
53
53
|
length += blob.length;
|
|
54
54
|
await writeStream.write(blob);
|
|
55
55
|
}
|
|
56
56
|
await writeStream.close();
|
|
57
57
|
console.log(
|
|
58
|
-
`Done video ${id.sopInstanceRootPath}\\${filename} of length ${length}
|
|
58
|
+
`Done video ${id.sopInstanceRootPath}\\${filename} of length ${length}`,
|
|
59
59
|
);
|
|
60
60
|
return `series/${id.seriesInstanceUid}/instances/${id.sopInstanceUid}/rendered?length=${length}&offset=0&accept=video/mp4`;
|
|
61
61
|
};
|
|
@@ -9,7 +9,9 @@ const WriteMultipart = async (writeStream, headers, content) => {
|
|
|
9
9
|
if (header.attributes) {
|
|
10
10
|
for (let j = 0; j < header.attributes.length; j++) {
|
|
11
11
|
const attribute = header.attributes[j];
|
|
12
|
-
await writeStream.write(
|
|
12
|
+
await writeStream.write(
|
|
13
|
+
`;${attribute.attributeName}=${attribute.attributeValue}`,
|
|
14
|
+
);
|
|
13
15
|
}
|
|
14
16
|
}
|
|
15
17
|
await writeStream.write("\r\n");
|
|
@@ -11,17 +11,25 @@ let writeCount = 0;
|
|
|
11
11
|
*/
|
|
12
12
|
const WriteStream = (dir, nameSrc, options = {}) => {
|
|
13
13
|
const isGzip = nameSrc.indexOf(".gz") != -1 || options.gzip;
|
|
14
|
-
const name =
|
|
15
|
-
|
|
14
|
+
const name =
|
|
15
|
+
(isGzip && nameSrc.indexOf(".gz") === -1 && `${nameSrc}.gz`) || nameSrc;
|
|
16
|
+
if (options.mkdir) {
|
|
17
|
+
fs.mkdirSync(dir, { recursive: true });
|
|
18
|
+
}
|
|
16
19
|
|
|
17
|
-
const tempName = path.join(
|
|
20
|
+
const tempName = path.join(
|
|
21
|
+
dir,
|
|
22
|
+
`tempFile-${Math.round(Math.random() * 1000000000)}`,
|
|
23
|
+
);
|
|
18
24
|
const finalName = path.join(dir, name);
|
|
19
25
|
writeCount++;
|
|
20
26
|
if (writeCount > 10) {
|
|
21
27
|
console.log("Write count", tempName, finalName, writeCount);
|
|
22
28
|
if (writeCount > 100) {
|
|
23
29
|
console.error("Too many open writes", new Error());
|
|
24
|
-
throw new Error(
|
|
30
|
+
throw new Error(
|
|
31
|
+
`Write count too high ${writeCount} destination ${finalName}`,
|
|
32
|
+
);
|
|
25
33
|
}
|
|
26
34
|
}
|
|
27
35
|
const rawStream = fs.createWriteStream(tempName);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@radicalimaging/static-wado-creator",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.6.10",
|
|
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"
|
|
@@ -10,11 +10,9 @@
|
|
|
10
10
|
"DICOM",
|
|
11
11
|
"DICOMweb"
|
|
12
12
|
],
|
|
13
|
-
"author":
|
|
14
|
-
"Chris Hafey <chafey@gmail.com>",
|
|
15
|
-
"Bill Wallace <bill.wallace@radicalimaging.com>"
|
|
16
|
-
],
|
|
13
|
+
"author": "Bill Wallace <bill.wallace@radicalimaging.com>",
|
|
17
14
|
"contributors": [
|
|
15
|
+
"Chris Hafey <chafey@gmail.com>",
|
|
18
16
|
"Rodolfo Costa <rodolfo.costa@radicalimaging.com>"
|
|
19
17
|
],
|
|
20
18
|
"engines": {
|
|
@@ -24,48 +22,54 @@
|
|
|
24
22
|
},
|
|
25
23
|
"repository": {
|
|
26
24
|
"type": "git",
|
|
27
|
-
"url": "https://github.com/
|
|
25
|
+
"url": "https://github.com/radicalimaging/static-dicomweb",
|
|
28
26
|
"directory": "packages/static-wado-creator"
|
|
29
27
|
},
|
|
30
28
|
"bugs": {
|
|
31
|
-
"url": "https://github.com/
|
|
29
|
+
"url": "https://github.com/radicalimaging/static-dicomweb/issues"
|
|
32
30
|
},
|
|
33
|
-
"homepage": "https://github.com/
|
|
31
|
+
"homepage": "https://github.com/radicalimaging/static-dicomweb#readme",
|
|
34
32
|
"license": "ISC",
|
|
35
33
|
"main": "lib/index.js",
|
|
34
|
+
"module": "dist/index.js",
|
|
36
35
|
"directories": {
|
|
37
36
|
"lib": "lib",
|
|
37
|
+
"dist": "dist",
|
|
38
38
|
"bin": "bin"
|
|
39
39
|
},
|
|
40
40
|
"files": [
|
|
41
41
|
"bin",
|
|
42
|
+
"dist",
|
|
42
43
|
"lib"
|
|
43
44
|
],
|
|
44
45
|
"bin": {
|
|
45
|
-
"mkdicomweb": "bin/mkdicomweb.
|
|
46
|
+
"mkdicomweb": "bin/mkdicomweb.mjs"
|
|
46
47
|
},
|
|
47
48
|
"scripts": {
|
|
48
49
|
"test": "jest --config ./jest.config.js",
|
|
49
|
-
"build": "
|
|
50
|
+
"build": "bun run build:esm",
|
|
51
|
+
"build:esm": "bun build lib/index.js --target node --outdir dist --",
|
|
52
|
+
"clean": "rimraf dist",
|
|
50
53
|
"link:exec": "npm install -g && npm link",
|
|
51
54
|
"lint": "npx eslint --color \"**/*.{js,mjs,cjs}\"",
|
|
55
|
+
"mkdicomweb": "bun bin/mkdicomwebDev.mjs --",
|
|
56
|
+
"pack:js": "npm pack --",
|
|
57
|
+
"publishJS": "yarn publish --no-git-tag-version",
|
|
52
58
|
"lint:fix": "npx eslint --fix --color \"**/*.{js,mjs,cjs}\""
|
|
53
59
|
},
|
|
54
60
|
"jest": {
|
|
55
61
|
"verbose": true
|
|
56
62
|
},
|
|
57
63
|
"dependencies": {
|
|
58
|
-
"@
|
|
59
|
-
"@radicalimaging/static-
|
|
60
|
-
"
|
|
61
|
-
"canvas": "^2.11.1",
|
|
64
|
+
"@radicalimaging/cs3d": ">=1.6.1",
|
|
65
|
+
"@radicalimaging/static-wado-util": ">=1.6.1",
|
|
66
|
+
"canvas": ">=3.1.0",
|
|
62
67
|
"config-point": ">=0.5.1",
|
|
63
|
-
"dcmjs": "
|
|
68
|
+
"dcmjs": "0.35.0",
|
|
64
69
|
"dicom-parser": "^1.8.13",
|
|
65
|
-
"glob": "^
|
|
70
|
+
"glob": "^11.0.0",
|
|
66
71
|
"node-object-hash": "^3.0.0",
|
|
67
|
-
"
|
|
68
|
-
"uuid": "^8.3.2"
|
|
72
|
+
"uuid": "^11.0.2"
|
|
69
73
|
},
|
|
70
74
|
"devDependencies": {
|
|
71
75
|
"must": "^0.13.4"
|
package/bin/mkdicomweb.js
DELETED