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.
Files changed (229) hide show
  1. package/.github/workflows/deploy.yml +3 -12
  2. package/MIGRATION.md +25 -0
  3. package/README.md +28 -27
  4. package/docs/documentation/Mixins.polygonSegmentationMixin%20-%20segmentation%20operations%20for%20polyline.html +171 -0
  5. package/docs/documentation/Tools.Annotation.ContoursTool.html +218 -0
  6. package/docs/documentation/Tools.Annotation.DiameterTool.html +219 -0
  7. package/docs/documentation/Tools.Annotation.SeedsTool.html +214 -0
  8. package/docs/documentation/Tools.Brush.BrushTool.html +218 -0
  9. package/docs/documentation/Tools.Brush.ThresholdsBrushTool.html +218 -0
  10. package/docs/documentation/Tools.PolylineScissorsTool.html +218 -0
  11. package/docs/documentation/fonts/Montserrat/Montserrat-Bold.eot +0 -0
  12. package/docs/documentation/fonts/Montserrat/Montserrat-Bold.ttf +0 -0
  13. package/docs/documentation/fonts/Montserrat/Montserrat-Bold.woff +0 -0
  14. package/docs/documentation/fonts/Montserrat/Montserrat-Bold.woff2 +0 -0
  15. package/docs/documentation/fonts/Montserrat/Montserrat-Regular.eot +0 -0
  16. package/docs/documentation/fonts/Montserrat/Montserrat-Regular.ttf +0 -0
  17. package/docs/documentation/fonts/Montserrat/Montserrat-Regular.woff +0 -0
  18. package/docs/documentation/fonts/Montserrat/Montserrat-Regular.woff2 +0 -0
  19. package/docs/documentation/fonts/Source-Sans-Pro/sourcesanspro-light-webfont.eot +0 -0
  20. package/docs/documentation/fonts/Source-Sans-Pro/sourcesanspro-light-webfont.svg +978 -0
  21. package/docs/documentation/fonts/Source-Sans-Pro/sourcesanspro-light-webfont.ttf +0 -0
  22. package/docs/documentation/fonts/Source-Sans-Pro/sourcesanspro-light-webfont.woff +0 -0
  23. package/docs/documentation/fonts/Source-Sans-Pro/sourcesanspro-light-webfont.woff2 +0 -0
  24. package/docs/documentation/fonts/Source-Sans-Pro/sourcesanspro-regular-webfont.eot +0 -0
  25. package/docs/documentation/fonts/Source-Sans-Pro/sourcesanspro-regular-webfont.svg +1049 -0
  26. package/docs/documentation/fonts/Source-Sans-Pro/sourcesanspro-regular-webfont.ttf +0 -0
  27. package/docs/documentation/fonts/Source-Sans-Pro/sourcesanspro-regular-webfont.woff +0 -0
  28. package/docs/documentation/fonts/Source-Sans-Pro/sourcesanspro-regular-webfont.woff2 +0 -0
  29. package/docs/documentation/global.html +1303 -0
  30. package/docs/documentation/imageAnonymization.js.html +245 -0
  31. package/docs/documentation/imageColormaps.js.html +283 -0
  32. package/docs/documentation/imageContours.js.html +278 -0
  33. package/docs/documentation/imageIo.js.html +291 -0
  34. package/docs/documentation/imageLayers.js.html +188 -0
  35. package/docs/documentation/imageLoading.js.html +297 -0
  36. package/docs/documentation/imageParsing.js.html +385 -0
  37. package/docs/documentation/imagePresets.js.html +207 -0
  38. package/docs/documentation/imageRendering.js.html +849 -0
  39. package/docs/documentation/imageReslice.js.html +162 -0
  40. package/docs/documentation/imageStore.js.html +360 -0
  41. package/docs/documentation/imageTools.js.html +784 -0
  42. package/docs/documentation/imageUtils.js.html +1609 -0
  43. package/docs/documentation/image_colormaps.js.html +283 -0
  44. package/docs/documentation/image_contours.js.html +279 -0
  45. package/docs/documentation/image_io.js.html +288 -0
  46. package/docs/documentation/image_layers.js.html +188 -0
  47. package/docs/documentation/image_loading.js.html +294 -0
  48. package/docs/documentation/image_parsing.js.html +391 -0
  49. package/docs/documentation/image_presets.js.html +207 -0
  50. package/docs/documentation/image_rendering.js.html +845 -0
  51. package/docs/documentation/image_reslice.js.html +164 -0
  52. package/docs/documentation/image_store.js.html +359 -0
  53. package/docs/documentation/image_tools.js.html +792 -0
  54. package/docs/documentation/image_utils.js.html +1609 -0
  55. package/docs/documentation/index.html +175 -0
  56. package/docs/documentation/loaders_commonLoader.js.html +306 -0
  57. package/docs/documentation/loaders_dicomLoader.js.html +130 -0
  58. package/docs/documentation/loaders_fileLoader.js.html +155 -0
  59. package/docs/documentation/loaders_multiframeLoader.js.html +443 -0
  60. package/docs/documentation/loaders_niftiLoader.js.html +150 -0
  61. package/docs/documentation/loaders_nrrdLoader.js.html +545 -0
  62. package/docs/documentation/loaders_resliceLoader.js.html +258 -0
  63. package/docs/documentation/module-imaging_contours.html +954 -0
  64. package/docs/documentation/module-imaging_imageAnonymization.html +544 -0
  65. package/docs/documentation/module-imaging_imageColormaps.html +1012 -0
  66. package/docs/documentation/module-imaging_imageContours.html +954 -0
  67. package/docs/documentation/module-imaging_imageIo.html +1057 -0
  68. package/docs/documentation/module-imaging_imageLayers.html +904 -0
  69. package/docs/documentation/module-imaging_imageLoading.html +1301 -0
  70. package/docs/documentation/module-imaging_imageParsing.html +1356 -0
  71. package/docs/documentation/module-imaging_imagePresets.html +679 -0
  72. package/docs/documentation/module-imaging_imageRendering.html +3223 -0
  73. package/docs/documentation/module-imaging_imageReslice.html +413 -0
  74. package/docs/documentation/module-imaging_imageStore-Larvitar_Store.html +284 -0
  75. package/docs/documentation/module-imaging_imageStore.html +1560 -0
  76. package/docs/documentation/module-imaging_imageTools.html +3617 -0
  77. package/docs/documentation/module-imaging_imageUtils.html +7253 -0
  78. package/docs/documentation/module-imaging_io.html +1057 -0
  79. package/docs/documentation/module-imaging_layers.html +904 -0
  80. package/docs/documentation/module-imaging_loading.html +1301 -0
  81. package/docs/documentation/module-imaging_parsing.html +1375 -0
  82. package/docs/documentation/module-imaging_presets.html +679 -0
  83. package/docs/documentation/module-imaging_rendering.html +8094 -0
  84. package/docs/documentation/module-imaging_reslice.html +411 -0
  85. package/docs/documentation/module-imaging_store-Larvitar_Store.html +284 -0
  86. package/docs/documentation/module-imaging_store.html +1537 -0
  87. package/docs/documentation/module-imaging_strategies_eraseFreehand.html +708 -0
  88. package/docs/documentation/module-imaging_strategies_fillFreehand.html +708 -0
  89. package/docs/documentation/module-imaging_tools.html +3617 -0
  90. package/docs/documentation/module-imaging_tools_custom_contourTool.html +207 -0
  91. package/docs/documentation/module-imaging_tools_custom_diameterTool.html +205 -0
  92. package/docs/documentation/module-imaging_tools_custom_editMaskTool.html +205 -0
  93. package/docs/documentation/module-imaging_tools_custom_polygonScissorsTool.html +203 -0
  94. package/docs/documentation/module-imaging_tools_custom_thresholdBrushTool.html +684 -0
  95. package/docs/documentation/module-imaging_tools_default.html +205 -0
  96. package/docs/documentation/module-imaging_tools_interaction.html +530 -0
  97. package/docs/documentation/module-imaging_tools_io.html +832 -0
  98. package/docs/documentation/module-imaging_tools_main.html +2028 -0
  99. package/docs/documentation/module-imaging_tools_polygonSegmentationMixin.html +567 -0
  100. package/docs/documentation/module-imaging_tools_segmentation.html +3586 -0
  101. package/docs/documentation/module-imaging_tools_state.html +494 -0
  102. package/docs/documentation/module-imaging_utils.html +7253 -0
  103. package/docs/documentation/module-loaders_commonLoader.html +1313 -0
  104. package/docs/documentation/module-loaders_dicomLoader.html +522 -0
  105. package/docs/documentation/module-loaders_fileLoader.html +593 -0
  106. package/docs/documentation/module-loaders_multiframeLoader.html +1169 -0
  107. package/docs/documentation/module-loaders_niftiLoader.html +565 -0
  108. package/docs/documentation/module-loaders_nrrdLoader.html +1459 -0
  109. package/docs/documentation/module-loaders_resliceLoader.html +590 -0
  110. package/docs/documentation/module-monitors_memory.html +980 -0
  111. package/docs/documentation/module-tools_default.html +740 -0
  112. package/docs/documentation/module.exports_module.exports.html +203 -0
  113. package/docs/documentation/monitors_memory.js.html +189 -0
  114. package/docs/documentation/parsers_nrrd.js.html +569 -0
  115. package/docs/documentation/scripts/collapse.js +20 -0
  116. package/docs/documentation/scripts/linenumber.js +25 -0
  117. package/docs/documentation/scripts/nav.js +12 -0
  118. package/docs/documentation/scripts/polyfill.js +4 -0
  119. package/docs/documentation/scripts/prettify/Apache-License-2.0.txt +202 -0
  120. package/docs/documentation/scripts/prettify/lang-css.js +2 -0
  121. package/docs/documentation/scripts/prettify/prettify.js +28 -0
  122. package/docs/documentation/scripts/search.js +83 -0
  123. package/docs/documentation/styles/jsdoc.css +765 -0
  124. package/docs/documentation/styles/prettify.css +80 -0
  125. package/docs/documentation/tools_contourTool.js.html +1963 -0
  126. package/docs/documentation/tools_custom_contourTool.js.html +1968 -0
  127. package/docs/documentation/tools_custom_diameterTool.js.html +225 -0
  128. package/docs/documentation/tools_custom_editMaskTool.js.html +225 -0
  129. package/docs/documentation/tools_custom_polylineScissorsTool.js.html +143 -0
  130. package/docs/documentation/tools_custom_thresholdsBrushTool.js.html +245 -0
  131. package/docs/documentation/tools_default.js.html +576 -0
  132. package/docs/documentation/tools_diameterTool.js.html +219 -0
  133. package/docs/documentation/tools_editMaskTool.js.html +219 -0
  134. package/docs/documentation/tools_interaction.js.html +258 -0
  135. package/docs/documentation/tools_io.js.html +297 -0
  136. package/docs/documentation/tools_main.js.html +443 -0
  137. package/docs/documentation/tools_polygonSegmentationMixin.js.html +329 -0
  138. package/docs/documentation/tools_polylineScissorsTool.js.html +136 -0
  139. package/docs/documentation/tools_seedTool.js.html +423 -0
  140. package/docs/documentation/tools_segmentation.js.html +558 -0
  141. package/docs/documentation/tools_state.js.html +163 -0
  142. package/docs/documentation/tools_strategies_eraseFreehand.js.html +160 -0
  143. package/docs/documentation/tools_strategies_fillFreehand.js.html +163 -0
  144. package/docs/documentation/tools_thresholdsBrushTool.js.html +239 -0
  145. package/docs/documentation/tools_tools.default.js.html +569 -0
  146. package/docs/documentation/tools_tools.interaction.js.html +251 -0
  147. package/docs/documentation/tools_tools.io.js.html +288 -0
  148. package/docs/documentation/tools_tools.main.js.html +442 -0
  149. package/docs/documentation/tools_tools.segmentation.js.html +445 -0
  150. package/docs/documentation/tools_tools.state.js.html +157 -0
  151. package/docs/examples/base.html +170 -0
  152. package/docs/examples/colorMaps.html +181 -0
  153. package/docs/examples/defaultTools.html +246 -0
  154. package/docs/examples/demo/anon1 +0 -0
  155. package/docs/examples/demo/anon10 +0 -0
  156. package/docs/examples/demo/anon11 +0 -0
  157. package/docs/examples/demo/anon12 +0 -0
  158. package/docs/examples/demo/anon13 +0 -0
  159. package/docs/examples/demo/anon14 +0 -0
  160. package/docs/examples/demo/anon15 +0 -0
  161. package/docs/examples/demo/anon16 +0 -0
  162. package/docs/examples/demo/anon17 +0 -0
  163. package/docs/examples/demo/anon18 +0 -0
  164. package/docs/examples/demo/anon19 +0 -0
  165. package/docs/examples/demo/anon2 +0 -0
  166. package/docs/examples/demo/anon20 +0 -0
  167. package/docs/examples/demo/anon21 +0 -0
  168. package/docs/examples/demo/anon22 +0 -0
  169. package/docs/examples/demo/anon23 +0 -0
  170. package/docs/examples/demo/anon24 +0 -0
  171. package/docs/examples/demo/anon3 +0 -0
  172. package/docs/examples/demo/anon4 +0 -0
  173. package/docs/examples/demo/anon5 +0 -0
  174. package/docs/examples/demo/anon6 +0 -0
  175. package/docs/examples/demo/anon7 +0 -0
  176. package/docs/examples/demo/anon8 +0 -0
  177. package/docs/examples/demo/anon9 +0 -0
  178. package/docs/examples/demo/example.nrrd +0 -0
  179. package/docs/examples/demo/segmentation.nrrd +0 -0
  180. package/docs/examples/demo/xa_integris.dcm +0 -0
  181. package/docs/examples/index.html +129 -0
  182. package/docs/examples/larvitar.js +108623 -0
  183. package/docs/examples/layers.html +250 -0
  184. package/docs/examples/masks.html +273 -0
  185. package/docs/examples/multiframe.html +200 -0
  186. package/docs/examples/nrrd.html +96 -0
  187. package/docs/examples/reslice.html +174 -0
  188. package/docs/index.html +92 -0
  189. package/imaging/dataDictionary.json +21865 -21865
  190. package/imaging/imageAnonymization.js +161 -0
  191. package/imaging/{image_colormaps.js → imageColormaps.js} +2 -2
  192. package/imaging/{image_contours.js → imageContours.js} +1 -2
  193. package/imaging/{image_io.js → imageIo.js} +18 -15
  194. package/imaging/{image_layers.js → imageLayers.js} +2 -2
  195. package/imaging/{image_loading.js → imageLoading.js} +9 -6
  196. package/imaging/imageParsing.js +301 -0
  197. package/imaging/{image_presets.js → imagePresets.js} +2 -2
  198. package/imaging/{image_rendering.js → imageRendering.js} +36 -32
  199. package/imaging/imageReslice.js +78 -0
  200. package/imaging/{image_store.js → imageStore.js} +8 -7
  201. package/imaging/{image_tools.js → imageTools.js} +15 -23
  202. package/imaging/{image_utils.js → imageUtils.js} +1 -1
  203. package/imaging/loaders/commonLoader.js +1 -1
  204. package/imaging/loaders/dicomLoader.js +1 -1
  205. package/imaging/loaders/fileLoader.js +2 -2
  206. package/imaging/loaders/multiframeLoader.js +6 -2
  207. package/imaging/loaders/nrrdLoader.js +11 -7
  208. package/imaging/tools/{contourTool.js → custom/contourTool.js} +25 -20
  209. package/imaging/tools/{diameterTool.js → custom/diameterTool.js} +9 -3
  210. package/imaging/tools/{editMaskTool.js → custom/editMaskTool.js} +7 -1
  211. package/imaging/tools/{polylineScissorsTool.js → custom/polylineScissorsTool.js} +12 -5
  212. package/imaging/tools/{seedTool.js → custom/seedTool.js} +3 -3
  213. package/imaging/tools/{thresholdsBrushTool.js → custom/thresholdsBrushTool.js} +7 -1
  214. package/imaging/tools/{tools.default.js → default.js} +10 -3
  215. package/imaging/tools/{tools.interaction.js → interaction.js} +13 -6
  216. package/imaging/tools/{tools.io.js → io.js} +15 -6
  217. package/imaging/tools/{tools.main.js → main.js} +16 -14
  218. package/imaging/tools/polygonSegmentationMixin.js +8 -4
  219. package/imaging/tools/{tools.segmentation.js → segmentation.js} +171 -58
  220. package/imaging/tools/segmentations.md +38 -0
  221. package/imaging/tools/setLabelMap3D.js +248 -0
  222. package/imaging/tools/{tools.state.js → state.js} +7 -1
  223. package/imaging/tools/strategies/eraseFreehand.js +8 -9
  224. package/imaging/tools/strategies/fillFreehand.js +8 -9
  225. package/index.js +44 -39
  226. package/modules/vuex/larvitar.js +13 -3
  227. package/package.json +13 -10
  228. package/imaging/image_parsing.js +0 -307
  229. package/imaging/image_reslice.js +0 -80
@@ -0,0 +1,248 @@
1
+ /**
2
+ * This is a custom version of setLabelMap3D from cs tools source code
3
+ * This let us implement a non-blocking version of the for loop that loads 3d labelmaps on a volume
4
+ * @ronzim
5
+ */
6
+
7
+ // import getElement from "./getElement";
8
+ // import { getToolState } from "../../../stateManagement/toolState.js";
9
+ // import state from "./state";
10
+ // import getSegmentsOnPixelData from "./getSegmentsOnPixeldata";
11
+ // import { triggerLabelmapModifiedEvent } from "../../../util/segmentation";
12
+ // import ARRAY_TYPES from "./arrayTypes";
13
+ // import { getModule } from "../../index.js";
14
+
15
+ const ARRAY_TYPES = {
16
+ UINT_16_ARRAY: 0,
17
+ FLOAT_32_ARRAY: 1
18
+ };
19
+ const { UINT_16_ARRAY, FLOAT_32_ARRAY } = ARRAY_TYPES;
20
+
21
+ import cornerstoneTools from "cornerstone-tools/dist/cornerstoneTools.js";
22
+ const { triggerLabelmapModifiedEvent } = cornerstoneTools.importInternal(
23
+ "util/segmentationUtils"
24
+ );
25
+ const getModule = cornerstoneTools.getModule;
26
+ const getToolState = cornerstoneTools.getToolState;
27
+ const storeGetters = cornerstoneTools.store.getters;
28
+ const state = getModule("segmentation").state;
29
+
30
+ /**
31
+ * These function are reported since they are not exposed by cs tools
32
+ *
33
+ */
34
+
35
+ // from getSegmentsOnPixelData.js
36
+ function getSegmentsOnPixelData(pixelData) {
37
+ return [...new Set(pixelData)];
38
+ }
39
+
40
+ // from getElement.js
41
+ function getElement(elementOrEnabledElementUID) {
42
+ if (elementOrEnabledElementUID instanceof HTMLElement) {
43
+ return elementOrEnabledElementUID;
44
+ }
45
+
46
+ return storeGetters.enabledElementByUID(elementOrEnabledElementUID);
47
+ }
48
+
49
+ /**
50
+ * Takes a 16-bit encoded `ArrayBuffer` and stores it as a `Labelmap3D` for the
51
+ * `BrushStackState` associated with the element.
52
+ *
53
+ * @param {HTMLElement|string} elementOrEnabledElementUID The cornerstone
54
+ * enabled element or its UUID.
55
+ * @param {ArrayBuffer} buffer
56
+ * @param {number} labelmapIndex The index to store the labelmap under.
57
+ * @param {Object[]} metadata = [] Any metadata about the segments.
58
+ * @param {number[][]} [segmentsOnLabelmapArray] An array of array of segments on each imageIdIndex.
59
+ * If not present, is calculated.
60
+ * @param {colorLUTIndex} [colorLUTIndex = 0] The index of the colorLUT to use to render the segmentation.
61
+ * @returns {null}
62
+ */
63
+ async function setLabelmap3DForElement(
64
+ elementOrEnabledElementUID,
65
+ buffer,
66
+ labelmapIndex,
67
+ metadata = [],
68
+ segmentsOnLabelmapArray,
69
+ colorLUTIndex = 0
70
+ ) {
71
+ const element = getElement(elementOrEnabledElementUID);
72
+
73
+ if (!element) {
74
+ return;
75
+ }
76
+
77
+ const stackState = getToolState(element, "stack");
78
+ const numberOfFrames = stackState.data[0].imageIds.length;
79
+ const firstImageId = stackState.data[0].imageIds[0];
80
+
81
+ const res = await setLabelmap3DByFirstImageId(
82
+ firstImageId,
83
+ buffer,
84
+ labelmapIndex,
85
+ metadata,
86
+ numberOfFrames,
87
+ segmentsOnLabelmapArray,
88
+ colorLUTIndex
89
+ );
90
+
91
+ triggerLabelmapModifiedEvent(element, labelmapIndex);
92
+
93
+ return res;
94
+ }
95
+
96
+ /**
97
+ * Takes an 16-bit encoded `ArrayBuffer` and stores it as a `Labelmap3D` for
98
+ * the `BrushStackState` associated with the firstImageId.
99
+ *
100
+ * @param {HTMLElement|string} firstImageId The firstImageId of the series to
101
+ * store the segmentation on.
102
+ * @param {ArrayBuffer} buffer
103
+ * @param {number} labelmapIndex The index to store the labelmap under.
104
+ * @param {Object[]} metadata = [] Any metadata about the segments.
105
+ * @param {number} numberOfFrames The number of frames, required to set up the
106
+ * relevant labelmap2D views.
107
+ * @param {number[][]} [segmentsOnLabelmapArray] An array of array of segments on each imageIdIndex.
108
+ * If not present, is calculated.
109
+ * @param {colorLUTIndex} [colorLUTIndex = 0] The index of the colorLUT to use to render the segmentation.
110
+ * @returns {null}
111
+ */
112
+ function setLabelmap3DByFirstImageId(
113
+ firstImageId,
114
+ buffer,
115
+ labelmapIndex,
116
+ metadata = [],
117
+ numberOfFrames,
118
+ segmentsOnLabelmapArray,
119
+ colorLUTIndex = 0
120
+ ) {
121
+ const { configuration } = getModule("segmentation");
122
+
123
+ let brushStackState = state.series[firstImageId];
124
+
125
+ if (!brushStackState) {
126
+ state.series[firstImageId] = {
127
+ activeLabelmapIndex: labelmapIndex,
128
+ labelmaps3D: []
129
+ };
130
+
131
+ brushStackState = state.series[firstImageId];
132
+ }
133
+
134
+ brushStackState.labelmaps3D[labelmapIndex] = {
135
+ buffer,
136
+ labelmaps2D: [],
137
+ metadata,
138
+ activeSegmentIndex: 1,
139
+ colorLUTIndex,
140
+ segmentsHidden: [],
141
+ undo: [],
142
+ redo: []
143
+ };
144
+
145
+ const labelmaps2D = brushStackState.labelmaps3D[labelmapIndex].labelmaps2D;
146
+ const slicelengthInBytes = buffer.byteLength / numberOfFrames;
147
+
148
+ /* non-blocking implementation by @ronzim */
149
+
150
+ return new Promise(resolve => {
151
+ function setSingleSlice(i, numberOfFrames) {
152
+ var pixelData = void 0;
153
+
154
+ switch (configuration.arrayType) {
155
+ case UINT_16_ARRAY:
156
+ pixelData = new Uint16Array(
157
+ buffer,
158
+ slicelengthInBytes * i, // 2 bytes/voxel
159
+ slicelengthInBytes / 2
160
+ );
161
+ break;
162
+
163
+ case FLOAT_32_ARRAY:
164
+ pixelData = new Float32Array(
165
+ buffer,
166
+ slicelengthInBytes * i,
167
+ slicelengthInBytes / 4
168
+ );
169
+ break;
170
+
171
+ default:
172
+ throw new Error(
173
+ "Unsupported Array Type ".concat(configuration.arrayType)
174
+ );
175
+ }
176
+
177
+ var segmentsOnLabelmap = segmentsOnLabelmapArray
178
+ ? segmentsOnLabelmapArray[i]
179
+ : getSegmentsOnPixelData(pixelData);
180
+
181
+ if (
182
+ segmentsOnLabelmap &&
183
+ segmentsOnLabelmap.some(function (segment) {
184
+ return segment;
185
+ })
186
+ ) {
187
+ labelmaps2D[i] = {
188
+ pixelData: pixelData,
189
+ segmentsOnLabelmap: segmentsOnLabelmap
190
+ };
191
+ }
192
+
193
+ ++i;
194
+
195
+ if (i < numberOfFrames) {
196
+ setTimeout(() => {
197
+ setSingleSlice(i, numberOfFrames);
198
+ }, 0);
199
+ } else {
200
+ resolve("OK");
201
+ }
202
+ }
203
+
204
+ setSingleSlice(0, numberOfFrames);
205
+ });
206
+
207
+ /* original implementation
208
+
209
+ for (let i = 0; i < numberOfFrames; i++) {
210
+ let pixelData;
211
+
212
+ switch (configuration.arrayType) {
213
+ case UINT_16_ARRAY:
214
+ pixelData = new Uint16Array(
215
+ buffer,
216
+ slicelengthInBytes * i, // 2 bytes/voxel
217
+ slicelengthInBytes / 2
218
+ );
219
+
220
+ break;
221
+
222
+ case FLOAT_32_ARRAY:
223
+ pixelData = new Float32Array(
224
+ buffer,
225
+ slicelengthInBytes * i,
226
+ slicelengthInBytes / 4
227
+ );
228
+ break;
229
+
230
+ default:
231
+ throw new Error(`Unsupported Array Type ${configuration.arrayType}`);
232
+ }
233
+
234
+ const segmentsOnLabelmap = segmentsOnLabelmapArray
235
+ ? segmentsOnLabelmapArray[i]
236
+ : getSegmentsOnPixelData(pixelData);
237
+
238
+ if (segmentsOnLabelmap && segmentsOnLabelmap.some(segment => segment)) {
239
+ labelmaps2D[i] = {
240
+ pixelData,
241
+ segmentsOnLabelmap
242
+ };
243
+ }
244
+ }
245
+ */
246
+ }
247
+
248
+ export { setLabelmap3DByFirstImageId, setLabelmap3DForElement };
@@ -1,8 +1,14 @@
1
+ /** @module imaging/tools/state
2
+ * @desc This file provides functionalities
3
+ * for handling tools' state
4
+ */
5
+
1
6
  // external libraries
2
7
  import cornerstone from "cornerstone-core";
3
8
  import cornerstoneTools from "cornerstone-tools";
4
-
5
9
  import { each } from "lodash";
10
+
11
+ // internal libraries
6
12
  import { state_example } from "./cstools_state_example.js";
7
13
 
8
14
  /**
@@ -1,17 +1,16 @@
1
- import cornerstoneTools from "cornerstone-tools";
2
-
3
- const {
4
- getBoundingBoxAroundPolygon,
5
- eraseInsideShape,
6
- eraseOutsideShape
7
- } = cornerstoneTools.importInternal("util/segmentationUtils");
1
+ /** @module imaging/strategies/eraseFreehand
2
+ * @desc This file provides functionalities for
3
+ * erasing pixels
4
+ */
8
5
 
6
+ // external libraries
7
+ import cornerstoneTools from "cornerstone-tools";
8
+ const { getBoundingBoxAroundPolygon, eraseInsideShape, eraseOutsideShape } =
9
+ cornerstoneTools.importInternal("util/segmentationUtils");
9
10
  const isPointInPolygon = cornerstoneTools.importInternal(
10
11
  "util/isPointInPolygon"
11
12
  );
12
-
13
13
  const getLogger = cornerstoneTools.importInternal("util/getLogger");
14
-
15
14
  const logger = getLogger("util:segmentation:operations:eraseInsideFreehand");
16
15
 
17
16
  /**
@@ -1,17 +1,16 @@
1
- import cornerstoneTools from "cornerstone-tools";
2
-
3
- const {
4
- getBoundingBoxAroundPolygon,
5
- fillInsideShape,
6
- fillOutsideShape
7
- } = cornerstoneTools.importInternal("util/segmentationUtils");
1
+ /** @module imaging/strategies/fillFreehand
2
+ * @desc This file provides functionalities for
3
+ * filling pixels
4
+ */
8
5
 
6
+ // external libraries
7
+ import cornerstoneTools from "cornerstone-tools";
8
+ const { getBoundingBoxAroundPolygon, fillInsideShape, fillOutsideShape } =
9
+ cornerstoneTools.importInternal("util/segmentationUtils");
9
10
  const isPointInPolygon = cornerstoneTools.importInternal(
10
11
  "util/isPointInPolygon"
11
12
  );
12
-
13
13
  const getLogger = cornerstoneTools.importInternal("util/getLogger");
14
-
15
14
  const logger = getLogger("util:segmentation:operations:fillInsideFreehand");
16
15
 
17
16
  /**
package/index.js CHANGED
@@ -5,6 +5,7 @@ console.log(`LARVITAR v${VERSION}`);
5
5
  import cornerstone from "cornerstone-core";
6
6
  import cornerstoneTools from "cornerstone-tools";
7
7
  import cornerstoneWADOImageLoader from "cornerstone-wado-image-loader";
8
+ const segModule = cornerstoneTools.getModule("segmentation");
8
9
 
9
10
  import larvitarModule from "./modules/vuex/larvitar";
10
11
 
@@ -14,15 +15,15 @@ import {
14
15
  getAvailableMemory
15
16
  } from "./imaging/monitors/memory";
16
17
 
17
- import { initLarvitarStore, larvitar_store } from "./imaging/image_store";
18
+ import { initLarvitarStore, larvitar_store } from "./imaging/imageStore";
18
19
 
19
- import { parseContours } from "./imaging/image_contours";
20
+ import { parseContours } from "./imaging/imageContours";
20
21
 
21
22
  import {
22
23
  getImagePresets,
23
24
  setImagePreset,
24
25
  setImageCustomPreset
25
- } from "./imaging/image_presets";
26
+ } from "./imaging/imagePresets";
26
27
 
27
28
  import {
28
29
  getNormalOrientation,
@@ -37,7 +38,7 @@ import {
37
38
  getReslicedMetadata,
38
39
  getReslicedPixeldata,
39
40
  getDistanceBetweenSlices
40
- } from "./imaging/image_utils";
41
+ } from "./imaging/imageUtils";
41
42
 
42
43
  import {
43
44
  buildHeader,
@@ -45,14 +46,16 @@ import {
45
46
  buildData,
46
47
  buildDataAsync,
47
48
  importNRRDImage
48
- } from "./imaging/image_io";
49
+ } from "./imaging/imageIo";
50
+
51
+ import { anonymize, encrypt } from "./imaging/imageAnonymization";
49
52
 
50
53
  import {
51
54
  buildLayer,
52
55
  updateLayer,
53
56
  getActiveLayer,
54
57
  setActiveLayer
55
- } from "./imaging/image_layers";
58
+ } from "./imaging/imageLayers";
56
59
 
57
60
  import {
58
61
  initializeImageLoader,
@@ -62,14 +65,14 @@ import {
62
65
  registerResliceLoader,
63
66
  registerMultiFrameImageLoader,
64
67
  updateLoadedStack
65
- } from "./imaging/image_loading";
68
+ } from "./imaging/imageLoading";
66
69
 
67
70
  import {
68
71
  readFile,
69
72
  readFiles,
70
- dumpDataSet,
73
+ parseDataSet,
71
74
  clearImageParsing
72
- } from "./imaging/image_parsing";
75
+ } from "./imaging/imageParsing";
73
76
 
74
77
  import {
75
78
  clearImageCache,
@@ -83,16 +86,15 @@ import {
83
86
  updateImage,
84
87
  resetViewports,
85
88
  updateViewportData,
86
- // toggleMouseHandlers,
87
89
  storeViewportData,
88
90
  invertImage,
89
91
  flipImageHorizontal,
90
92
  flipImageVertical,
91
93
  rotateImageLeft,
92
94
  rotateImageRight
93
- } from "./imaging/image_rendering";
95
+ } from "./imaging/imageRendering";
94
96
 
95
- import { resliceSeries } from "./imaging/image_reslice";
97
+ import { resliceSeries } from "./imaging/imageReslice";
96
98
 
97
99
  import {
98
100
  addDiameterTool,
@@ -110,7 +112,7 @@ import {
110
112
  syncToolStack,
111
113
  updateStackToolState,
112
114
  setSegmentationConfig
113
- } from "./imaging/image_tools";
115
+ } from "./imaging/imageTools";
114
116
 
115
117
  import {
116
118
  csToolsCreateStack,
@@ -125,13 +127,13 @@ import {
125
127
  setToolEnabled,
126
128
  setToolPassive,
127
129
  exportAnnotations
128
- } from "./imaging/tools/tools.main";
130
+ } from "./imaging/tools/main";
129
131
 
130
132
  import {
131
133
  DEFAULT_TOOLS,
132
134
  getDefaultToolsByType,
133
135
  setDefaultToolsProps
134
- } from "./imaging/tools/tools.default";
136
+ } from "./imaging/tools/default";
135
137
 
136
138
  import {
137
139
  initSegmentationModule,
@@ -141,7 +143,7 @@ import {
141
143
  undoLastStroke,
142
144
  redoLastStroke,
143
145
  setBrushProps
144
- } from "./imaging/tools/tools.segmentation";
146
+ } from "./imaging/tools/segmentation";
145
147
 
146
148
  import {
147
149
  updateLarvitarManager,
@@ -188,20 +190,21 @@ import {
188
190
  addColorMap,
189
191
  fillPixelData,
190
192
  HSVToRGB
191
- } from "./imaging/image_colormaps";
193
+ } from "./imaging/imageColormaps";
192
194
 
193
- import { saveAnnotations, loadAnnotations } from "./imaging/tools/tools.io";
195
+ import { saveAnnotations, loadAnnotations } from "./imaging/tools/io";
194
196
 
195
197
  import {
196
198
  addMouseKeyHandlers,
197
199
  toggleMouseToolsListeners
198
- } from "./imaging/tools/tools.interaction";
200
+ } from "./imaging/tools/interaction";
199
201
 
200
202
  export {
201
203
  VERSION,
202
204
  // global cornerstone variables
203
205
  cornerstone,
204
206
  cornerstoneTools,
207
+ segModule,
205
208
  cornerstoneWADOImageLoader,
206
209
  // vuex module
207
210
  larvitarModule,
@@ -209,14 +212,14 @@ export {
209
212
  checkMemoryAllocation,
210
213
  getUsedMemory,
211
214
  getAvailableMemory,
212
- // larvitar store
215
+ // larvitarStore
213
216
  initLarvitarStore,
214
217
  larvitar_store,
215
- // image_presets
218
+ // imagePresets
216
219
  getImagePresets,
217
220
  setImagePreset,
218
221
  setImageCustomPreset,
219
- // image_utils
222
+ // imageUtils
220
223
  getNormalOrientation,
221
224
  getMinPixelValue,
222
225
  getMaxPixelValue,
@@ -229,18 +232,21 @@ export {
229
232
  getReslicedMetadata,
230
233
  getReslicedPixeldata,
231
234
  getDistanceBetweenSlices,
232
- // image_io
235
+ // imageIo
233
236
  buildHeader,
234
237
  getCachedPixelData,
235
238
  buildData,
236
239
  buildDataAsync,
237
240
  importNRRDImage,
238
- // image_layers
241
+ // imageAnonymization
242
+ anonymize,
243
+ encrypt,
244
+ // imageLayers
239
245
  buildLayer,
240
246
  updateLayer,
241
247
  getActiveLayer,
242
248
  setActiveLayer,
243
- // image_loading
249
+ // imageLoading
244
250
  initializeImageLoader,
245
251
  initializeWebImageLoader,
246
252
  initializeFileImageLoader,
@@ -248,12 +254,12 @@ export {
248
254
  registerResliceLoader,
249
255
  registerMultiFrameImageLoader,
250
256
  updateLoadedStack,
251
- // image_parsing
257
+ // imageParsing
252
258
  readFile,
253
259
  readFiles,
254
- dumpDataSet,
260
+ parseDataSet,
255
261
  clearImageParsing,
256
- // image_rendering
262
+ // imageRendering
257
263
  clearImageCache,
258
264
  loadAndCacheImages,
259
265
  renderFileImage,
@@ -265,7 +271,6 @@ export {
265
271
  updateImage,
266
272
  resetViewports,
267
273
  updateViewportData,
268
- // toggleMouseHandlers,
269
274
  toggleMouseToolsListeners,
270
275
  storeViewportData,
271
276
  invertImage,
@@ -273,15 +278,15 @@ export {
273
278
  flipImageVertical,
274
279
  rotateImageLeft,
275
280
  rotateImageRight,
276
- // image_reslice
281
+ // imageReslice
277
282
  resliceSeries,
278
- // image_colormaps
283
+ // imageColormaps
279
284
  getColormapsList,
280
285
  applyColorMap,
281
286
  addColorMap,
282
287
  fillPixelData,
283
288
  HSVToRGB,
284
- // image_contours
289
+ // imageContours
285
290
  parseContours,
286
291
  // loaders/commonLoader
287
292
  updateLarvitarManager,
@@ -304,7 +309,7 @@ export {
304
309
  // loaders/dicomLoader
305
310
  getDicomImageId,
306
311
  cacheImages,
307
- // loaders/multiFrameLoader
312
+ // loaders/multiframeLoader
308
313
  loadMultiFrameImage,
309
314
  buildMultiFrameImage,
310
315
  getMultiFrameImageId,
@@ -315,7 +320,7 @@ export {
315
320
  resetFileManager,
316
321
  populateFileManager,
317
322
  getFileImageId,
318
- // image_tools
323
+ // imageTools
319
324
  addDiameterTool,
320
325
  addContoursTool,
321
326
  addMaskEditingTool,
@@ -331,7 +336,7 @@ export {
331
336
  syncToolStack,
332
337
  updateStackToolState,
333
338
  setSegmentationConfig,
334
- // tools.main
339
+ // tools/main
335
340
  csToolsCreateStack,
336
341
  csToolsUpdateImageIds,
337
342
  csToolsUpdateImageIndex,
@@ -344,16 +349,16 @@ export {
344
349
  setToolEnabled,
345
350
  setToolPassive,
346
351
  exportAnnotations,
347
- // tools.default
352
+ // tools/default
348
353
  DEFAULT_TOOLS,
349
354
  getDefaultToolsByType,
350
355
  setDefaultToolsProps,
351
- // tools.io
356
+ // tools/io
352
357
  saveAnnotations,
353
358
  loadAnnotations,
354
- // tools.interaction
359
+ // tools/interaction
355
360
  addMouseKeyHandlers,
356
- // tools.segmentation
361
+ // tools/segmentation
357
362
  initSegmentationModule,
358
363
  addSegmentationMask,
359
364
  setActiveLabelmap,
@@ -1,4 +1,4 @@
1
- // Larvitare storage
1
+ // Larvitar Vuex storage
2
2
 
3
3
  import Vue from "vue";
4
4
 
@@ -74,6 +74,12 @@ export default {
74
74
  }
75
75
 
76
76
  Vue.set(state.viewports, id, { ...state.viewports[id], ...d });
77
+ },
78
+ leftActiveTool: (state, { d }) => {
79
+ state.leftActiveTool = d.value;
80
+ },
81
+ rightActiveTool: (state, { d }) => {
82
+ state.rightActiveTool = d.value;
77
83
  }
78
84
  },
79
85
  actions: {
@@ -85,8 +91,12 @@ export default {
85
91
  deleteViewport: ({ state }, viewportId) =>
86
92
  Vue.delete(state.viewports, viewportId),
87
93
  setManager: ({ state }, value) => (state.manager = value),
88
- setLeftActiveTool: ({ state }, value) => (state.leftActiveTool = value),
89
- setRightActiveTool: ({ state }, value) => (state.rightActiveTool = value),
94
+ setLeftActiveTool: ({ commit }, value) => {
95
+ commit("leftActiveTool", { d: { value } });
96
+ },
97
+ setRightActiveTool: ({ commit }, value) => {
98
+ commit("rightActiveTool", { d: { value } });
99
+ },
90
100
  removeSeriesIds: ({ state }, seriesId) =>
91
101
  Vue.delete(state.series, seriesId),
92
102
  setErrorLog: () => {}, // TODO LT pass elementId
package/package.json CHANGED
@@ -1,11 +1,13 @@
1
1
  {
2
2
  "name": "larvitar",
3
3
  "keywords": [
4
- "dicom",
5
- "imaging"
4
+ "DICOM",
5
+ "imaging",
6
+ "medical",
7
+ "cornerstone"
6
8
  ],
7
- "version": "0.18.2",
8
- "description": "javascript library for loading, rendering and interact with DICOM images",
9
+ "version": "1.2.0",
10
+ "description": "javascript library for parsing, loading, rendering and interacting with DICOM images",
9
11
  "repository": {
10
12
  "url": "https://github.com/dvisionlab/Larvitar.git",
11
13
  "type": "git"
@@ -18,25 +20,26 @@
18
20
  "author": "Simone Manini <simone.manini@dvisionlab.com> (https://www.dvisionlab.com)",
19
21
  "contributors": [
20
22
  "Mattia Ronzoni <mattia.ronzoni@dvisionlab.com> (https://www.dvisionlab.com)",
21
- "Sara Zanchi <sara.zanchi@dvisionlab.com> (https://www.dvisionlab.com)"
23
+ "Sara Zanchi <sara.zanchi@dvisionlab.com> (https://www.dvisionlab.com)",
24
+ "Ale Re <ale.re@dvisionlab.com> (https://www.dvisionlab.com)"
22
25
  ],
23
26
  "license": "MIT",
24
27
  "dependencies": {
25
28
  "@rollup/plugin-commonjs": "^17.1.0",
26
- "cornerstone-core": "^2.3.0",
29
+ "cornerstone-core": "^2.6.1",
27
30
  "cornerstone-file-image-loader": "^0.3.0",
28
- "cornerstone-tools": "^5.1.4",
29
- "cornerstone-wado-image-loader": "^3.0.6",
31
+ "cornerstone-tools": "^6.0.6",
32
+ "cornerstone-wado-image-loader": "^4.0.1",
30
33
  "cornerstone-web-image-loader": "^2.1.1",
34
+ "crypto-js": "^4.1.1",
31
35
  "dicom-character-set": "^1.0.3",
32
- "dicom-parser": "^1.8.4",
36
+ "dicom-parser": "^1.8.11",
33
37
  "docdash": "^1.2.0",
34
38
  "hammerjs": "^2.0.8",
35
39
  "keycode-js": "^3.1.0",
36
40
  "lodash": "^4.17.15",
37
41
  "pako": "^1.0.10",
38
42
  "papaparse": "^5.3.0",
39
- "serialize-javascript": "^3.1.0",
40
43
  "uuid": "^8.3.2"
41
44
  },
42
45
  "devDependencies": {