larvitar 1.4.1 → 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.
- package/.github/workflows/build-docs.yml +19 -15
- package/README.md +2 -2
- package/imaging/imageParsing.js +24 -1
- package/imaging/imageRendering.js +38 -0
- package/index.js +2 -0
- package/package.json +2 -2
|
@@ -1,23 +1,24 @@
|
|
|
1
1
|
name: CI-docs
|
|
2
2
|
|
|
3
|
-
# Controls when the action will run. Triggers the workflow on push or pull request
|
|
4
|
-
# events but only for the master branch
|
|
5
3
|
on:
|
|
6
|
-
|
|
7
|
-
|
|
4
|
+
pull_request:
|
|
5
|
+
types:
|
|
6
|
+
- opened
|
|
7
|
+
- reopened
|
|
8
|
+
- synchronize
|
|
8
9
|
|
|
9
|
-
# A workflow run is made up of one or more jobs that can run sequentially or in parallel
|
|
10
10
|
jobs:
|
|
11
|
-
# First job, build package
|
|
12
11
|
build:
|
|
13
|
-
# The type of runner that the job will run on
|
|
14
12
|
runs-on: ubuntu-latest
|
|
15
13
|
|
|
16
|
-
# Steps represent a sequence of tasks that will be executed as part of the job
|
|
17
14
|
steps:
|
|
18
|
-
#
|
|
15
|
+
# CLone repo at current branch
|
|
19
16
|
- name: Clone repo
|
|
20
17
|
uses: actions/checkout@v2
|
|
18
|
+
with:
|
|
19
|
+
persist-credentials: false
|
|
20
|
+
ref: ${{ github.head_ref }}
|
|
21
|
+
token: ${{ secrets.GIT_TOKEN }}
|
|
21
22
|
|
|
22
23
|
# Setup node environment
|
|
23
24
|
- name: Setup Node.js environment
|
|
@@ -42,10 +43,13 @@ jobs:
|
|
|
42
43
|
run: |
|
|
43
44
|
yarn generate-docs
|
|
44
45
|
|
|
45
|
-
# Commit
|
|
46
|
+
# Commit docs on current branch (update pull request)
|
|
46
47
|
- name: Commit docs
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
48
|
+
uses: actions-js/push@master
|
|
49
|
+
with:
|
|
50
|
+
github_token: ${{ secrets.GITHUB_TOKEN }}
|
|
51
|
+
message: "Update docs"
|
|
52
|
+
branch: ${{ github.head_ref }}
|
|
53
|
+
empty: true
|
|
54
|
+
|
|
55
|
+
|
package/README.md
CHANGED
|
@@ -6,9 +6,9 @@
|
|
|
6
6
|
|
|
7
7
|
## Dicom Image Toolkit for CornerstoneJS
|
|
8
8
|
|
|
9
|
-
### Current version: 1.
|
|
9
|
+
### Current version: 1.5.0
|
|
10
10
|
|
|
11
|
-
### Latest Published Release: 1.
|
|
11
|
+
### Latest Published Release: 1.5.0
|
|
12
12
|
|
|
13
13
|
This library provides common DICOM functionalities to be used in web-applications: it's wrapper that simplifies the use of cornerstone-js environment.
|
|
14
14
|
Orthogonal multiplanar reformat is included as well as custom loader/exporter for nrrd files and [Vuex](https://vuex.vuejs.org/) custom integration.
|
package/imaging/imageParsing.js
CHANGED
|
@@ -270,7 +270,7 @@ let parseFile = function (file) {
|
|
|
270
270
|
reject(dataSet.warnings);
|
|
271
271
|
} else {
|
|
272
272
|
let pixelDataElement = dataSet.elements.x7fe00010;
|
|
273
|
-
|
|
273
|
+
let SOPUID = metadata["x00080016"];
|
|
274
274
|
if (pixelDataElement) {
|
|
275
275
|
// done, pixelDataElement found
|
|
276
276
|
let instanceUID = metadata["x00080018"] || randomId();
|
|
@@ -323,6 +323,29 @@ let parseFile = function (file) {
|
|
|
323
323
|
imageObject.metadata.length = pixelDataElement.length;
|
|
324
324
|
imageObject.metadata.repr = getPixelRepresentation(dataSet);
|
|
325
325
|
resolve(imageObject);
|
|
326
|
+
} else if (SOPUID == "1.2.840.10008.5.1.4.1.1.104.1") {
|
|
327
|
+
let pdfObject = {
|
|
328
|
+
// data needed for rendering
|
|
329
|
+
file: file,
|
|
330
|
+
dataSet: dataSet
|
|
331
|
+
};
|
|
332
|
+
pdfObject.metadata = metadata;
|
|
333
|
+
pdfObject.metadata.seriesUID = seriesInstanceUID;
|
|
334
|
+
pdfObject.instanceUID = metadata["x00080018"] || randomId();
|
|
335
|
+
pdfObject.metadata.studyUID = metadata["x0020000d"];
|
|
336
|
+
pdfObject.metadata.accessionNumber = metadata["x00080050"];
|
|
337
|
+
pdfObject.metadata.studyDescription = metadata["x00081030"];
|
|
338
|
+
pdfObject.metadata.patientName = metadata["x00100010"];
|
|
339
|
+
pdfObject.metadata.patientBirthdate = metadata["x00100030"];
|
|
340
|
+
pdfObject.metadata.seriesDate = metadata["x00080021"];
|
|
341
|
+
pdfObject.metadata.seriesModality =
|
|
342
|
+
metadata["x00080060"].toLowerCase();
|
|
343
|
+
pdfObject.metadata.mimeType = metadata["x00420012"];
|
|
344
|
+
pdfObject.metadata.is4D = false;
|
|
345
|
+
pdfObject.metadata.numberOfFrames = 0;
|
|
346
|
+
pdfObject.metadata.numberOfSlices = 0;
|
|
347
|
+
pdfObject.metadata.numberOfTemporalPositions = 0;
|
|
348
|
+
resolve(pdfObject);
|
|
326
349
|
} else {
|
|
327
350
|
// done, no pixelData
|
|
328
351
|
reject("no pixelData");
|
|
@@ -115,6 +115,44 @@ export function loadAndCacheImages(series, callback) {
|
|
|
115
115
|
});
|
|
116
116
|
}
|
|
117
117
|
|
|
118
|
+
/**
|
|
119
|
+
* Render a PDF from a DICOM Encapsulated PDF
|
|
120
|
+
* @instance
|
|
121
|
+
* @function renderDICOMPDF
|
|
122
|
+
* @param {Object} image - The image PDF object
|
|
123
|
+
* @param {String} elementId - The html div id used for rendering or its DOM HTMLElement
|
|
124
|
+
* @returns {Promise} - Return a promise which will resolve when image is displayed
|
|
125
|
+
*/
|
|
126
|
+
export const renderDICOMPDF = function (image, elementId) {
|
|
127
|
+
let element = isElement(elementId)
|
|
128
|
+
? elementId
|
|
129
|
+
: document.getElementById(elementId);
|
|
130
|
+
if (!element) {
|
|
131
|
+
console.error("invalid html element: " + elementId);
|
|
132
|
+
return;
|
|
133
|
+
}
|
|
134
|
+
const SOPUID = image.dataSet.string("x00080016");
|
|
135
|
+
if (SOPUID === "1.2.840.10008.5.1.4.1.1.104.1") {
|
|
136
|
+
let fileTag = image.dataSet.elements.x00420011;
|
|
137
|
+
let pdfByteArray = image.dataSet.byteArray.slice(
|
|
138
|
+
fileTag.dataOffset,
|
|
139
|
+
fileTag.dataOffset + fileTag.length
|
|
140
|
+
);
|
|
141
|
+
let PDF = new Blob([pdfByteArray], { type: "application/pdf" });
|
|
142
|
+
let fileURL = URL.createObjectURL(PDF);
|
|
143
|
+
element.innerHTML =
|
|
144
|
+
'<object data="' +
|
|
145
|
+
fileURL +
|
|
146
|
+
'" type="application/pdf" width="100%" height="100%"></object>';
|
|
147
|
+
fileTag = null;
|
|
148
|
+
pdfByteArray = null;
|
|
149
|
+
PDF = null;
|
|
150
|
+
fileURL = null;
|
|
151
|
+
} else {
|
|
152
|
+
throw new Error("This is not a DICOM with a PDF");
|
|
153
|
+
}
|
|
154
|
+
};
|
|
155
|
+
|
|
118
156
|
/**
|
|
119
157
|
* Render an image (png or jpg) from File on a html div using cornerstone
|
|
120
158
|
* @instance
|
package/index.js
CHANGED
|
@@ -78,6 +78,7 @@ import {
|
|
|
78
78
|
clearImageCache,
|
|
79
79
|
loadAndCacheImages,
|
|
80
80
|
renderFileImage,
|
|
81
|
+
renderDICOMPDF,
|
|
81
82
|
renderWebImage,
|
|
82
83
|
disableViewport,
|
|
83
84
|
unloadViewport,
|
|
@@ -273,6 +274,7 @@ export {
|
|
|
273
274
|
clearImageCache,
|
|
274
275
|
loadAndCacheImages,
|
|
275
276
|
renderFileImage,
|
|
277
|
+
renderDICOMPDF,
|
|
276
278
|
renderWebImage,
|
|
277
279
|
disableViewport,
|
|
278
280
|
unloadViewport,
|
package/package.json
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
"medical",
|
|
7
7
|
"cornerstone"
|
|
8
8
|
],
|
|
9
|
-
"version": "1.
|
|
9
|
+
"version": "1.5.0",
|
|
10
10
|
"description": "javascript library for parsing, loading, rendering and interacting with DICOM images",
|
|
11
11
|
"repository": {
|
|
12
12
|
"url": "https://github.com/dvisionlab/Larvitar.git",
|
|
@@ -54,4 +54,4 @@
|
|
|
54
54
|
"module": "dist/larvitar.js",
|
|
55
55
|
"browser": "dist/larvitar.js",
|
|
56
56
|
"type": "module"
|
|
57
|
-
}
|
|
57
|
+
}
|