larvitar 0.18.2 → 1.2.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/deploy.yml +3 -12
- package/MIGRATION.md +25 -0
- package/README.md +28 -27
- package/docs/documentation/Mixins.polygonSegmentationMixin%20-%20segmentation%20operations%20for%20polyline.html +171 -0
- package/docs/documentation/Tools.Annotation.ContoursTool.html +218 -0
- package/docs/documentation/Tools.Annotation.DiameterTool.html +219 -0
- package/docs/documentation/Tools.Annotation.SeedsTool.html +214 -0
- package/docs/documentation/Tools.Brush.BrushTool.html +218 -0
- package/docs/documentation/Tools.Brush.ThresholdsBrushTool.html +218 -0
- package/docs/documentation/Tools.PolylineScissorsTool.html +218 -0
- package/docs/documentation/fonts/Montserrat/Montserrat-Bold.eot +0 -0
- package/docs/documentation/fonts/Montserrat/Montserrat-Bold.ttf +0 -0
- package/docs/documentation/fonts/Montserrat/Montserrat-Bold.woff +0 -0
- package/docs/documentation/fonts/Montserrat/Montserrat-Bold.woff2 +0 -0
- package/docs/documentation/fonts/Montserrat/Montserrat-Regular.eot +0 -0
- package/docs/documentation/fonts/Montserrat/Montserrat-Regular.ttf +0 -0
- package/docs/documentation/fonts/Montserrat/Montserrat-Regular.woff +0 -0
- package/docs/documentation/fonts/Montserrat/Montserrat-Regular.woff2 +0 -0
- package/docs/documentation/fonts/Source-Sans-Pro/sourcesanspro-light-webfont.eot +0 -0
- package/docs/documentation/fonts/Source-Sans-Pro/sourcesanspro-light-webfont.svg +978 -0
- package/docs/documentation/fonts/Source-Sans-Pro/sourcesanspro-light-webfont.ttf +0 -0
- package/docs/documentation/fonts/Source-Sans-Pro/sourcesanspro-light-webfont.woff +0 -0
- package/docs/documentation/fonts/Source-Sans-Pro/sourcesanspro-light-webfont.woff2 +0 -0
- package/docs/documentation/fonts/Source-Sans-Pro/sourcesanspro-regular-webfont.eot +0 -0
- package/docs/documentation/fonts/Source-Sans-Pro/sourcesanspro-regular-webfont.svg +1049 -0
- package/docs/documentation/fonts/Source-Sans-Pro/sourcesanspro-regular-webfont.ttf +0 -0
- package/docs/documentation/fonts/Source-Sans-Pro/sourcesanspro-regular-webfont.woff +0 -0
- package/docs/documentation/fonts/Source-Sans-Pro/sourcesanspro-regular-webfont.woff2 +0 -0
- package/docs/documentation/global.html +1303 -0
- package/docs/documentation/imageAnonymization.js.html +245 -0
- package/docs/documentation/imageColormaps.js.html +283 -0
- package/docs/documentation/imageContours.js.html +278 -0
- package/docs/documentation/imageIo.js.html +291 -0
- package/docs/documentation/imageLayers.js.html +188 -0
- package/docs/documentation/imageLoading.js.html +297 -0
- package/docs/documentation/imageParsing.js.html +385 -0
- package/docs/documentation/imagePresets.js.html +207 -0
- package/docs/documentation/imageRendering.js.html +849 -0
- package/docs/documentation/imageReslice.js.html +162 -0
- package/docs/documentation/imageStore.js.html +360 -0
- package/docs/documentation/imageTools.js.html +784 -0
- package/docs/documentation/imageUtils.js.html +1609 -0
- package/docs/documentation/image_colormaps.js.html +283 -0
- package/docs/documentation/image_contours.js.html +279 -0
- package/docs/documentation/image_io.js.html +288 -0
- package/docs/documentation/image_layers.js.html +188 -0
- package/docs/documentation/image_loading.js.html +294 -0
- package/docs/documentation/image_parsing.js.html +391 -0
- package/docs/documentation/image_presets.js.html +207 -0
- package/docs/documentation/image_rendering.js.html +845 -0
- package/docs/documentation/image_reslice.js.html +164 -0
- package/docs/documentation/image_store.js.html +359 -0
- package/docs/documentation/image_tools.js.html +792 -0
- package/docs/documentation/image_utils.js.html +1609 -0
- package/docs/documentation/index.html +175 -0
- package/docs/documentation/loaders_commonLoader.js.html +306 -0
- package/docs/documentation/loaders_dicomLoader.js.html +130 -0
- package/docs/documentation/loaders_fileLoader.js.html +155 -0
- package/docs/documentation/loaders_multiframeLoader.js.html +443 -0
- package/docs/documentation/loaders_niftiLoader.js.html +150 -0
- package/docs/documentation/loaders_nrrdLoader.js.html +545 -0
- package/docs/documentation/loaders_resliceLoader.js.html +258 -0
- package/docs/documentation/module-imaging_contours.html +954 -0
- package/docs/documentation/module-imaging_imageAnonymization.html +544 -0
- package/docs/documentation/module-imaging_imageColormaps.html +1012 -0
- package/docs/documentation/module-imaging_imageContours.html +954 -0
- package/docs/documentation/module-imaging_imageIo.html +1057 -0
- package/docs/documentation/module-imaging_imageLayers.html +904 -0
- package/docs/documentation/module-imaging_imageLoading.html +1301 -0
- package/docs/documentation/module-imaging_imageParsing.html +1356 -0
- package/docs/documentation/module-imaging_imagePresets.html +679 -0
- package/docs/documentation/module-imaging_imageRendering.html +3223 -0
- package/docs/documentation/module-imaging_imageReslice.html +413 -0
- package/docs/documentation/module-imaging_imageStore-Larvitar_Store.html +284 -0
- package/docs/documentation/module-imaging_imageStore.html +1560 -0
- package/docs/documentation/module-imaging_imageTools.html +3617 -0
- package/docs/documentation/module-imaging_imageUtils.html +7253 -0
- package/docs/documentation/module-imaging_io.html +1057 -0
- package/docs/documentation/module-imaging_layers.html +904 -0
- package/docs/documentation/module-imaging_loading.html +1301 -0
- package/docs/documentation/module-imaging_parsing.html +1375 -0
- package/docs/documentation/module-imaging_presets.html +679 -0
- package/docs/documentation/module-imaging_rendering.html +8094 -0
- package/docs/documentation/module-imaging_reslice.html +411 -0
- package/docs/documentation/module-imaging_store-Larvitar_Store.html +284 -0
- package/docs/documentation/module-imaging_store.html +1537 -0
- package/docs/documentation/module-imaging_strategies_eraseFreehand.html +708 -0
- package/docs/documentation/module-imaging_strategies_fillFreehand.html +708 -0
- package/docs/documentation/module-imaging_tools.html +3617 -0
- package/docs/documentation/module-imaging_tools_custom_contourTool.html +207 -0
- package/docs/documentation/module-imaging_tools_custom_diameterTool.html +205 -0
- package/docs/documentation/module-imaging_tools_custom_editMaskTool.html +205 -0
- package/docs/documentation/module-imaging_tools_custom_polygonScissorsTool.html +203 -0
- package/docs/documentation/module-imaging_tools_custom_thresholdBrushTool.html +684 -0
- package/docs/documentation/module-imaging_tools_default.html +205 -0
- package/docs/documentation/module-imaging_tools_interaction.html +530 -0
- package/docs/documentation/module-imaging_tools_io.html +832 -0
- package/docs/documentation/module-imaging_tools_main.html +2028 -0
- package/docs/documentation/module-imaging_tools_polygonSegmentationMixin.html +567 -0
- package/docs/documentation/module-imaging_tools_segmentation.html +3586 -0
- package/docs/documentation/module-imaging_tools_state.html +494 -0
- package/docs/documentation/module-imaging_utils.html +7253 -0
- package/docs/documentation/module-loaders_commonLoader.html +1313 -0
- package/docs/documentation/module-loaders_dicomLoader.html +522 -0
- package/docs/documentation/module-loaders_fileLoader.html +593 -0
- package/docs/documentation/module-loaders_multiframeLoader.html +1169 -0
- package/docs/documentation/module-loaders_niftiLoader.html +565 -0
- package/docs/documentation/module-loaders_nrrdLoader.html +1459 -0
- package/docs/documentation/module-loaders_resliceLoader.html +590 -0
- package/docs/documentation/module-monitors_memory.html +980 -0
- package/docs/documentation/module-tools_default.html +740 -0
- package/docs/documentation/module.exports_module.exports.html +203 -0
- package/docs/documentation/monitors_memory.js.html +189 -0
- package/docs/documentation/parsers_nrrd.js.html +569 -0
- package/docs/documentation/scripts/collapse.js +20 -0
- package/docs/documentation/scripts/linenumber.js +25 -0
- package/docs/documentation/scripts/nav.js +12 -0
- package/docs/documentation/scripts/polyfill.js +4 -0
- package/docs/documentation/scripts/prettify/Apache-License-2.0.txt +202 -0
- package/docs/documentation/scripts/prettify/lang-css.js +2 -0
- package/docs/documentation/scripts/prettify/prettify.js +28 -0
- package/docs/documentation/scripts/search.js +83 -0
- package/docs/documentation/styles/jsdoc.css +765 -0
- package/docs/documentation/styles/prettify.css +80 -0
- package/docs/documentation/tools_contourTool.js.html +1963 -0
- package/docs/documentation/tools_custom_contourTool.js.html +1968 -0
- package/docs/documentation/tools_custom_diameterTool.js.html +225 -0
- package/docs/documentation/tools_custom_editMaskTool.js.html +225 -0
- package/docs/documentation/tools_custom_polylineScissorsTool.js.html +143 -0
- package/docs/documentation/tools_custom_thresholdsBrushTool.js.html +245 -0
- package/docs/documentation/tools_default.js.html +576 -0
- package/docs/documentation/tools_diameterTool.js.html +219 -0
- package/docs/documentation/tools_editMaskTool.js.html +219 -0
- package/docs/documentation/tools_interaction.js.html +258 -0
- package/docs/documentation/tools_io.js.html +297 -0
- package/docs/documentation/tools_main.js.html +443 -0
- package/docs/documentation/tools_polygonSegmentationMixin.js.html +329 -0
- package/docs/documentation/tools_polylineScissorsTool.js.html +136 -0
- package/docs/documentation/tools_seedTool.js.html +423 -0
- package/docs/documentation/tools_segmentation.js.html +558 -0
- package/docs/documentation/tools_state.js.html +163 -0
- package/docs/documentation/tools_strategies_eraseFreehand.js.html +160 -0
- package/docs/documentation/tools_strategies_fillFreehand.js.html +163 -0
- package/docs/documentation/tools_thresholdsBrushTool.js.html +239 -0
- package/docs/documentation/tools_tools.default.js.html +569 -0
- package/docs/documentation/tools_tools.interaction.js.html +251 -0
- package/docs/documentation/tools_tools.io.js.html +288 -0
- package/docs/documentation/tools_tools.main.js.html +442 -0
- package/docs/documentation/tools_tools.segmentation.js.html +445 -0
- package/docs/documentation/tools_tools.state.js.html +157 -0
- package/docs/examples/base.html +170 -0
- package/docs/examples/colorMaps.html +181 -0
- package/docs/examples/defaultTools.html +246 -0
- package/docs/examples/demo/anon1 +0 -0
- package/docs/examples/demo/anon10 +0 -0
- package/docs/examples/demo/anon11 +0 -0
- package/docs/examples/demo/anon12 +0 -0
- package/docs/examples/demo/anon13 +0 -0
- package/docs/examples/demo/anon14 +0 -0
- package/docs/examples/demo/anon15 +0 -0
- package/docs/examples/demo/anon16 +0 -0
- package/docs/examples/demo/anon17 +0 -0
- package/docs/examples/demo/anon18 +0 -0
- package/docs/examples/demo/anon19 +0 -0
- package/docs/examples/demo/anon2 +0 -0
- package/docs/examples/demo/anon20 +0 -0
- package/docs/examples/demo/anon21 +0 -0
- package/docs/examples/demo/anon22 +0 -0
- package/docs/examples/demo/anon23 +0 -0
- package/docs/examples/demo/anon24 +0 -0
- package/docs/examples/demo/anon3 +0 -0
- package/docs/examples/demo/anon4 +0 -0
- package/docs/examples/demo/anon5 +0 -0
- package/docs/examples/demo/anon6 +0 -0
- package/docs/examples/demo/anon7 +0 -0
- package/docs/examples/demo/anon8 +0 -0
- package/docs/examples/demo/anon9 +0 -0
- package/docs/examples/demo/example.nrrd +0 -0
- package/docs/examples/demo/segmentation.nrrd +0 -0
- package/docs/examples/demo/xa_integris.dcm +0 -0
- package/docs/examples/index.html +129 -0
- package/docs/examples/larvitar.js +108623 -0
- package/docs/examples/layers.html +250 -0
- package/docs/examples/masks.html +273 -0
- package/docs/examples/multiframe.html +200 -0
- package/docs/examples/nrrd.html +96 -0
- package/docs/examples/reslice.html +174 -0
- package/docs/index.html +92 -0
- package/imaging/dataDictionary.json +21865 -21865
- package/imaging/imageAnonymization.js +161 -0
- package/imaging/{image_colormaps.js → imageColormaps.js} +2 -2
- package/imaging/{image_contours.js → imageContours.js} +1 -2
- package/imaging/{image_io.js → imageIo.js} +18 -15
- package/imaging/{image_layers.js → imageLayers.js} +2 -2
- package/imaging/{image_loading.js → imageLoading.js} +9 -6
- package/imaging/imageParsing.js +301 -0
- package/imaging/{image_presets.js → imagePresets.js} +2 -2
- package/imaging/{image_rendering.js → imageRendering.js} +36 -32
- package/imaging/imageReslice.js +78 -0
- package/imaging/{image_store.js → imageStore.js} +8 -7
- package/imaging/{image_tools.js → imageTools.js} +15 -23
- package/imaging/{image_utils.js → imageUtils.js} +1 -1
- package/imaging/loaders/commonLoader.js +1 -1
- package/imaging/loaders/dicomLoader.js +1 -1
- package/imaging/loaders/fileLoader.js +2 -2
- package/imaging/loaders/multiframeLoader.js +6 -2
- package/imaging/loaders/nrrdLoader.js +11 -7
- package/imaging/tools/{contourTool.js → custom/contourTool.js} +25 -20
- package/imaging/tools/{diameterTool.js → custom/diameterTool.js} +9 -3
- package/imaging/tools/{editMaskTool.js → custom/editMaskTool.js} +7 -1
- package/imaging/tools/{polylineScissorsTool.js → custom/polylineScissorsTool.js} +12 -5
- package/imaging/tools/{seedTool.js → custom/seedTool.js} +3 -3
- package/imaging/tools/{thresholdsBrushTool.js → custom/thresholdsBrushTool.js} +7 -1
- package/imaging/tools/{tools.default.js → default.js} +10 -3
- package/imaging/tools/{tools.interaction.js → interaction.js} +13 -6
- package/imaging/tools/{tools.io.js → io.js} +15 -6
- package/imaging/tools/{tools.main.js → main.js} +16 -14
- package/imaging/tools/polygonSegmentationMixin.js +8 -4
- package/imaging/tools/{tools.segmentation.js → segmentation.js} +171 -58
- package/imaging/tools/segmentations.md +38 -0
- package/imaging/tools/setLabelMap3D.js +248 -0
- package/imaging/tools/{tools.state.js → state.js} +7 -1
- package/imaging/tools/strategies/eraseFreehand.js +8 -9
- package/imaging/tools/strategies/fillFreehand.js +8 -9
- package/index.js +44 -39
- package/modules/vuex/larvitar.js +13 -3
- package/package.json +13 -10
- package/imaging/image_parsing.js +0 -307
- package/imaging/image_reslice.js +0 -80
package/imaging/image_parsing.js
DELETED
|
@@ -1,307 +0,0 @@
|
|
|
1
|
-
/** @module imaging/parsing
|
|
2
|
-
* @desc This file provides functionalities for parsing DICOM image files
|
|
3
|
-
*/
|
|
4
|
-
|
|
5
|
-
// external libraries
|
|
6
|
-
import { parseDicom } from "dicom-parser";
|
|
7
|
-
import { forEach, each, has, pick } from "lodash";
|
|
8
|
-
|
|
9
|
-
// internal libraries
|
|
10
|
-
import { getPixelRepresentation, randomId, parseTag } from "./image_utils.js";
|
|
11
|
-
import { updateLoadedStack } from "./image_loading.js";
|
|
12
|
-
import { checkMemoryAllocation } from "./monitors/memory.js";
|
|
13
|
-
|
|
14
|
-
// global module variables
|
|
15
|
-
var parsingQueueFlag = null; // flag to handle the queue
|
|
16
|
-
var t0 = null; // t0 variable for timing debugging purpose
|
|
17
|
-
|
|
18
|
-
/*
|
|
19
|
-
* This module provides the following functions to be exported:
|
|
20
|
-
* readFiles(fileList, callback)
|
|
21
|
-
* readFile(file, callback)
|
|
22
|
-
* dumpDataSet(dataSet, metadata, customFilter)
|
|
23
|
-
* clearImageParsing(seriesStack)
|
|
24
|
-
*/
|
|
25
|
-
|
|
26
|
-
/**
|
|
27
|
-
* Reset series stack object and its internal data
|
|
28
|
-
* @instance
|
|
29
|
-
* @function clearImageParsing
|
|
30
|
-
* @param {Object} seriesStack - Parsed series stack object
|
|
31
|
-
*/
|
|
32
|
-
export const clearImageParsing = function (seriesStack) {
|
|
33
|
-
each(seriesStack, function (stack) {
|
|
34
|
-
each(stack.instances, function (instance) {
|
|
35
|
-
if (instance.dataSet) {
|
|
36
|
-
instance.dataSet.byteArray = null;
|
|
37
|
-
}
|
|
38
|
-
instance.dataSet = null;
|
|
39
|
-
instance.file = null;
|
|
40
|
-
instance.metadata = null;
|
|
41
|
-
});
|
|
42
|
-
});
|
|
43
|
-
seriesStack = null;
|
|
44
|
-
};
|
|
45
|
-
|
|
46
|
-
/**
|
|
47
|
-
* Read dicom files and return allSeriesStack object
|
|
48
|
-
* @instance
|
|
49
|
-
* @function readFiles
|
|
50
|
-
* @param {Array} entries - List of file objects
|
|
51
|
-
* @param {Function} callback - Will receive (imageObject, errorString) as args
|
|
52
|
-
*/
|
|
53
|
-
export const readFiles = function (entries, callback) {
|
|
54
|
-
let allSeriesStack = {};
|
|
55
|
-
let parsingQueue = [];
|
|
56
|
-
dumpFiles(entries, parsingQueue, allSeriesStack, callback);
|
|
57
|
-
};
|
|
58
|
-
|
|
59
|
-
/**
|
|
60
|
-
* Read a single dicom file and return parsed object
|
|
61
|
-
* @instance
|
|
62
|
-
* @function readFile
|
|
63
|
-
* @param {File} entry - File object
|
|
64
|
-
* @param {Function} callback - Will receive (imageObject, errorString) as args
|
|
65
|
-
*/
|
|
66
|
-
export const readFile = function (entry, callback) {
|
|
67
|
-
dumpFile(entry, callback);
|
|
68
|
-
};
|
|
69
|
-
|
|
70
|
-
/* Internal module functions */
|
|
71
|
-
|
|
72
|
-
/**
|
|
73
|
-
* Dump metadata from dicom parser dataSet object
|
|
74
|
-
* @instance
|
|
75
|
-
* @function dumpDataSet
|
|
76
|
-
* @param {Object} dataSet - dicom parser dataSet object
|
|
77
|
-
* @param {Array} metadata - Initialized metadata object
|
|
78
|
-
* @param {Array} customFilter - Optional filter: {tags:[], frameId: 0}
|
|
79
|
-
*/
|
|
80
|
-
// This function iterates through dataSet recursively and adds new HTML strings
|
|
81
|
-
// to the output array passed into it
|
|
82
|
-
export const dumpDataSet = function (dataSet, metadata, customFilter) {
|
|
83
|
-
// customFilter= {tags:[], frameId:xxx}
|
|
84
|
-
// the dataSet.elements object contains properties for each element parsed. The name of the property
|
|
85
|
-
// is based on the elements tag and looks like 'xGGGGEEEE' where GGGG is the group number and EEEE is the
|
|
86
|
-
// element number both with lowercase hexadecimal letters. For example, the Series Description DICOM element 0008,103E would
|
|
87
|
-
// be named 'x0008103e'. Here we iterate over each property (element) so we can build a string describing its
|
|
88
|
-
// contents to add to the output array
|
|
89
|
-
try {
|
|
90
|
-
let elements =
|
|
91
|
-
customFilter && has(customFilter, "tags")
|
|
92
|
-
? pick(dataSet.elements, customFilter.tags)
|
|
93
|
-
: dataSet.elements;
|
|
94
|
-
for (let propertyName in elements) {
|
|
95
|
-
let element = elements[propertyName];
|
|
96
|
-
// Here we check for Sequence items and iterate over them if present. items will not be set in the
|
|
97
|
-
// element object for elements that don't have SQ VR type. Note that implicit little endian
|
|
98
|
-
// sequences will are currently not parsed.
|
|
99
|
-
if (element.items) {
|
|
100
|
-
// each item contains its own data set so we iterate over the items
|
|
101
|
-
// and recursively call this function
|
|
102
|
-
if (customFilter && has(customFilter, "frameId")) {
|
|
103
|
-
let item = element.items[customFilter.frameId];
|
|
104
|
-
dumpDataSet(item.dataSet, metadata);
|
|
105
|
-
} else {
|
|
106
|
-
element.items.forEach(function (item) {
|
|
107
|
-
dumpDataSet(item.dataSet, metadata);
|
|
108
|
-
});
|
|
109
|
-
}
|
|
110
|
-
} else {
|
|
111
|
-
let tagValue = parseTag(dataSet, propertyName, element);
|
|
112
|
-
metadata[propertyName] = tagValue;
|
|
113
|
-
}
|
|
114
|
-
}
|
|
115
|
-
} catch (err) {
|
|
116
|
-
console.log(err);
|
|
117
|
-
}
|
|
118
|
-
};
|
|
119
|
-
|
|
120
|
-
/**
|
|
121
|
-
* Manage the parsing process waiting for the parsed object before proceeding with the next parse request
|
|
122
|
-
* @inner
|
|
123
|
-
* @function parseNextFile
|
|
124
|
-
* @param {Array} parsingQueue - Array of queued files to be parsed
|
|
125
|
-
* @param {Object} allSeriesStack - Series stack object to be populated
|
|
126
|
-
* @param {Function} callback - Passed through
|
|
127
|
-
*/
|
|
128
|
-
let parseNextFile = function (parsingQueue, allSeriesStack, callback) {
|
|
129
|
-
// initialize t0 on first file of the queue
|
|
130
|
-
if (
|
|
131
|
-
Object.keys(allSeriesStack).length === 0 &&
|
|
132
|
-
allSeriesStack.constructor === Object
|
|
133
|
-
) {
|
|
134
|
-
t0 = performance.now();
|
|
135
|
-
}
|
|
136
|
-
|
|
137
|
-
if (!parsingQueueFlag || parsingQueue.length === 0) {
|
|
138
|
-
if (parsingQueue.length === 0) {
|
|
139
|
-
let t1 = performance.now();
|
|
140
|
-
console.log(`Call to readFiles took ${t1 - t0} milliseconds.`);
|
|
141
|
-
parsingQueueFlag = null;
|
|
142
|
-
callback(allSeriesStack);
|
|
143
|
-
}
|
|
144
|
-
return;
|
|
145
|
-
}
|
|
146
|
-
|
|
147
|
-
parsingQueueFlag = false;
|
|
148
|
-
|
|
149
|
-
// remove and return first item from queue
|
|
150
|
-
let file = parsingQueue.shift();
|
|
151
|
-
|
|
152
|
-
// Check if there is enough memory to dump the file
|
|
153
|
-
if (checkMemoryAllocation(file.size) === false) {
|
|
154
|
-
// do not parse the file and stop parsing
|
|
155
|
-
clearImageParsing(allSeriesStack);
|
|
156
|
-
let t1 = performance.now();
|
|
157
|
-
console.log(`Call to readFiles took ${t1 - t0} milliseconds.`);
|
|
158
|
-
parsingQueueFlag = null;
|
|
159
|
-
file = null;
|
|
160
|
-
callback(allSeriesStack, "Available memory is not enough");
|
|
161
|
-
} else {
|
|
162
|
-
// parse the file and wait for results
|
|
163
|
-
dumpFile(file, function (seriesData, err) {
|
|
164
|
-
if (parsingQueueFlag === null) {
|
|
165
|
-
console.log("parsingQueueFlag is null");
|
|
166
|
-
// parsing process has been stopped, but there could be a
|
|
167
|
-
// dumpFile callback still working: prevent actions
|
|
168
|
-
return;
|
|
169
|
-
}
|
|
170
|
-
if (err) {
|
|
171
|
-
console.warn(err);
|
|
172
|
-
parsingQueueFlag = true;
|
|
173
|
-
parseNextFile(parsingQueue, allSeriesStack, callback);
|
|
174
|
-
} else {
|
|
175
|
-
// add file to cornerstoneWADOImageLoader file manager
|
|
176
|
-
updateLoadedStack(seriesData, allSeriesStack);
|
|
177
|
-
// proceed with the next file to parse
|
|
178
|
-
parsingQueueFlag = true;
|
|
179
|
-
parseNextFile(parsingQueue, allSeriesStack, callback);
|
|
180
|
-
}
|
|
181
|
-
file = null;
|
|
182
|
-
seriesData = null;
|
|
183
|
-
});
|
|
184
|
-
}
|
|
185
|
-
};
|
|
186
|
-
|
|
187
|
-
/**
|
|
188
|
-
* Push files in queue and start parsing next file
|
|
189
|
-
* @inner
|
|
190
|
-
* @function dumpFiles
|
|
191
|
-
* @param {Array} fileList - Array of file objects
|
|
192
|
-
* @param {Array} parsingQueue - Array of queued files to be parsed
|
|
193
|
-
* @param {Object} allSeriesStack - Series stack object to be populated
|
|
194
|
-
* @param {Function} callback - Passed through
|
|
195
|
-
*/
|
|
196
|
-
let dumpFiles = function (fileList, parsingQueue, allSeriesStack, callback) {
|
|
197
|
-
forEach(fileList, function (file) {
|
|
198
|
-
if (!file.name.startsWith(".") && !file.name.startsWith("DICOMDIR")) {
|
|
199
|
-
parsingQueue.push(file);
|
|
200
|
-
// enable parsing on first available path
|
|
201
|
-
if (parsingQueueFlag === null) {
|
|
202
|
-
parsingQueueFlag = true;
|
|
203
|
-
}
|
|
204
|
-
}
|
|
205
|
-
});
|
|
206
|
-
parseNextFile(parsingQueue, allSeriesStack, callback);
|
|
207
|
-
};
|
|
208
|
-
|
|
209
|
-
/**
|
|
210
|
-
* Dump a single DICOM File (metaData and pixelData)
|
|
211
|
-
* @inner
|
|
212
|
-
* @function dumpFile
|
|
213
|
-
* @param {File} file - File object to be dumped
|
|
214
|
-
* @param {Function} callback - called with (imageObject, errorString)
|
|
215
|
-
*/
|
|
216
|
-
let dumpFile = function (file, callback) {
|
|
217
|
-
let reader = new FileReader();
|
|
218
|
-
reader.onload = function () {
|
|
219
|
-
let arrayBuffer = reader.result;
|
|
220
|
-
// Here we have the file data as an ArrayBuffer.
|
|
221
|
-
// dicomParser requires as input a Uint8Array so we create that here.
|
|
222
|
-
let byteArray = new Uint8Array(arrayBuffer);
|
|
223
|
-
|
|
224
|
-
let dataSet;
|
|
225
|
-
try {
|
|
226
|
-
dataSet = parseDicom(byteArray);
|
|
227
|
-
byteArray = null;
|
|
228
|
-
let metadata = {};
|
|
229
|
-
dumpDataSet(dataSet, metadata);
|
|
230
|
-
|
|
231
|
-
let numberOfFrames = metadata["x00280008"];
|
|
232
|
-
let isMultiframe = numberOfFrames > 1 ? true : false;
|
|
233
|
-
// Overwrite SOPInstanceUID to manage multiframes.
|
|
234
|
-
// Usually different SeriesInstanceUID means different series and that value
|
|
235
|
-
// is used into the application to group different instances into the same series,
|
|
236
|
-
// but if a DICOM file contains a multiframe series, then the SeriesInstanceUID
|
|
237
|
-
// can be shared by other files of the same study.
|
|
238
|
-
// In multiframe cases, the SOPInstanceUID (unique) is used as SeriesInstanceUID.
|
|
239
|
-
let seriesInstanceUID = isMultiframe
|
|
240
|
-
? metadata["x00080018"]
|
|
241
|
-
: metadata["x0020000e"];
|
|
242
|
-
let pixelSpacing = metadata["x00280030"];
|
|
243
|
-
let imageOrientation = metadata["x00200037"];
|
|
244
|
-
let imagePosition = metadata["x00200032"];
|
|
245
|
-
let sliceThickness = metadata["x00180050"];
|
|
246
|
-
|
|
247
|
-
if (dataSet.warnings.length > 0) {
|
|
248
|
-
// warnings
|
|
249
|
-
callback(null, dataSet.warnings);
|
|
250
|
-
} else {
|
|
251
|
-
let pixelDataElement = dataSet.elements.x7fe00010;
|
|
252
|
-
|
|
253
|
-
if (pixelDataElement) {
|
|
254
|
-
// done, pixelDataElement found
|
|
255
|
-
let instanceUID = metadata["x00080018"] || randomId();
|
|
256
|
-
let imageObject = {
|
|
257
|
-
// data needed for rendering
|
|
258
|
-
file: file,
|
|
259
|
-
dataSet: dataSet
|
|
260
|
-
};
|
|
261
|
-
imageObject.metadata = metadata;
|
|
262
|
-
imageObject.metadata.seriesUID = seriesInstanceUID;
|
|
263
|
-
imageObject.metadata.instanceUID = instanceUID;
|
|
264
|
-
imageObject.metadata.studyUID = metadata["x0020000d"];
|
|
265
|
-
imageObject.metadata.accessionNumber = metadata["x00080050"];
|
|
266
|
-
imageObject.metadata.studyDescription = metadata["x00081030"];
|
|
267
|
-
imageObject.metadata.patientName = metadata["x00100010"];
|
|
268
|
-
imageObject.metadata.patientBirthdate = metadata["x00100030"];
|
|
269
|
-
imageObject.metadata.seriesDescription = metadata["x0008103e"];
|
|
270
|
-
imageObject.metadata.seriesDate = metadata["x00080021"];
|
|
271
|
-
imageObject.metadata.seriesModality =
|
|
272
|
-
metadata["x00080060"].toLowerCase();
|
|
273
|
-
imageObject.metadata.intercept = metadata["x00281052"];
|
|
274
|
-
imageObject.metadata.slope = metadata["x00281053"];
|
|
275
|
-
imageObject.metadata.pixelSpacing = pixelSpacing;
|
|
276
|
-
imageObject.metadata.sliceThickness = sliceThickness;
|
|
277
|
-
imageObject.metadata.imageOrientation = imageOrientation;
|
|
278
|
-
imageObject.metadata.imagePosition = imagePosition;
|
|
279
|
-
imageObject.metadata.rows = metadata["x00280010"];
|
|
280
|
-
imageObject.metadata.cols = metadata["x00280011"];
|
|
281
|
-
imageObject.metadata.numberOfSlices = metadata["x00540081"]
|
|
282
|
-
? metadata["x00540081"] // number of slices
|
|
283
|
-
: metadata["x00201002"]; // number of instances
|
|
284
|
-
imageObject.metadata.numberOfFrames = numberOfFrames;
|
|
285
|
-
if (isMultiframe) {
|
|
286
|
-
imageObject.metadata.frameTime = metadata["x00181063"];
|
|
287
|
-
imageObject.metadata.frameDelay = metadata["x00181066"];
|
|
288
|
-
}
|
|
289
|
-
imageObject.metadata.windowCenter = metadata["x00281050"];
|
|
290
|
-
imageObject.metadata.windowWidth = metadata["x00281051"];
|
|
291
|
-
imageObject.metadata.minPixelValue = metadata["x00280106"];
|
|
292
|
-
imageObject.metadata.maxPixelValue = metadata["x00280107"];
|
|
293
|
-
imageObject.metadata.length = pixelDataElement.length;
|
|
294
|
-
imageObject.metadata.repr = getPixelRepresentation(dataSet);
|
|
295
|
-
callback(imageObject);
|
|
296
|
-
} else {
|
|
297
|
-
// done, no pixelData
|
|
298
|
-
callback(null, "no pixelData.");
|
|
299
|
-
}
|
|
300
|
-
}
|
|
301
|
-
} catch (err) {
|
|
302
|
-
console.log(err);
|
|
303
|
-
callback(null, "can not read this file.");
|
|
304
|
-
}
|
|
305
|
-
};
|
|
306
|
-
reader.readAsArrayBuffer(file);
|
|
307
|
-
};
|
package/imaging/image_reslice.js
DELETED
|
@@ -1,80 +0,0 @@
|
|
|
1
|
-
/** @module imaging/reslice
|
|
2
|
-
* @desc This file provides functionalities for
|
|
3
|
-
* image reslice in orthogonal directions
|
|
4
|
-
*/
|
|
5
|
-
|
|
6
|
-
// external libraries
|
|
7
|
-
import { v4 as uuidv4 } from "uuid";
|
|
8
|
-
import { each } from "lodash";
|
|
9
|
-
|
|
10
|
-
// internal libraries
|
|
11
|
-
import { getReslicedMetadata, getReslicedPixeldata } from "./image_utils";
|
|
12
|
-
import {
|
|
13
|
-
getLarvitarImageTracker,
|
|
14
|
-
getLarvitarManager
|
|
15
|
-
} from "./loaders/commonLoader";
|
|
16
|
-
import { larvitar_store } from "./image_store";
|
|
17
|
-
|
|
18
|
-
/*
|
|
19
|
-
* This module provides the following functions to be exported:
|
|
20
|
-
* resliceSeries(seriesId, seriesData, orientation, callback)
|
|
21
|
-
*/
|
|
22
|
-
|
|
23
|
-
/**
|
|
24
|
-
* Reslice a serie from native orientation to coronal or sagittal orientation
|
|
25
|
-
* @instance
|
|
26
|
-
* @function resliceSeries
|
|
27
|
-
* @param {Object} seriesData the original series data
|
|
28
|
-
* @param {String} orientation the reslice orientation [coronal or sagittal]
|
|
29
|
-
* @param {String} seriesId the series id
|
|
30
|
-
* @return {Object} cornerstone data
|
|
31
|
-
*/
|
|
32
|
-
export function resliceSeries(seriesData, orientation, callback) {
|
|
33
|
-
let reslicedSeries = {};
|
|
34
|
-
let reslicedSeriesId = uuidv4();
|
|
35
|
-
let reslicedMetaData = getReslicedMetadata(
|
|
36
|
-
reslicedSeriesId,
|
|
37
|
-
"axial",
|
|
38
|
-
orientation,
|
|
39
|
-
seriesData,
|
|
40
|
-
"resliceLoader"
|
|
41
|
-
);
|
|
42
|
-
|
|
43
|
-
reslicedSeries.imageIds = reslicedMetaData.imageIds;
|
|
44
|
-
reslicedSeries.instances = reslicedMetaData.instances;
|
|
45
|
-
|
|
46
|
-
reslicedSeries.currentImageIdIndex = Math.floor(
|
|
47
|
-
reslicedSeries.imageIds.length / 2
|
|
48
|
-
);
|
|
49
|
-
|
|
50
|
-
function computeReslice(
|
|
51
|
-
seriesData,
|
|
52
|
-
reslicedSeriesId,
|
|
53
|
-
reslicedSeries,
|
|
54
|
-
callback
|
|
55
|
-
) {
|
|
56
|
-
let t0 = performance.now();
|
|
57
|
-
let imageTracker = getLarvitarImageTracker();
|
|
58
|
-
let manager = getLarvitarManager();
|
|
59
|
-
each(reslicedSeries.imageIds, function (imageId) {
|
|
60
|
-
reslicedSeries.instances[imageId].pixelData = getReslicedPixeldata(
|
|
61
|
-
imageId,
|
|
62
|
-
seriesData,
|
|
63
|
-
reslicedSeries
|
|
64
|
-
);
|
|
65
|
-
imageTracker[imageId] = reslicedSeriesId;
|
|
66
|
-
});
|
|
67
|
-
larvitar_store.addSeriesIds(reslicedSeriesId, reslicedSeries.imageIds);
|
|
68
|
-
reslicedSeries.numberOfImages = reslicedSeries.imageIds.length;
|
|
69
|
-
reslicedSeries.seriesUID = reslicedSeriesId;
|
|
70
|
-
reslicedSeries.seriesDescription = seriesData.seriesDescription;
|
|
71
|
-
reslicedSeries.orientation = orientation;
|
|
72
|
-
manager[reslicedSeriesId] = reslicedSeries;
|
|
73
|
-
manager[seriesData.seriesUID][orientation] = reslicedSeriesId;
|
|
74
|
-
let t1 = performance.now();
|
|
75
|
-
console.log(`Call to resliceSeries took ${t1 - t0} milliseconds.`);
|
|
76
|
-
callback(reslicedSeries);
|
|
77
|
-
}
|
|
78
|
-
// reslice the data
|
|
79
|
-
computeReslice(seriesData, reslicedSeriesId, reslicedSeries, callback);
|
|
80
|
-
}
|