larvitar 2.0.4 → 2.0.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (72) hide show
  1. package/README.md +2 -2
  2. package/dist/larvitar.js +5 -3
  3. package/dist/larvitar.js.map +1 -1
  4. package/package.json +6 -2
  5. package/.github/workflows/build-docs.yml +0 -59
  6. package/.github/workflows/codeql-analysis.yml +0 -71
  7. package/.github/workflows/deploy.yml +0 -37
  8. package/.vscode/settings.json +0 -4
  9. package/CODE_OF_CONDUCT.md +0 -76
  10. package/MIGRATION.md +0 -25
  11. package/bundler/webpack.common.js +0 -27
  12. package/bundler/webpack.dev.js +0 -23
  13. package/bundler/webpack.prod.js +0 -19
  14. package/decs.d.ts +0 -12
  15. package/imaging/MetaDataReadable.ts +0 -42
  16. package/imaging/MetaDataTypes.ts +0 -3491
  17. package/imaging/dataDictionary.json +0 -21866
  18. package/imaging/imageAnonymization.ts +0 -135
  19. package/imaging/imageColormaps.ts +0 -217
  20. package/imaging/imageContours.ts +0 -196
  21. package/imaging/imageIo.ts +0 -251
  22. package/imaging/imageLayers.ts +0 -121
  23. package/imaging/imageLoading.ts +0 -299
  24. package/imaging/imageParsing.ts +0 -444
  25. package/imaging/imagePresets.ts +0 -156
  26. package/imaging/imageRendering.ts +0 -1091
  27. package/imaging/imageReslice.ts +0 -87
  28. package/imaging/imageStore.ts +0 -487
  29. package/imaging/imageTags.ts +0 -609
  30. package/imaging/imageTools.js +0 -708
  31. package/imaging/imageUtils.ts +0 -1079
  32. package/imaging/loaders/commonLoader.ts +0 -275
  33. package/imaging/loaders/dicomLoader.ts +0 -66
  34. package/imaging/loaders/fileLoader.ts +0 -71
  35. package/imaging/loaders/multiframeLoader.ts +0 -435
  36. package/imaging/loaders/nrrdLoader.ts +0 -630
  37. package/imaging/loaders/resliceLoader.ts +0 -205
  38. package/imaging/monitors/memory.ts +0 -151
  39. package/imaging/monitors/performance.ts +0 -34
  40. package/imaging/parsers/ecg.ts +0 -54
  41. package/imaging/parsers/nrrd.js +0 -485
  42. package/imaging/tools/README.md +0 -27
  43. package/imaging/tools/custom/4dSliceScrollTool.js +0 -146
  44. package/imaging/tools/custom/BorderMagnifyTool.js +0 -99
  45. package/imaging/tools/custom/contourTool.js +0 -1884
  46. package/imaging/tools/custom/diameterTool.js +0 -141
  47. package/imaging/tools/custom/editMaskTool.js +0 -141
  48. package/imaging/tools/custom/ellipticalRoiOverlayTool.js +0 -534
  49. package/imaging/tools/custom/polygonSegmentationMixin.js +0 -245
  50. package/imaging/tools/custom/polylineScissorsTool.js +0 -59
  51. package/imaging/tools/custom/rectangleRoiOverlayTool.js +0 -564
  52. package/imaging/tools/custom/seedTool.js +0 -342
  53. package/imaging/tools/custom/setLabelMap3D.ts +0 -242
  54. package/imaging/tools/custom/thresholdsBrushTool.js +0 -161
  55. package/imaging/tools/default.ts +0 -594
  56. package/imaging/tools/interaction.ts +0 -266
  57. package/imaging/tools/io.ts +0 -229
  58. package/imaging/tools/main.ts +0 -424
  59. package/imaging/tools/segmentation.ts +0 -532
  60. package/imaging/tools/segmentations.md +0 -38
  61. package/imaging/tools/state.ts +0 -74
  62. package/imaging/tools/strategies/eraseFreehand.js +0 -76
  63. package/imaging/tools/strategies/fillFreehand.js +0 -79
  64. package/imaging/tools/strategies/index.js +0 -2
  65. package/imaging/tools/types.d.ts +0 -243
  66. package/imaging/types.d.ts +0 -200
  67. package/imaging/waveforms/ecg.ts +0 -191
  68. package/index.ts +0 -431
  69. package/jsdoc.json +0 -52
  70. package/rollup.config.js +0 -51
  71. package/template/.gitkeep +0 -0
  72. package/tsconfig.json +0 -102
@@ -1,594 +0,0 @@
1
- /** @module imaging/tools/default
2
- * @desc This file provides definitions
3
- * for default tools
4
- */
5
-
6
- // external libraries
7
-
8
- /** @module tools/default */
9
-
10
- /* DEFINE DEFAULT TOOLS
11
- * example
12
- *
13
- * toolName : {
14
- * name : toolName (string),
15
- * viewports : "all" or [array of target viewports],
16
- * configuration : configuration {object},
17
- * options : options {object},
18
- * class : cornerstone tool library class name (ie "LengthTool" for Length tool),
19
- * sync : cornerstone synchronizer name (ie "wwwcSynchronizer" for Wwwc sync tool),
20
- * cleanable : if true, this tool will be removed when calling "no tools",
21
- * defaultActive : if true, this tool will be activated when calling "addDefaultTools",
22
- * shortcut : keyboard shortcut [not implemented],
23
- * type : tool category inside Larvitar (one of: "utils", "annotation", "segmentation", "overlay")
24
- * }
25
- *
26
- */
27
-
28
- import { filter, isArray } from "lodash";
29
- import ThresholdsBrushTool from "./custom/thresholdsBrushTool";
30
- // import Slice4DScrollMouseWheelTool from "./custom/4dSliceScrollTool";
31
- import PolylineScissorsTool from "./custom/polylineScissorsTool";
32
- import RectangleRoiOverlayTool from "./custom/rectangleRoiOverlayTool";
33
- import EllipticalRoiOverlayTool from "./custom/ellipticalRoiOverlayTool";
34
- import BorderMagnifyTool from "./custom/BorderMagnifyTool";
35
-
36
- import type {
37
- ToolConfig,
38
- ToolMouseKeys,
39
- ToolSettings,
40
- ToolStyle
41
- } from "./types";
42
-
43
- /**
44
- * These tools are added with `addDefaultTools()`
45
- */
46
- const DEFAULT_TOOLS: {
47
- [key: string]: ToolConfig;
48
- } = {
49
- ScaleOverlay: {
50
- name: "ScaleOverlay",
51
- viewports: "all",
52
- configuration: {
53
- minorTickLength: 25,
54
- majorTickLength: 50
55
- },
56
- options: {
57
- mouseButtonMask: 1
58
- },
59
- cleanable: false,
60
- defaultActive: false,
61
- class: "ScaleOverlayTool",
62
- description: "Add scale overlay",
63
- shortcut: "ctrl-m",
64
- type: "overlay"
65
- },
66
- OrientationMarkers: {
67
- name: "OrientationMarkers",
68
- viewports: "all",
69
- configuration: {},
70
- options: {
71
- mouseButtonMask: 1
72
- },
73
- cleanable: false,
74
- defaultActive: false,
75
- class: "OrientationMarkersTool",
76
- description: "Add orientation markers",
77
- shortcut: "ctrl-m",
78
- type: "overlay"
79
- },
80
- Wwwc: {
81
- name: "Wwwc",
82
- viewports: "all",
83
- configuration: {},
84
- options: {
85
- mouseButtonMask: 1,
86
- supportedInteractionTypes: ["Mouse", "Touch"]
87
- },
88
- cleanable: false,
89
- defaultActive: true,
90
- class: "WwwcTool",
91
- // sync: "wwwcSynchronizer",
92
- description: "Change image contrast",
93
- shortcut: "ctrl-m",
94
- type: "utils"
95
- },
96
- WwwcRegion: {
97
- name: "WwwcRegion",
98
- viewports: "all",
99
- configuration: {},
100
- options: {
101
- mouseButtonMask: 1,
102
- supportedInteractionTypes: ["Mouse", "Touch"]
103
- },
104
- cleanable: false,
105
- defaultActive: false,
106
- class: "WwwcRegionTool",
107
- // sync: "wwwcSynchronizer",
108
- description: "Change image contrast based on selected region",
109
- shortcut: "ctrl-m",
110
- type: "utils"
111
- },
112
- StackScroll: {
113
- name: "StackScroll",
114
- viewports: "all",
115
- configuration: {
116
- loop: false, // default false
117
- allowSkipping: true // default true
118
- },
119
- options: {
120
- mouseButtonMask: 1,
121
- deltaY: 0 // default 0
122
- },
123
- cleanable: false,
124
- defaultActive: false,
125
- class: "StackScrollTool"
126
- },
127
- StackScrollMouseWheel: {
128
- name: "StackScrollMouseWheel",
129
- viewports: "all",
130
- configuration: {
131
- loop: false, // default false
132
- allowSkipping: true, // default true
133
- invert: false
134
- },
135
- options: {},
136
- cleanable: false,
137
- defaultActive: true,
138
- class: "StackScrollMouseWheelTool"
139
- },
140
- // Slice4DScrollMouseWheel: {
141
- // name: "Slice4DScrollMouseWheel",
142
- // viewports: "all",
143
- // configuration: {
144
- // loop: false, // default false
145
- // allowSkipping: false, // default true
146
- // invert: false,
147
- // framesNumber: 1
148
- // },
149
- // options: {},
150
- // cleanable: false,
151
- // defaultActive: true,
152
- // class: "Slice4DScrollMouseWheelTool"
153
- // },
154
- Pan: {
155
- name: "Pan",
156
- viewports: "all",
157
- configuration: {},
158
- options: {
159
- mouseButtonMask: 1,
160
- supportedInteractionTypes: ["Mouse", "Touch"]
161
- },
162
- cleanable: false,
163
- class: "PanTool",
164
- description: "Move image xy",
165
- shortcut: "ctrl-p",
166
- type: "utils"
167
- },
168
- Zoom: {
169
- name: "Zoom",
170
- viewports: "all",
171
- configuration: {
172
- invert: false,
173
- preventZoomOutsideImage: false,
174
- minScale: 0.01,
175
- maxScale: 25.0
176
- },
177
- options: {
178
- mouseButtonMask: 1,
179
- supportedInteractionTypes: ["Mouse", "Touch"],
180
- defaultStrategy: "default" // can be 'default', 'translate' or 'zoomToCenter'
181
- },
182
- cleanable: false,
183
- class: "ZoomTool",
184
- defaultActive: false,
185
- description: "Zoom image at mouse position",
186
- shortcut: "ctrl-z",
187
- type: "utils"
188
- },
189
- BorderMagnify: {
190
- name: "BorderMagnify",
191
- viewports: "all",
192
- configuration: {},
193
- options: {
194
- mouseButtonMask: 1,
195
- supportedInteractionTypes: ["Mouse", "Touch"]
196
- },
197
- cleanable: false,
198
- class: "BorderMagnifyTool",
199
- defaultActive: false,
200
- description: "Magnify image at mouse position",
201
- shortcut: "ctrl-m",
202
- type: "utils"
203
- },
204
- DragProbe: {
205
- name: "DragProbe",
206
- viewports: "all",
207
- configuration: {},
208
- options: {
209
- mouseButtonMask: 1,
210
- supportedInteractionTypes: ["Mouse", "Touch"]
211
- },
212
- cleanable: false,
213
- class: "DragProbeTool",
214
- description: "Probe image at mouse position",
215
- shortcut: "ctrl-p",
216
- type: "utils"
217
- },
218
- Rotate: {
219
- name: "Rotate",
220
- viewports: "all",
221
- configuration: {},
222
- options: {
223
- mouseButtonMask: 1,
224
- supportedInteractionTypes: ["Mouse", "Touch"]
225
- },
226
- cleanable: false,
227
- class: "RotateTool",
228
- description: "Rotate image"
229
- },
230
- Length: {
231
- name: "Length",
232
- viewports: "all",
233
- configuration: {},
234
- options: {
235
- mouseButtonMask: 1,
236
- supportedInteractionTypes: ["Mouse", "Touch"]
237
- },
238
- cleanable: true,
239
- class: "LengthTool"
240
- },
241
- Angle: {
242
- name: "Angle",
243
- viewports: "all",
244
- configuration: {},
245
- options: {
246
- mouseButtonMask: 1,
247
- supportedInteractionTypes: ["Mouse", "Touch"]
248
- },
249
- cleanable: true,
250
- class: "AngleTool"
251
- },
252
- Bidirectional: {
253
- name: "Bidirectional",
254
- viewports: "all",
255
- configuration: {},
256
- options: { mouseButtonMask: 1 },
257
- cleanable: true,
258
- class: "BidirectionalTool"
259
- },
260
- EllipticalRoi: {
261
- name: "EllipticalRoi",
262
- viewports: "all",
263
- configuration: {},
264
- options: { mouseButtonMask: 1 },
265
- cleanable: true,
266
- class: "EllipticalRoiTool",
267
- description: "Draw an ellipse",
268
- shortcut: "ctrl-f",
269
- type: "annotation"
270
- },
271
- RectangleRoi: {
272
- name: "RectangleRoi",
273
- viewports: "all",
274
- configuration: {},
275
- options: { mouseButtonMask: 1 },
276
- cleanable: true,
277
- defaultActive: false,
278
- class: "RectangleRoiTool",
279
- description: "Draw a rectangle",
280
- shortcut: "ctrl-a",
281
- type: "annotation"
282
- },
283
- EllipticalRoiOverlay: {
284
- name: "EllipticalRoiOverlay",
285
- viewports: "all",
286
- configuration: {},
287
- options: { mouseButtonMask: 1 },
288
- cleanable: true,
289
- class: "EllipticalRoiOverlayTool",
290
- description: "Draw an ellipse",
291
- shortcut: "ctrl-f",
292
- type: "annotation"
293
- },
294
- RectangleRoiOverlay: {
295
- name: "RectangleRoiOverlay",
296
- viewports: "all",
297
- configuration: {},
298
- options: { mouseButtonMask: 1 },
299
- cleanable: true,
300
- defaultActive: false,
301
- class: "RectangleRoiOverlayTool",
302
- description: "Draw a rectangle",
303
- shortcut: "ctrl-a",
304
- type: "annotation"
305
- },
306
- FreehandRoi: {
307
- name: "FreehandRoi",
308
- viewports: "all",
309
- configuration: {},
310
- options: { mouseButtonMask: 1 },
311
- cleanable: true,
312
- class: "FreehandRoiTool",
313
- description: "Draw a polyline / freehand form",
314
- shortcut: "ctrl-s",
315
- type: "annotation"
316
- },
317
- Probe: {
318
- name: "Probe",
319
- viewports: "all",
320
- configuration: {},
321
- options: { mouseButtonMask: 1 },
322
- cleanable: true,
323
- class: "ProbeTool"
324
- },
325
- ArrowAnnotate: {
326
- name: "ArrowAnnotate",
327
- viewports: "all",
328
- configuration: {},
329
- options: { mouseButtonMask: 1 },
330
- cleanable: true,
331
- class: "ArrowAnnotateTool",
332
- description: "Draw an arrow",
333
- shortcut: "ctrl-d",
334
- type: "annotation"
335
- },
336
- TextMarker: {
337
- name: "TextMarker",
338
- viewports: "all",
339
- configuration: {
340
- markers: Object.keys(new Array(100).fill(0)),
341
- current: "0",
342
- ascending: true,
343
- loop: true
344
- },
345
- options: { mouseButtonMask: 1 },
346
- cleanable: true,
347
- class: "TextMarkerTool"
348
- },
349
- Eraser: {
350
- name: "Eraser",
351
- viewports: "all",
352
- configuration: {},
353
- options: { mouseButtonMask: 1 },
354
- class: "EraserTool"
355
- },
356
- ZoomTouchPinch: {
357
- name: "ZoomTouchPinch",
358
- viewports: "all",
359
- configuration: {},
360
- options: {
361
- mouseButtonMask: 1,
362
- supportedInteractionTypes: ["TouchPinch"]
363
- },
364
- cleanable: false,
365
- class: "ZoomTouchPinchTool",
366
- defaultActive: true
367
- },
368
- PanMultiTouch: {
369
- name: "PanMultiTouch",
370
- viewports: "all",
371
- configuration: {
372
- touchPointers: 2
373
- },
374
- options: {
375
- mouseButtonMask: 1,
376
- supportedInteractionTypes: ["MultiTouch"]
377
- },
378
- cleanable: false,
379
- class: "PanMultiTouchTool",
380
- defaultActive: true
381
- },
382
- Brush: {
383
- name: "Brush",
384
- viewports: "all",
385
- configuration: {},
386
- options: { mouseButtonMask: 1 },
387
- cleanable: true,
388
- class: "BrushTool",
389
- description: "A simple brush",
390
- shortcut: "ctrl-q",
391
- type: "segmentation"
392
- },
393
- ThresholdsBrush: {
394
- name: "ThresholdsBrush",
395
- viewports: "all",
396
- configuration: {},
397
- options: { mouseButtonMask: 1 },
398
- cleanable: true,
399
- class: "ThresholdsBrushTool",
400
- description: "Brush only values inside thresholds",
401
- shortcut: "ctrl-t",
402
- type: "segmentation"
403
- },
404
- RectangleScissors: {
405
- name: "RectangleScissors",
406
- viewports: "all",
407
- configuration: {},
408
- options: { mouseButtonMask: 1 },
409
- cleanable: true,
410
- class: "RectangleScissorsTool",
411
- description: "A rectangular segmentation tool",
412
- shortcut: "ctrl-w",
413
- type: "segmentation"
414
- },
415
- FreehandScissors: {
416
- name: "FreehandScissors",
417
- viewports: "all",
418
- configuration: {},
419
- options: { mouseButtonMask: 1 },
420
- cleanable: true,
421
- class: "FreehandScissorsTool",
422
- description: "A free-hand segmentation tool",
423
- shortcut: "ctrl-e",
424
- type: "segmentation"
425
- },
426
- CircleScissors: {
427
- name: "CircleScissors",
428
- viewports: "all",
429
- configuration: {},
430
- options: { mouseButtonMask: 1 },
431
- cleanable: true,
432
- class: "CircleScissorsTool",
433
- description: "A circular segmentation tool",
434
- shortcut: "ctrl-r",
435
- type: "segmentation"
436
- },
437
- CorrectionScissors: {
438
- name: "CorrectionScissors",
439
- viewports: "all",
440
- configuration: {},
441
- options: { mouseButtonMask: 1 },
442
- cleanable: true,
443
- class: "CorrectionScissorsTool",
444
- description: "A correction segmentation tool",
445
- shortcut: "ctrl-p",
446
- type: "segmentation"
447
- },
448
- PolylineScissors: {
449
- name: "PolylineScissors",
450
- viewports: "all",
451
- configuration: {},
452
- options: { mouseButtonMask: 1 },
453
- cleanable: true,
454
- class: "PolylineScissorsTool",
455
- description: "A polyline segmentation tool",
456
- shortcut: "ctrl-s",
457
- type: "segmentation"
458
- }
459
- };
460
-
461
- /**
462
- * D/Vision Lab custom tools
463
- */
464
- const dvTools: {
465
- [key: string]: any; // TODO-ts tools class type @mronzoni
466
- } = {
467
- ThresholdsBrushTool: ThresholdsBrushTool,
468
- PolylineScissorsTool: PolylineScissorsTool,
469
- // Slice4DScrollMouseWheelTool: Slice4DScrollMouseWheelTool,
470
- RectangleRoiOverlayTool: RectangleRoiOverlayTool,
471
- EllipticalRoiOverlayTool: EllipticalRoiOverlayTool,
472
- BorderMagnifyTool: BorderMagnifyTool
473
- };
474
-
475
- /**
476
- * Tools default style
477
- * Available font families :
478
- * Work Sans, Roboto, OpenSans, HelveticaNeue-Light,
479
- * Helvetica Neue Light, Helvetica Neue, Helvetica,
480
- * Arial, Lucida Grande, sans-serif;
481
- */
482
- const DEFAULT_STYLE: ToolStyle = {
483
- width: 1,
484
- color: "#02FAE5",
485
- activeColor: "#00FF00",
486
- fillColor: "#0000FF",
487
- fontFamily: "Roboto",
488
- fontSize: 18,
489
- backgroundColor: "rgba(1, 1, 1, 0.7)"
490
- };
491
-
492
- /**
493
- * Tools default settings
494
- */
495
- const DEFAULT_SETTINGS: ToolSettings = {
496
- mouseEnabled: true,
497
- touchEnabled: true,
498
- showSVGCursors: true,
499
- globalToolSyncEnabled: false,
500
- autoResizeViewports: true,
501
- lineDash: [4, 4]
502
- };
503
-
504
- /**
505
- * Shortcut and mouse bindings defaults
506
- */
507
- const DEFAULT_MOUSE_KEYS: ToolMouseKeys = {
508
- debug: true, // log changes
509
- mouse_button_left: {
510
- shift: "Zoom",
511
- ctrl: "Pan",
512
- default: "Wwwc"
513
- },
514
- mouse_button_right: {
515
- shift: "Zoom",
516
- ctrl: "Pan",
517
- default: "Wwwc"
518
- },
519
- keyboard_shortcuts: {
520
- // alt key + letter
521
- KEY_R: "Rotate",
522
- KEY_A: "Angle",
523
- KEY_L: "Length"
524
- }
525
- };
526
-
527
- /**
528
- * Get available tools by type (useful to populate menus)
529
- * @param {String} type
530
- */
531
- const getDefaultToolsByType = function (type: NonNullable<ToolConfig["type"]>) {
532
- return filter(DEFAULT_TOOLS, ["type", type]);
533
- };
534
-
535
- /**
536
- * Override default tools props
537
- * @param {Array} newProps - An array of objects as in the DEFAULT_TOOLS list, but with a subset of props
538
- * NOTE: prop "name" is mandatory
539
- */
540
- const setDefaultToolsProps = function (newProps: Partial<ToolConfig>[]) {
541
- if (isArray(newProps)) {
542
- newProps.forEach(props => {
543
- if (!props.name) {
544
- console.error("newProps must have a name property");
545
- return;
546
- }
547
-
548
- let targetTool = DEFAULT_TOOLS[props.name];
549
- if (targetTool) {
550
- DEFAULT_TOOLS[props.name] = Object.assign(targetTool, props);
551
- } else {
552
- console.error(`${props.name} does not exist`);
553
- }
554
- });
555
- } else {
556
- console.error("newProps must be an array");
557
- }
558
- };
559
-
560
- /**
561
- * Register a custom tool
562
- * @param {String} toolName - The name of the tool
563
- * @param {Object} toolClass - The tool class
564
- * NOTE: toolName must be unique
565
- * NOTE: toolClass must be a valid cornerstone tool
566
- */
567
-
568
- const registerExternalTool = function (toolName: string, toolClass: any) {
569
- if (dvTools[toolName] || DEFAULT_TOOLS[toolName]) {
570
- console.error(`${toolName} already exists`);
571
- return;
572
- }
573
-
574
- dvTools[toolClass.name] = toolClass;
575
- DEFAULT_TOOLS[toolName] = {
576
- name: toolName,
577
- class: toolClass.name,
578
- viewports: "all",
579
- configuration: {},
580
- options: { mouseButtonMask: 1 },
581
- defaultActive: false
582
- };
583
- };
584
-
585
- export {
586
- DEFAULT_TOOLS,
587
- DEFAULT_STYLE,
588
- DEFAULT_SETTINGS,
589
- DEFAULT_MOUSE_KEYS,
590
- dvTools,
591
- getDefaultToolsByType,
592
- setDefaultToolsProps,
593
- registerExternalTool
594
- };