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
@@ -1,4 +1,4 @@
1
- /** @module imaging/rendering
1
+ /** @module imaging/imageRendering
2
2
  * @desc This file provides functionalities for
3
3
  * rendering images in html canvas using cornerstone
4
4
  */
@@ -10,16 +10,16 @@ import { each, has } from "lodash";
10
10
 
11
11
  // internal libraries
12
12
  import { getFileImageId } from "./loaders/fileLoader";
13
- import { csToolsCreateStack } from "./tools/tools.main";
14
- import { toggleMouseToolsListeners } from "./tools/tools.interaction";
15
- import { larvitar_store } from "./image_store";
16
- import { applyColorMap } from "./image_colormaps";
17
- import { isElement } from "./image_utils";
13
+ import { csToolsCreateStack } from "./tools/main";
14
+ import { toggleMouseToolsListeners } from "./tools/interaction";
15
+ import { larvitar_store } from "./imageStore";
16
+ import { applyColorMap } from "./imageColormaps";
17
+ import { isElement } from "./imageUtils";
18
18
 
19
19
  /*
20
20
  * This module provides the following functions to be exported:
21
21
  * clearImageCache(seriesId)
22
- * loadAndCacheImages(seriesData, callback)
22
+ * loadAndCacheImages(seriesData)
23
23
  * renderFileImage(file, elementId)
24
24
  * renderWebImage(url, elementId)
25
25
  * disableViewport(elementId)
@@ -121,9 +121,9 @@ export function loadAndCacheImages(series, callback) {
121
121
  * @function renderWebImage
122
122
  * @param {Object} file - The image File object
123
123
  * @param {String} elementId - The html div id used for rendering or its DOM HTMLElement
124
- * @param {Function} callback - Optional callback function with image object
124
+ * @returns {Promise} - Return a promise which will resolve when image is displayed
125
125
  */
126
- export const renderFileImage = function (file, elementId, callback) {
126
+ export const renderFileImage = function (file, elementId) {
127
127
  let element = isElement(elementId)
128
128
  ? elementId
129
129
  : document.getElementById(elementId);
@@ -136,23 +136,23 @@ export const renderFileImage = function (file, elementId, callback) {
136
136
  cornerstone.enable(element);
137
137
  }
138
138
 
139
- // check if imageId is already stored in fileManager
140
- const imageId = getFileImageId(file);
141
- if (imageId) {
142
- cornerstone.loadImage(imageId).then(function (image) {
143
- cornerstone.displayImage(element, image);
144
- let viewport = cornerstone.getViewport(element);
145
- viewport.displayedArea.brhc.x = image.width;
146
- viewport.displayedArea.brhc.y = image.height;
147
- cornerstone.setViewport(element, viewport);
148
- cornerstone.fitToWindow(element);
149
-
150
- csToolsCreateStack(element);
151
- if (callback) {
152
- callback(image);
153
- }
154
- });
155
- }
139
+ let renderPromise = new Promise(resolve => {
140
+ // check if imageId is already stored in fileManager
141
+ const imageId = getFileImageId(file);
142
+ if (imageId) {
143
+ cornerstone.loadImage(imageId).then(function (image) {
144
+ cornerstone.displayImage(element, image);
145
+ let viewport = cornerstone.getViewport(element);
146
+ viewport.displayedArea.brhc.x = image.width;
147
+ viewport.displayedArea.brhc.y = image.height;
148
+ cornerstone.setViewport(element, viewport);
149
+ cornerstone.fitToWindow(element);
150
+ csToolsCreateStack(element);
151
+ resolve(image);
152
+ });
153
+ }
154
+ });
155
+ return renderPromise;
156
156
  };
157
157
 
158
158
  /**
@@ -161,6 +161,7 @@ export const renderFileImage = function (file, elementId, callback) {
161
161
  * @function renderWebImage
162
162
  * @param {String} url - The image data url
163
163
  * @param {String} elementId - The html div id used for rendering or its DOM HTMLElement
164
+ * @returns {Promise} - Return a promise which will resolve when image is displayed
164
165
  */
165
166
  export const renderWebImage = function (url, elementId) {
166
167
  let element = isElement(elementId)
@@ -170,12 +171,15 @@ export const renderWebImage = function (url, elementId) {
170
171
  console.error("invalid html element: " + elementId);
171
172
  return;
172
173
  }
173
-
174
- cornerstone.enable(element);
175
- cornerstone.loadImage(url).then(function (image) {
176
- cornerstone.displayImage(element, image);
177
- csToolsCreateStack(element);
174
+ let renderPromise = new Promise(resolve => {
175
+ cornerstone.enable(element);
176
+ cornerstone.loadImage(url).then(function (image) {
177
+ cornerstone.displayImage(element, image);
178
+ csToolsCreateStack(element);
179
+ resolve(image);
180
+ });
178
181
  });
182
+ return renderPromise;
179
183
  };
180
184
 
181
185
  /**
@@ -245,7 +249,7 @@ export const resizeViewport = function (elementId) {
245
249
  * @param {Object} seriesStack - The original series data object
246
250
  * @param {String} elementId - The html div id used for rendering or its DOM HTMLElement
247
251
  * @param {Object} defaultProps - Optional default props
248
- * @return {Promise} Return a promise when the image has been rendered succesfully
252
+ * @return {Promise} Return a promise which will resolve when image is displayed
249
253
  */
250
254
  export const renderImage = function (seriesStack, elementId, defaultProps) {
251
255
  let t0 = performance.now();
@@ -0,0 +1,78 @@
1
+ /** @module imaging/imageReslice
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 "./imageUtils";
12
+ import {
13
+ getLarvitarImageTracker,
14
+ getLarvitarManager
15
+ } from "./loaders/commonLoader";
16
+ import { larvitar_store } from "./imageStore";
17
+
18
+ /*
19
+ * This module provides the following functions to be exported:
20
+ * resliceSeries(seriesId, seriesData, orientation)
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
+ * @returns {Promise} - Return a promise which will resolve when data is available
31
+ */
32
+ export function resliceSeries(seriesData, orientation) {
33
+ let reslicePromise = new Promise(resolve => {
34
+ let reslicedSeries = {};
35
+ let reslicedSeriesId = uuidv4();
36
+ let reslicedMetaData = getReslicedMetadata(
37
+ reslicedSeriesId,
38
+ "axial",
39
+ orientation,
40
+ seriesData,
41
+ "resliceLoader"
42
+ );
43
+
44
+ reslicedSeries.imageIds = reslicedMetaData.imageIds;
45
+ reslicedSeries.instances = reslicedMetaData.instances;
46
+
47
+ reslicedSeries.currentImageIdIndex = Math.floor(
48
+ reslicedSeries.imageIds.length / 2
49
+ );
50
+
51
+ function computeReslice(seriesData, reslicedSeriesId, reslicedSeries) {
52
+ let t0 = performance.now();
53
+ let imageTracker = getLarvitarImageTracker();
54
+ let manager = getLarvitarManager();
55
+ each(reslicedSeries.imageIds, function (imageId) {
56
+ reslicedSeries.instances[imageId].pixelData = getReslicedPixeldata(
57
+ imageId,
58
+ seriesData,
59
+ reslicedSeries
60
+ );
61
+ imageTracker[imageId] = reslicedSeriesId;
62
+ });
63
+ larvitar_store.addSeriesIds(reslicedSeriesId, reslicedSeries.imageIds);
64
+ reslicedSeries.numberOfImages = reslicedSeries.imageIds.length;
65
+ reslicedSeries.seriesUID = reslicedSeriesId;
66
+ reslicedSeries.seriesDescription = seriesData.seriesDescription;
67
+ reslicedSeries.orientation = orientation;
68
+ manager[reslicedSeriesId] = reslicedSeries;
69
+ manager[seriesData.seriesUID][orientation] = reslicedSeriesId;
70
+ let t1 = performance.now();
71
+ console.log(`Call to resliceSeries took ${t1 - t0} milliseconds.`);
72
+ resolve(reslicedSeries);
73
+ }
74
+ // reslice the data
75
+ computeReslice(seriesData, reslicedSeriesId, reslicedSeries);
76
+ });
77
+ return reslicePromise;
78
+ }
@@ -1,4 +1,4 @@
1
- /** @module imaging/store
1
+ /** @module imaging/imageStore
2
2
  * @desc This file provides functionalities
3
3
  * for data config store.
4
4
  */
@@ -259,15 +259,16 @@ class Larvitar_Store {
259
259
 
260
260
  /**
261
261
  * Instancing the store
262
- * @param {Object} vuex_store - The app vuex store [optional]
263
- * @param {String} vuex_module - The name of the vuex store module, can be null
262
+ * @param {Object} vuexStore - The app vuex store [optional]
263
+ * @param {String} vuexModule - The name of the vuex store module, can be null
264
+ * @param {Boolean} registerModule - If true, the module is registered under Vuex global store
264
265
  */
265
266
 
266
- export function initLarvitarStore(vuex_store, vuex_module, registerModule) {
267
- if (vuex_store) {
268
- larvitar_store = new Larvitar_Store(vuex_store, vuex_module);
267
+ export function initLarvitarStore(vuexStore, vuexModule, registerModule) {
268
+ if (vuexStore) {
269
+ larvitar_store = new Larvitar_Store(vuexStore, vuexModule);
269
270
  if (registerModule) {
270
- vuex_store.registerModule(vuex_module, larvitar);
271
+ vuexStore.registerModule(vuexModule, larvitar);
271
272
  }
272
273
  } else {
273
274
  larvitar_store = new Larvitar_Store();
@@ -1,4 +1,4 @@
1
- /** @module imaging/tools
1
+ /** @module imaging/imageTools
2
2
  * @desc This file provides functionalities for
3
3
  * interacting with cornerstone tools
4
4
  */
@@ -9,20 +9,20 @@ import cornerstoneTools from "cornerstone-tools";
9
9
  import { each, extend, filter, remove, cloneDeep } from "lodash";
10
10
 
11
11
  // internal libraries
12
- import { DEFAULT_TOOLS } from "./tools/tools.default";
13
- // import { SeedsTool } from "./tools/seedTool";
14
- import { ContoursTool } from "./tools/contourTool";
15
- import { EditMaskTool } from "./tools/editMaskTool";
16
- import { DiameterTool } from "./tools/diameterTool";
12
+ import { DEFAULT_TOOLS } from "./tools/default";
13
+ // import { SeedsTool } from "./tools/custom/seedTool";
14
+ import { ContoursTool } from "./tools/custom/contourTool";
15
+ import { EditMaskTool } from "./tools/custom/editMaskTool";
16
+ import { DiameterTool } from "./tools/custom/diameterTool";
17
17
  import { getImageIdFromSlice } from "./loaders/nrrdLoader";
18
18
  import { getSeriesDataFromLarvitarManager } from "./loaders/commonLoader";
19
- import { parseContours } from "./image_contours";
20
- import { isElement } from "./image_utils";
19
+ import { parseContours } from "./imageContours";
20
+ import { isElement } from "./imageUtils";
21
21
 
22
22
  /*
23
23
  * This module provides the following functions to be exported:
24
24
  * csToolsCreateStack(element)
25
- * addDefaultTools()
25
+ * addDefaultTools(toolToActivate)
26
26
  * clearMeasurements()
27
27
  * addContoursTool(rawContours, maskName)
28
28
  * addMaskEditingTool(seriesId,mask,setConfig,callback, targetViewport)
@@ -44,11 +44,11 @@ import { isElement } from "./image_utils";
44
44
  */
45
45
 
46
46
  /**
47
- * Add all default tools, as listed in tools.default.js
47
+ * Add all default tools, as listed in tools/default.js
48
48
  * @function addDefaultTools
49
49
  * @deprecated (OBSOLETE)
50
50
  */
51
- export const addDefaultTools = function (toolToActivate, cb) {
51
+ export const addDefaultTools = function (toolToActivate) {
52
52
  // for each default tool
53
53
  each(DEFAULT_TOOLS, tool => {
54
54
  // check if already added
@@ -99,10 +99,6 @@ export const addDefaultTools = function (toolToActivate, cb) {
99
99
  allowSkipping: false, // default true
100
100
  invert: false
101
101
  });
102
-
103
- if (cb) {
104
- cb();
105
- }
106
102
  };
107
103
 
108
104
  /**
@@ -146,8 +142,8 @@ export const addContoursTool = function (rawContours, maskName) {
146
142
  * Add mask editing tool
147
143
  * @function addMaskEditingTool
148
144
  * @param {Array} mask - The mask data.
149
- * @param {String} targetViewport - The target hmtl element id.
150
145
  * @param {Function} callback - The tool initialization callback
146
+ * @param {String} targetViewport - The target hmtl element id.
151
147
  */
152
148
  export const addMaskEditingTool = function (mask, callback, targetViewport) {
153
149
  let enabledElements = cornerstone.getEnabledElements();
@@ -257,10 +253,10 @@ export const addSeedsTool = function (preLoadSeeds, initViewport) {
257
253
  };
258
254
 
259
255
  /**
260
- * Delete all measurements from tools state, for tools that have the "cleaneable" prop set to true in tools.default.js
256
+ * Delete all measurements from tools state, for tools that have the "cleaneable" prop set to true in tools/default.js
261
257
  * @function clearMeasurements
262
258
  */
263
- export const clearMeasurements = function (cb) {
259
+ export const clearMeasurements = function () {
264
260
  let enabledElements = cornerstone.getEnabledElements();
265
261
  let clenableTools = filter(DEFAULT_TOOLS, "cleanable");
266
262
 
@@ -272,17 +268,13 @@ export const clearMeasurements = function (cb) {
272
268
  each(enabledElements, el => {
273
269
  cornerstone.updateImage(el.element);
274
270
  });
275
-
276
- if (cb) {
277
- cb();
278
- }
279
271
  };
280
272
 
281
273
  /**
282
274
  * Set Tool "active" on all elements (ie, rendered and manipulable) & refresh cornerstone elements
283
275
  * @function setToolActive
284
276
  * @param {String} toolName - The tool name.
285
- * @param {Object} options - The custom options. @default from tools.default.js
277
+ * @param {Object} options - The custom options. @default from tools/default.js
286
278
  * @param {String} activeViewport - The active viewport (if "all", viewports array will be used)
287
279
  * @param {Array} viewports - The hmtl element id to be used for tool initialization.
288
280
  */
@@ -1,4 +1,4 @@
1
- /** @module imaging/utils
1
+ /** @module imaging/imageUtils
2
2
  * @desc This file provides utility functions for
3
3
  * manipulating image pixels and image metadata
4
4
  */
@@ -6,7 +6,7 @@
6
6
  // external libraries
7
7
  import cornerstoneWADOImageLoader from "cornerstone-wado-image-loader";
8
8
  import { each } from "lodash";
9
- import { updateLoadedStack } from "../image_loading";
9
+ import { updateLoadedStack } from "../imageLoading";
10
10
 
11
11
  // internal libraries
12
12
  import { buildMultiFrameImage, clearMultiFrameCache } from "./multiframeLoader";
@@ -4,7 +4,7 @@
4
4
  */
5
5
 
6
6
  // internal libraries
7
- import { loadAndCacheImages } from "../image_rendering";
7
+ import { loadAndCacheImages } from "../imageRendering";
8
8
 
9
9
  /*
10
10
  * This module provides the following functions to be exported:
@@ -8,8 +8,8 @@ import cornerstoneFileImageLoader from "cornerstone-file-image-loader";
8
8
  import { has } from "lodash";
9
9
 
10
10
  // internal libraries
11
- import { clearImageCache } from "../image_rendering";
12
- import { clearCornerstoneElements } from "../image_tools";
11
+ import { clearImageCache } from "../imageRendering";
12
+ import { clearCornerstoneElements } from "../imageTools";
13
13
 
14
14
  // global variables
15
15
  export var fileManager = {};
@@ -1,3 +1,7 @@
1
+ /** @module loaders/multiframeLoader
2
+ * @desc This file is a custom wado loader for multiframe images
3
+ */
4
+
1
5
  // external libraries
2
6
  import cornerstoneWADOImageLoader from "cornerstone-wado-image-loader";
3
7
  import { each, range } from "lodash";
@@ -8,7 +12,7 @@ import {
8
12
  getLarvitarImageTracker,
9
13
  getLarvitarManager
10
14
  } from "./commonLoader";
11
- import { dumpDataSet } from "../image_parsing";
15
+ import { parseDataSet } from "../imageParsing";
12
16
 
13
17
  // global module variables
14
18
  let customImageLoaderCounter = 0;
@@ -84,7 +88,7 @@ export const buildMultiFrameImage = function (seriesId, serie) {
84
88
  // EXTRACT MULTIFRAME METADATA (x52009230) Per-frame Functional Groups Sequence
85
89
  let frameMetadata = { ...metadata };
86
90
 
87
- dumpDataSet(dataSet, frameMetadata, {
91
+ parseDataSet(dataSet, frameMetadata, {
88
92
  tags: ["x52009230"],
89
93
  frameId: frameNumber
90
94
  });
@@ -14,7 +14,7 @@ import {
14
14
  getNormalOrientation,
15
15
  getPixelRepresentation,
16
16
  getTypedArrayFromDataType
17
- } from "../image_utils";
17
+ } from "../imageUtils";
18
18
 
19
19
  import {
20
20
  getImageFrame,
@@ -243,7 +243,11 @@ export const loadNrrdImage = function (imageId) {
243
243
  * @param {String} seriesId The series id
244
244
  * @return {String} image id
245
245
  */
246
- export function getImageIdFromSlice(sliceNumber, orientation, seriesId) {
246
+ export const getImageIdFromSlice = function (
247
+ sliceNumber,
248
+ orientation,
249
+ seriesId
250
+ ) {
247
251
  var prefix = "nrrdLoader://";
248
252
  var serieImageTracker;
249
253
  let imageTracker = getLarvitarImageTracker();
@@ -266,7 +270,7 @@ export function getImageIdFromSlice(sliceNumber, orientation, seriesId) {
266
270
  var imageId = prefix.concat(imageIndex.toString());
267
271
 
268
272
  return imageId;
269
- }
273
+ };
270
274
 
271
275
  /**
272
276
  * Retrieve slice number for a the given orientation
@@ -277,7 +281,7 @@ export function getImageIdFromSlice(sliceNumber, orientation, seriesId) {
277
281
  * @param {String} seriesId The series id
278
282
  * @return {Integer} The image slice number
279
283
  */
280
- export function getSliceNumberFromImageId(imageId, orientation) {
284
+ export const getSliceNumberFromImageId = function (imageId, orientation) {
281
285
  let imageTracker = getLarvitarImageTracker();
282
286
  var firstImageId = findKey(imageTracker, entry => {
283
287
  return entry[1] == orientation;
@@ -289,7 +293,7 @@ export function getSliceNumberFromImageId(imageId, orientation) {
289
293
  parseInt(imageNumber) - parseInt(firstImageId.split("//").pop());
290
294
 
291
295
  return imageIndex;
292
- }
296
+ };
293
297
 
294
298
  /**
295
299
  * Get series dimension for each view
@@ -297,7 +301,7 @@ export function getSliceNumberFromImageId(imageId, orientation) {
297
301
  * @function getNrrdSerieDimensions
298
302
  * @return {Object} Series dimension for each view
299
303
  */
300
- export function getNrrdSerieDimensions() {
304
+ export const getNrrdSerieDimensions = function () {
301
305
  let imageTracker = getLarvitarImageTracker();
302
306
  var dim_axial = filter(imageTracker, img => {
303
307
  return img[1] == "axial";
@@ -314,7 +318,7 @@ export function getNrrdSerieDimensions() {
314
318
  coronal: [dim_sagittal.length, dim_axial.length, dim_coronal.length],
315
319
  sagittal: [dim_coronal.length, dim_axial.length, dim_sagittal.length]
316
320
  };
317
- }
321
+ };
318
322
 
319
323
  /* Internal functions */
320
324
 
@@ -1,10 +1,16 @@
1
+ /** @module imaging/tools/custom/contourTool
2
+ * @desc This file provides functionalities for
3
+ * rendering segmentation contours with a
4
+ * custom cornestone tool
5
+ */
6
+
1
7
  // external libraries
2
8
  import cornerstone from "cornerstone-core";
3
9
  import csTools from "cornerstone-tools";
4
10
  import { each, map } from "lodash";
5
11
 
6
12
  // internal libraries
7
- import { addToolStateSingleSlice } from "../image_tools";
13
+ import { addToolStateSingleSlice } from "../../imageTools";
8
14
 
9
15
  // cornerstone tools imports
10
16
  const external = csTools.external;
@@ -99,19 +105,16 @@ export class ContoursTool extends BaseAnnotationTool {
99
105
  this._drawingMouseMoveCallback = this._drawingMouseMoveCallback.bind(this);
100
106
  this._drawingMouseDragCallback = this._drawingMouseDragCallback.bind(this);
101
107
  this._drawingMouseUpCallback = this._drawingMouseUpCallback.bind(this);
102
- this._drawingMouseDoubleClickCallback = this._drawingMouseDoubleClickCallback.bind(
103
- this
104
- );
108
+ this._drawingMouseDoubleClickCallback =
109
+ this._drawingMouseDoubleClickCallback.bind(this);
105
110
  this._editMouseUpCallback = this._editMouseUpCallback.bind(this);
106
111
  this._editMouseDragCallback = this._editMouseDragCallback.bind(this);
107
112
 
108
- this._drawingTouchStartCallback = this._drawingTouchStartCallback.bind(
109
- this
110
- );
113
+ this._drawingTouchStartCallback =
114
+ this._drawingTouchStartCallback.bind(this);
111
115
  this._drawingTouchDragCallback = this._drawingTouchDragCallback.bind(this);
112
- this._drawingDoubleTapClickCallback = this._drawingDoubleTapClickCallback.bind(
113
- this
114
- );
116
+ this._drawingDoubleTapClickCallback =
117
+ this._drawingDoubleTapClickCallback.bind(this);
115
118
  this._editTouchDragCallback = this._editTouchDragCallback.bind(this);
116
119
 
117
120
  this.throttledUpdateCachedStats = throttle(this.updateCachedStats, 110);
@@ -1340,11 +1343,12 @@ export class ContoursTool extends BaseAnnotationTool {
1340
1343
 
1341
1344
  data.canComplete = false;
1342
1345
 
1343
- const mouseAtOriginHandle = this._isDistanceSmallerThanCompleteSpacingCanvas(
1344
- element,
1345
- points[0],
1346
- mousePoint
1347
- );
1346
+ const mouseAtOriginHandle =
1347
+ this._isDistanceSmallerThanCompleteSpacingCanvas(
1348
+ element,
1349
+ points[0],
1350
+ mousePoint
1351
+ );
1348
1352
 
1349
1353
  if (
1350
1354
  mouseAtOriginHandle &&
@@ -1398,11 +1402,12 @@ export class ContoursTool extends BaseAnnotationTool {
1398
1402
  const mousePoint = config.mouseLocation.handles.start;
1399
1403
  const points = data.handles.points;
1400
1404
 
1401
- const mouseAtOriginHandle = this._isDistanceSmallerThanCompleteSpacingCanvas(
1402
- element,
1403
- points[0],
1404
- mousePoint
1405
- );
1405
+ const mouseAtOriginHandle =
1406
+ this._isDistanceSmallerThanCompleteSpacingCanvas(
1407
+ element,
1408
+ points[0],
1409
+ mousePoint
1410
+ );
1406
1411
 
1407
1412
  if (mouseAtOriginHandle) {
1408
1413
  data.canComplete = true;
@@ -1,10 +1,16 @@
1
- import csTools from "cornerstone-tools";
1
+ /** @module imaging/tools/custom/diameterTool
2
+ * @desc This file provides functionalities for
3
+ * a custom diameter cornestone tool
4
+ */
2
5
 
6
+ // external libraries
7
+ import csTools from "cornerstone-tools";
3
8
  const BidirectionalTool = csTools.BidirectionalTool;
4
-
5
- import { addToolStateSingleSlice } from "../image_tools";
6
9
  import { each } from "lodash";
7
10
 
11
+ // internal libraries
12
+ import { addToolStateSingleSlice } from "../../imageTools";
13
+
8
14
  /**
9
15
  * @public
10
16
  * @class DiameterTool
@@ -1,3 +1,9 @@
1
+ /** @module imaging/tools/custom/editMaskTool
2
+ * @desc This file provides functionalities for
3
+ * a custom mask cornestone tool
4
+ */
5
+
6
+ // external libraries
1
7
  import csTools from "cornerstone-tools";
2
8
  const external = csTools.external;
3
9
  const BaseBrushTool = csTools.importInternal("base/BaseBrushTool");
@@ -95,7 +101,7 @@ export class EditMaskTool extends BaseBrushTool {
95
101
  }
96
102
 
97
103
  preventCtrl() {
98
- this.__proto__.__proto__._isCtrlDown = function() {
104
+ this.__proto__.__proto__._isCtrlDown = function () {
99
105
  return false;
100
106
  };
101
107
  }
@@ -1,14 +1,21 @@
1
+ /** @module imaging/tools/custom/polygonScissorsTool
2
+ * @desc This file provides functionalities for
3
+ * a custom polyline scissors cornestone tool
4
+ */
5
+
6
+ // external libraries
1
7
  import cornerstoneTools from "cornerstone-tools";
8
+ const BaseTool = cornerstoneTools.importInternal("base/BaseTool");
9
+ const { rectangleRoiCursor } = cornerstoneTools.importInternal("tools/cursors");
10
+
11
+ // internal libraries
2
12
  import {
3
13
  fillInsideFreehand,
4
14
  fillOutsideFreehand,
5
15
  eraseOutsideFreehand,
6
16
  eraseInsideFreehand
7
- } from "./strategies"; // cannot import strategies in other way 🤷
8
- import polygonSegmentationMixin from "./polygonSegmentationMixin";
9
-
10
- const BaseTool = cornerstoneTools.importInternal("base/BaseTool");
11
- const { rectangleRoiCursor } = cornerstoneTools.importInternal("tools/cursors");
17
+ } from "../strategies"; // cannot import strategies in other way 🤷
18
+ import polygonSegmentationMixin from "../polygonSegmentationMixin";
12
19
 
13
20
  // Register custom mixin
14
21
  cornerstoneTools.register(
@@ -3,9 +3,9 @@
3
3
  // import { each, cloneDeep } from "lodash";
4
4
 
5
5
  // // internal libraries
6
- // import { remapVoxel } from "../image_utils";
7
- // import { addToolStateSingleSlice, setToolEnabled } from "../image_tools";
8
- // import { getSliceNumberFromImageId } from "../loaders/nrrdLoader";
6
+ // import { remapVoxel } from "../../imageUtils";
7
+ // import { addToolStateSingleSlice, setToolEnabled } from "../../imageTools";
8
+ // import { getSliceNumberFromImageId } from "../../loaders/nrrdLoader";
9
9
 
10
10
  // // cornerstone tools imports
11
11
  // const BaseAnnotationTool = csTools.importInternal("base/BaseAnnotationTool");
@@ -1,5 +1,11 @@
1
- import cornerstoneTools from "cornerstone-tools";
1
+ /** @module imaging/tools/custom/thresholdBrushTool
2
+ * @desc This file provides functionalities for
3
+ * a brush tool with thresholds using a
4
+ * custom cornestone tool
5
+ */
2
6
 
7
+ // external libraries
8
+ import cornerstoneTools from "cornerstone-tools";
3
9
  const external = cornerstoneTools.external;
4
10
  const BaseBrushTool = cornerstoneTools.importInternal("base/BaseBrushTool");
5
11
  const segmentationUtils = cornerstoneTools.importInternal(
@@ -1,3 +1,10 @@
1
+ /** @module imaging/tools/default
2
+ * @desc This file provides definitions
3
+ * for default tools
4
+ */
5
+
6
+ // external libraries
7
+
1
8
  /** @module tools/default */
2
9
 
3
10
  /* DEFINE DEFAULT TOOLS
@@ -19,8 +26,8 @@
19
26
  */
20
27
 
21
28
  import { filter, isArray } from "lodash";
22
- import ThresholdsBrushTool from "./thresholdsBrushTool";
23
- import PolylineScissorsTool from "./polylineScissorsTool";
29
+ import ThresholdsBrushTool from "./custom/thresholdsBrushTool";
30
+ import PolylineScissorsTool from "./custom/polylineScissorsTool";
24
31
 
25
32
  /**
26
33
  * These tools are added with `addDefaultTools()`
@@ -416,7 +423,7 @@ const DEFAULT_STYLE = {
416
423
  */
417
424
  const DEFAULT_SETTINGS = {
418
425
  mouseEnabled: true,
419
- touchEnabled: false, // TODO
426
+ touchEnabled: true,
420
427
  showSVGCursors: true,
421
428
  globalToolSyncEnabled: false,
422
429
  autoResizeViewports: true,