larvitar 1.5.13 → 2.0.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.
Files changed (103) hide show
  1. package/.vscode/settings.json +4 -0
  2. package/README.md +78 -48
  3. package/bundler/webpack.common.js +27 -0
  4. package/bundler/webpack.dev.js +23 -0
  5. package/bundler/webpack.prod.js +19 -0
  6. package/decs.d.ts +12 -0
  7. package/dist/imaging/MetaDataReadable.d.ts +39 -0
  8. package/dist/imaging/MetaDataTypes.d.ts +3488 -0
  9. package/dist/imaging/imageAnonymization.d.ts +12 -0
  10. package/dist/imaging/imageColormaps.d.ts +47 -0
  11. package/dist/imaging/imageContours.d.ts +18 -0
  12. package/dist/imaging/imageIo.d.ts +42 -0
  13. package/dist/imaging/imageLayers.d.ts +56 -0
  14. package/dist/imaging/imageLoading.d.ts +65 -0
  15. package/dist/imaging/imageParsing.d.ts +46 -0
  16. package/dist/imaging/imagePresets.d.ts +43 -0
  17. package/dist/imaging/imageRendering.d.ts +238 -0
  18. package/dist/imaging/imageReslice.d.ts +14 -0
  19. package/dist/imaging/imageStore.d.ts +121 -0
  20. package/dist/imaging/imageTags.d.ts +22 -0
  21. package/dist/imaging/imageTools.d.ts +20 -0
  22. package/dist/imaging/imageUtils.d.ts +165 -0
  23. package/dist/imaging/loaders/commonLoader.d.ts +103 -0
  24. package/dist/imaging/loaders/dicomLoader.d.ts +29 -0
  25. package/dist/imaging/loaders/fileLoader.d.ts +33 -0
  26. package/dist/imaging/loaders/multiframeLoader.d.ts +37 -0
  27. package/dist/imaging/loaders/nrrdLoader.d.ts +112 -0
  28. package/dist/imaging/loaders/resliceLoader.d.ts +15 -0
  29. package/dist/imaging/monitors/memory.d.ts +41 -0
  30. package/dist/imaging/monitors/performance.d.ts +23 -0
  31. package/dist/imaging/parsers/ecg.d.ts +15 -0
  32. package/dist/imaging/parsers/nrrd.d.ts +3 -0
  33. package/dist/imaging/tools/custom/4dSliceScrollTool.d.ts +12 -0
  34. package/dist/imaging/tools/custom/contourTool.d.ts +409 -0
  35. package/dist/imaging/tools/custom/diameterTool.d.ts +18 -0
  36. package/dist/imaging/tools/custom/editMaskTool.d.ts +22 -0
  37. package/dist/imaging/tools/custom/ellipticalRoiOverlayTool.d.ts +45 -0
  38. package/dist/imaging/tools/custom/polygonSegmentationMixin.d.ts +54 -0
  39. package/dist/imaging/tools/custom/polylineScissorsTool.d.ts +11 -0
  40. package/dist/imaging/tools/custom/rectangleRoiOverlayTool.d.ts +45 -0
  41. package/dist/imaging/tools/custom/seedTool.d.ts +0 -0
  42. package/dist/imaging/tools/custom/setLabelMap3D.d.ts +39 -0
  43. package/dist/imaging/tools/custom/thresholdsBrushTool.d.ts +19 -0
  44. package/dist/imaging/tools/default.d.ts +53 -0
  45. package/dist/imaging/tools/interaction.d.ts +30 -0
  46. package/dist/imaging/tools/io.d.ts +38 -0
  47. package/dist/imaging/tools/main.d.ts +81 -0
  48. package/dist/imaging/tools/segmentation.d.ts +125 -0
  49. package/dist/imaging/tools/state.d.ts +17 -0
  50. package/dist/imaging/tools/strategies/eraseFreehand.d.ts +16 -0
  51. package/dist/imaging/tools/strategies/fillFreehand.d.ts +16 -0
  52. package/dist/imaging/tools/strategies/index.d.ts +2 -0
  53. package/dist/index.d.ts +34 -0
  54. package/dist/larvitar.js +89801 -0
  55. package/dist/larvitar.js.map +1 -0
  56. package/imaging/MetaDataReadable.ts +40 -0
  57. package/imaging/MetaDataTypes.ts +3490 -0
  58. package/imaging/dataDictionary.json +5328 -5328
  59. package/imaging/{imageAnonymization.js → imageAnonymization.ts} +41 -13
  60. package/imaging/{imageColormaps.js → imageColormaps.ts} +48 -30
  61. package/imaging/{imageContours.js → imageContours.ts} +24 -22
  62. package/imaging/{imageIo.js → imageIo.ts} +89 -52
  63. package/imaging/{imageLayers.js → imageLayers.ts} +31 -14
  64. package/imaging/{imageLoading.js → imageLoading.ts} +108 -45
  65. package/imaging/{imageParsing.js → imageParsing.ts} +158 -80
  66. package/imaging/{imagePresets.js → imagePresets.ts} +44 -11
  67. package/imaging/imageRendering.ts +1091 -0
  68. package/imaging/{imageReslice.js → imageReslice.ts} +18 -9
  69. package/imaging/imageStore.ts +487 -0
  70. package/imaging/imageTags.ts +609 -0
  71. package/imaging/imageTools.js +2 -1
  72. package/imaging/{imageUtils.js → imageUtils.ts} +211 -701
  73. package/imaging/loaders/{commonLoader.js → commonLoader.ts} +73 -24
  74. package/imaging/loaders/{dicomLoader.js → dicomLoader.ts} +25 -5
  75. package/imaging/loaders/{fileLoader.js → fileLoader.ts} +5 -5
  76. package/imaging/loaders/{multiframeLoader.js → multiframeLoader.ts} +145 -90
  77. package/imaging/loaders/{nrrdLoader.js → nrrdLoader.ts} +230 -64
  78. package/imaging/loaders/{resliceLoader.js → resliceLoader.ts} +51 -20
  79. package/imaging/monitors/{memory.js → memory.ts} +54 -8
  80. package/imaging/monitors/performance.ts +34 -0
  81. package/imaging/parsers/ecg.ts +51 -0
  82. package/imaging/tools/README.md +27 -0
  83. package/imaging/tools/custom/4dSliceScrollTool.js +47 -46
  84. package/imaging/tools/custom/ellipticalRoiOverlayTool.js +534 -0
  85. package/imaging/tools/custom/polylineScissorsTool.js +1 -1
  86. package/imaging/tools/custom/rectangleRoiOverlayTool.js +564 -0
  87. package/imaging/tools/{setLabelMap3D.js → custom/setLabelMap3D.ts} +19 -25
  88. package/imaging/tools/{default.js → default.ts} +114 -30
  89. package/imaging/tools/{interaction.js → interaction.ts} +42 -23
  90. package/imaging/tools/{io.js → io.ts} +47 -31
  91. package/imaging/tools/{main.js → main.ts} +105 -40
  92. package/imaging/tools/{segmentation.js → segmentation.ts} +95 -68
  93. package/imaging/tools/{state.js → state.ts} +7 -12
  94. package/imaging/tools/types.d.ts +243 -0
  95. package/imaging/types.d.ts +197 -0
  96. package/{index.js → index.ts} +43 -14
  97. package/jsdoc.json +1 -1
  98. package/package.json +32 -14
  99. package/tsconfig.json +102 -0
  100. package/imaging/imageRendering.js +0 -860
  101. package/imaging/imageStore.js +0 -322
  102. package/modules/vuex/larvitar.js +0 -187
  103. /package/imaging/tools/{polygonSegmentationMixin.js → custom/polygonSegmentationMixin.js} +0 -0
@@ -1,19 +1,27 @@
1
1
  /** @module loaders/commonLoader
2
2
  * @desc This file provides functionalities for
3
- * custom WadoImageLoaders
3
+ * custom DICOMImageLoaders
4
4
  */
5
5
 
6
6
  // external libraries
7
7
  import { default as cornerstoneDICOMImageLoader } from "cornerstone-wado-image-loader";
8
+ import { DataSet } from "dicom-parser";
8
9
  import { each } from "lodash";
9
10
  import { updateLoadedStack } from "../imageLoading";
11
+ import type {
12
+ ImageObject,
13
+ ImageTracker,
14
+ LarvitarManager,
15
+ MetaData,
16
+ Series
17
+ } from "../types";
10
18
 
11
19
  // internal libraries
12
20
  import { buildMultiFrameImage, clearMultiFrameCache } from "./multiframeLoader";
13
21
 
14
22
  // global variables
15
- var larvitarManager = null;
16
- var imageTracker = null;
23
+ var larvitarManager: LarvitarManager = null;
24
+ var imageTracker: ImageTracker = null;
17
25
 
18
26
  /*
19
27
  * This module provides the following functions to be exported:
@@ -25,6 +33,7 @@ var imageTracker = null;
25
33
  * removeSeriesFromLarvitarManager(seriesId)
26
34
  * getSeriesDataFromLarvitarManager(seriesId)
27
35
  * getImageFrame(metadata, dataSet)
36
+ * getSopInstanceUIDFromLarvitarManager(larvitarSeriesInstanceUID, imageId)
28
37
  */
29
38
 
30
39
  /**
@@ -33,21 +42,29 @@ var imageTracker = null;
33
42
  * @function updateLarvitarManager
34
43
  * @param {Object} imageObject The single dicom object
35
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
36
46
  */
37
- export const updateLarvitarManager = function (imageObject, customId) {
47
+ export const updateLarvitarManager = function (
48
+ imageObject: ImageObject,
49
+ customId?: string,
50
+ sliceIndex?: number
51
+ ) {
38
52
  if (larvitarManager === null) {
39
53
  larvitarManager = {};
40
54
  }
41
55
 
42
- let seriesId = customId || imageObject.seriesUID;
43
56
  let data = { ...imageObject };
44
57
 
45
- if (data.metadata.isMultiframe) {
46
- seriesId = customId || imageObject.metadata.seriesUID;
47
- updateLoadedStack(data, larvitarManager, customId);
48
- buildMultiFrameImage(seriesId, larvitarManager[seriesId]);
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
+ );
49
66
  } else {
50
- updateLoadedStack(data, larvitarManager, customId);
67
+ updateLoadedStack(data, larvitarManager, customId, sliceIndex);
51
68
  }
52
69
  return larvitarManager;
53
70
  };
@@ -60,7 +77,10 @@ export const updateLarvitarManager = function (imageObject, customId) {
60
77
  * @param {Object} seriesData The series data
61
78
  * @returns {manager} the Larvitar manager
62
79
  */
63
- export const populateLarvitarManager = function (seriesId, seriesData) {
80
+ export const populateLarvitarManager = function (
81
+ seriesId: string,
82
+ seriesData: Series
83
+ ) {
64
84
  if (larvitarManager === null) {
65
85
  larvitarManager = {};
66
86
  }
@@ -106,20 +126,23 @@ export const getLarvitarImageTracker = function () {
106
126
  */
107
127
  export const resetLarvitarManager = function () {
108
128
  each(larvitarManager, function (stack) {
109
- if (stack.isMultiframe) {
110
- if (stack.dataSet) {
111
- stack.dataSet.byteArray = null;
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;
112
133
  }
113
- stack.dataSet = null;
114
- stack.elements = null;
134
+ (stack as Series).dataSet = null;
135
+ (stack as Series).elements = null;
115
136
  clearMultiFrameCache(stack.seriesUID);
116
137
  }
117
138
  each(stack.instances, function (instance) {
118
139
  if (instance.dataSet) {
140
+ //@ts-ignore for memory leak
119
141
  instance.dataSet.byteArray = null;
120
142
  }
121
143
  instance.dataSet = null;
122
144
  instance.file = null;
145
+ //@ts-ignore for memory leak
123
146
  instance.metadata = null;
124
147
  });
125
148
  });
@@ -133,22 +156,26 @@ export const resetLarvitarManager = function () {
133
156
  * @function removeSeriesFromLarvitarManager
134
157
  * @param {String} seriesId The Id of the series
135
158
  */
136
- export const removeSeriesFromLarvitarManager = function (seriesId) {
159
+ export const removeSeriesFromLarvitarManager = function (seriesId: string) {
137
160
  if (larvitarManager && larvitarManager[seriesId]) {
138
- if (larvitarManager[seriesId].isMultiframe) {
139
- larvitarManager[seriesId].dataSet.byteArray = null;
140
- larvitarManager[seriesId].dataSet = null;
141
- larvitarManager[seriesId].elements = null;
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;
142
166
  clearMultiFrameCache(seriesId);
143
167
  }
144
168
  each(larvitarManager[seriesId].instances, function (instance) {
145
169
  if (instance.dataSet) {
170
+ //@ts-ignore for memory leak
146
171
  instance.dataSet.byteArray = null;
147
172
  }
148
173
  instance.dataSet = null;
149
174
  instance.file = null;
175
+ //@ts-ignore for memory leak
150
176
  instance.metadata = null;
151
177
  });
178
+ //@ts-ignore for memory leak
152
179
  larvitarManager[seriesId] = null;
153
180
  delete larvitarManager[seriesId];
154
181
  }
@@ -161,7 +188,7 @@ export const removeSeriesFromLarvitarManager = function (seriesId) {
161
188
  * @param {String} seriesId The Id of the series
162
189
  * @return {Object} larvitar manager data
163
190
  */
164
- export const getSeriesDataFromLarvitarManager = function (seriesId) {
191
+ export const getSeriesDataFromLarvitarManager = function (seriesId: string) {
165
192
  return larvitarManager ? larvitarManager[seriesId] : null;
166
193
  };
167
194
 
@@ -173,7 +200,7 @@ export const getSeriesDataFromLarvitarManager = function (seriesId) {
173
200
  * @param {Object} dataSet dicom dataset
174
201
  * @returns {Object} specific image frame
175
202
  */
176
- export const getImageFrame = function (metadata, dataSet) {
203
+ export const getImageFrame = function (metadata: MetaData, dataSet: DataSet) {
177
204
  let imagePixelModule;
178
205
 
179
206
  if (dataSet) {
@@ -221,6 +248,28 @@ export const getImageFrame = function (metadata, dataSet) {
221
248
  imagePixelModule.greenPaletteColorLookupTableData,
222
249
  bluePaletteColorLookupTableData:
223
250
  imagePixelModule.bluePaletteColorLookupTableData,
224
- pixelData: undefined // populated later after decoding
251
+ pixelData: undefined, // populated later after decoding,
252
+ ImageData: undefined
225
253
  };
226
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
+ };
@@ -4,25 +4,45 @@
4
4
  */
5
5
 
6
6
  // internal libraries
7
- import { loadAndCacheImages } from "../imageRendering";
7
+ import { loadAndCacheImage, loadAndCacheImages } from "../imageRendering";
8
+ import type { Series, CachingResponse } from "../types";
8
9
 
9
10
  /*
10
11
  * This module provides the following functions to be exported:
12
+ * cacheImage(seriesData, imageIndex)
11
13
  * cacheImages(seriesData, callback)
12
14
  * getDicomImageId(dicomLoaderName)
13
15
  */
14
16
 
15
17
  let imageLoaderCounter = 0;
16
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
+
17
34
  /**
18
35
  * Load and cache images
19
36
  * @instance
20
37
  * @function cacheImages
21
38
  * @param {Object} seriesData The series data
22
- * @param {Function} callback An optional callback function
39
+ * @param {Function} callback Optional callback function
23
40
  */
24
- export const cacheImages = function (seriesData, callback) {
25
- loadAndCacheImages(seriesData, function (resp) {
41
+ export const cacheImages = async function (
42
+ seriesData: Series,
43
+ callback?: Function
44
+ ) {
45
+ loadAndCacheImages(seriesData, function (resp: CachingResponse) {
26
46
  if (resp.loading == 100) {
27
47
  imageLoaderCounter += seriesData.imageIds.length;
28
48
  }
@@ -39,7 +59,7 @@ export const cacheImages = function (seriesData, callback) {
39
59
  * @param {String} dicomLoaderName dicom loader name
40
60
  * @return {String} current dicom image id
41
61
  */
42
- export const getDicomImageId = function (dicomLoaderName) {
62
+ export const getDicomImageId = function (dicomLoaderName: string) {
43
63
  let imageId = dicomLoaderName + ":" + imageLoaderCounter;
44
64
  imageLoaderCounter++;
45
65
  return imageId;
@@ -12,7 +12,9 @@ import { clearImageCache } from "../imageRendering";
12
12
  import { clearCornerstoneElements } from "../imageTools";
13
13
 
14
14
  // global variables
15
- export var fileManager = {};
15
+ export var fileManager: {
16
+ [key: string]: string;
17
+ } = {};
16
18
 
17
19
  /*
18
20
  * This module provides the following functions to be exported:
@@ -48,7 +50,7 @@ export const resetFileManager = function () {
48
50
  * @function populateFileManager
49
51
  * @return {String} current file image id
50
52
  */
51
- export const populateFileManager = function (file) {
53
+ export const populateFileManager = function (file: File) {
52
54
  let uuid = file.webkitRelativePath || file.name;
53
55
  if (!has(fileManager, uuid)) {
54
56
  const imageId = cornerstoneFileImageLoader.fileManager.add(file);
@@ -62,10 +64,8 @@ export const populateFileManager = function (file) {
62
64
  * @function getFileImageId
63
65
  * @return {String} current file image id
64
66
  */
65
- export const getFileImageId = function (file) {
67
+ export const getFileImageId = function (file: File) {
66
68
  let uuid = file.webkitRelativePath || file.name;
67
69
  const imageId = has(fileManager, uuid) ? fileManager[uuid] : null;
68
70
  return imageId;
69
71
  };
70
-
71
- /* Internal module functions */