larvitar 2.0.4 → 2.0.6

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.
Files changed (72) hide show
  1. package/README.md +2 -2
  2. package/dist/larvitar.js +5 -3
  3. package/dist/larvitar.js.map +1 -1
  4. package/package.json +6 -2
  5. package/.github/workflows/build-docs.yml +0 -59
  6. package/.github/workflows/codeql-analysis.yml +0 -71
  7. package/.github/workflows/deploy.yml +0 -37
  8. package/.vscode/settings.json +0 -4
  9. package/CODE_OF_CONDUCT.md +0 -76
  10. package/MIGRATION.md +0 -25
  11. package/bundler/webpack.common.js +0 -27
  12. package/bundler/webpack.dev.js +0 -23
  13. package/bundler/webpack.prod.js +0 -19
  14. package/decs.d.ts +0 -12
  15. package/imaging/MetaDataReadable.ts +0 -42
  16. package/imaging/MetaDataTypes.ts +0 -3491
  17. package/imaging/dataDictionary.json +0 -21866
  18. package/imaging/imageAnonymization.ts +0 -135
  19. package/imaging/imageColormaps.ts +0 -217
  20. package/imaging/imageContours.ts +0 -196
  21. package/imaging/imageIo.ts +0 -251
  22. package/imaging/imageLayers.ts +0 -121
  23. package/imaging/imageLoading.ts +0 -299
  24. package/imaging/imageParsing.ts +0 -444
  25. package/imaging/imagePresets.ts +0 -156
  26. package/imaging/imageRendering.ts +0 -1091
  27. package/imaging/imageReslice.ts +0 -87
  28. package/imaging/imageStore.ts +0 -487
  29. package/imaging/imageTags.ts +0 -609
  30. package/imaging/imageTools.js +0 -708
  31. package/imaging/imageUtils.ts +0 -1079
  32. package/imaging/loaders/commonLoader.ts +0 -275
  33. package/imaging/loaders/dicomLoader.ts +0 -66
  34. package/imaging/loaders/fileLoader.ts +0 -71
  35. package/imaging/loaders/multiframeLoader.ts +0 -435
  36. package/imaging/loaders/nrrdLoader.ts +0 -630
  37. package/imaging/loaders/resliceLoader.ts +0 -205
  38. package/imaging/monitors/memory.ts +0 -151
  39. package/imaging/monitors/performance.ts +0 -34
  40. package/imaging/parsers/ecg.ts +0 -54
  41. package/imaging/parsers/nrrd.js +0 -485
  42. package/imaging/tools/README.md +0 -27
  43. package/imaging/tools/custom/4dSliceScrollTool.js +0 -146
  44. package/imaging/tools/custom/BorderMagnifyTool.js +0 -99
  45. package/imaging/tools/custom/contourTool.js +0 -1884
  46. package/imaging/tools/custom/diameterTool.js +0 -141
  47. package/imaging/tools/custom/editMaskTool.js +0 -141
  48. package/imaging/tools/custom/ellipticalRoiOverlayTool.js +0 -534
  49. package/imaging/tools/custom/polygonSegmentationMixin.js +0 -245
  50. package/imaging/tools/custom/polylineScissorsTool.js +0 -59
  51. package/imaging/tools/custom/rectangleRoiOverlayTool.js +0 -564
  52. package/imaging/tools/custom/seedTool.js +0 -342
  53. package/imaging/tools/custom/setLabelMap3D.ts +0 -242
  54. package/imaging/tools/custom/thresholdsBrushTool.js +0 -161
  55. package/imaging/tools/default.ts +0 -594
  56. package/imaging/tools/interaction.ts +0 -266
  57. package/imaging/tools/io.ts +0 -229
  58. package/imaging/tools/main.ts +0 -424
  59. package/imaging/tools/segmentation.ts +0 -532
  60. package/imaging/tools/segmentations.md +0 -38
  61. package/imaging/tools/state.ts +0 -74
  62. package/imaging/tools/strategies/eraseFreehand.js +0 -76
  63. package/imaging/tools/strategies/fillFreehand.js +0 -79
  64. package/imaging/tools/strategies/index.js +0 -2
  65. package/imaging/tools/types.d.ts +0 -243
  66. package/imaging/types.d.ts +0 -200
  67. package/imaging/waveforms/ecg.ts +0 -191
  68. package/index.ts +0 -431
  69. package/jsdoc.json +0 -52
  70. package/rollup.config.js +0 -51
  71. package/template/.gitkeep +0 -0
  72. package/tsconfig.json +0 -102
@@ -1,275 +0,0 @@
1
- /** @module loaders/commonLoader
2
- * @desc This file provides functionalities for
3
- * custom DICOMImageLoaders
4
- */
5
-
6
- // external libraries
7
- import { default as cornerstoneDICOMImageLoader } from "cornerstone-wado-image-loader";
8
- import { DataSet } from "dicom-parser";
9
- import { each } from "lodash";
10
- import { updateLoadedStack } from "../imageLoading";
11
- import type {
12
- ImageObject,
13
- ImageTracker,
14
- LarvitarManager,
15
- MetaData,
16
- Series
17
- } from "../types";
18
-
19
- // internal libraries
20
- import { buildMultiFrameImage, clearMultiFrameCache } from "./multiframeLoader";
21
-
22
- // global variables
23
- var larvitarManager: LarvitarManager = null;
24
- var imageTracker: ImageTracker = null;
25
-
26
- /*
27
- * This module provides the following functions to be exported:
28
- * updateLarvitarManager(imageObject)
29
- * populateLarvitarManager(seriesId, seriesData)
30
- * getLarvitarManager()
31
- * getLarvitarImageTracker()
32
- * resetLarvitarManager()
33
- * removeSeriesFromLarvitarManager(seriesId)
34
- * getSeriesDataFromLarvitarManager(seriesId)
35
- * getImageFrame(metadata, dataSet)
36
- * getSopInstanceUIDFromLarvitarManager(larvitarSeriesInstanceUID, imageId)
37
- */
38
-
39
- /**
40
- * Update and initialize larvitar manager in order to parse and load a single dicom object
41
- * @instance
42
- * @function updateLarvitarManager
43
- * @param {Object} imageObject The single dicom object
44
- * @param {String} customId - Optional custom id to overwrite seriesUID as default one
45
- * @param {number} sliceIndex - Optional custom index to overwrite slice index as default one
46
- */
47
- export const updateLarvitarManager = function (
48
- imageObject: ImageObject,
49
- customId?: string,
50
- sliceIndex?: number
51
- ) {
52
- if (larvitarManager === null) {
53
- larvitarManager = {};
54
- }
55
-
56
- let data = { ...imageObject };
57
-
58
- if (data.metadata?.isMultiframe) {
59
- let seriesId = customId || imageObject.metadata.seriesUID;
60
- let loadedStack: ReturnType<typeof getLarvitarManager> = {};
61
- updateLoadedStack(data, loadedStack, customId, sliceIndex);
62
- buildMultiFrameImage(
63
- seriesId as string,
64
- loadedStack[seriesId as string] as Series
65
- );
66
- } else {
67
- updateLoadedStack(data, larvitarManager, customId, sliceIndex);
68
- }
69
- return larvitarManager;
70
- };
71
-
72
- /**
73
- * This function can be called in order to populate the Larvitar manager
74
- * @instance
75
- * @function populateLarvitarManager
76
- * @param {String} seriesId The Id of the series
77
- * @param {Object} seriesData The series data
78
- * @returns {manager} the Larvitar manager
79
- */
80
- export const populateLarvitarManager = function (
81
- seriesId: string,
82
- seriesData: Series
83
- ) {
84
- if (larvitarManager === null) {
85
- larvitarManager = {};
86
- }
87
- let data = { ...seriesData };
88
- if (data.isMultiframe) {
89
- buildMultiFrameImage(seriesId, data);
90
- } else {
91
- larvitarManager[seriesId] = data;
92
- }
93
- return larvitarManager;
94
- };
95
-
96
- /**
97
- * Return the common data loader manager
98
- * @instance
99
- * @function getLarvitarManager
100
- * @returns {Object} the loader manager
101
- */
102
- export const getLarvitarManager = function () {
103
- if (larvitarManager == null) {
104
- larvitarManager = {};
105
- }
106
- return larvitarManager;
107
- };
108
-
109
- /**
110
- * Return the common image tracker
111
- * @instance
112
- * @function getLarvitarImageTracker
113
- * @returns {Object} the image tracker
114
- */
115
- export const getLarvitarImageTracker = function () {
116
- if (imageTracker == null) {
117
- imageTracker = {};
118
- }
119
- return imageTracker;
120
- };
121
-
122
- /**
123
- * Reset the Larvitar Manager store
124
- * @instance
125
- * @function resetLarvitarManager
126
- */
127
- export const resetLarvitarManager = function () {
128
- each(larvitarManager, function (stack) {
129
- if ((stack as Series).isMultiframe) {
130
- if ((stack as Series).dataSet) {
131
- //@ts-ignore for memory leak
132
- (stack as Series).dataSet!.byteArray = null;
133
- }
134
- (stack as Series).dataSet = null;
135
- (stack as Series).elements = null;
136
- clearMultiFrameCache(stack.seriesUID);
137
- }
138
- each(stack.instances, function (instance) {
139
- if (instance.dataSet) {
140
- //@ts-ignore for memory leak
141
- instance.dataSet.byteArray = null;
142
- }
143
- instance.dataSet = null;
144
- instance.file = null;
145
- //@ts-ignore for memory leak
146
- instance.metadata = null;
147
- });
148
- });
149
- larvitarManager = null;
150
- imageTracker = null;
151
- };
152
-
153
- /**
154
- * Remove a stored seriesId from the larvitar Manager
155
- * @instance
156
- * @function removeSeriesFromLarvitarManager
157
- * @param {String} seriesId The Id of the series
158
- */
159
- export const removeSeriesFromLarvitarManager = function (seriesId: string) {
160
- if (larvitarManager && larvitarManager[seriesId]) {
161
- if ((larvitarManager[seriesId] as Series).isMultiframe) {
162
- //@ts-ignore for memory leak
163
- (larvitarManager[seriesId] as Series).dataSet.byteArray = null;
164
- (larvitarManager[seriesId] as Series).dataSet = null;
165
- (larvitarManager[seriesId] as Series).elements = null;
166
- clearMultiFrameCache(seriesId);
167
- }
168
- each(larvitarManager[seriesId].instances, function (instance) {
169
- if (instance.dataSet) {
170
- //@ts-ignore for memory leak
171
- instance.dataSet.byteArray = null;
172
- }
173
- instance.dataSet = null;
174
- instance.file = null;
175
- //@ts-ignore for memory leak
176
- instance.metadata = null;
177
- });
178
- //@ts-ignore for memory leak
179
- larvitarManager[seriesId] = null;
180
- delete larvitarManager[seriesId];
181
- }
182
- };
183
-
184
- /**
185
- * Return the data of a specific seriesId stored in the DICOM Manager
186
- * @instance
187
- * @function getSeriesDataFromLarvitarManager
188
- * @param {String} seriesId The Id of the series
189
- * @return {Object} larvitar manager data
190
- */
191
- export const getSeriesDataFromLarvitarManager = function (seriesId: string) {
192
- return larvitarManager ? larvitarManager[seriesId] : null;
193
- };
194
-
195
- /**
196
- * Compute and return image frame
197
- * @instance
198
- * @function getImageFrame
199
- * @param {Object} metadata metadata object
200
- * @param {Object} dataSet dicom dataset
201
- * @returns {Object} specific image frame
202
- */
203
- export const getImageFrame = function (metadata: MetaData, dataSet: DataSet) {
204
- let imagePixelModule;
205
-
206
- if (dataSet) {
207
- imagePixelModule =
208
- cornerstoneDICOMImageLoader.wadouri.metaData.getImagePixelModule(dataSet);
209
- } else {
210
- imagePixelModule = {
211
- samplesPerPixel: metadata.x00280002,
212
- photometricInterpretation: metadata.x00280004,
213
- planarConfiguration: metadata.x00280006,
214
- rows: metadata.x00280010,
215
- columns: metadata.x00280011,
216
- bitsAllocated: metadata.x00280100,
217
- pixelRepresentation: metadata.x00280103,
218
- smallestPixelValue: metadata.x00280106,
219
- largestPixelValue: metadata.x00280107,
220
- redPaletteColorLookupTableDescriptor: metadata.x00281101,
221
- greenPaletteColorLookupTableDescriptor: metadata.x00281102,
222
- bluePaletteColorLookupTableDescriptor: metadata.x00281103,
223
- redPaletteColorLookupTableData: metadata.x00281201,
224
- greenPaletteColorLookupTableData: metadata.x00281202,
225
- bluePaletteColorLookupTableData: metadata.x00281203
226
- };
227
- }
228
-
229
- return {
230
- samplesPerPixel: imagePixelModule.samplesPerPixel,
231
- photometricInterpretation: imagePixelModule.photometricInterpretation,
232
- planarConfiguration: imagePixelModule.planarConfiguration,
233
- rows: imagePixelModule.rows,
234
- columns: imagePixelModule.columns,
235
- bitsAllocated: imagePixelModule.bitsAllocated,
236
- pixelRepresentation: imagePixelModule.pixelRepresentation, // 0 = unsigned,
237
- smallestPixelValue: imagePixelModule.smallestPixelValue,
238
- largestPixelValue: imagePixelModule.largestPixelValue,
239
- redPaletteColorLookupTableDescriptor:
240
- imagePixelModule.redPaletteColorLookupTableDescriptor,
241
- greenPaletteColorLookupTableDescriptor:
242
- imagePixelModule.greenPaletteColorLookupTableDescriptor,
243
- bluePaletteColorLookupTableDescriptor:
244
- imagePixelModule.bluePaletteColorLookupTableDescriptor,
245
- redPaletteColorLookupTableData:
246
- imagePixelModule.redPaletteColorLookupTableData,
247
- greenPaletteColorLookupTableData:
248
- imagePixelModule.greenPaletteColorLookupTableData,
249
- bluePaletteColorLookupTableData:
250
- imagePixelModule.bluePaletteColorLookupTableData,
251
- pixelData: undefined, // populated later after decoding,
252
- ImageData: undefined
253
- };
254
- };
255
-
256
- /**
257
- * Return the SOP Instance UID of a specific imageId stored in the Larvitar Manager
258
- * @instance
259
- * @function getSopInstanceUIDFromLarvitarManager
260
- * @param {String} larvitarSeriesInstanceUID The Id of the series
261
- * @param {String} imageId The Id of the image
262
- * @returns {String} sopInstanceUID
263
- */
264
- export const getSopInstanceUIDFromLarvitarManager = function (
265
- larvitarSeriesInstanceUID: string,
266
- imageId: string
267
- ) {
268
- if (larvitarManager === null) {
269
- return null;
270
- }
271
- let series = larvitarManager[larvitarSeriesInstanceUID];
272
- return Object.keys(series.instanceUIDs).find(
273
- key => series.instanceUIDs[key] === imageId
274
- );
275
- };
@@ -1,66 +0,0 @@
1
- /** @module loaders/dicomLoader
2
- * @desc This file provides functionalities for
3
- * custom DICOM Loader
4
- */
5
-
6
- // internal libraries
7
- import { loadAndCacheImage, loadAndCacheImages } from "../imageRendering";
8
- import type { Series, CachingResponse } from "../types";
9
-
10
- /*
11
- * This module provides the following functions to be exported:
12
- * cacheImage(seriesData, imageIndex)
13
- * cacheImages(seriesData, callback)
14
- * getDicomImageId(dicomLoaderName)
15
- */
16
-
17
- let imageLoaderCounter = 0;
18
-
19
- /**
20
- * Load and cache a single image
21
- * @instance
22
- * @function cacheImage
23
- * @param {Object} seriesData The series data
24
- * @param {number} imageIndex The image index in the imageIds array
25
- */
26
-
27
- export const cacheImage = async function (
28
- seriesData: Series,
29
- imageIndex: number
30
- ) {
31
- return loadAndCacheImage(seriesData, imageIndex);
32
- };
33
-
34
- /**
35
- * Load and cache images
36
- * @instance
37
- * @function cacheImages
38
- * @param {Object} seriesData The series data
39
- * @param {Function} callback Optional callback function
40
- */
41
- export const cacheImages = async function (
42
- seriesData: Series,
43
- callback?: Function
44
- ) {
45
- loadAndCacheImages(seriesData, function (resp: CachingResponse) {
46
- if (resp.loading == 100) {
47
- imageLoaderCounter += seriesData.imageIds.length;
48
- }
49
- if (callback) {
50
- callback(resp);
51
- }
52
- });
53
- };
54
-
55
- /**
56
- * Get the dicom imageId from dicom loader
57
- * @instance
58
- * @function getDicomImageId
59
- * @param {String} dicomLoaderName dicom loader name
60
- * @return {String} current dicom image id
61
- */
62
- export const getDicomImageId = function (dicomLoaderName: string) {
63
- let imageId = dicomLoaderName + ":" + imageLoaderCounter;
64
- imageLoaderCounter++;
65
- return imageId;
66
- };
@@ -1,71 +0,0 @@
1
- /** @module loaders/fileLoader
2
- * @desc This file provides functionalities for
3
- * custom File Loader
4
- */
5
-
6
- // external libraries
7
- import cornerstoneFileImageLoader from "cornerstone-file-image-loader";
8
- import { has } from "lodash";
9
-
10
- // internal libraries
11
- import { clearImageCache } from "../imageRendering";
12
- import { clearCornerstoneElements } from "../imageTools";
13
-
14
- // global variables
15
- export var fileManager: {
16
- [key: string]: string;
17
- } = {};
18
-
19
- /*
20
- * This module provides the following functions to be exported:
21
- * resetFileLoader()
22
- * resetFileManager()
23
- * populateFileManager(file)
24
- * getFileImageId(file)
25
- */
26
-
27
- /**
28
- * Reset the Custom File Loader
29
- * @instance
30
- * @function resetFileLoader
31
- */
32
- export const resetFileLoader = function () {
33
- clearCornerstoneElements();
34
- resetFileManager();
35
- clearImageCache();
36
- };
37
-
38
- /**
39
- * Reset the File Manager store
40
- * @instance
41
- * @function resetFileManager
42
- */
43
- export const resetFileManager = function () {
44
- fileManager = {};
45
- };
46
-
47
- /**
48
- * Populate File Manager
49
- * @instance
50
- * @function populateFileManager
51
- * @return {String} current file image id
52
- */
53
- export const populateFileManager = function (file: File) {
54
- let uuid = file.webkitRelativePath || file.name;
55
- if (!has(fileManager, uuid)) {
56
- const imageId = cornerstoneFileImageLoader.fileManager.add(file);
57
- fileManager[uuid] = imageId;
58
- }
59
- };
60
-
61
- /**
62
- * Get the file imageId from file loader
63
- * @instance
64
- * @function getFileImageId
65
- * @return {String} current file image id
66
- */
67
- export const getFileImageId = function (file: File) {
68
- let uuid = file.webkitRelativePath || file.name;
69
- const imageId = has(fileManager, uuid) ? fileManager[uuid] : null;
70
- return imageId;
71
- };