@cornerstonejs/adapters 2.0.0-beta.1 → 2.0.0-beta.2
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/dist/adapters.es.js +38 -16
- package/dist/adapters.es.js.map +1 -1
- package/dist/types/adapters/Cornerstone3D/Segmentation/generateSegmentation.d.ts +1 -1
- package/dist/types/adapters/helpers/downloadDICOMData.d.ts +10 -0
- package/dist/types/adapters/helpers/index.d.ts +2 -1
- package/dist/types/adapters/index.d.ts +1 -10
- package/package.json +5 -5
package/dist/adapters.es.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { utilities, derivations, normalizers,
|
|
1
|
+
import { data, utilities, derivations, normalizers, log } from 'dcmjs';
|
|
2
|
+
import { Buffer } from 'buffer';
|
|
2
3
|
import ndarray from 'ndarray';
|
|
3
4
|
import cloneDeep from 'lodash.clonedeep';
|
|
4
|
-
import { Buffer } from 'buffer';
|
|
5
5
|
import { vec3 } from 'gl-matrix';
|
|
6
6
|
|
|
7
7
|
function _iterableToArrayLimit(arr, i) {
|
|
@@ -545,9 +545,34 @@ var graphicTypeEquals = function (graphicType) {
|
|
|
545
545
|
};
|
|
546
546
|
};
|
|
547
547
|
|
|
548
|
+
var datasetToDict = data.datasetToDict;
|
|
549
|
+
/**
|
|
550
|
+
* Trigger file download from an array buffer
|
|
551
|
+
* @param bufferOrDataset - ArrayBuffer or DicomDataset
|
|
552
|
+
* @param filename - name of the file to download
|
|
553
|
+
*/
|
|
554
|
+
function downloadDICOMData(bufferOrDataset, filename) {
|
|
555
|
+
var blob;
|
|
556
|
+
if (bufferOrDataset instanceof ArrayBuffer) {
|
|
557
|
+
blob = new Blob([bufferOrDataset], { type: "application/dicom" });
|
|
558
|
+
}
|
|
559
|
+
else {
|
|
560
|
+
if (!bufferOrDataset._meta) {
|
|
561
|
+
throw new Error("Dataset must have a _meta property");
|
|
562
|
+
}
|
|
563
|
+
var buffer = Buffer.from(datasetToDict(bufferOrDataset).write());
|
|
564
|
+
blob = new Blob([buffer], { type: "application/dicom" });
|
|
565
|
+
}
|
|
566
|
+
var link = document.createElement("a");
|
|
567
|
+
link.href = window.URL.createObjectURL(blob);
|
|
568
|
+
link.download = filename;
|
|
569
|
+
link.click();
|
|
570
|
+
}
|
|
571
|
+
|
|
548
572
|
var index$1 = /*#__PURE__*/Object.freeze({
|
|
549
573
|
__proto__: null,
|
|
550
574
|
codeMeaningEquals: codeMeaningEquals,
|
|
575
|
+
downloadDICOMData: downloadDICOMData,
|
|
551
576
|
graphicTypeEquals: graphicTypeEquals,
|
|
552
577
|
toArray: toArray
|
|
553
578
|
});
|
|
@@ -2240,8 +2265,7 @@ var _utilities$orientatio = utilities.orientation,
|
|
|
2240
2265
|
flipMatrix2D = _utilities$orientatio.flipMatrix2D,
|
|
2241
2266
|
rotateMatrix902D = _utilities$orientatio.rotateMatrix902D,
|
|
2242
2267
|
nearlyEqual = _utilities$orientatio.nearlyEqual;
|
|
2243
|
-
var
|
|
2244
|
-
BitArray$1 = data.BitArray,
|
|
2268
|
+
var BitArray$1 = data.BitArray,
|
|
2245
2269
|
DicomMessage = data.DicomMessage,
|
|
2246
2270
|
DicomMetaDictionary$1 = data.DicomMetaDictionary;
|
|
2247
2271
|
var Normalizer$2 = normalizers.Normalizer;
|
|
@@ -2280,12 +2304,13 @@ function generateSegmentation$2(images, inputLabelmaps3D) {
|
|
|
2280
2304
|
}
|
|
2281
2305
|
|
|
2282
2306
|
/**
|
|
2283
|
-
*
|
|
2307
|
+
* Fills a given segmentation object with data from the input labelmaps3D
|
|
2284
2308
|
*
|
|
2285
|
-
* @param
|
|
2286
|
-
* @param
|
|
2287
|
-
* @param
|
|
2288
|
-
*
|
|
2309
|
+
* @param segmentation - The segmentation object to be filled.
|
|
2310
|
+
* @param inputLabelmaps3D - An array of 3D labelmaps, or a single 3D labelmap.
|
|
2311
|
+
* @param userOptions - Optional configuration settings. Will override the default options.
|
|
2312
|
+
*
|
|
2313
|
+
* @returns {object} The filled segmentation object.
|
|
2289
2314
|
*/
|
|
2290
2315
|
function fillSegmentation$1(segmentation, inputLabelmaps3D) {
|
|
2291
2316
|
var userOptions = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
|
|
@@ -2367,11 +2392,7 @@ function fillSegmentation$1(segmentation, inputLabelmaps3D) {
|
|
|
2367
2392
|
// If no rleEncoding, at least bitpack the data.
|
|
2368
2393
|
segmentation.bitPackPixelData();
|
|
2369
2394
|
}
|
|
2370
|
-
|
|
2371
|
-
var segBlob = new Blob([buffer], {
|
|
2372
|
-
type: "application/dicom"
|
|
2373
|
-
});
|
|
2374
|
-
return segBlob;
|
|
2395
|
+
return segmentation;
|
|
2375
2396
|
}
|
|
2376
2397
|
function _getLabelmapsFromReferencedFrameIndicies(labelmap3D, referencedFrameIndicies) {
|
|
2377
2398
|
var labelmaps2D = labelmap3D.labelmaps2D;
|
|
@@ -4853,6 +4874,7 @@ var SegmentationDerivation = derivations.Segmentation;
|
|
|
4853
4874
|
* @param labelmaps - An array of the 3D Volumes that contain the segmentation data.
|
|
4854
4875
|
*/
|
|
4855
4876
|
function generateSegmentation(images, labelmaps, metadata, options) {
|
|
4877
|
+
if (options === void 0) { options = {}; }
|
|
4856
4878
|
var segmentation = _createMultiframeSegmentationFromReferencedImages(images, metadata, options);
|
|
4857
4879
|
return fillSegmentation$1(segmentation, labelmaps, options);
|
|
4858
4880
|
}
|
|
@@ -4872,7 +4894,7 @@ function _createMultiframeSegmentationFromReferencedImages(images, metadata, opt
|
|
|
4872
4894
|
var instance = metadata.get("instance", image.imageId);
|
|
4873
4895
|
return __assign(__assign(__assign({}, image), instance), {
|
|
4874
4896
|
// Todo: move to dcmjs tag style
|
|
4875
|
-
SOPClassUID: instance.SopClassUID, SOPInstanceUID: instance.SopInstanceUID, PixelData: image.getPixelData(), _vrMap: {
|
|
4897
|
+
SOPClassUID: instance.SopClassUID || instance.SOPClassUID, SOPInstanceUID: instance.SopInstanceUID || instance.SOPInstanceUID, PixelData: image.getPixelData(), _vrMap: {
|
|
4876
4898
|
PixelData: "OW"
|
|
4877
4899
|
}, _meta: {} });
|
|
4878
4900
|
});
|
|
@@ -5163,7 +5185,7 @@ var adaptersSR = {
|
|
|
5163
5185
|
Cornerstone3D: Cornerstone3DSR
|
|
5164
5186
|
};
|
|
5165
5187
|
var adaptersSEG = {
|
|
5166
|
-
Cornerstone:
|
|
5188
|
+
Cornerstone: CornerstoneSEG,
|
|
5167
5189
|
Cornerstone3D: Cornerstone3DSEG,
|
|
5168
5190
|
VTKjs: VTKjsSEG
|
|
5169
5191
|
};
|