dwv 0.37.0-beta.2 → 0.37.0-beta.20

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.
package/dist/dwv.d.ts CHANGED
@@ -4,14 +4,19 @@ import Konva from 'konva';
4
4
  * Add tags to the dictionary.
5
5
  *
6
6
  * @param {string} group The group key.
7
- * @param {Object<string, string[]>} tags The tags to add as an
7
+ * @param {Record<string, string[]>} tags The tags to add as an
8
8
  * object indexed by element key with values as:
9
9
  * [VR, multiplicity, TagName] (all strings).
10
10
  */
11
- export declare function addTagsToDictionary(group: string, tags: {
12
- [x: string]: string[];
13
- }): void;
11
+ export declare function addTagsToDictionary(group: string, tags: Record<string, string[]>): void;
14
12
 
13
+ /**
14
+ * @import {Index} from '../math/index.js';
15
+ * @import {NumberValue} from '../math/number.js';
16
+ * @import {ViewController} from '../app/viewController.js';
17
+ * @import {PlaneHelper} from './planeHelper.js';
18
+ * @import {DicomCode} from '../dicom/dicomCode.js';
19
+ */
15
20
  /**
16
21
  * Image annotation.
17
22
  */
@@ -29,7 +34,7 @@ export declare class Annotation {
29
34
  */
30
35
  trackingUid: string;
31
36
  /**
32
- * Referenced image SOP isntance UID.
37
+ * Referenced image SOP instance UID.
33
38
  *
34
39
  * @type {string}
35
40
  */
@@ -41,7 +46,9 @@ export declare class Annotation {
41
46
  */
42
47
  referencedSopClassUID: string;
43
48
  /**
44
- * Referenced frame number.
49
+ * Referenced frame number, 1-based as the DICOM
50
+ * Referenced Frame Number: frame number 1 is
51
+ * the first frame (time index 0).
45
52
  *
46
53
  * @type {number|undefined}
47
54
  */
@@ -67,11 +74,9 @@ export declare class Annotation {
67
74
  /**
68
75
  * Annotation quantification.
69
76
  *
70
- * @type {Object<string, Value>|undefined}
77
+ * @type {Record<string, NumberValue>|undefined}
71
78
  */
72
- quantification: {
73
- [x: string]: Value;
74
- } | undefined;
79
+ quantification: Record<string, NumberValue> | undefined;
75
80
  /**
76
81
  * Text expression. Can contain variables surrounded with '{}' that will
77
82
  * be extracted from the quantification object.
@@ -164,15 +169,23 @@ export declare class Annotation {
164
169
  * @returns {Point|undefined} The 3D centroid point.
165
170
  */
166
171
  getCentroid(): Point | undefined;
172
+ /**
173
+ * Check if a plane point is on the annotation math shape,
174
+ * within a tolerance.
175
+ *
176
+ * @param {Point2D} point The plane point to check.
177
+ * @param {number} [tolerance] Optional maximum distance to the shape,
178
+ * defaults to 0.
179
+ * @returns {boolean} True if the point is on the shape.
180
+ */
181
+ contains(point: Point2D, tolerance?: number): boolean;
167
182
  /**
168
183
  * Set the annotation text expression.
169
184
  *
170
- * @param {Object.<string, string>} labelText The list of label
185
+ * @param {Record<string, string>} labelText The list of label
171
186
  * texts indexed by modality.
172
187
  */
173
- setTextExpr(labelText: {
174
- [x: string]: string;
175
- }): void;
188
+ setTextExpr(labelText: Record<string, string>): void;
176
189
  /**
177
190
  * Get the annotation label text by applying the
178
191
  * text expression on the current quantification.
@@ -196,7 +209,7 @@ export declare class Annotation {
196
209
  /**
197
210
  * Annotation group.
198
211
  */
199
- export declare class AnnotationGroup {
212
+ export declare class AnnotationGroup extends EventTarget {
200
213
  /**
201
214
  * @param {Annotation[]} [list] Optional list, will
202
215
  * create new if not provided.
@@ -279,11 +292,9 @@ export declare class AnnotationGroup {
279
292
  /**
280
293
  * Get the meta data.
281
294
  *
282
- * @returns {Object<string, any>} The meta data.
295
+ * @returns {Record<string, any>} The meta data.
283
296
  */
284
- getMeta(): {
285
- [x: string]: any;
286
- };
297
+ getMeta(): Record<string, any>;
287
298
  /**
288
299
  * Check if this list contains a meta data value.
289
300
  *
@@ -305,22 +316,6 @@ export declare class AnnotationGroup {
305
316
  * @param {string|object} value The value of the meta data.
306
317
  */
307
318
  setMetaValue(key: string, value: string | object): void;
308
- /**
309
- * Add an event listener to this class.
310
- *
311
- * @param {string} type The event type.
312
- * @param {Function} callback The function associated with the provided
313
- * event type, will be called with the fired event.
314
- */
315
- addEventListener(type: string, callback: Function): void;
316
- /**
317
- * Remove an event listener from this class.
318
- *
319
- * @param {string} type The event type.
320
- * @param {Function} callback The function associated with the provided
321
- * event type.
322
- */
323
- removeEventListener(type: string, callback: Function): void;
324
319
  #private;
325
320
  }
326
321
 
@@ -338,64 +333,50 @@ export declare class AnnotationGroupFactory {
338
333
  /**
339
334
  * Check dicom elements.
340
335
  *
341
- * @param {Object<string, DataElement>} dataElements The DICOM data elements.
336
+ * @param {Record<string, DataElement>} dataElements The DICOM data elements.
342
337
  * @returns {string|undefined} A possible warning.
343
338
  */
344
- checkElements(dataElements: {
345
- [x: string]: DataElement;
346
- }): string | undefined;
339
+ checkElements(dataElements: Record<string, DataElement>): string | undefined;
347
340
  /**
348
341
  * Get an {@link AnnotationGroup} object from the read DICOM file.
349
342
  *
350
- * @param {Object<string, DataElement>} dataElements The DICOM tags.
343
+ * @param {Record<string, DataElement>} dataElements The DICOM tags.
351
344
  * @returns {AnnotationGroup} A new annotation group.
352
345
  * @throws {Error} Error for missing or wrong data.
353
346
  */
354
- create(dataElements: {
355
- [x: string]: DataElement;
356
- }): AnnotationGroup;
347
+ create(dataElements: Record<string, DataElement>): AnnotationGroup;
357
348
  /**
358
349
  * Get an {@link CADReport} object from the read DICOM file.
359
350
  *
360
- * @param {Object<string, DataElement>} dataElements The DICOM tags.
351
+ * @param {Record<string, DataElement>} dataElements The DICOM tags.
361
352
  * @returns {CADReport|undefined} A new CAD report.
362
353
  */
363
- createCADReport(dataElements: {
364
- [x: string]: DataElement;
365
- }): CADReport | undefined;
354
+ createCADReport(dataElements: Record<string, DataElement>): CADReport | undefined;
366
355
  /**
367
356
  * Convert an annotation group into a DICOM SR object using the
368
357
  * TID 1500 template.
369
358
  *
370
359
  * @param {AnnotationGroup} annotationGroup The annotation group.
371
- * @param {Object<string, any>} [extraTags] Optional list of extra tags.
372
- * @returns {Object<string, DataElement>} A list of dicom elements.
360
+ * @param {SimpleTagValues} [extraTags] Optional list of extra tags.
361
+ * @returns {Record<string, DataElement>} A list of dicom elements.
373
362
  */
374
- toDicom(annotationGroup: AnnotationGroup, extraTags?: {
375
- [x: string]: any;
376
- }): {
377
- [x: string]: DataElement;
378
- };
363
+ toDicom(annotationGroup: AnnotationGroup, extraTags?: SimpleTagValues): Record<string, DataElement>;
379
364
  /**
380
365
  * Convert a CAD report into a DICOM CAD report SR object using
381
366
  * the TID 4100 template.
382
367
  *
383
368
  * @param {CADReport} report The CAD report.
384
- * @param {Object<string, any>} [extraTags] Optional list of extra tags.
385
- * @returns {Object<string, DataElement>} A list of dicom elements.
369
+ * @param {SimpleTagValues} [extraTags] Optional list of extra tags.
370
+ * @returns {Record<string, DataElement>} A list of dicom elements.
386
371
  */
387
- toDicomCADReport(report: CADReport, extraTags?: {
388
- [x: string]: any;
389
- }): {
390
- [x: string]: DataElement;
391
- };
372
+ toDicomCADReport(report: CADReport, extraTags?: SimpleTagValues): Record<string, DataElement>;
392
373
  #private;
393
374
  }
394
375
 
395
376
  /**
396
377
  * List of ViewConfigs indexed by dataIds.
397
378
  *
398
- * @typedef {Object<string, ViewConfig[]>} DataViewConfigs
379
+ * @typedef {Record<string, ViewConfig[]>} DataViewConfigs
399
380
  */
400
381
  /**
401
382
  * Main application class.
@@ -414,12 +395,19 @@ export declare class AnnotationGroupFactory {
414
395
  * 'https://raw.githubusercontent.com/ivmartel/dwv/master/tests/data/bbmri-53323851.dcm'
415
396
  * ]);
416
397
  */
417
- export declare class App {
398
+ export declare class App extends EventTarget {
399
+ /**
400
+ * Get the data controller.
401
+ *
402
+ * @returns {DataController} The data controller.
403
+ */
404
+ getDataController(): DataController;
418
405
  /**
419
406
  * Get a DicomData.
420
407
  *
421
408
  * @param {string} dataId The data id.
422
409
  * @returns {DicomData|undefined} The data.
410
+ * @deprecated Since v0.37, please use via app.getDataController.
423
411
  */
424
412
  getData(dataId: string): DicomData | undefined;
425
413
  /**
@@ -435,12 +423,14 @@ export declare class App {
435
423
  *
436
424
  * @param {string} dataId The data id.
437
425
  * @param {Image} img The associated image.
426
+ * @deprecated Since v0.37, please use via app.getDataController.
438
427
  */
439
428
  setImage(dataId: string, img: Image_2): void;
440
429
  /**
441
430
  * Get the next data id.
442
431
  *
443
432
  * @returns {string} The data id.
433
+ * @deprecated Since v0.37, please use via app.getDataController.
444
434
  */
445
435
  getNextDataId(): string;
446
436
  /**
@@ -449,21 +439,22 @@ export declare class App {
449
439
  * @param {string} dataId The data id.
450
440
  * @param {DicomData} data The new data.
451
441
  * @returns {boolean} False if the data cannot be added.
442
+ * @deprecated Since v0.37, please use via app.getDataController.
452
443
  */
453
444
  addData(dataId: string, data: DicomData): boolean;
454
445
  /**
455
446
  * Get the meta data.
456
447
  *
457
448
  * @param {string} dataId The data id.
458
- * @returns {Object<string, DataElement>|undefined} The list of meta data.
449
+ * @returns {Record<string, DataElement>|undefined} The list of meta data.
450
+ * @deprecated Since v0.37, please use via app.getDataController.
459
451
  */
460
- getMetaData(dataId: string): {
461
- [x: string]: DataElement;
462
- } | undefined;
452
+ getMetaData(dataId: string): Record<string, DataElement> | undefined;
463
453
  /**
464
454
  * Get the list of ids in the data storage.
465
455
  *
466
456
  * @returns {string[]} The list of data ids.
457
+ * @deprecated Since v0.37, please use via app.getDataController.
467
458
  */
468
459
  getDataIds(): string[];
469
460
  /**
@@ -471,6 +462,7 @@ export declare class App {
471
462
  *
472
463
  * @param {string[]} uids A list of UIDs.
473
464
  * @returns {string[]} The list of dataIds that contain the UIDs.
465
+ * @deprecated Since v0.37, please use via app.getDataController.
474
466
  */
475
467
  getDataIdsFromSopUids(uids: string[]): string[];
476
468
  /**
@@ -478,6 +470,7 @@ export declare class App {
478
470
  *
479
471
  * @param {string} uid The SeriesInstanceUID.
480
472
  * @returns {string} The data id.
473
+ * @deprecated Since v0.37, please use via app.getDataController.
481
474
  */
482
475
  getDataIdFromSeriesUid(uid: string): string;
483
476
  /**
@@ -501,18 +494,21 @@ export declare class App {
501
494
  * Get the active layer group scale on top of the base scale.
502
495
  *
503
496
  * @returns {Scalar3D} The scale as {x,y,z}.
497
+ * @deprecated Since v0.37, please access from the active layer group.
504
498
  */
505
499
  getAddedScale(): Scalar3D;
506
500
  /**
507
501
  * Get the base scale of the active layer group.
508
502
  *
509
503
  * @returns {Scalar3D} The scale as {x,y,z}.
504
+ * @deprecated Since v0.37, please access from the active layer group.
510
505
  */
511
506
  getBaseScale(): Scalar3D;
512
507
  /**
513
508
  * Get the layer offset of the active layer group.
514
509
  *
515
510
  * @returns {Scalar3D} The offset as {x,y,z}.
511
+ * @deprecated Since v0.37, please access from the active layer group.
516
512
  */
517
513
  getOffset(): Scalar3D;
518
514
  /**
@@ -521,17 +517,33 @@ export declare class App {
521
517
  * @returns {ToolboxController} The controller.
522
518
  */
523
519
  getToolboxController(): ToolboxController;
520
+ /**
521
+ * Get the stage controller.
522
+ *
523
+ * @returns {StageController} The stage controller.
524
+ */
525
+ getStageController(): StageController;
526
+ /**
527
+ * Get the undo controller.
528
+ *
529
+ * @returns {UndoController} The undo controller.
530
+ */
531
+ getUndoController(): UndoController;
524
532
  /**
525
533
  * Get the active layer group.
526
534
  * The layer is available after the first loaded item.
527
535
  *
528
536
  * @returns {LayerGroup|undefined} The layer group.
537
+ * @deprecated Since v0.37, use
538
+ * `app.getStageController().getActiveLayerGroup()` instead.
529
539
  */
530
540
  getActiveLayerGroup(): LayerGroup | undefined;
531
541
  /**
532
542
  * Set the active layer group.
533
543
  *
534
544
  * @param {number} index The layer group index.
545
+ * @deprecated Since v0.37, use
546
+ * `app.getStageController().setActiveLayerGroup()` instead.
535
547
  */
536
548
  setActiveLayerGroup(index: number): void;
537
549
  /**
@@ -540,6 +552,8 @@ export declare class App {
540
552
  *
541
553
  * @param {string} dataId The data id.
542
554
  * @returns {ViewLayer[]} The layers.
555
+ * @deprecated Since v0.37, use
556
+ * `app.getStageController().getViewLayersByDataId()` instead.
543
557
  */
544
558
  getViewLayersByDataId(dataId: string): ViewLayer[];
545
559
  /**
@@ -550,6 +564,8 @@ export declare class App {
550
564
  * returns all view layers.
551
565
  * @returns {ViewLayer[]} The layers that
552
566
  * satisfy the callbackFn.
567
+ * @deprecated Since v0.37, use
568
+ * `app.getStageController().getViewLayers()` instead.
553
569
  */
554
570
  getViewLayers(callbackFn?: Function): ViewLayer[];
555
571
  /**
@@ -558,6 +574,8 @@ export declare class App {
558
574
  *
559
575
  * @param {string} dataId The data id.
560
576
  * @returns {DrawLayer[]} The layers.
577
+ * @deprecated Since v0.37, use
578
+ * `app.getStageController().getDrawLayersByDataId()` instead.
561
579
  */
562
580
  getDrawLayersByDataId(dataId: string): DrawLayer[];
563
581
  /**
@@ -568,6 +586,8 @@ export declare class App {
568
586
  * returns all draw layers.
569
587
  * @returns {DrawLayer[]} The layers that
570
588
  * satisfy the callbackFn.
589
+ * @deprecated Since v0.37, use
590
+ * `app.getStageController().getDrawLayers()` instead.
571
591
  */
572
592
  getDrawLayers(callbackFn?: Function): DrawLayer[];
573
593
  /**
@@ -576,12 +596,16 @@ export declare class App {
576
596
  *
577
597
  * @param {string} divId The div id.
578
598
  * @returns {LayerGroup|undefined} The layer group.
599
+ * @deprecated Since v0.37, use
600
+ * `app.getStageController().getLayerGroupByDivId()` instead.
579
601
  */
580
602
  getLayerGroupByDivId(divId: string): LayerGroup | undefined;
581
603
  /**
582
604
  * Get the number of layer groups.
583
605
  *
584
606
  * @returns {number} The number of groups.
607
+ * @deprecated Since v0.37, use
608
+ * `app.getStageController().getNumberOfLayerGroups()` instead.
585
609
  */
586
610
  getNumberOfLayerGroups(): number;
587
611
  /**
@@ -595,6 +619,7 @@ export declare class App {
595
619
  *
596
620
  * @param {Command} cmd The command to add.
597
621
  * @fires UndoStack#undoadd
622
+ * @deprecated Since v0.37, please use via app.getUndoController.
598
623
  * @function
599
624
  */
600
625
  addToUndoStack: (cmd: Command) => void;
@@ -604,6 +629,7 @@ export declare class App {
604
629
  * @param {string} name The name of the command to remove.
605
630
  * @returns {boolean} True if the command was found and removed.
606
631
  * @fires UndoStack#undoremove
632
+ * @deprecated Since v0.37, please use via app.getUndoController.
607
633
  * @function
608
634
  */
609
635
  removeFromUndoStack: (name: string) => boolean;
@@ -632,7 +658,7 @@ export declare class App {
632
658
  * button.disabled = false;
633
659
  * button.onclick = function () {
634
660
  * // render data #0
635
- * app.render(0);
661
+ * app.getStageController().render(0);
636
662
  * };
637
663
  * });
638
664
  * // load dicom data
@@ -653,30 +679,108 @@ export declare class App {
653
679
  resetLayout(): void;
654
680
  /**
655
681
  * Reset the zoom and pan of the stage.
682
+ *
683
+ * @deprecated Since v0.37, use
684
+ * `app.getStageController().resetZoomPan()` instead.
656
685
  */
657
686
  resetZoomPan(): void;
658
687
  /**
659
688
  * Reset the position and window level of the stage.
689
+ *
690
+ * @deprecated Since v0.37, use
691
+ * `app.getStageController().resetViews()` instead.
660
692
  */
661
693
  resetViews(): void;
662
694
  /**
663
- * Add an event listener to this class.
695
+ * Load start event.
664
696
  *
665
- * @param {string} type The event type.
666
- * @param {Function} callback The function associated with the provided
667
- * event type, will be called with the fired event.
697
+ * @event App#loadstart
698
+ * @type {CustomEvent}
699
+ * @property {object} detail The event detail.
700
+ * @property {string} detail.dataid The data id.
701
+ * @property {*} detail.source The load source: string for an url,
702
+ * File for a file.
668
703
  */
669
- addEventListener(type: string, callback: Function): void;
670
704
  /**
671
- * Remove an event listener from this class.
705
+ * Load progress event.
672
706
  *
673
- * @param {string} type The event type.
674
- * @param {Function} callback The function associated with the provided
675
- * event type.
707
+ * @event App#loadprogress
708
+ * @type {CustomEvent}
709
+ * @property {object} detail The event detail.
710
+ * @property {string} detail.dataid The data id.
711
+ * @property {*} detail.source The load source: string for an url,
712
+ * File for a file.
713
+ * @property {number} detail.loaded The loaded percentage.
714
+ * @property {number} detail.total The total percentage.
715
+ */
716
+ /**
717
+ * Load item event: fired when an item has been successfully loaded.
718
+ *
719
+ * @event App#loaditem
720
+ * @type {CustomEvent}
721
+ * @property {object} detail The event detail.
722
+ * @property {string} detail.dataid The data id.
723
+ * @property {*} detail.source The load source: string for an url,
724
+ * File for a file.
725
+ * @property {object} detail.data The loaded meta data.
726
+ * @property {boolean} detail.isfirstitem True if the item is the first
727
+ * one loaded for the data id.
728
+ */
729
+ /**
730
+ * Load event: fired when a load finishes successfully.
731
+ *
732
+ * @event App#load
733
+ * @type {CustomEvent}
734
+ * @property {object} detail The event detail.
735
+ * @property {string} detail.dataid The data id.
736
+ * @property {*} detail.source The load source: string for an url,
737
+ * File for a file.
738
+ */
739
+ /**
740
+ * Load end event: fired when the load finishes,
741
+ * successfully or not.
742
+ *
743
+ * @event App#loadend
744
+ * @type {CustomEvent}
745
+ * @property {object} detail The event detail.
746
+ * @property {string} detail.dataid The data id.
747
+ * @property {*} detail.source The load source: string for an url,
748
+ * File for a file.
749
+ */
750
+ /**
751
+ * Load error event.
752
+ *
753
+ * @event App#error
754
+ * @type {CustomEvent}
755
+ * @property {object} detail The event detail.
756
+ * @property {string} detail.dataid The data id.
757
+ * @property {*} detail.source The load source: string for an url,
758
+ * File for a file.
759
+ * @property {object} detail.error The error.
760
+ * @property {object} detail.target The event target.
761
+ */
762
+ /**
763
+ * Load timeout event.
764
+ *
765
+ * @event App#timeout
766
+ * @type {CustomEvent}
767
+ * @property {object} detail The event detail.
768
+ * @property {string} detail.dataid The data id.
769
+ * @property {*} detail.source The load source: an url as a string.
770
+ * @property {object} detail.target The event target.
771
+ */
772
+ /**
773
+ * Load abort event.
774
+ *
775
+ * @event App#abort
776
+ * @type {CustomEvent}
777
+ * @property {object} detail The event detail.
778
+ * @property {string} detail.dataid The data id.
779
+ * @property {*} detail.source The load source: string for an url,
780
+ * File for a file.
676
781
  */
677
- removeEventListener(type: string, callback: Function): void;
678
782
  /**
679
- * Load a list of files. Can be image files or a state file.
783
+ * Load a list of image files.
680
784
  *
681
785
  * @param {File[]} files The list of files to load.
682
786
  * @returns {string} The data ID, '-1' if problem.
@@ -690,7 +794,7 @@ export declare class App {
690
794
  */
691
795
  loadFiles: (files: File[]) => string;
692
796
  /**
693
- * Load a list of URLs. Can be image files or a state file.
797
+ * Load a list of image URLs.
694
798
  *
695
799
  * @param {string[]} urls The list of urls to load.
696
800
  * @param {object} [options] The options object, can contain:
@@ -745,6 +849,9 @@ export declare class App {
745
849
  /**
746
850
  * Fit the display to the data of each layer group.
747
851
  * To be called once the image is loaded.
852
+ *
853
+ * @deprecated Since v0.37, use
854
+ * `app.getStageController().fitToContainer()` instead.
748
855
  */
749
856
  fitToContainer(): void;
750
857
  /**
@@ -759,6 +866,8 @@ export declare class App {
759
866
  * Set the imageSmoothing flag value. Default is false.
760
867
  *
761
868
  * @param {boolean} flag True to enable smoothing.
869
+ * @deprecated Since v0.37, use
870
+ * `app.getStageController().setImageSmoothing()` instead.
762
871
  */
763
872
  setImageSmoothing(flag: boolean): void;
764
873
  /**
@@ -768,37 +877,40 @@ export declare class App {
768
877
  * @param {boolean} [excludeStarConfig] Exclude the star config
769
878
  * (default to false).
770
879
  * @returns {ViewConfig[]} The list of associated configs.
880
+ * @deprecated Since v0.37, use
881
+ * `app.getStageController().getViewConfigs()` instead.
771
882
  */
772
883
  getViewConfigs(dataId: string, excludeStarConfig?: boolean): ViewConfig[];
773
884
  /**
774
- * Get the layer group configuration for a data id and group
775
- * div id.
885
+ * Get the layer group configuration for a data id and group div id.
776
886
  *
777
887
  * @param {string} dataId The data id.
778
888
  * @param {string} groupDivId The layer group div id.
779
889
  * @param {boolean} [excludeStarConfig] Exclude the star config
780
890
  * (default to false).
781
891
  * @returns {ViewConfig|undefined} The associated config.
892
+ * @deprecated Since v0.37, use
893
+ * `app.getStageController().getViewConfig()` instead.
782
894
  */
783
895
  getViewConfig(dataId: string, groupDivId: string, excludeStarConfig?: boolean): ViewConfig | undefined;
784
896
  /**
785
897
  * Get the data view config.
786
- * Carefull, returns a reference, do not modify without resetting.
898
+ * Careful, returns a reference; do not modify without resetting.
787
899
  *
788
- * @returns {Object<string, ViewConfig[]>} The configuration list.
900
+ * @returns {Record<string, ViewConfig[]>} The configuration list.
901
+ * @deprecated Since v0.37, use
902
+ * `app.getStageController().getDataViewConfigs()` instead.
789
903
  */
790
- getDataViewConfigs(): {
791
- [x: string]: ViewConfig[];
792
- };
904
+ getDataViewConfigs(): Record<string, ViewConfig[]>;
793
905
  /**
794
906
  * Set the data view configuration.
795
907
  * Resets the stage and recreates all the views.
796
908
  *
797
- * @param {Object<string, ViewConfig[]>} configs The configuration list.
909
+ * @param {Record<string, ViewConfig[]>} configs The configuration list.
910
+ * @deprecated Since v0.37, use
911
+ * `app.getStageController().setDataViewConfigs()` instead.
798
912
  */
799
- setDataViewConfigs(configs: {
800
- [x: string]: ViewConfig[];
801
- }): void;
913
+ setDataViewConfigs(configs: Record<string, ViewConfig[]>): void;
802
914
  /**
803
915
  * Add a data view config.
804
916
  *
@@ -806,6 +918,8 @@ export declare class App {
806
918
  * @param {ViewConfig} config The view configuration.
807
919
  * @param {boolean} [doRender] Render data after configuration
808
920
  * add. Defaults to true.
921
+ * @deprecated Since v0.37, use
922
+ * `app.getStageController().addDataViewConfig()` instead.
809
923
  */
810
924
  addDataViewConfig(dataId: string, config: ViewConfig, doRender?: boolean): void;
811
925
  /**
@@ -815,6 +929,8 @@ export declare class App {
815
929
  *
816
930
  * @param {string} dataId The data id.
817
931
  * @param {string} divId The div id.
932
+ * @deprecated Since v0.37, use
933
+ * `app.getStageController().removeDataViewConfig()` instead.
818
934
  */
819
935
  removeDataViewConfig(dataId: string, divId: string): void;
820
936
  /**
@@ -824,6 +940,8 @@ export declare class App {
824
940
  * @param {string} dataId The data id.
825
941
  * @param {string} divId The div id.
826
942
  * @param {ViewConfig} config The view configuration.
943
+ * @deprecated Since v0.37, use
944
+ * `app.getStageController().updateDataViewConfig()` instead.
827
945
  */
828
946
  updateDataViewConfig(dataId: string, divId: string, config: ViewConfig): void;
829
947
  /**
@@ -837,6 +955,8 @@ export declare class App {
837
955
  *
838
956
  * @param {string} dataId The data id to render.
839
957
  * @param {ViewConfig[]} [viewConfigs] The list of configs to render.
958
+ * @deprecated Since v0.37, use
959
+ * `app.getStageController().render()` instead.
840
960
  */
841
961
  render(dataId: string, viewConfigs?: ViewConfig[]): void;
842
962
  /**
@@ -845,6 +965,7 @@ export declare class App {
845
965
  * @param {number} step The step to add to the current zoom.
846
966
  * @param {number} cx The zoom center X coordinate.
847
967
  * @param {number} cy The zoom center Y coordinate.
968
+ * @deprecated Since v0.37, please access from the active layer group.
848
969
  */
849
970
  zoom(step: number, cx: number, cy: number): void;
850
971
  /**
@@ -852,6 +973,7 @@ export declare class App {
852
973
  *
853
974
  * @param {number} tx The translation along X.
854
975
  * @param {number} ty The translation along Y.
976
+ * @deprecated Since v0.37, please access from the active layer group.
855
977
  */
856
978
  translate(tx: number, ty: number): void;
857
979
  /**
@@ -883,24 +1005,6 @@ export declare class App {
883
1005
  * of the desired view layer directly.
884
1006
  */
885
1007
  setOpacity(alpha: number): void;
886
- /**
887
- * Set the drawings of the active layer group.
888
- *
889
- * @deprecated Since v0.34, please switch to DICOM SR annotations.
890
- * @param {Array} drawings An array of drawings.
891
- * @param {Array} drawingsDetails An array of drawings details.
892
- * @param {string} dataId The converted data id.
893
- */
894
- setDrawings(drawings: any[], drawingsDetails: any[], dataId: string): void;
895
- /**
896
- * Apply a JSON state to this app.
897
- *
898
- * @deprecated Since v0.34, please switch to DICOM SR
899
- * for annotations.
900
- * @param {string} jsonState The state of the app as a JSON string.
901
- * @param {string} dataId The state data id.
902
- */
903
- applyJsonState(jsonState: string, dataId: string): void;
904
1008
  /**
905
1009
  * Handle resize: fit the display to the window.
906
1010
  * To be called once the image is loaded.
@@ -912,11 +1016,12 @@ export declare class App {
912
1016
  /**
913
1017
  * Key down callback. Meant to be used in tools.
914
1018
  *
915
- * @param {KeyboardEvent} event The key down event.
1019
+ * @param {object} event The KeyboardEvent down event
1020
+ * augmented with a context.
916
1021
  * @fires App#keydown
917
1022
  * @function
918
1023
  */
919
- onKeydown: (event: KeyboardEvent) => void;
1024
+ onKeydown: (event: object) => void;
920
1025
  /**
921
1026
  * Key down event handler example.
922
1027
  * - CRTL-Z: undo,
@@ -974,24 +1079,28 @@ export declare class App {
974
1079
  * Undo the last action.
975
1080
  *
976
1081
  * @fires UndoStack#undo
1082
+ * @deprecated Since v0.37, please use via app.getUndoController.
977
1083
  */
978
1084
  undo(): void;
979
1085
  /**
980
1086
  * Redo the last action.
981
1087
  *
982
1088
  * @fires UndoStack#redo
1089
+ * @deprecated Since v0.37, please use via app.getUndoController.
983
1090
  */
984
1091
  redo(): void;
985
1092
  /**
986
1093
  * Get the undo stack size.
987
1094
  *
988
1095
  * @returns {number} The size of the stack.
1096
+ * @deprecated Since v0.37, please use via app.getUndoController.
989
1097
  */
990
1098
  getStackSize(): number;
991
1099
  /**
992
1100
  * Get the current undo stack index.
993
1101
  *
994
1102
  * @returns {number} The stack index.
1103
+ * @deprecated Since v0.37, please use via app.getUndoController.
995
1104
  */
996
1105
  getCurrentStackIndex(): number;
997
1106
  /**
@@ -1023,13 +1132,6 @@ export declare class App {
1023
1132
  * @param {string} refDataId The reference data id.
1024
1133
  */
1025
1134
  addAndRenderAnnotationData(data: DicomData, divId: string, refDataId: string): void;
1026
- /**
1027
- * Add a draw layer.
1028
- *
1029
- * @param {string} dataId The data id.
1030
- * @param {ViewConfig} viewConfig The data view config.
1031
- */
1032
- addDrawLayer(dataId: string, viewConfig: ViewConfig): void;
1033
1135
  #private;
1034
1136
  }
1035
1137
 
@@ -1038,28 +1140,22 @@ export declare class App {
1038
1140
  */
1039
1141
  export declare class AppOptions {
1040
1142
  /**
1041
- * @param {Object<string, ViewConfig[]>} [dataViewConfigs] Optional dataId
1143
+ * @param {Record<string, ViewConfig[]>} [dataViewConfigs] Optional dataId
1042
1144
  * indexed object containing the data view configurations.
1043
1145
  */
1044
- constructor(dataViewConfigs?: {
1045
- [x: string]: ViewConfig[];
1046
- });
1146
+ constructor(dataViewConfigs?: Record<string, ViewConfig[]>);
1047
1147
  /**
1048
1148
  * DataId indexed object containing the data view configurations.
1049
1149
  *
1050
- * @type {Object<string, ViewConfig[]>|undefined}
1150
+ * @type {Record<string, ViewConfig[]>|undefined}
1051
1151
  */
1052
- dataViewConfigs: {
1053
- [x: string]: ViewConfig[];
1054
- } | undefined;
1152
+ dataViewConfigs: Record<string, ViewConfig[]> | undefined;
1055
1153
  /**
1056
1154
  * Tool name indexed object containing individual tool configurations.
1057
1155
  *
1058
- * @type {Object<string, ToolConfig>|undefined}
1156
+ * @type {Record<string, ToolConfig>|undefined}
1059
1157
  */
1060
- tools: {
1061
- [x: string]: ToolConfig;
1062
- } | undefined;
1158
+ tools: Record<string, ToolConfig> | undefined;
1063
1159
  /**
1064
1160
  * Optional array of layerGroup binder names.
1065
1161
  *
@@ -1114,6 +1210,23 @@ export declare class BooleanResult {
1114
1210
  message: string | undefined;
1115
1211
  }
1116
1212
 
1213
+ /**
1214
+ * Extract polygon contours from a mask slice using Moore neighborhood tracing.
1215
+ * Returns one polygon per connected region with the given segment value.
1216
+ *
1217
+ * @param {Uint8Array} buffer The mask buffer (all slices).
1218
+ * @param {number} sliceOffset Byte offset of the slice in buffer.
1219
+ * @param {number} width Slice width in pixels.
1220
+ * @param {number} height Slice height in pixels.
1221
+ * @param {number} value Segment value to trace.
1222
+ * @returns {Array.<Array.<{x: number, y: number}>>} One polygon per
1223
+ * connected region.
1224
+ */
1225
+ export declare function bufferToPolygons(buffer: Uint8Array, sliceOffset: number, width: number, height: number, value: number): Array<Array<{
1226
+ x: number;
1227
+ y: number;
1228
+ }>>;
1229
+
1117
1230
  /**
1118
1231
  * Build a multipart message.
1119
1232
  *
@@ -1146,17 +1259,22 @@ export declare class CADReport {
1146
1259
  comment: string;
1147
1260
  }
1148
1261
 
1262
+ /**
1263
+ * @import {MaskImage} from '../image/maskImage.js';
1264
+ * @import {MaskSegment} from '../dicom/dicomSegment.js';
1265
+ * @import {RGB} from '../utils/colour.js';
1266
+ */
1149
1267
  /**
1150
1268
  * Change segment colour command.
1151
1269
  */
1152
1270
  export declare class ChangeSegmentColourCommand extends Command {
1153
1271
  /**
1154
- * @param {Image} mask The mask image.
1272
+ * @param {MaskImage} mask The mask image.
1155
1273
  * @param {MaskSegment} segment The segment to modify.
1156
1274
  * @param {RGB|number} newColour The new segment colour.
1157
1275
  * @param {boolean} [silent] Whether to send a creation event or not.
1158
1276
  */
1159
- constructor(mask: Image_2, segment: MaskSegment, newColour: RGB | number, silent?: boolean);
1277
+ constructor(mask: MaskImage, segment: MaskSegment, newColour: RGB | number, silent?: boolean);
1160
1278
  /**
1161
1279
  * Check if a command is valid and can be executed.
1162
1280
  *
@@ -1206,6 +1324,16 @@ export declare class Circle {
1206
1324
  * @returns {number} The radius of the circle.
1207
1325
  */
1208
1326
  getRadius(): number;
1327
+ /**
1328
+ * Check if a point is inside the circle, or within a tolerance
1329
+ * of its outline.
1330
+ *
1331
+ * @param {Point2D} point The point to check.
1332
+ * @param {number} [tolerance] Optional maximum distance to the outline
1333
+ * for an outside point, defaults to 0.
1334
+ * @returns {boolean} True if the point is in the circle.
1335
+ */
1336
+ contains(point: Point2D, tolerance?: number): boolean;
1209
1337
  /**
1210
1338
  * Check for equality.
1211
1339
  *
@@ -1247,11 +1375,9 @@ export declare class Circle {
1247
1375
  * @param {Index} index The index at which to get the
1248
1376
  * image values.
1249
1377
  * @param {string[]} flags A list of stat values to calculate.
1250
- * @returns {Object<string, Value>} A quantification object.
1378
+ * @returns {Record<string, NumberValue>} A quantification object.
1251
1379
  */
1252
- quantify(viewController: ViewController, index: Index, flags: string[]): {
1253
- [x: string]: Value;
1254
- };
1380
+ quantify(viewController: ViewController, index: Index, flags: string[]): Record<string, NumberValue>;
1255
1381
  #private;
1256
1382
  }
1257
1383
 
@@ -1306,55 +1432,128 @@ export declare class Command {
1306
1432
  undo(): void;
1307
1433
  }
1308
1434
 
1309
- /**
1310
- * Create an Image from DICOM elements.
1311
- *
1312
- * @param {Object<string, DataElement>} elements The DICOM elements.
1313
- * @returns {Image} The Image object.
1314
- */
1315
- export declare function createImage(elements: {
1316
- [x: string]: DataElement;
1317
- }): Image_2;
1318
-
1319
- /**
1320
- * Create a mask Image from DICOM elements.
1321
- *
1322
- * @param {Object<string, DataElement>} elements The DICOM elements.
1323
- * @returns {Image} The mask Image object.
1324
- */
1325
- export declare function createMaskImage(elements: {
1326
- [x: string]: DataElement;
1327
- }): Image_2;
1328
-
1329
- /**
1330
- * Create a View from DICOM elements and image.
1331
- *
1332
- * @param {Object<string, DataElement>} elements The DICOM elements.
1333
- * @param {Image} image The associated image.
1334
- * @returns {View} The View object.
1335
- */
1336
- export declare function createView(elements: {
1337
- [x: string]: DataElement;
1338
- }, image: Image_2): View;
1339
-
1340
1435
  export declare namespace custom {
1341
- let wlPresets: {
1342
- [x: string]: {
1343
- [x: string]: WindowLevel;
1344
- };
1345
- };
1346
- let labelTexts: {
1347
- [x: string]: {
1348
- [x: string]: string;
1349
- };
1350
- };
1351
- let privateBValueRules: object[];
1436
+ let wlPresets: Record<string, Record<string, WindowLevel>>;
1437
+ let labelTexts: Record<string, Record<string, string>>;
1438
+ let privateBValueRules: PrivateBValueRule[];
1352
1439
  let openRoiDialog: any;
1440
+ let highlightAnnotation: any;
1441
+ let highlightSegment: any;
1353
1442
  let getVolumeIdTagValue: any;
1354
1443
  let getPostLoadVolumeIdTagValue: any;
1444
+ let volumeIdCandidates: VolumeIdCandidate[];
1355
1445
  let getTagPixelUnit: any;
1356
1446
  }
1357
1447
 
1448
+ /**
1449
+ * DicomData controller.
1450
+ */
1451
+ export declare class DataController extends EventTarget {
1452
+ /**
1453
+ * Get the next data id.
1454
+ *
1455
+ * @returns {string} The data id.
1456
+ */
1457
+ getNextDataId(): string;
1458
+ /**
1459
+ * Get the list of ids in the data storage.
1460
+ *
1461
+ * @returns {string[]} The list of data ids.
1462
+ */
1463
+ getDataIds(): string[];
1464
+ /**
1465
+ * Reset the class: empty the data storage.
1466
+ */
1467
+ reset(): void;
1468
+ /**
1469
+ * Get a data at a given index.
1470
+ *
1471
+ * @param {string} dataId The data id.
1472
+ * @returns {DicomData|undefined} The DICOM data.
1473
+ */
1474
+ get(dataId: string): DicomData | undefined;
1475
+ /**
1476
+ * Get the list of dataIds that contain the input UIDs.
1477
+ *
1478
+ * @param {string[]} uids A list of UIDs.
1479
+ * @returns {string[]} The list of dataIds that contain the UIDs.
1480
+ */
1481
+ getDataIdsFromSopUids(uids: string[]): string[];
1482
+ /**
1483
+ * Get the first data id with the given SeriesInstanceUID.
1484
+ *
1485
+ * @param {string} uid The SeriesInstanceUID.
1486
+ * @returns {string} The data id.
1487
+ */
1488
+ getDataIdFromSeriesUid(uid: string): string;
1489
+ /**
1490
+ * Set the image at a given index.
1491
+ *
1492
+ * @param {string} dataId The data id.
1493
+ * @param {Image} image The image to set.
1494
+ */
1495
+ setImage(dataId: string, image: Image_2): void;
1496
+ /**
1497
+ * Add a new data.
1498
+ *
1499
+ * @param {string} dataId The data id.
1500
+ * @param {DicomData} data The data.
1501
+ * @returns {boolean} False if the data cannot be added.
1502
+ */
1503
+ add(dataId: string, data: DicomData): boolean;
1504
+ /**
1505
+ * Remove a data from the list.
1506
+ *
1507
+ * @param {string} dataId The data id.
1508
+ */
1509
+ remove(dataId: string): void;
1510
+ /**
1511
+ * Stash a data from the list.
1512
+ *
1513
+ * @param {string} dataId The data id.
1514
+ */
1515
+ stash(dataId: string): void;
1516
+ /**
1517
+ * Unstash a data from the list.
1518
+ *
1519
+ * @param {string} dataId The data id.
1520
+ */
1521
+ unstash(dataId: string): void;
1522
+ /**
1523
+ * Get the list of ids in the stashed data storage.
1524
+ *
1525
+ * @returns {string[]} The list of data ids.
1526
+ */
1527
+ getStashedDataIds(): string[];
1528
+ /**
1529
+ * Get a stashed data at a given index.
1530
+ *
1531
+ * @param {string} dataId The data id.
1532
+ * @returns {DicomData|undefined} The DICOM data.
1533
+ */
1534
+ getStashed(dataId: string): DicomData | undefined;
1535
+ /**
1536
+ * Update the current data.
1537
+ *
1538
+ * @param {string} dataId The data id.
1539
+ * @param {DicomData} data The data.
1540
+ */
1541
+ update(dataId: string, data: DicomData): void;
1542
+ /**
1543
+ * Mark a data a complete (fully loaded).
1544
+ *
1545
+ * @param {string} dataId The data id.
1546
+ * @returns {{imageHasChanged}} An object with an imageHasChanged property.
1547
+ */
1548
+ markDataAsComplete(dataId: string): {
1549
+ imageHasChanged: any;
1550
+ };
1551
+ #private;
1552
+ }
1553
+
1554
+ /**
1555
+ * @import {Tag} from './dicomTag.js';
1556
+ */
1358
1557
  /**
1359
1558
  * DICOM data element.
1360
1559
  */
@@ -1413,36 +1612,61 @@ export declare class DataElement {
1413
1612
  items: any[];
1414
1613
  }
1415
1614
 
1615
+ /**
1616
+ * Default private b-value tag rules. Tested in order.
1617
+ * Rules are either `{manufacturer, key}` or `{uidPrefix, key}`.
1618
+ * Can be used to extend `custom.privateBValueRules`.
1619
+ *
1620
+ * @type {PrivateBValueRule[]}
1621
+ */
1622
+ export declare const defaultPrivateBValueRules: PrivateBValueRule[];
1623
+
1416
1624
  /**
1417
1625
  * Default tool list.
1418
1626
  *
1419
- * @type {Object<string, any>}
1627
+ * @type {Record<string, any>}
1420
1628
  */
1421
- export declare const defaultToolList: {
1422
- [x: string]: any;
1423
- };
1629
+ export declare const defaultToolList: Record<string, any>;
1424
1630
 
1425
1631
  /**
1426
1632
  * Default tool options.
1427
1633
  *
1428
- * @type {Object<string, Object<string, any>>}
1634
+ * @type {Record<string, Record<string, any>>}
1429
1635
  */
1430
- export declare const defaultToolOptions: {
1431
- [x: string]: {
1432
- [x: string]: any;
1433
- };
1434
- };
1636
+ export declare const defaultToolOptions: Record<string, Record<string, any>>;
1637
+
1638
+ /**
1639
+ * Ordered list of candidate volume id getters. Since the tag that
1640
+ * actually discriminates volumes is not known until the full data
1641
+ * is loaded, `guessVolumeIndices` tries these in order and keeps the
1642
+ * first one that produces a valid, consistent per-volume grouping.
1643
+ * It is used for the files of a series (see `DicomSliceDataList`)
1644
+ * and for the frames of a multi-frame file (see
1645
+ * `getSortedFramesGeometry`).
1646
+ * Most explicit/reliable discriminators come first, AcquisitionTime
1647
+ * (the historical default) comes last.
1648
+ * Candidates flagged with `preLoad` are also used while loading
1649
+ * (see `getVolumeIdTagValue`): they must not vary between the
1650
+ * slices of a single volume.
1651
+ *
1652
+ * @type {VolumeIdCandidate[]}
1653
+ */
1654
+ export declare const defaultVolumeIdCandidates: VolumeIdCandidate[];
1435
1655
 
1656
+ /**
1657
+ * @import {MaskImage} from '../image/maskImage.js';
1658
+ * @import {MaskSegment} from '../dicom/dicomSegment.js';
1659
+ */
1436
1660
  /**
1437
1661
  * Delete segment command.
1438
1662
  */
1439
1663
  export declare class DeleteSegmentCommand extends Command {
1440
1664
  /**
1441
- * @param {Image} mask The mask image.
1665
+ * @param {MaskImage} mask The mask image.
1442
1666
  * @param {MaskSegment} segment The segment to remove.
1443
1667
  * @param {boolean} [silent] Whether to send a creation event or not.
1444
1668
  */
1445
- constructor(mask: Image_2, segment: MaskSegment, silent?: boolean);
1669
+ constructor(mask: MaskImage, segment: MaskSegment, silent?: boolean);
1446
1670
  /**
1447
1671
  * Check if a command is valid and can be executed.
1448
1672
  *
@@ -1464,6 +1688,45 @@ export declare class DeleteSegmentCommand extends Command {
1464
1688
  #private;
1465
1689
  }
1466
1690
 
1691
+ /**
1692
+ * Demo Image creation from DICOM elements: takes
1693
+ * elements and first element of the pixel buffer
1694
+ * to create an image.
1695
+ *
1696
+ * Warning: not to be used in production code.
1697
+ *
1698
+ * @param {Record<string, DataElement>} elements The DICOM elements.
1699
+ * @returns {Image} The Image object.
1700
+ */
1701
+ export declare function demoCreateImage(elements: Record<string, DataElement>): Image_2;
1702
+
1703
+ /**
1704
+ * Demo mask Image creation from DICOM elements: takes
1705
+ * elements and first element of the pixel buffer
1706
+ * to create an image.
1707
+ *
1708
+ * Warning: not to be used in production code.
1709
+ *
1710
+ * @param {Record<string, DataElement>} elements The DICOM elements.
1711
+ * @returns {MaskImage} The mask Image object.
1712
+ */
1713
+ export declare function demoCreateMaskImage(elements: Record<string, DataElement>): MaskImage;
1714
+
1715
+ /**
1716
+ * Demo View creation from DICOM elements and image.
1717
+ *
1718
+ * Warning: not to be used in production code.
1719
+ *
1720
+ * @param {Record<string, DataElement>} elements The DICOM elements.
1721
+ * @param {Image} image The associated image.
1722
+ * @returns {View} The View object.
1723
+ */
1724
+ export declare function demoCreateView(elements: Record<string, DataElement>, image: Image_2): View;
1725
+
1726
+ /**
1727
+ * @import {Point} from '../math/point.js';
1728
+ * @import {NumberValue} from '../math/number.js';
1729
+ */
1467
1730
  /**
1468
1731
  * Diameter type.
1469
1732
  */
@@ -1471,9 +1734,9 @@ export declare class Diameter {
1471
1734
  /**
1472
1735
  * The scaled diameter value.
1473
1736
  *
1474
- * @type {Value}
1737
+ * @type {NumberValue}
1475
1738
  */
1476
- diameter: Value;
1739
+ diameter: NumberValue;
1477
1740
  /**
1478
1741
  * The offset of the pixel at the start
1479
1742
  * of the line used to calculate this diameter.
@@ -1561,19 +1824,15 @@ export declare class DicomCode {
1561
1824
  */
1562
1825
  export declare class DicomData {
1563
1826
  /**
1564
- * @param {Object<string, DataElement>} meta The DICOM meta data.
1827
+ * @param {Record<string, DataElement>} meta The DICOM meta data.
1565
1828
  */
1566
- constructor(meta: {
1567
- [x: string]: DataElement;
1568
- });
1829
+ constructor(meta: Record<string, DataElement>);
1569
1830
  /**
1570
1831
  * DICOM meta data.
1571
1832
  *
1572
- * @type {Object<string, DataElement>}
1833
+ * @type {Record<string, DataElement>}
1573
1834
  */
1574
- meta: {
1575
- [x: string]: DataElement;
1576
- };
1835
+ meta: Record<string, DataElement>;
1577
1836
  /**
1578
1837
  * Image extracted from meta data.
1579
1838
  *
@@ -1581,7 +1840,7 @@ export declare class DicomData {
1581
1840
  */
1582
1841
  image: Image_2 | undefined;
1583
1842
  /**
1584
- * Annotattion group extracted from meta data.
1843
+ * Annotation group extracted from meta data.
1585
1844
  *
1586
1845
  * @type {AnnotationGroup|undefined}
1587
1846
  */
@@ -1593,11 +1852,20 @@ export declare class DicomData {
1593
1852
  */
1594
1853
  buffer: any | undefined;
1595
1854
  /**
1596
- * Number of files/urls associated to the data.
1855
+ * Number of load items (files, urls, buffers...) associated
1856
+ * to the data.
1597
1857
  *
1598
1858
  * @type {number}
1599
1859
  */
1600
- numberOfFiles: number;
1860
+ numberOfItems: number;
1861
+ /**
1862
+ * Frame number, set when the buffer only contains one frame
1863
+ * of a multi-frame data: frames are sent one by one and assembled
1864
+ * by the image (see Image.appendSlice).
1865
+ *
1866
+ * @type {number|undefined}
1867
+ */
1868
+ frameNumber: number | undefined;
1601
1869
  /**
1602
1870
  * List of data creation warning.
1603
1871
  *
@@ -1623,7 +1891,7 @@ export declare class DicomData {
1623
1891
  */
1624
1892
  hasDuplicateOrigin(): boolean;
1625
1893
  /**
1626
- * Append slice and update meta data.
1894
+ * Append data and update meta data.
1627
1895
  *
1628
1896
  * @param {DicomData} data The data to append.
1629
1897
  */
@@ -1680,11 +1948,9 @@ export declare class DicomParser {
1680
1948
  /**
1681
1949
  * Get the DICOM data elements.
1682
1950
  *
1683
- * @returns {Object<string, DataElement>} The data elements.
1951
+ * @returns {Record<string, DataElement>} The data elements.
1684
1952
  */
1685
- getDicomElements(): {
1686
- [x: string]: DataElement;
1687
- };
1953
+ getDicomElements(): Record<string, DataElement>;
1688
1954
  /**
1689
1955
  * Safely get an elements' first value from the parsed elements.
1690
1956
  *
@@ -1806,29 +2072,55 @@ export declare class DicomWriter {
1806
2072
  * @param {boolean} flag True to activate the check and fix.
1807
2073
  */
1808
2074
  setFixUnknownVR(flag: boolean): void;
2075
+ /**
2076
+ * Set the list of private tags (odd group number) to write.
2077
+ * All other private tags are not written, including the ones
2078
+ * in sequence items. Takes precedence over the writing rules,
2079
+ * whitelisted tags still go through them.
2080
+ * The private creator of each whitelisted tag is also kept:
2081
+ * for example, whitelisting '0019100C' also keeps '00190010'.
2082
+ * Use an empty list to remove all private tags and undefined
2083
+ * to keep them all (default).
2084
+ *
2085
+ * @param {string[]|undefined} keys The list of private tag keys
2086
+ * (as '########').
2087
+ */
2088
+ setPrivateTagsWhitelist(keys: string[] | undefined): void;
1809
2089
  /**
1810
2090
  * Set the writing rules.
1811
2091
  * List of writer rules indexed by either `default`,
1812
- * tagKey, tagName or groupName.
2092
+ * tag key (for example '00100010') or group key (for example '0010').
2093
+ * Keys can be ranges using 'x' as any hex digit, as in the DICOM
2094
+ * standard repeating groups notation: for example '60xx3000'
2095
+ * (tag range) or '50xx' (group range). Note that 'x' matches any
2096
+ * hex digit: '60xx' also matches odd (private) groups.
1813
2097
  * Each DICOM element will be checked to see if a rule is applicable.
1814
- * First checked by tagKey, tagName and then by groupName,
1815
- * if nothing is found the default rule is applied.
1816
- *
1817
- * @param {Object<string, WriterRule>} rules The input rules.
2098
+ * First checked by tag key, tag range, group key and then group range,
2099
+ * if nothing is found the default rule is applied. If several ranges
2100
+ * match, the most specific one (with less 'x') is used, and, for same
2101
+ * specificity, the first one in the rules order.
2102
+ * Rules are also applied to the elements of sequence items.
2103
+ * Use `translateWriterRules` to convert tag or group name based rules.
2104
+ * Rules with an unknown action are ignored (with a warning), the
2105
+ * next matching rule is then used. If there is no valid default
2106
+ * rule, the default is to copy.
2107
+ *
2108
+ * @param {Record<string, WriterRule>} rules The input rules.
1818
2109
  * @param {boolean} [addMissingTags] If true, explicit tags that
1819
2110
  * have replace rule and a value will be
1820
2111
  * added if missing. Defaults to false.
1821
2112
  */
1822
- setRules(rules: {
1823
- [x: string]: WriterRule;
1824
- }, addMissingTags?: boolean): void;
2113
+ setRules(rules: Record<string, WriterRule>, addMissingTags?: boolean): void;
1825
2114
  /**
1826
2115
  * Use a TextEncoder instead of the default text decoder.
1827
2116
  */
1828
2117
  useSpecialTextEncoder(): void;
1829
2118
  /**
1830
2119
  * Get the element to write according to the class rules.
1831
- * Priority order: tagName, groupName, default.
2120
+ * Priority order: tag key, tag range, group key, group range, default.
2121
+ * Non whitelisted private tags are removed if a whitelist
2122
+ * is set, whatever the rules.
2123
+ * For sequences, rules are also applied to the item elements.
1832
2124
  *
1833
2125
  * @param {DataElement} element The element to check.
1834
2126
  * @returns {DataElement|null} The element to write, can be null.
@@ -1837,50 +2129,125 @@ export declare class DicomWriter {
1837
2129
  /**
1838
2130
  * Get the ArrayBuffer corresponding to input DICOM elements.
1839
2131
  *
1840
- * @param {Object<string, DataElement>} dataElements The elements to write.
2132
+ * @param {Record<string, DataElement>} dataElements The elements to write.
1841
2133
  * @returns {ArrayBuffer} The elements as a buffer.
1842
2134
  */
1843
- getBuffer(dataElements: {
1844
- [x: string]: DataElement;
1845
- }): ArrayBuffer;
2135
+ getBuffer(dataElements: Record<string, DataElement>): ArrayBuffer;
1846
2136
  #private;
1847
2137
  }
1848
2138
 
1849
2139
  /**
1850
- * Draw controller.
2140
+ * Draw brush command.
1851
2141
  */
1852
- export declare class DrawController {
2142
+ export declare class DrawBrushCommand extends Command {
1853
2143
  /**
1854
- * @param {AnnotationGroup} [group] Optional annotation group.
2144
+ * @param {DrawBrushCommandProperties} properties The command properties.
1855
2145
  */
1856
- constructor(group?: AnnotationGroup);
2146
+ constructor(properties: DrawBrushCommandProperties);
1857
2147
  /**
1858
- * Get an annotation.
2148
+ * Get the original values before applying brush.
1859
2149
  *
1860
- * @param {string} uid The annotation UID.
1861
- * @returns {Annotation|undefined} The annotation.
2150
+ * @returns {Array|undefined} Lists of original value iterators,
2151
+ * undefined when erasing.
1862
2152
  */
1863
- getAnnotation(uid: string): Annotation | undefined;
2153
+ getOriginalValuesLists(): any[] | undefined;
1864
2154
  /**
1865
- * Get the annotation group.
2155
+ * Get the execute event.
1866
2156
  *
1867
- * @returns {AnnotationGroup} The list.
2157
+ * @returns {CustomEvent} The event.
1868
2158
  */
1869
- getAnnotationGroup(): AnnotationGroup;
2159
+ getExecuteEvent(): CustomEvent;
1870
2160
  /**
1871
- * Check if the annotation group is editable.
2161
+ * Handle an execute event.
1872
2162
  *
1873
- * @returns {boolean} True if editable.
2163
+ * @param {CustomEvent} _event The execute event with type and id.
1874
2164
  */
1875
- isAnnotationGroupEditable(): boolean;
2165
+ onExecute(_event: CustomEvent): void;
1876
2166
  /**
1877
- * Set the annotation group editability.
2167
+ * Handle an undo event.
1878
2168
  *
1879
- * @param {boolean} flag True to make the annotation group editable.
2169
+ * @param {CustomEvent} _event The undo event with type and id.
1880
2170
  */
1881
- setAnnotationGroupEditable(flag: boolean): void;
2171
+ onUndo(_event: CustomEvent): void;
2172
+ #private;
2173
+ }
2174
+
2175
+ /**
2176
+ * @import {MaskImage} from '../image/maskImage.js';
2177
+ */
2178
+ export declare class DrawBrushCommandProperties {
1882
2179
  /**
1883
- * Add an annotation.
2180
+ * @type {MaskImage}
2181
+ */
2182
+ mask: MaskImage;
2183
+ /**
2184
+ * @type {string}
2185
+ */
2186
+ dataId: string;
2187
+ /**
2188
+ * @type {number[][]}
2189
+ */
2190
+ offsetsLists: number[][];
2191
+ /**
2192
+ * @type {string}
2193
+ */
2194
+ mode: string;
2195
+ /**
2196
+ * @type {number}
2197
+ */
2198
+ segmentNumber: number;
2199
+ /**
2200
+ * @type {string}
2201
+ */
2202
+ srclayerid: string;
2203
+ /**
2204
+ * @type {Array}
2205
+ */
2206
+ originalValuesLists: any[];
2207
+ /**
2208
+ * @type {boolean}
2209
+ */
2210
+ isSilent: boolean;
2211
+ }
2212
+
2213
+ /**
2214
+ * @import {Annotation} from '../image/annotation.js';
2215
+ */
2216
+ /**
2217
+ * Draw controller.
2218
+ */
2219
+ export declare class DrawController {
2220
+ /**
2221
+ * @param {AnnotationGroup} [group] Optional annotation group.
2222
+ */
2223
+ constructor(group?: AnnotationGroup);
2224
+ /**
2225
+ * Get an annotation.
2226
+ *
2227
+ * @param {string} uid The annotation UID.
2228
+ * @returns {Annotation|undefined} The annotation.
2229
+ */
2230
+ getAnnotation(uid: string): Annotation | undefined;
2231
+ /**
2232
+ * Get the annotation group.
2233
+ *
2234
+ * @returns {AnnotationGroup} The list.
2235
+ */
2236
+ getAnnotationGroup(): AnnotationGroup;
2237
+ /**
2238
+ * Check if the annotation group is editable.
2239
+ *
2240
+ * @returns {boolean} True if editable.
2241
+ */
2242
+ isAnnotationGroupEditable(): boolean;
2243
+ /**
2244
+ * Set the annotation group editability.
2245
+ *
2246
+ * @param {boolean} flag True to make the annotation group editable.
2247
+ */
2248
+ setAnnotationGroupEditable(flag: boolean): void;
2249
+ /**
2250
+ * Add an annotation.
1884
2251
  *
1885
2252
  * @param {Annotation} annotation The annotation to add.
1886
2253
  */
@@ -1941,6 +2308,17 @@ export declare class DrawController {
1941
2308
  #private;
1942
2309
  }
1943
2310
 
2311
+ /**
2312
+ * @import {Point, Point2D, Point3D} from '../math/point.js';
2313
+ * @import {Vector3D} from '../math/vector.js';
2314
+ * @import {Scalar2D, Scalar3D} from '../math/scalar.js';
2315
+ * @import {Index} from '../math/index.js';
2316
+ * @import {Image} from '../image/image.js';
2317
+ * @import {PlaneHelper} from '../image/planeHelper.js';
2318
+ * @import {Annotation} from '../image/annotation.js';
2319
+ * @import {AnnotationGroup} from '../image/annotationGroup.js';
2320
+ * @import {DrawShapeHandler} from '../tools/shapes/drawShapeHandler.js';
2321
+ */
1944
2322
  /**
1945
2323
  * Debug function to output the layer hierarchy as text.
1946
2324
  *
@@ -1950,6 +2328,9 @@ export declare class DrawController {
1950
2328
  */
1951
2329
  /**
1952
2330
  * Draw layer.
2331
+ *
2332
+ * Not an EventTarget in order to forward native DOM events while
2333
+ * preserving `preventDefault()` for tools (see '#fireDomEvent').
1953
2334
  */
1954
2335
  export declare class DrawLayer {
1955
2336
  /**
@@ -2123,6 +2504,17 @@ export declare class DrawLayer {
2123
2504
  * @param {Scalar2D} fitOffset The fit offset as {x,y}.
2124
2505
  */
2125
2506
  fitToContainer(containerSize: Scalar2D, divToWorldSizeRatio: number, fitOffset: Scalar2D): void;
2507
+ /**
2508
+ * Get the top most visible annotation at the current position
2509
+ * that contains the input plane point.
2510
+ *
2511
+ * @param {Point2D} planePoint The plane point, in the reference
2512
+ * view layer plane coordinates.
2513
+ * @param {number} [tolerance] Optional maximum distance to a shape,
2514
+ * in plane coordinates, defaults to 0.
2515
+ * @returns {Annotation|undefined} The annotation, undefined if none.
2516
+ */
2517
+ getAnnotationAt(planePoint: Point2D, tolerance?: number): Annotation | undefined;
2126
2518
  /**
2127
2519
  * Check the visibility of an annotation.
2128
2520
  *
@@ -2139,6 +2531,18 @@ export declare class DrawLayer {
2139
2531
  * @returns {boolean} False if the annotation shape cannot be found.
2140
2532
  */
2141
2533
  setAnnotationVisibility(id: string, visible?: boolean): boolean;
2534
+ /**
2535
+ * Temporarily highlight an annotation: its opacity progressively
2536
+ * dims to 20% and comes back to normal in one pulse. Only one
2537
+ * annotation is highlighted at a time: a new call resets the
2538
+ * previous highlight.
2539
+ *
2540
+ * @param {string} id The id of the annotation.
2541
+ * @param {number} [duration] The highlight duration in milliseconds,
2542
+ * defaults to 500.
2543
+ * @returns {boolean} False if the annotation shape cannot be found.
2544
+ */
2545
+ highlightAnnotation(id: string, duration?: number): boolean;
2142
2546
  /**
2143
2547
  * Set the visibility of all labels.
2144
2548
  *
@@ -2215,16 +2619,11 @@ export declare class DrawLayer {
2215
2619
  /**
2216
2620
  * Draw shape handler: handle action on existing shapes.
2217
2621
  */
2218
- export declare class DrawShapeHandler {
2219
- /**
2220
- * @callback eventFn@callback eventFn
2221
- * @param {object} event The event.
2222
- */
2622
+ export declare class DrawShapeHandler extends EventTarget {
2223
2623
  /**
2224
2624
  * @param {App} app The associated application.
2225
- * @param {Function} eventCallback Event callback.
2226
2625
  */
2227
- constructor(app: App, eventCallback: Function);
2626
+ constructor(app: App);
2228
2627
  /**
2229
2628
  * Set the draw editor shape.
2230
2629
  *
@@ -2310,6 +2709,15 @@ export declare class Ellipse {
2310
2709
  * @returns {number} The radius of the ellipse on the vertical axe.
2311
2710
  */
2312
2711
  getB(): number;
2712
+ /**
2713
+ * Check if a point is inside the ellipse, the ellipse radii being
2714
+ * extended by a tolerance.
2715
+ *
2716
+ * @param {Point2D} point The point to check.
2717
+ * @param {number} [tolerance] Optional radius extension, defaults to 0.
2718
+ * @returns {boolean} True if the point is in the ellipse.
2719
+ */
2720
+ contains(point: Point2D, tolerance?: number): boolean;
2313
2721
  /**
2314
2722
  * Check for equality.
2315
2723
  *
@@ -2351,11 +2759,9 @@ export declare class Ellipse {
2351
2759
  * @param {Index} index The index at which to get the
2352
2760
  * image values.
2353
2761
  * @param {string[]} flags A list of stat values to calculate.
2354
- * @returns {Object<string, Value>} A quantification object.
2762
+ * @returns {Record<string, NumberValue>} A quantification object.
2355
2763
  */
2356
- quantify(viewController: ViewController, index: Index, flags: string[]): {
2357
- [x: string]: Value;
2358
- };
2764
+ quantify(viewController: ViewController, index: Index, flags: string[]): Record<string, NumberValue>;
2359
2765
  #private;
2360
2766
  }
2361
2767
 
@@ -2368,6 +2774,11 @@ export declare class Ellipse {
2368
2774
  */
2369
2775
  export declare function equalWl(wl0: WindowLevel, wl1: WindowLevel): boolean;
2370
2776
 
2777
+ /**
2778
+ * List of compatible float typed arrays.
2779
+ */
2780
+ export declare type FloatTypedArray = Float32Array | Float64Array;
2781
+
2371
2782
  /**
2372
2783
  * 2D/3D Geometry class.
2373
2784
  */
@@ -2435,6 +2846,10 @@ export declare class Geometry {
2435
2846
  * @returns {Point3D[]} The object origins.
2436
2847
  */
2437
2848
  getOrigins(): Point3D[];
2849
+ /**
2850
+ * Sort origins by Z position ascending.
2851
+ */
2852
+ sortOrigins(): void;
2438
2853
  /**
2439
2854
  * Check if a point is in the origin list.
2440
2855
  *
@@ -2480,7 +2895,7 @@ export declare class Geometry {
2480
2895
  */
2481
2896
  getOrientation(): Matrix33;
2482
2897
  /**
2483
- * Get the slice position of a point in the current slice layout.
2898
+ * Get the slice position of an origin in the current slice layout.
2484
2899
  * Slice indices increase with decreasing origins (high index -> low origin),
2485
2900
  * this simplified the handling of reconstruction since it means
2486
2901
  * the displayed data is in the same 'direction' as the extracted data.
@@ -2488,11 +2903,25 @@ export declare class Geometry {
2488
2903
  * This implies that the index to world and reverse method do some flipping
2489
2904
  * magic...
2490
2905
  *
2491
- * @param {Point3D} point The point to evaluate.
2906
+ * Limitation: the codirectional (before/after) refinement below is a
2907
+ * strict sign check on the normal-projected residual, with no
2908
+ * tolerance - unlike worldToIndex's magnitude-based half-spacing
2909
+ * gate. That is safe for this method's one real caller
2910
+ * (Image#appendSlice, which only ever compares exact, already-known
2911
+ * slice origins - a clean, large residual, never close to zero),
2912
+ * but this method should not be used for an arbitrary point with a
2913
+ * large in-plane offset from its closest origin (eg a click
2914
+ * position): float noise in that offset, amplified by a
2915
+ * lower-precision orientation (eg gantry-tilt direction cosines
2916
+ * with few decimal digits), can flip the sign of a residual that
2917
+ * should be exactly zero. Use worldToIndex (or a plain
2918
+ * Point3D#getClosest) instead for that case.
2919
+ *
2920
+ * @param {Point3D} origin The origin to locate.
2492
2921
  * @param {number} [time] Optional time index.
2493
2922
  * @returns {number} The slice index.
2494
2923
  */
2495
- getSliceIndex(point: Point3D, time?: number): number;
2924
+ getSliceIndex(origin: Point3D, time?: number): number;
2496
2925
  /**
2497
2926
  * Check if another geometry is compatible with this one, ie that
2498
2927
  * slices with these geometries can be merged into one volume.
@@ -2501,7 +2930,7 @@ export declare class Geometry {
2501
2930
  * @returns {BooleanResult} Result with success set to true if
2502
2931
  * the geometry is compatible.
2503
2932
  */
2504
- canAppend(rhs: Geometry): BooleanResult;
2933
+ canAppendSlice(rhs: Geometry): BooleanResult;
2505
2934
  /**
2506
2935
  * Check if an origin can be appended to this geometry.
2507
2936
  *
@@ -2539,6 +2968,16 @@ export declare class Geometry {
2539
2968
  * @returns {boolean} True if both objects are equal.
2540
2969
  */
2541
2970
  equals(rhs: Geometry): boolean;
2971
+ /**
2972
+ * Check for similarity for origin and orientation, equality
2973
+ * for size and spacing.
2974
+ *
2975
+ * @param {Geometry} rhs The object to compare to.
2976
+ * @param {number} [tol] Optional number comparison tolerance,
2977
+ * defaults to Number.EPSILON.
2978
+ * @returns {boolean} True if both objects are equal.
2979
+ */
2980
+ isSimilar(rhs: Geometry, tol?: number): boolean;
2542
2981
  /**
2543
2982
  * Check that a point is within bounds.
2544
2983
  *
@@ -2578,6 +3017,18 @@ export declare class Geometry {
2578
3017
  /**
2579
3018
  * Convert world coordinates into an index.
2580
3019
  *
3020
+ * Always returns an index, even for a point outside the geometry:
3021
+ * this does not itself mean the point is in bounds, use
3022
+ * isIndexInBounds/isInBounds for that. In-plane (row/column), an
3023
+ * out-of-bounds point extrapolates freely (eg -5 or size+12). On the
3024
+ * scroll axis, a point close to a real per-slice origin snaps to it;
3025
+ * further away, it is pinned to just past the first/last known
3026
+ * origin (ie the origins array length, or -1) rather than left to
3027
+ * drift arbitrarily far via linear extrapolation - except when there
3028
+ * are few or no real origins to compare against (eg a root geometry
3029
+ * with only its first slice known), where it still falls back to
3030
+ * that unclamped extrapolation.
3031
+ *
2581
3032
  * @param {Point} point The point to convert.
2582
3033
  * @returns {Index} The corresponding index.
2583
3034
  */
@@ -2593,42 +3044,63 @@ export declare class Geometry {
2593
3044
  }
2594
3045
 
2595
3046
  /**
2596
- * Get the meta data as simple elements:
3047
+ * Get the meta data as simple tag values:
2597
3048
  * - indexed by tag names instead of tag keys,
2598
3049
  * - no element object, just value if not sequence nor merged item.
2599
3050
  *
2600
- * @param {Object<string, DataElement>} metaData The meta data
3051
+ * @param {Record<string, DataElement>} dataElements The data elements
2601
3052
  * index by tag keys.
2602
- * @returns {Object<string, any>} The simple elements.
3053
+ * @returns {SimpleTagValues} The simple tag values.
2603
3054
  */
2604
- export declare function getAsSimpleElements(metaData: {
2605
- [x: string]: DataElement;
2606
- }): {
2607
- [x: string]: any;
2608
- };
3055
+ export declare function getAsSimpleTagValues(dataElements: Record<string, DataElement>): SimpleTagValues;
3056
+
3057
+ /**
3058
+ * Get the default DICOM RT Structure Set tags as an object.
3059
+ *
3060
+ * @returns {SimpleTagValues} The default tags.
3061
+ */
3062
+ export declare function getDefaultDicomRTStructJson(): SimpleTagValues;
2609
3063
 
2610
3064
  /**
2611
3065
  * Get the default DICOM seg tags as an object.
2612
3066
  *
2613
- * @returns {object} The default tags.
3067
+ * @returns {SimpleTagValues} The default tags.
2614
3068
  */
2615
- export declare function getDefaultDicomSegJson(): object;
3069
+ export declare function getDefaultDicomSegJson(): SimpleTagValues;
2616
3070
 
2617
3071
  /**
2618
3072
  * Get a simple dicom element item from a content item object.
2619
3073
  *
2620
3074
  * @param {DicomSRContent} content The content item object.
2621
- * @returns {Object<string, any>} The item as a list of (key, value) pairs.
3075
+ * @returns {SimpleTagValues} The item as a list of (key, value) pairs.
2622
3076
  */
2623
- export declare function getDicomSRContentItem(content: DicomSRContent): {
2624
- [x: string]: any;
2625
- };
3077
+ export declare function getDicomSRContentItem(content: DicomSRContent): SimpleTagValues;
3078
+
3079
+ /**
3080
+ * Get the DICOM tag group name as defined in TagGroups.
3081
+ *
3082
+ * @param {Tag} tag The DICOM tag.
3083
+ * @returns {string|undefined} The group name.
3084
+ */
3085
+ export declare function getDicomTagGroupName(tag: Tag): string | undefined;
3086
+
3087
+ /**
3088
+ * Get the DICOM tag info for a tag using the
3089
+ * local DICOM tag dictionary.
3090
+ *
3091
+ * @param {Tag} tag The DICOM tag.
3092
+ * @returns {TagInfo|undefined} The info.
3093
+ */
3094
+ export declare function getDicomTagInfo(tag: Tag): TagInfo | undefined;
2626
3095
 
3096
+ /**
3097
+ * @import {IntTypedArray, TypedArray} from '../math/arrayTypes.js';
3098
+ */
2627
3099
  /**
2628
3100
  * List of DICOM data elements indexed via a 8 character string formed from
2629
3101
  * the group and element numbers.
2630
3102
  *
2631
- * @typedef {Object<string, DataElement>} DataElements
3103
+ * @typedef {Record<string, DataElement>} DataElements
2632
3104
  */
2633
3105
  /**
2634
3106
  * Get the version of the library.
@@ -2643,15 +3115,11 @@ export declare function getDwvVersion(): string;
2643
3115
  * tag names instead of keys and direct values (no value property) for
2644
3116
  * simple tags. See synthetic test data (in tests/dicom) for examples.
2645
3117
  *
2646
- * @param {Object<string, any>} simpleTags The 'simple' DICOM
3118
+ * @param {SimpleTagValues} simpleTags The 'simple' DICOM
2647
3119
  * tags object.
2648
- * @returns {Object<string, DataElement>} The DICOM elements.
3120
+ * @returns {Record<string, DataElement>} The DICOM elements.
2649
3121
  */
2650
- export declare function getElementsFromJSONTags(simpleTags: {
2651
- [x: string]: any;
2652
- }): {
2653
- [x: string]: DataElement;
2654
- };
3122
+ export declare function getElementsFromSimpleTagValues(simpleTags: SimpleTagValues): Record<string, DataElement>;
2655
3123
 
2656
3124
  /**
2657
3125
  * Get the indices that form a ellpise.
@@ -2676,31 +3144,27 @@ export declare function getLayerDetailsFromEvent(event: object): object;
2676
3144
  /**
2677
3145
  * Get the manufacturer.
2678
3146
  *
2679
- * @param {Object<string, DataElement>} elements The DICOM tags.
3147
+ * @param {Record<string, DataElement>} elements The DICOM tags.
2680
3148
  * @returns {string|undefined} The manufacturer.
2681
3149
  */
2682
- export declare function getManufacturer(elements: {
2683
- [x: string]: DataElement;
2684
- }): string | undefined;
3150
+ export declare function getManufacturer(elements: Record<string, DataElement>): string | undefined;
2685
3151
 
2686
3152
  /**
2687
3153
  * Get the offset of an input mouse event.
2688
3154
  *
2689
- * @param {object} event The event to get the offset from.
3155
+ * @param {MouseEvent} event The event to get the offset from.
2690
3156
  * @returns {Point2D} The 2D point.
2691
3157
  */
2692
- export declare function getMousePoint(event: object): Point2D;
3158
+ export declare function getMousePoint(event: MouseEvent): Point2D;
2693
3159
 
2694
3160
  /**
2695
3161
  * Get the normalised manufacturer.
2696
3162
  *
2697
- * @param {Object<string, DataElement>} elements The DICOM tags.
3163
+ * @param {Record<string, DataElement>} elements The DICOM tags.
2698
3164
  * @returns {string|undefined} The manufacturer as a unique
2699
3165
  * all lower case string.
2700
3166
  */
2701
- export declare function getNormalisedManufacturer(elements: {
2702
- [x: string]: DataElement;
2703
- }): string | undefined;
3167
+ export declare function getNormalisedManufacturer(elements: Record<string, DataElement>): string | undefined;
2704
3168
 
2705
3169
  /**
2706
3170
  * Get the name of an image orientation patient.
@@ -2732,12 +3196,23 @@ export declare function getRectangleIndices(center: Index, size: number[], dir:
2732
3196
  /**
2733
3197
  * Get the referenced series UID from the data elements.
2734
3198
  *
2735
- * @param {Object<string, DataElement>} dataElements The data elements.
3199
+ * @param {Record<string, DataElement>} dataElements The data elements.
3200
+ * @returns {string|undefined} The referenced series UID.
3201
+ */
3202
+ export declare function getReferencedSeriesUID(dataElements: Record<string, DataElement>): string | undefined;
3203
+
3204
+ /**
3205
+ * Get the referenced series UID from an RT Structure Set.
3206
+ *
3207
+ * Path: ReferencedFrameOfReferenceSequence (3006,0010) →
3208
+ * RTReferencedStudySequence (3006,0012) →
3209
+ * RTReferencedSeriesSequence (3006,0014) →
3210
+ * SeriesInstanceUID (0020,000E).
3211
+ *
3212
+ * @param {Record<string, DataElement>} dataElements The data elements.
2736
3213
  * @returns {string|undefined} The referenced series UID.
2737
3214
  */
2738
- export declare function getReferencedSeriesUID(dataElements: {
2739
- [x: string]: DataElement;
2740
- }): string | undefined;
3215
+ export declare function getReferencedSeriesUIDFromRTStruct(dataElements: Record<string, DataElement>): string | undefined;
2741
3216
 
2742
3217
  /**
2743
3218
  * Get patient orientation label in the reverse direction.
@@ -2747,6 +3222,14 @@ export declare function getReferencedSeriesUID(dataElements: {
2747
3222
  */
2748
3223
  export declare function getReverseOrientation(ori: string): string;
2749
3224
 
3225
+ /**
3226
+ * Get a list of {@link RTROI} objects from RTSTRUCT DICOM elements.
3227
+ *
3228
+ * @param {Record<string, DataElement>} dataElements The DICOM data elements.
3229
+ * @returns {RTROI[]} The list of RT ROIs.
3230
+ */
3231
+ export declare function getRTStructFromElements(dataElements: Record<string, DataElement>): RTROI[];
3232
+
2750
3233
  /**
2751
3234
  * Get a segmentation DICOM code.
2752
3235
  *
@@ -2757,12 +3240,10 @@ export declare function getSegmentationCode(): DicomCode;
2757
3240
  /**
2758
3241
  * Get a content item object from a dicom element.
2759
3242
  *
2760
- * @param {Object<string, DataElement>} dataElements The dicom element.
3243
+ * @param {Record<string, DataElement>} dataElements The dicom element.
2761
3244
  * @returns {DicomSRContent} A content item object.
2762
3245
  */
2763
- export declare function getSRContent(dataElements: {
2764
- [x: string]: DataElement;
2765
- }): DicomSRContent;
3246
+ export declare function getSRContent(dataElements: Record<string, DataElement>): DicomSRContent;
2766
3247
 
2767
3248
  /**
2768
3249
  * Split a group-element key used to store DICOM elements.
@@ -2775,10 +3256,10 @@ export declare function getTagFromKey(key: string): Tag;
2775
3256
  /**
2776
3257
  * Get the offsets of an input touch event.
2777
3258
  *
2778
- * @param {object} event The event to get the offset from.
3259
+ * @param {TouchEvent} event The event to get the offset from.
2779
3260
  * @returns {Point2D[]} The array of points.
2780
3261
  */
2781
- export declare function getTouchPoints(event: object): Point2D[];
3262
+ export declare function getTouchPoints(event: TouchEvent): Point2D[];
2782
3263
 
2783
3264
  /**
2784
3265
  * Get the appropriate TypedArray in function of arguments.
@@ -2788,10 +3269,9 @@ export declare function getTouchPoints(event: object): Point2D[];
2788
3269
  * @param {number} pixelRepresentation The pixel representation,
2789
3270
  * 0:unsigned;1:signed.
2790
3271
  * @param {number} size The size of the new array.
2791
- * @returns {Uint8Array|Int8Array|Uint16Array|Int16Array|Uint32Array|Int32Array}
2792
- * The good typed array.
3272
+ * @returns {IntTypedArray} The good typed array.
2793
3273
  */
2794
- export declare function getTypedArray(bitsAllocated: number, pixelRepresentation: number, size: number): Uint8Array | Int8Array | Uint16Array | Int16Array | Uint32Array | Int32Array;
3274
+ export declare function getTypedArray(bitsAllocated: number, pixelRepresentation: number, size: number): IntTypedArray;
2795
3275
 
2796
3276
  /**
2797
3277
  * Get a UID for a DICOM tag.
@@ -2846,6 +3326,91 @@ export declare function hasDicomPrefix(buffer: ArrayBuffer): boolean;
2846
3326
  */
2847
3327
  export declare function hexToRgb(hexStr: string): RGB;
2848
3328
 
3329
+ /**
3330
+ * @import {NumberRange} from './number.js';
3331
+ */
3332
+ /**
3333
+ * Histogram entry.
3334
+ *
3335
+ * @typedef {object} HistogramEntry@typedef {object} HistogramEntry
3336
+ * @property {number} value The value.
3337
+ * @property {number} count The number of occurrences.
3338
+ */
3339
+ /**
3340
+ * Histogram of values: number of occurrences per distinct value.
3341
+ */
3342
+ export declare class Histogram {
3343
+ /**
3344
+ * Add occurrences of a value.
3345
+ *
3346
+ * @param {number} value The value.
3347
+ * @param {number} [count] The number of occurrences, defaults to 1.
3348
+ */
3349
+ add(value: number, count?: number): void;
3350
+ /**
3351
+ * Get the total number of counted values.
3352
+ *
3353
+ * @returns {number} The total count.
3354
+ */
3355
+ getTotal(): number;
3356
+ /**
3357
+ * Get the histogram entries sorted by ascending value.
3358
+ *
3359
+ * @returns {HistogramEntry[]} The entries.
3360
+ */
3361
+ getEntries(): HistogramEntry[];
3362
+ /**
3363
+ * Get the value range.
3364
+ *
3365
+ * @returns {NumberRange|undefined} The range, undefined if empty.
3366
+ */
3367
+ getRange(): NumberRange | undefined;
3368
+ /**
3369
+ * Get the number of values in [min, max).
3370
+ *
3371
+ * @param {number} [min] Inclusive lower bound, unbounded if undefined.
3372
+ * @param {number} [max] Exclusive upper bound, unbounded if undefined.
3373
+ * @returns {number} The count.
3374
+ */
3375
+ getCountInRange(min?: number, max?: number): number;
3376
+ /**
3377
+ * Get the percentage of counts that fall in each interval defined by
3378
+ * interior thresholds.
3379
+ *
3380
+ * For thresholds `[1, 5]`, the intervals are `[min, 1)`, `[1, 5)` and
3381
+ * `[5, max]`, where `min` / `max` are the histogram range.
3382
+ *
3383
+ * @param {number[]} thresholds Interior cut points in ascending order.
3384
+ * @returns {number[]} The percentages in [0, 100], one per interval
3385
+ * (`thresholds.length + 1` entries), all 0 for an empty histogram.
3386
+ */
3387
+ getIntervalPercentages(thresholds: number[]): number[];
3388
+ /**
3389
+ * Get the statistics of the values: minimum, maximum, mean,
3390
+ * standard deviation, median, 25th and 75th percentiles.
3391
+ * Gives the same results as `getStats` (`math/stats.js`) on the full
3392
+ * list of values.
3393
+ *
3394
+ * @returns {Statistics|undefined} The statistics, undefined if empty.
3395
+ */
3396
+ getStats(): Statistics | undefined;
3397
+ #private;
3398
+ }
3399
+
3400
+ /**
3401
+ * Histogram entry.
3402
+ */
3403
+ declare type HistogramEntry = {
3404
+ /**
3405
+ * The value.
3406
+ */
3407
+ value: number;
3408
+ /**
3409
+ * The number of occurrences.
3410
+ */
3411
+ count: number;
3412
+ };
3413
+
2849
3414
  export declare namespace i18n {
2850
3415
  /**
2851
3416
  * Get the translated text.
@@ -2864,14 +3429,14 @@ export declare namespace i18n {
2864
3429
  * - planar configuration (default RGBRGB...).
2865
3430
  *
2866
3431
  * @example
2867
- * import {DicomParser, createImage} from '//esm.sh/dwv';
3432
+ * import {DicomParser, demoCreateImage} from '//esm.sh/dwv';
2868
3433
  * // XMLHttpRequest onload callback
2869
3434
  * const onload = function (event) {
2870
3435
  * // parse the dicom buffer
2871
3436
  * const dicomParser = new DicomParser();
2872
3437
  * dicomParser.parse(event.target.response);
2873
3438
  * // create the image object
2874
- * const image = createImage(dicomParser.getDicomElements());
3439
+ * const image = demoCreateImage(dicomParser.getDicomElements());
2875
3440
  * // result div
2876
3441
  * const div = document.getElementById('dwv');
2877
3442
  * // display the image size
@@ -2895,13 +3460,13 @@ export declare namespace i18n {
2895
3460
  * request.onload = onload;
2896
3461
  * request.send();
2897
3462
  */
2898
- declare class Image_2 {
3463
+ declare class Image_2 extends EventTarget {
2899
3464
  /**
2900
3465
  * @param {Geometry} geometry The geometry of the image.
2901
3466
  * @param {TypedArray} buffer The image data as a one dimensional buffer.
2902
3467
  * @param {string[]} [imageUids] An array of Uids indexed to slice number.
2903
3468
  */
2904
- constructor(geometry: Geometry, buffer: Int8Array | Uint8Array | Int16Array | Uint16Array | Int32Array | Uint32Array, imageUids?: string[]);
3469
+ constructor(geometry: Geometry, buffer: TypedArray, imageUids?: string[]);
2905
3470
  /**
2906
3471
  * Set the image complete flag.
2907
3472
  *
@@ -2914,6 +3479,22 @@ declare class Image_2 {
2914
3479
  * @returns {boolean} True if the data is complete.
2915
3480
  */
2916
3481
  getComplete(): boolean;
3482
+ /**
3483
+ * Get the initial index, used as default position by views:
3484
+ * the middle of the image (first frame for 4D).
3485
+ *
3486
+ * @returns {Index} The index.
3487
+ */
3488
+ getInitialIndex(): Index;
3489
+ /**
3490
+ * Check whether the image has overlapping segments. Always false for a
3491
+ * plain image; {@link MaskImage} overrides this with a real check.
3492
+ *
3493
+ * @returns {boolean} False.
3494
+ * @deprecated Since v0.37, please use `instanceof MaskImage` and
3495
+ * `MaskImage#getHasOverlap` instead.
3496
+ */
3497
+ getHasOverlap(): boolean;
2917
3498
  /**
2918
3499
  * Get the image UID at a given index.
2919
3500
  *
@@ -2954,7 +3535,7 @@ declare class Image_2 {
2954
3535
  * @todo Dangerous...
2955
3536
  * @returns {TypedArray} The data buffer of the image.
2956
3537
  */
2957
- getBuffer(): Int8Array | Uint8Array | Int16Array | Uint16Array | Int32Array | Uint32Array;
3538
+ getBuffer(): TypedArray;
2958
3539
  /**
2959
3540
  * Can the image values be quantified?
2960
3541
  *
@@ -2974,6 +3555,13 @@ declare class Image_2 {
2974
3555
  * @returns {boolean} True if the data is monochrome.
2975
3556
  */
2976
3557
  isMonochrome(): boolean;
3558
+ /**
3559
+ * Check is the image is a mask.
3560
+ *
3561
+ * @returns {boolean} True if mask.
3562
+ * @deprecated Since v0.37, please use `instanceof MaskImage` instead.
3563
+ */
3564
+ isMask(): boolean;
2977
3565
  /**
2978
3566
  * Can the data be scrolled?
2979
3567
  *
@@ -3069,19 +3657,15 @@ declare class Image_2 {
3069
3657
  /**
3070
3658
  * Get the meta information of the image.
3071
3659
  *
3072
- * @returns {Object<string, any>} The meta information of the image.
3660
+ * @returns {Record<string, any>} The meta information of the image.
3073
3661
  */
3074
- getMeta(): {
3075
- [x: string]: any;
3076
- };
3662
+ getMeta(): Record<string, any>;
3077
3663
  /**
3078
3664
  * Set the meta information of the image.
3079
3665
  *
3080
- * @param {Object<string, any>} rhs The meta information of the image.
3666
+ * @param {Record<string, any>} rhs The meta information of the image.
3081
3667
  */
3082
- setMeta(rhs: {
3083
- [x: string]: any;
3084
- }): void;
3668
+ setMeta(rhs: Record<string, any>): void;
3085
3669
  /**
3086
3670
  * Get value at offset. Warning: No size check...
3087
3671
  *
@@ -3089,14 +3673,6 @@ declare class Image_2 {
3089
3673
  * @returns {number} The value at offset.
3090
3674
  */
3091
3675
  getValueAtOffset(offset: number): number;
3092
- /**
3093
- * Get the offsets where the buffer equals the input value.
3094
- * Loops through the whole volume, can get long for big data...
3095
- *
3096
- * @param {number|RGB} value The value to check.
3097
- * @returns {number[]} The list of offsets.
3098
- */
3099
- getOffsets(value: number | RGB): number[];
3100
3676
  /**
3101
3677
  * Check if the input values are in the buffer.
3102
3678
  * Could loop through the whole volume, can get long for big data...
@@ -3112,6 +3688,15 @@ declare class Image_2 {
3112
3688
  * @returns {Image} A clone of this image.
3113
3689
  */
3114
3690
  clone(): Image_2;
3691
+ /**
3692
+ * Replace the inner buffer wholesale (as opposed to editing its content
3693
+ * in place). Primarily intended for subclass use, where a private
3694
+ * (`#`) field on this class isn't reachable directly.
3695
+ *
3696
+ * @param {TypedArray} newBuffer The new buffer.
3697
+ * @fires Image#imagecontentchange
3698
+ */
3699
+ replaceBuffer(newBuffer: TypedArray): void;
3115
3700
  /**
3116
3701
  * Check if another image can be appended to this one.
3117
3702
  *
@@ -3119,7 +3704,7 @@ declare class Image_2 {
3119
3704
  * @returns {BooleanResult} Result with success set to true if
3120
3705
  * the image can be appended.
3121
3706
  */
3122
- canAppend(rhs: Image_2): BooleanResult;
3707
+ canAppendSlice(rhs: Image_2): BooleanResult;
3123
3708
  /**
3124
3709
  * Append a slice to the image.
3125
3710
  *
@@ -3156,53 +3741,9 @@ declare class Image_2 {
3156
3741
  /**
3157
3742
  * Get the histogram.
3158
3743
  *
3159
- * @returns {Array} The histogram.
3160
- */
3161
- getHistogram(): any[];
3162
- /**
3163
- * Add an event listener to this class.
3164
- *
3165
- * @param {string} type The event type.
3166
- * @param {Function} callback The function associated with the provided
3167
- * event type, will be called with the fired event.
3168
- */
3169
- addEventListener(type: string, callback: Function): void;
3170
- /**
3171
- * Remove an event listener from this class.
3172
- *
3173
- * @param {string} type The event type.
3174
- * @param {Function} callback The function associated with the provided
3175
- * event type.
3176
- */
3177
- removeEventListener(type: string, callback: Function): void;
3178
- /**
3179
- * Set the inner buffer values at given offsets.
3180
- *
3181
- * @param {number[]} offsets List of offsets where to set the data.
3182
- * @param {number|RGB} value The value to set at the given offsets.
3183
- * @fires Image#imagecontentchange
3184
- */
3185
- setAtOffsets(offsets: number[], value: number | RGB): void;
3186
- /**
3187
- * Set the inner buffer values at given offsets.
3188
- *
3189
- * @param {number[][]} offsetsLists List of offset lists where
3190
- * to set the data.
3191
- * @param {number} value The value to set at the given offsets.
3192
- * @returns {Array} A list of objects representing the original values before
3193
- * replacing them.
3194
- * @fires Image#imagecontentchange
3195
- */
3196
- setAtOffsetsAndGetOriginals(offsetsLists: number[][], value: number): any[];
3197
- /**
3198
- * Set the inner buffer values at given offsets.
3199
- *
3200
- * @param {number[][]} offsetsLists List of offset lists
3201
- * where to set the data.
3202
- * @param {number|Array} value The value to set at the given offsets.
3203
- * @fires Image#imagecontentchange
3744
+ * @returns {ImageHistogram} The histogram.
3204
3745
  */
3205
- setAtOffsetsWithIterator(offsetsLists: number[][], value: number | any[]): void;
3746
+ getHistogram(): ImageHistogram;
3206
3747
  /**
3207
3748
  * Get the value of the image at a specific coordinate.
3208
3749
  *
@@ -3263,12 +3804,6 @@ declare class Image_2 {
3263
3804
  * @returns {object} The range {min, max}.
3264
3805
  */
3265
3806
  calculateRescaledDataRange(): object;
3266
- /**
3267
- * Calculate the histogram of the image.
3268
- *
3269
- * @returns {object} The histogram, data range and rescaled data range.
3270
- */
3271
- calculateHistogram(): object;
3272
3807
  /**
3273
3808
  * Convolute the image with a given 2D kernel.
3274
3809
  *
@@ -3287,7 +3822,7 @@ declare class Image_2 {
3287
3822
  * @param {TypedArray} buffer The buffer to convolute.
3288
3823
  * @param {number} startOffset The index to start at.
3289
3824
  */
3290
- convoluteBuffer(weights: number[], buffer: Int8Array | Uint8Array | Int16Array | Uint16Array | Int32Array | Uint32Array, startOffset: number): void;
3825
+ convoluteBuffer(weights: number[], buffer: TypedArray, startOffset: number): void;
3291
3826
  /**
3292
3827
  * Transform an image using a specific operator.
3293
3828
  * WARNING: no size check!
@@ -3307,31 +3842,6 @@ declare class Image_2 {
3307
3842
  * Note: Uses the raw buffer values.
3308
3843
  */
3309
3844
  compose(rhs: Image_2, operator: Function): Image_2;
3310
- /**
3311
- * Initialize the contour buffer.
3312
- * Should be called on every segmentation image, or any image where
3313
- * contour rendering needs to be supported.
3314
- */
3315
- initializeContour(): void;
3316
- /**
3317
- * Get whether or not the contour buffer has been initialized.
3318
- *
3319
- * @returns {boolean} True if buffer has been initialized.
3320
- */
3321
- countourIsInitialized(): boolean;
3322
- /**
3323
- * Calculate the distance to the nearest border pixel.
3324
- * (or return the cached distance).
3325
- *
3326
- * @param {number} index Index/offset of the pixel to check.
3327
- * @param {Matrix33} viewOrientation The orientation of the view.
3328
- * @returns {number} The distance to the nearest border pixel or 0.
3329
- */
3330
- getContourDistance(index: number, viewOrientation: Matrix33): number;
3331
- /**
3332
- * Recalculate labels.
3333
- */
3334
- recalculateLabels(): void;
3335
3845
  /**
3336
3846
  * Return if this image has been resampled.
3337
3847
  *
@@ -3356,8 +3866,149 @@ declare class Image_2 {
3356
3866
  export { Image_2 as Image }
3357
3867
 
3358
3868
  /**
3359
- * Immutable index.
3360
- * Warning: the input array is NOT cloned, modifying it will
3869
+ * Image contour buffer manager.
3870
+ * Caches per-pixel distance-to-border values for contour rendering.
3871
+ * Stores 3 distance values per pixel (one per orientation: x, y, z).
3872
+ */
3873
+ export declare class ImageContour {
3874
+ /**
3875
+ * Initialize the contour buffer.
3876
+ * Should be called on every segmentation image, or any image where
3877
+ * contour rendering needs to be supported.
3878
+ *
3879
+ * @param {Uint8Array} imageBuffer The image data buffer.
3880
+ * @param {Size} imageSize The image size.
3881
+ */
3882
+ initialize(imageBuffer: Uint8Array, imageSize: Size): void;
3883
+ /**
3884
+ * Get whether or not the contour buffer has been initialized.
3885
+ *
3886
+ * @returns {boolean} True if buffer has been initialized.
3887
+ */
3888
+ isInitialized(): boolean;
3889
+ /**
3890
+ * Re-allocate contour buffer memory after an image buffer resize.
3891
+ * Updates the stored image buffer and size references.
3892
+ *
3893
+ * @param {Uint8Array} imageBuffer The new image data buffer.
3894
+ * @param {Size} imageSize The new image size.
3895
+ */
3896
+ realloc(imageBuffer: Uint8Array, imageSize: Size): void;
3897
+ /**
3898
+ * Shift contour buffer content to make room for an inserted slice.
3899
+ *
3900
+ * @param {number} contourIndexOffset Start offset of the slice to shift.
3901
+ * @param {number} contourSliceSize Size of one contour slice.
3902
+ * @param {number} contourMaxOffset End offset of content to shift.
3903
+ */
3904
+ shiftSlice(contourIndexOffset: number, contourSliceSize: number, contourMaxOffset: number): void;
3905
+ /**
3906
+ * Reset contour buffer for the values around an offset.
3907
+ * Prevents certain artifacts, especially at small brush sizes
3908
+ * and when erasing.
3909
+ *
3910
+ * @param {number} offset The offset to reset.
3911
+ */
3912
+ resetAroundOffset(offset: number): void;
3913
+ /**
3914
+ * Calculate the distance to the nearest border pixel
3915
+ * (or return the cached distance).
3916
+ * Returns 0 if the contour buffer is not initialized.
3917
+ *
3918
+ * @param {number} index Index/offset of the pixel to check.
3919
+ * @param {Matrix33} viewOrientation The orientation of the view.
3920
+ * @returns {number} The distance to the nearest border pixel or 0.
3921
+ */
3922
+ getDistance(index: number, viewOrientation: Matrix33): number;
3923
+ #private;
3924
+ }
3925
+
3926
+ /**
3927
+ * @import {RescaleSlopeAndIntercept} from './rsi.js';
3928
+ * @import {NumberRange} from '../math/number.js';
3929
+ * @import {Statistics} from '../math/stats.js';
3930
+ */
3931
+ /**
3932
+ * Histogram of image values.
3933
+ *
3934
+ * Raw (stored) values are counted in one {@link Histogram} per rescale
3935
+ * slope and intercept (RSI). Values are rescaled when read. An image
3936
+ * with a constant RSI only has one histogram.
3937
+ */
3938
+ export declare class ImageHistogram {
3939
+ /**
3940
+ * @param {string} [unit] The unit of the rescaled values.
3941
+ */
3942
+ constructor(unit?: string);
3943
+ /**
3944
+ * Get the unit of the rescaled values.
3945
+ *
3946
+ * @returns {string|undefined} The unit, undefined if not known.
3947
+ */
3948
+ getUnit(): string | undefined;
3949
+ /**
3950
+ * Get the raw value histogram for an RSI, creating it if needed.
3951
+ *
3952
+ * @param {RescaleSlopeAndIntercept} rsi The RSI of the raw values.
3953
+ * @returns {Histogram} The raw value histogram.
3954
+ */
3955
+ getHistogram(rsi: RescaleSlopeAndIntercept): Histogram;
3956
+ /**
3957
+ * Add one raw value.
3958
+ *
3959
+ * @param {number} rawValue The raw value.
3960
+ * @param {RescaleSlopeAndIntercept} rsi The RSI of the raw value.
3961
+ */
3962
+ add(rawValue: number, rsi: RescaleSlopeAndIntercept): void;
3963
+ /**
3964
+ * Get the total number of counted values.
3965
+ *
3966
+ * @returns {number} The total count.
3967
+ */
3968
+ getTotal(): number;
3969
+ /**
3970
+ * Get the value range (raw values).
3971
+ *
3972
+ * @returns {NumberRange|undefined} The range, undefined if empty.
3973
+ */
3974
+ getRange(): NumberRange | undefined;
3975
+ /**
3976
+ * Get the histogram of the rescaled values: raw values of each RSI
3977
+ * are rescaled and equal rescaled values merged.
3978
+ *
3979
+ * @returns {Histogram} The rescaled value histogram.
3980
+ */
3981
+ getRescaledHistogram(): Histogram;
3982
+ /**
3983
+ * Get the rescaled value range.
3984
+ *
3985
+ * @returns {NumberRange|undefined} The range, undefined if empty.
3986
+ */
3987
+ getRescaledRange(): NumberRange | undefined;
3988
+ /**
3989
+ * Get the percentage of counts that fall in each interval defined by
3990
+ * interior rescaled thresholds,
3991
+ * see {@link Histogram#getIntervalPercentages}.
3992
+ *
3993
+ * @param {number[]} thresholds Interior rescaled cut points in ascending
3994
+ * order.
3995
+ * @returns {number[]} The percentages in [0, 100], one per interval
3996
+ * (`thresholds.length + 1` entries), all 0 for an empty histogram.
3997
+ */
3998
+ getIntervalPercentages(thresholds: number[]): number[];
3999
+ /**
4000
+ * Get the statistics of the rescaled values,
4001
+ * see {@link Histogram#getStats}.
4002
+ *
4003
+ * @returns {Statistics|undefined} The statistics, undefined if empty.
4004
+ */
4005
+ getStats(): Statistics | undefined;
4006
+ #private;
4007
+ }
4008
+
4009
+ /**
4010
+ * Immutable index.
4011
+ * Warning: the input array is NOT cloned, modifying it will
3361
4012
  * modify the index values.
3362
4013
  */
3363
4014
  export declare class Index {
@@ -3450,15 +4101,13 @@ export declare class Index {
3450
4101
  /**
3451
4102
  * DICOM Header info data.
3452
4103
  */
3453
- export declare class InfoData {
4104
+ export declare class InfoData extends EventTarget {
3454
4105
  /**
3455
4106
  * @param {App} app The associated application.
3456
4107
  * @param {string} dataId The associated data id.
3457
- * @param {Object<string, InfoDataItem[]>} configs The info data config.
4108
+ * @param {Record<string, InfoDataItem[]>} configs The info data config.
3458
4109
  */
3459
- constructor(app: App, dataId: string, configs: {
3460
- [x: string]: InfoDataItem[];
3461
- });
4110
+ constructor(app: App, dataId: string, configs: Record<string, InfoDataItem[]>);
3462
4111
  /**
3463
4112
  * Reset the data.
3464
4113
  */
@@ -3466,17 +4115,23 @@ export declare class InfoData {
3466
4115
  /**
3467
4116
  * Handle a new loaded item event.
3468
4117
  *
3469
- * @param {Object<string, DataElement>} data The item meta data.
4118
+ * @param {Record<string, DataElement>} data The item meta data.
3470
4119
  */
3471
- addItemMeta(data: {
3472
- [x: string]: DataElement;
3473
- }): void;
4120
+ addItemMeta(data: Record<string, DataElement>): void;
3474
4121
  /**
3475
4122
  * Handle a changed slice event.
3476
4123
  *
3477
- * @param {object} event The slicechange event.
4124
+ * @param {CustomEvent} event The slicechange event.
4125
+ * @deprecated Since v0.37, please use onPositionChange.
3478
4126
  */
3479
- onSliceChange: (event: object) => void;
4127
+ onSliceChange: (event: CustomEvent) => void;
4128
+ /**
4129
+ * Handle a changed position event: updates the tags on slice change
4130
+ * and the position event items.
4131
+ *
4132
+ * @param {CustomEvent} event The positionchange event.
4133
+ */
4134
+ onPositionChange: (event: CustomEvent) => void;
3480
4135
  /**
3481
4136
  * Is this class listening to app events.
3482
4137
  *
@@ -3491,25 +4146,13 @@ export declare class InfoData {
3491
4146
  * Toggle info listeners.
3492
4147
  */
3493
4148
  removeAppListeners(): void;
3494
- /**
3495
- * Add an event listener to this class.
3496
- *
3497
- * @param {string} type The event type.
3498
- * @param {object} callback The method associated with the provided
3499
- * event type, will be called with the fired event.
3500
- */
3501
- addEventListener(type: string, callback: object): void;
3502
- /**
3503
- * Remove an event listener from this class.
3504
- *
3505
- * @param {string} type The event type.
3506
- * @param {object} callback The method associated with the provided
3507
- * event type.
3508
- */
3509
- removeEventListener(type: string, callback: object): void;
3510
4149
  #private;
3511
4150
  }
3512
4151
 
4152
+ /**
4153
+ * @import {App} from '../app/application.js';
4154
+ * @import {DataElement} from '../dicom/dataElement.js';
4155
+ */
3513
4156
  /**
3514
4157
  * Info data item class.
3515
4158
  */
@@ -3542,6 +4185,11 @@ export declare class InfoDataItem {
3542
4185
  value: string;
3543
4186
  }
3544
4187
 
4188
+ /**
4189
+ * List of compatible integer typed arrays.
4190
+ */
4191
+ export declare type IntTypedArray = (Uint8Array | Int8Array | Uint16Array | Int16Array | Uint32Array | Int32Array);
4192
+
3545
4193
  /**
3546
4194
  * Check if two rgb objects are equal.
3547
4195
  *
@@ -3570,9 +4218,9 @@ export declare class Label {
3570
4218
  /**
3571
4219
  * The volume of the labeled segment.
3572
4220
  *
3573
- * @type {Value}
4221
+ * @type {NumberValue}
3574
4222
  */
3575
- volume: Value;
4223
+ volume: NumberValue;
3576
4224
  /**
3577
4225
  * The voxel count of the labeled segment.
3578
4226
  *
@@ -3588,9 +4236,9 @@ export declare class Label {
3588
4236
  /**
3589
4237
  * The scaled height of the segment.
3590
4238
  *
3591
- * @type {Value}
4239
+ * @type {NumberValue}
3592
4240
  */
3593
- height: Value;
4241
+ height: NumberValue;
3594
4242
  /**
3595
4243
  * The segment label id.
3596
4244
  *
@@ -3603,6 +4251,18 @@ export declare class Label {
3603
4251
  * @type {number}
3604
4252
  */
3605
4253
  largestSliceZ: number;
4254
+ /**
4255
+ * The minimum Z index of the segment.
4256
+ *
4257
+ * @type {number}
4258
+ */
4259
+ minZ: number;
4260
+ /**
4261
+ * The maximum Z index of the segment.
4262
+ *
4263
+ * @type {number}
4264
+ */
4265
+ maxZ: number;
3606
4266
  }
3607
4267
 
3608
4268
  /**
@@ -3630,7 +4290,7 @@ export declare function labToUintLab(triplet: object): object;
3630
4290
  * - planePos = viewController.getOffset3DFromPlaneOffset(pos)
3631
4291
  * no need yet for a planePos to displayPos...
3632
4292
  */
3633
- export declare class LayerGroup {
4293
+ export declare class LayerGroup extends EventTarget {
3634
4294
  /**
3635
4295
  * @param {HTMLElement} containerDiv The associated HTML div.
3636
4296
  * @param {boolean} [withInfoLayer] Optional with info layer flag,
@@ -3937,10 +4597,10 @@ export declare class LayerGroup {
3937
4597
  /**
3938
4598
  * Update layers (but not the event source layer) to a position change.
3939
4599
  *
3940
- * @param {object} event The position change event.
4600
+ * @param {CustomEvent} event The position change event.
3941
4601
  * @function
3942
4602
  */
3943
- updateLayersToPositionChange: (event: object) => void;
4603
+ updateLayersToPositionChange: (event: CustomEvent) => void;
3944
4604
  /**
3945
4605
  * Calculate the div to world size ratio needed to fit
3946
4606
  * the largest data.
@@ -4016,22 +4676,6 @@ export declare class LayerGroup {
4016
4676
  * @param {boolean} flag Whether to display the layer or not.
4017
4677
  */
4018
4678
  display(flag: boolean): void;
4019
- /**
4020
- * Add an event listener to this class.
4021
- *
4022
- * @param {string} type The event type.
4023
- * @param {Function} callback The function associated with the provided
4024
- * event type, will be called with the fired event.
4025
- */
4026
- addEventListener(type: string, callback: Function): void;
4027
- /**
4028
- * Remove an event listener from this class.
4029
- *
4030
- * @param {string} type The event type.
4031
- * @param {Function} callback The function associated with the provided
4032
- * event type.
4033
- */
4034
- removeEventListener(type: string, callback: Function): void;
4035
4679
  #private;
4036
4680
  }
4037
4681
 
@@ -4044,21 +4688,45 @@ export declare namespace logger {
4044
4688
  let ERROR: number;
4045
4689
  }
4046
4690
  let level: number;
4691
+ /**
4692
+ * Log a trace message.
4693
+ *
4694
+ * @param {string} msg The message to log.
4695
+ */
4047
4696
  export function trace(msg: string): void;
4697
+ /**
4698
+ * Log a debug message.
4699
+ * Careful: depends on console settings.
4700
+ *
4701
+ * @param {string} msg The message to log.
4702
+ */
4048
4703
  export function debug(msg: string): void;
4704
+ /**
4705
+ * Log an info message.
4706
+ *
4707
+ * @param {string} msg The message to log.
4708
+ */
4049
4709
  export function info(msg: string): void;
4710
+ /**
4711
+ * Log a warn message.
4712
+ *
4713
+ * @param {string} msg The message to log.
4714
+ */
4050
4715
  export function warn(msg: string): void;
4716
+ /**
4717
+ * Log an error message.
4718
+ *
4719
+ * @param {string} msg The message to log.
4720
+ */
4051
4721
  export function error(msg: string): void;
4052
4722
  }
4053
4723
 
4054
4724
  /**
4055
4725
  * List of available lookup tables (lut).
4056
4726
  *
4057
- * @type {Object<string, ColourMap>}
4727
+ * @type {Record<string, ColourMap>}
4058
4728
  */
4059
- export declare const luts: {
4060
- [x: string]: ColourMap;
4061
- };
4729
+ export declare const luts: Record<string, ColourMap>;
4062
4730
 
4063
4731
  /**
4064
4732
  * Mask {@link Image} factory.
@@ -4074,41 +4742,186 @@ export declare class MaskFactory {
4074
4742
  /**
4075
4743
  * Check dicom elements.
4076
4744
  *
4077
- * @param {Object<string, DataElement>} _dicomElements The DICOM tags.
4745
+ * @param {Record<string, DataElement>} _dicomElements The DICOM tags.
4078
4746
  * @returns {string|undefined} A possible warning.
4079
4747
  */
4080
- checkElements(_dicomElements: {
4081
- [x: string]: DataElement;
4082
- }): string | undefined;
4748
+ checkElements(_dicomElements: Record<string, DataElement>): string | undefined;
4083
4749
  /**
4084
- * Get an {@link Image} object from the read DICOM file.
4750
+ * Get a {@link MaskImage} object from the read DICOM file.
4085
4751
  *
4086
- * @param {Object<string, DataElement>} dataElements The DICOM tags.
4087
- * @param {Uint8Array | Int8Array |
4088
- * Uint16Array | Int16Array |
4089
- * Uint32Array | Int32Array} pixelBuffer The pixel buffer.
4752
+ * @param {Record<string, DataElement>} dataElements The DICOM tags.
4753
+ * @param {Uint8Array} pixelBuffer The pixel buffer.
4090
4754
  * @param {Image} [refImage] Reference image, code will use its
4091
4755
  * origins if present (best) or try to calculate them.
4092
- * @returns {Image} A new Image.
4756
+ * @returns {MaskImage} A new mask image.
4093
4757
  * @throws {Error} Error for missing or wrong data.
4094
4758
  */
4095
- create(dataElements: {
4096
- [x: string]: DataElement;
4097
- }, pixelBuffer: Uint8Array | Int8Array | Uint16Array | Int16Array | Uint32Array | Int32Array, refImage?: Image_2): Image_2;
4759
+ create(dataElements: Record<string, DataElement>, pixelBuffer: Uint8Array, refImage?: Image_2): MaskImage;
4098
4760
  /**
4099
4761
  * Convert a mask image into a DICOM segmentation object.
4100
4762
  *
4101
- * @param {Image} image The mask image.
4763
+ * @param {MaskImage} image The mask image.
4102
4764
  * @param {MaskSegment[]} segments The mask segments.
4103
4765
  * @param {Image} sourceImage The source image.
4104
- * @param {Object<string, any>} [extraTags] Optional list of extra tags.
4105
- * @returns {Object<string, DataElement>} A list of dicom elements.
4766
+ * @param {SimpleTagValues} [extraTags] Optional list of extra tags.
4767
+ * @returns {Record<string, DataElement>} A list of dicom elements.
4106
4768
  */
4107
- toDicom(image: Image_2, segments: MaskSegment[], sourceImage: Image_2, extraTags?: {
4108
- [x: string]: any;
4109
- }): {
4110
- [x: string]: DataElement;
4111
- };
4769
+ toDicom(image: MaskImage, segments: MaskSegment[], sourceImage: Image_2, extraTags?: SimpleTagValues): Record<string, DataElement>;
4770
+ #private;
4771
+ }
4772
+
4773
+ /**
4774
+ * Mask (segmentation) image class.
4775
+ * Extends {@link Image} with a {@link SegmentCollection} and the
4776
+ * segment-aware behavior built on top of it: per-segment/per-slice
4777
+ * bookkeeping, the brush tool's offset-editing methods, and per-segment
4778
+ * labeling statistics (volume/centroid/diameter).
4779
+ */
4780
+ export declare class MaskImage extends Image_2 {
4781
+ /**
4782
+ * @param {Geometry} geometry The geometry of the image.
4783
+ * @param {Uint8Array} buffer The mask data as a one dimensional buffer:
4784
+ * one byte per voxel, 0 for background, the segment number otherwise.
4785
+ * @param {string[]} [imageUids] An array of Uids indexed to slice number.
4786
+ * @param {SegmentCollection} [segmentCollection] The segment collection,
4787
+ * for a mask already parsed from DICOM (its own label map already
4788
+ * aliases `buffer`). When omitted (brush-created masks), a fresh
4789
+ * collection is created and its label map is aliased to `buffer`.
4790
+ */
4791
+ constructor(geometry: Geometry, buffer: Uint8Array, imageUids?: string[], segmentCollection?: SegmentCollection);
4792
+ /**
4793
+ * Initialize the contour buffer.
4794
+ * Should be called on every segmentation image, or any image where
4795
+ * contour rendering needs to be supported.
4796
+ */
4797
+ initializeContour(): void;
4798
+ /**
4799
+ * Get the image contour. Should only be available
4800
+ * for segmentation images, but can be initialized
4801
+ * for any Uint8Array image.
4802
+ *
4803
+ * @returns {ImageContour} The image contour.
4804
+ */
4805
+ getContour(): ImageContour;
4806
+ /**
4807
+ * Get the segment collection.
4808
+ *
4809
+ * @returns {SegmentCollection} The segment collection.
4810
+ */
4811
+ getSegmentCollection(): SegmentCollection;
4812
+ /**
4813
+ * Get the UID of the series referenced by the mask, if any.
4814
+ *
4815
+ * @returns {string|undefined} The UID.
4816
+ */
4817
+ getMaskReferencedSeriesUID(): string | undefined;
4818
+ /**
4819
+ * Get the numbers of the segments present at an index.
4820
+ * When segments overlap, all the segments at the index are returned,
4821
+ * not only the one stored in the buffer (first wins).
4822
+ *
4823
+ * @param {Index} index The index, no bounds check.
4824
+ * @returns {number[]} The sorted list of segment numbers,
4825
+ * empty for background.
4826
+ */
4827
+ getSegmentNumbersAtIndex(index: Index): number[];
4828
+ /**
4829
+ * Get the offsets where the buffer equals the input value.
4830
+ * Loops through the whole volume, can get long for big data...
4831
+ *
4832
+ * @param {number|RGB} value The value to check.
4833
+ * @returns {number[]} The list of offsets.
4834
+ */
4835
+ getOffsets(value: number | RGB): number[];
4836
+ /**
4837
+ * Set the inner buffer values at given offsets.
4838
+ *
4839
+ * @param {number[]} offsets List of offsets where to set the data.
4840
+ * @param {number|RGB} value The value to set at the given offsets.
4841
+ * @fires Image#imagecontentchange
4842
+ */
4843
+ setAtOffsets(offsets: number[], value: number | RGB): void;
4844
+ /**
4845
+ * Set the inner buffer values at given offsets, each to its own value.
4846
+ * Used when a single uniform value cannot be used across all offsets,
4847
+ * for example restoring the segment still present at a voxel that used
4848
+ * to be hidden by an overlapping, now deleted, segment.
4849
+ *
4850
+ * @param {number[]} offsets List of offsets where to set the data.
4851
+ * @param {number[]} values Per-offset values, same length as offsets.
4852
+ * @fires Image#imagecontentchange
4853
+ */
4854
+ setAtOffsetsWithValues(offsets: number[], values: number[]): void;
4855
+ /**
4856
+ * Set the inner buffer values at given offsets.
4857
+ *
4858
+ * @param {number[][]} offsetsLists List of offset lists where
4859
+ * to set the data.
4860
+ * @param {number} value The value to set at the given offsets.
4861
+ * @returns {Array} A list of objects representing the original values before
4862
+ * replacing them.
4863
+ * @fires Image#imagecontentchange
4864
+ */
4865
+ setAtOffsetsAndGetOriginals(offsetsLists: number[][], value: number): any[];
4866
+ /**
4867
+ * Set the inner buffer values at given offsets.
4868
+ *
4869
+ * @param {number[][]} offsetsLists List of offset lists
4870
+ * where to set the data.
4871
+ * @param {number|Array} value The value to set at the given offsets.
4872
+ * @fires Image#imagecontentchange
4873
+ */
4874
+ setAtOffsetsWithIterator(offsetsLists: number[][], value: number | any[]): void;
4875
+ /**
4876
+ * Get the labels from the last labeling (see
4877
+ * {@link MaskImage#recalculateLabels}).
4878
+ *
4879
+ * @returns {Label[]|undefined} The labels, undefined if not calculated.
4880
+ */
4881
+ getLabels(): Label[] | undefined;
4882
+ /**
4883
+ * Recalculate labels.
4884
+ *
4885
+ * @fires Image#labelingstart
4886
+ * @fires Image#labelschanged
4887
+ */
4888
+ recalculateLabels(): void;
4889
+ /**
4890
+ * Clone the mask image.
4891
+ *
4892
+ * @returns {MaskImage} A clone of this mask image.
4893
+ */
4894
+ clone(): MaskImage;
4895
+ /**
4896
+ * Get per-volume histograms of reference-image intensities for one segment.
4897
+ *
4898
+ * For each volume of `image`, counts how often each intensity
4899
+ * appears in voxels belonging to the given segment of this mask.
4900
+ * Segmentations are 3D: the same mask is applied to every volume.
4901
+ * Raw values are counted per rescale slope and intercept and rescaled
4902
+ * when read from the {@link ImageHistogram}.
4903
+ *
4904
+ * If labels are available (see {@link MaskImage#getLabels}), each entry
4905
+ * also has `labelHistograms`: one histogram per label of the segment, made of
4906
+ * the segment voxels between the label min and max Z. Since labels
4907
+ * of the same segment that share slices cannot be separated this way,
4908
+ * `labelHistograms` is not provided in that case.
4909
+ *
4910
+ * @param {Image} image The reference image (intensities).
4911
+ * @param {string} segmentId Segment tracking UID, or segment number as
4912
+ * string.
4913
+ * @returns {{volume: number, histogram: ImageHistogram,
4914
+ * labelHistograms?: {label: Label, histogram: ImageHistogram}[]}[]} One
4915
+ * entry per volume.
4916
+ */
4917
+ getHistogramBySegment(image: Image_2, segmentId: string): {
4918
+ volume: number;
4919
+ histogram: ImageHistogram;
4920
+ labelHistograms?: {
4921
+ label: Label;
4922
+ histogram: ImageHistogram;
4923
+ }[];
4924
+ }[];
4112
4925
  #private;
4113
4926
  }
4114
4927
 
@@ -4186,8 +4999,24 @@ export declare class MaskSegment {
4186
4999
  * @type {string|undefined}
4187
5000
  */
4188
5001
  trackingId: string | undefined;
5002
+ /**
5003
+ * RT ROI interpreted type (3006,00A4), only used for RTSTRUCT segments.
5004
+ *
5005
+ * @type {string|undefined}
5006
+ */
5007
+ interpretedType: string | undefined;
5008
+ /**
5009
+ * RT ROI interpreter name (3006,00A6), only used for RTSTRUCT segments.
5010
+ *
5011
+ * @type {string|undefined}
5012
+ */
5013
+ roiInterpreter: string | undefined;
4189
5014
  }
4190
5015
 
5016
+ /**
5017
+ * @import {MaskImage} from './maskImage.js';
5018
+ * @import {MaskSegment} from '../dicom/dicomSegment.js';
5019
+ */
4191
5020
  /**
4192
5021
  * Mask segment helper: helps handling the segments list,
4193
5022
  * but does *NOT* update the associated mask (use special commands
@@ -4195,15 +5024,15 @@ export declare class MaskSegment {
4195
5024
  */
4196
5025
  export declare class MaskSegmentHelper {
4197
5026
  /**
4198
- * @param {Image} mask The associated mask image.
5027
+ * @param {MaskImage} mask The associated mask image.
4199
5028
  */
4200
- constructor(mask: Image_2);
5029
+ constructor(mask: MaskImage);
4201
5030
  /**
4202
5031
  * Get the associated mask image.
4203
5032
  *
4204
- * @returns {Image} The mask image.
5033
+ * @returns {MaskImage} The mask image.
4205
5034
  */
4206
- getMask(): Image_2;
5035
+ getMask(): MaskImage;
4207
5036
  /**
4208
5037
  * Check if a segment is part of the segments list.
4209
5038
  *
@@ -4264,7 +5093,7 @@ export declare class MaskSegmentHelper {
4264
5093
  *
4265
5094
  * @typedef Overlap@typedef Overlap
4266
5095
  * @property {string} label The segment label.
4267
- * @property {Object.<number, OverlapCount>} overlap A Dictionary
5096
+ * @property {Record<number, OverlapCount>} overlap A Dictionary
4268
5097
  * containing the counts. The key is the segment number of the overlapping
4269
5098
  * segment.
4270
5099
  * @property {number} count The voxel volume of this segment.
@@ -4276,7 +5105,7 @@ export declare class MaskSegmentHelper {
4276
5105
  * The value is a Dictionary of all of the segments in the second set
4277
5106
  * that overlap with the key segment.
4278
5107
  *
4279
- * @typedef {Object.<number, Overlap>} OverlapMap
5108
+ * @typedef {Record<number, Overlap>} OverlapMap
4280
5109
  */
4281
5110
  /**
4282
5111
  * Find the overlap for each segment between two segmentation masks.
@@ -4287,39 +5116,35 @@ export declare class MaskSegmentHelper {
4287
5116
  * @returns {OverlapMap} The overlapping voxel counts. First level is the
4288
5117
  * segments from this image, second level is the compare image segments.
4289
5118
  */
4290
- findOverlap(rhs: MaskSegmentHelper): {
4291
- [x: number]: {
5119
+ findOverlap(rhs: MaskSegmentHelper): Record<number, {
5120
+ /**
5121
+ * The segment label.
5122
+ */
5123
+ label: string;
5124
+ /**
5125
+ * A Dictionary
5126
+ * containing the counts. The key is the segment number of the overlapping
5127
+ * segment.
5128
+ */
5129
+ overlap: Record<number, {
4292
5130
  /**
4293
5131
  * The segment label.
4294
5132
  */
4295
5133
  label: string;
4296
5134
  /**
4297
- * A Dictionary
4298
- * containing the counts. The key is the segment number of the overlapping
4299
- * segment.
5135
+ * The number of overlapping voxels.
4300
5136
  */
4301
- overlap: {
4302
- [x: number]: {
4303
- /**
4304
- * The segment label.
4305
- */
4306
- label: string;
4307
- /**
4308
- * The number of overlapping voxels.
4309
- */
4310
- count: number;
4311
- /**
4312
- * The overlap percentage between 0 and 100.
4313
- */
4314
- percentage: number;
4315
- };
4316
- };
5137
+ count: number;
4317
5138
  /**
4318
- * The voxel volume of this segment.
5139
+ * The overlap percentage between 0 and 100.
4319
5140
  */
4320
- count: number;
4321
- };
4322
- };
5141
+ percentage: number;
5142
+ }>;
5143
+ /**
5144
+ * The voxel volume of this segment.
5145
+ */
5146
+ count: number;
5147
+ }>;
4323
5148
  #private;
4324
5149
  }
4325
5150
 
@@ -4349,6 +5174,9 @@ export declare class MaskSegmentViewHelper {
4349
5174
  #private;
4350
5175
  }
4351
5176
 
5177
+ /**
5178
+ * @import {TypedArray} from './arrayTypes.js';
5179
+ */
4352
5180
  /**
4353
5181
  * Immutable 3x3 Matrix.
4354
5182
  */
@@ -4417,16 +5245,10 @@ export declare class Matrix33 {
4417
5245
  /**
4418
5246
  * Multiply this matrix by a 3D typed array.
4419
5247
  *
4420
- * @typedef {(
4421
- * Uint8Array | Int8Array |
4422
- * Uint16Array | Int16Array |
4423
- * Uint32Array | Int32Array
4424
- * )} TypedArray
4425
- *
4426
5248
  * @param {TypedArray} sourceArray The input 3D array.
4427
5249
  * @param {TypedArray} outArray The array to write to.
4428
5250
  */
4429
- multiplyTypedArray3D(sourceArray: Int8Array | Uint8Array | Int16Array | Uint16Array | Int32Array | Uint32Array, outArray: Int8Array | Uint8Array | Int16Array | Uint16Array | Int32Array | Uint32Array): void;
5251
+ multiplyTypedArray3D(sourceArray: TypedArray, outArray: TypedArray): void;
4430
5252
  /**
4431
5253
  * Multiply this matrix by a 3D vector.
4432
5254
  *
@@ -4483,15 +5305,43 @@ export declare class Matrix33 {
4483
5305
  #private;
4484
5306
  }
4485
5307
 
5308
+ /**
5309
+ * Merge two mask images into a new combined mask image.
5310
+ *
5311
+ * Segments from mask2 that share a segment number with mask1 are renumbered
5312
+ * (bumped to the next available number) to avoid conflicts. Both masks must
5313
+ * share the same spacing and orientation; the wider of the two geometries
5314
+ * (the one with more slices) is used as the merged geometry, so a mask
5315
+ * that only covers a sub-range of the other's slices does not get clipped.
5316
+ * Brush-painted masks (no per-segment SegmentCollection data) are supported.
5317
+ *
5318
+ * The returned image can be saved with the standard
5319
+ * `new MaskFactory().toDicom(merged, undefined, sourceImage)` workflow.
5320
+ *
5321
+ * @param {MaskImage} mask1 The first mask (provides meta).
5322
+ * @param {MaskImage} mask2 The second mask to merge into mask1.
5323
+ * @returns {MaskImage} The new merged mask image.
5324
+ */
5325
+ export declare function mergeMaskImages(mask1: MaskImage, mask2: MaskImage): MaskImage;
5326
+
5327
+ /**
5328
+ * Merge a simple tag value list into another. Mutates the
5329
+ * first input.
5330
+ *
5331
+ * @param {SimpleTagValues} list1 Base list, will be modified.
5332
+ * @param {SimpleTagValues} list2 List to merge into list1.
5333
+ */
5334
+ export declare function mergeTagValues(list1: SimpleTagValues, list2: SimpleTagValues): void;
5335
+
4486
5336
  export declare namespace NormalisedManufacturers {
4487
5337
  let GE: string;
4488
5338
  let SIEMENS: string;
4489
5339
  let PHILIPS: string;
4490
- let HITASHI: string;
5340
+ let HITACHI: string;
4491
5341
  }
4492
5342
 
4493
5343
  /**
4494
- * Number range.
5344
+ * Number range: [min, max].
4495
5345
  */
4496
5346
  export declare class NumberRange {
4497
5347
  /**
@@ -4509,12 +5359,34 @@ export declare class NumberRange {
4509
5359
  max: number;
4510
5360
  }
4511
5361
 
5362
+ /**
5363
+ * Class to store a number value and a unit.
5364
+ */
5365
+ export declare class NumberValue {
5366
+ /**
5367
+ * @type {number}
5368
+ */
5369
+ value: number;
5370
+ /**
5371
+ * @type {string|undefined}
5372
+ */
5373
+ unit: string | undefined;
5374
+ }
5375
+
4512
5376
  export declare namespace Orientation {
4513
5377
  let Axial: string;
4514
5378
  let Coronal: string;
4515
5379
  let Sagittal: string;
4516
5380
  }
4517
5381
 
5382
+ /**
5383
+ * @import {Point} from '../math/point.js';
5384
+ * @import {Index} from '../math/index.js';
5385
+ * @import {Geometry} from '../image/geometry.js';
5386
+ * @import {Matrix33} from '../math/matrix.js';
5387
+ * @import {Spacing} from './spacing.js';
5388
+ * @import {Scalar2D, Scalar3D} from '../math/scalar.js';
5389
+ */
4518
5390
  /**
4519
5391
  * Plane geometry helper.
4520
5392
  */
@@ -4782,6 +5654,14 @@ export declare class Point2D {
4782
5654
  * @returns {Point2D} The centroid point.
4783
5655
  */
4784
5656
  getCentroid(): Point2D;
5657
+ /**
5658
+ * Check if a point is at this point, within a tolerance.
5659
+ *
5660
+ * @param {Point2D} point The point to check.
5661
+ * @param {number} [tolerance] Optional maximum distance, defaults to 0.
5662
+ * @returns {boolean} True if the point is within tolerance.
5663
+ */
5664
+ contains(point: Point2D, tolerance?: number): boolean;
4785
5665
  /**
4786
5666
  * Check for Point2D equality.
4787
5667
  *
@@ -5056,11 +5936,35 @@ export declare class PositionHelper {
5056
5936
  export declare function precisionRound(number: number, precision: number): number;
5057
5937
 
5058
5938
  /**
5059
- * Protractor shape: 3 points from which to calculate an angle.
5939
+ * Private diffusion b-value tag rule: either `{manufacturer, key}`
5940
+ * or `{uidPrefix, key}`.
5060
5941
  */
5061
- export declare class Protractor {
5942
+ export declare type PrivateBValueRule = {
5062
5943
  /**
5063
- * @param {Point2D[]} points The list of Point2D that make
5944
+ * The normalised manufacturer.
5945
+ */
5946
+ manufacturer?: string;
5947
+ /**
5948
+ * The SOP instance UID prefix.
5949
+ */
5950
+ uidPrefix?: string;
5951
+ /**
5952
+ * The private tag key.
5953
+ */
5954
+ key: string;
5955
+ };
5956
+
5957
+ /**
5958
+ * @import {Point2D} from '../math/point.js';
5959
+ * @import {NumberValue} from './number.js';
5960
+ * @import {ViewController} from '../app/viewController.js';
5961
+ */
5962
+ /**
5963
+ * Protractor shape: 3 points from which to calculate an angle.
5964
+ */
5965
+ export declare class Protractor {
5966
+ /**
5967
+ * @param {Point2D[]} points The list of Point2D that make
5064
5968
  * the protractor.
5065
5969
  */
5066
5970
  constructor(points: Point2D[]);
@@ -5084,16 +5988,23 @@ export declare class Protractor {
5084
5988
  * @returns {Point2D} THe centroid point.
5085
5989
  */
5086
5990
  getCentroid(): Point2D;
5991
+ /**
5992
+ * Check if a point is on one of the protractor lines, within a tolerance.
5993
+ *
5994
+ * @param {Point2D} point The point to check.
5995
+ * @param {number} [tolerance] Optional maximum distance to the lines,
5996
+ * defaults to 0.
5997
+ * @returns {boolean} True if the point is on the protractor.
5998
+ */
5999
+ contains(point: Point2D, tolerance?: number): boolean;
5087
6000
  /**
5088
6001
  * Quantify a path according to view information.
5089
6002
  *
5090
6003
  * @param {ViewController} _viewController The associated view controller.
5091
6004
  * @param {string[]} _flags A list of stat values to calculate.
5092
- * @returns {Object<string, Value>} A quantification object.
6005
+ * @returns {Record<string, NumberValue>} A quantification object.
5093
6006
  */
5094
- quantify(_viewController: ViewController, _flags: string[]): {
5095
- [x: string]: Value;
5096
- };
6007
+ quantify(_viewController: ViewController, _flags: string[]): Record<string, NumberValue>;
5097
6008
  #private;
5098
6009
  }
5099
6010
 
@@ -5177,6 +6088,16 @@ export declare class Rectangle {
5177
6088
  * @returns {Point2D} The centroid point.
5178
6089
  */
5179
6090
  getCentroid(): Point2D;
6091
+ /**
6092
+ * Check if a point is inside the rectangle, or within a tolerance
6093
+ * of its outline.
6094
+ *
6095
+ * @param {Point2D} point The point to check.
6096
+ * @param {number} [tolerance] Optional maximum distance to the outline
6097
+ * for an outside point, defaults to 0.
6098
+ * @returns {boolean} True if the point is in the rectangle.
6099
+ */
6100
+ contains(point: Point2D, tolerance?: number): boolean;
5180
6101
  /**
5181
6102
  * Quantify a rectangle according to view information.
5182
6103
  *
@@ -5184,11 +6105,9 @@ export declare class Rectangle {
5184
6105
  * @param {Index} index The index at which to get the
5185
6106
  * image values.
5186
6107
  * @param {string[]} flags A list of stat values to calculate.
5187
- * @returns {Object<string, Value>} A quantification object.
6108
+ * @returns {Record<string, NumberValue>} A quantification object.
5188
6109
  */
5189
- quantify(viewController: ViewController, index: Index, flags: string[]): {
5190
- [x: string]: Value;
5191
- };
6110
+ quantify(viewController: ViewController, index: Index, flags: string[]): Record<string, NumberValue>;
5192
6111
  #private;
5193
6112
  }
5194
6113
 
@@ -5254,6 +6173,9 @@ export declare class ResponseEvaluation {
5254
6173
  measure: number;
5255
6174
  }
5256
6175
 
6176
+ /**
6177
+ * @import {Scalar3D} from '../math/scalar.js';
6178
+ */
5257
6179
  /**
5258
6180
  * RGB colour class.
5259
6181
  */
@@ -5341,6 +6263,168 @@ export declare class ROI {
5341
6263
  * @returns {Point2D|undefined} The centroid point.
5342
6264
  */
5343
6265
  getCentroid(): Point2D | undefined;
6266
+ /**
6267
+ * Check if a point is inside the roi (seen as a closed polygon),
6268
+ * or within a tolerance of its outline.
6269
+ *
6270
+ * @param {Point2D} point The point to check.
6271
+ * @param {number} [tolerance] Optional maximum distance to the outline
6272
+ * for an outside point, defaults to 0.
6273
+ * @returns {boolean} True if the point is in the roi.
6274
+ */
6275
+ contains(point: Point2D, tolerance?: number): boolean;
6276
+ #private;
6277
+ }
6278
+
6279
+ /**
6280
+ * An RT Region of Interest with its display colour and contours.
6281
+ */
6282
+ export declare class RTROI {
6283
+ /**
6284
+ * ROI number as stored in the DICOM file.
6285
+ *
6286
+ * @type {number}
6287
+ */
6288
+ number: number;
6289
+ /**
6290
+ * ROI name.
6291
+ *
6292
+ * @type {string}
6293
+ */
6294
+ name: string;
6295
+ /**
6296
+ * Display colour as {r, g, b} values in [0, 255].
6297
+ *
6298
+ * @type {{r: number, g: number, b: number}}
6299
+ */
6300
+ colour: {
6301
+ r: number;
6302
+ g: number;
6303
+ b: number;
6304
+ };
6305
+ /**
6306
+ * ROI generation algorithm (e.g. 'MANUAL', 'SEMIAUTOMATIC', 'AUTOMATIC').
6307
+ *
6308
+ * @type {string|undefined}
6309
+ */
6310
+ generationAlgorithm: string | undefined;
6311
+ /**
6312
+ * RT ROI interpreted type (e.g. 'GTV', 'CTV', 'PTV', 'ORGAN').
6313
+ *
6314
+ * @type {string|undefined}
6315
+ */
6316
+ interpretedType: string | undefined;
6317
+ /**
6318
+ * Name of the person who interpreted the ROI.
6319
+ *
6320
+ * @type {string|undefined}
6321
+ */
6322
+ roiInterpreter: string | undefined;
6323
+ /**
6324
+ * List of contours belonging to this ROI.
6325
+ *
6326
+ * @type {RTROIContour[]}
6327
+ */
6328
+ contours: RTROIContour[];
6329
+ }
6330
+
6331
+ /**
6332
+ * A single planar contour of an RT ROI.
6333
+ */
6334
+ export declare class RTROIContour {
6335
+ /**
6336
+ * Contour geometric type (e.g. 'CLOSED_PLANAR').
6337
+ *
6338
+ * @type {string}
6339
+ */
6340
+ type: string;
6341
+ /**
6342
+ * Flat array of 3D patient-space coordinates in mm:
6343
+ * [x0,y0,z0, x1,y1,z1, ...].
6344
+ *
6345
+ * @type {number[]}
6346
+ */
6347
+ points3D: number[];
6348
+ }
6349
+
6350
+ /**
6351
+ * {@link Image} factory for DICOM RT Structure Set (RTSTRUCT).
6352
+ *
6353
+ * Rasterizes ROI contour polygons into a PALETTE COLOR mask image using
6354
+ * the same geometry as the reference CT/MR image so that the result can
6355
+ * be rendered by the existing mask pipeline.
6356
+ */
6357
+ export declare class RtStructFactory {
6358
+ /**
6359
+ * Get a warning string if elements are not as expected.
6360
+ *
6361
+ * @returns {string|undefined} The warning.
6362
+ */
6363
+ getWarning(): string | undefined;
6364
+ /**
6365
+ * Check dicom elements.
6366
+ *
6367
+ * @param {Record<string, DataElement>} _dataElements The DICOM data elements.
6368
+ * @returns {string|undefined} A possible warning.
6369
+ */
6370
+ checkElements(_dataElements: Record<string, DataElement>): string | undefined;
6371
+ /**
6372
+ * Get a {@link MaskImage} from RTSTRUCT DICOM elements.
6373
+ *
6374
+ * Contours are rasterized into a Uint8Array whose voxel values are
6375
+ * segment numbers (0 = background, 1..N = ROI index).
6376
+ * A PALETTE COLOR colour map maps each segment number to the ROI's
6377
+ * display colour.
6378
+ *
6379
+ * @param {Record<string, DataElement>} dataElements The DICOM data elements.
6380
+ * @param {Image} refImage The reference image (CT/MR) that was loaded first.
6381
+ * @returns {MaskImage} The mask image.
6382
+ * @throws {Error} If the reference image geometry cannot be used.
6383
+ */
6384
+ create(dataElements: Record<string, DataElement>, refImage: Image_2): MaskImage;
6385
+ /**
6386
+ * Convert a {@link MaskImage} into DICOM RT Structure Set elements.
6387
+ *
6388
+ * Traces each segment's pixel regions per slice using Moore neighborhood
6389
+ * contour tracing, simplifies with Ramer-Douglas-Peucker, then maps the
6390
+ * 2D pixel coordinates back to 3D patient-space coordinates.
6391
+ *
6392
+ * @param {MaskImage} image The mask image.
6393
+ * @param {MaskSegment[]} [segments] The mask segments; if omitted, taken
6394
+ * from image meta.
6395
+ * @param {Image} [sourceImage] Source image (provides StudyInstanceUID).
6396
+ * @param {SimpleTagValues} [extraTags] Optional extra tags to merge.
6397
+ * @returns {Record<string, DataElement>} The DICOM data elements.
6398
+ */
6399
+ toDicom(image: MaskImage, segments?: MaskSegment[], sourceImage?: Image_2, extraTags?: SimpleTagValues): Record<string, DataElement>;
6400
+ #private;
6401
+ }
6402
+
6403
+ /**
6404
+ * @import {App} from '../app/application.js';
6405
+ */
6406
+ /**
6407
+ * Run filter command.
6408
+ */
6409
+ export declare class RunFilterCommand extends Command {
6410
+ /**
6411
+ * @param {object} filter The filter to run.
6412
+ * @param {string} dataId The data to filter.
6413
+ * @param {App} app The associated application.
6414
+ */
6415
+ constructor(filter: object, dataId: string, app: App);
6416
+ /**
6417
+ * Handle an execute event.
6418
+ *
6419
+ * @param {object} _event The execute event with type and id.
6420
+ */
6421
+ onExecute(_event: object): void;
6422
+ /**
6423
+ * Handle an undo event.
6424
+ *
6425
+ * @param {object} _event The undo event with type and id.
6426
+ */
6427
+ onUndo(_event: object): void;
5344
6428
  #private;
5345
6429
  }
5346
6430
 
@@ -5387,23 +6471,189 @@ export declare class Scalar3D {
5387
6471
  }
5388
6472
 
5389
6473
  /**
5390
- * Scroll wheel class: provides a wheel event handler
5391
- * that scroll the corresponding data.
6474
+ * Slice / dimension scrolling on wheel ticks.
6475
+ */
6476
+ export declare class ScrollWheelBehavior extends WheelBehavior {
6477
+ }
6478
+
6479
+ /**
6480
+ * Collection of mask segments: stores per-segment, per-slice pixel data
6481
+ * and segment metadata. Builds the combined label map on demand.
6482
+ * TODO: check if mergeable with MaskSegmentHelper.
5392
6483
  */
5393
- export declare class ScrollWheel {
6484
+ export declare class SegmentCollection {
5394
6485
  /**
5395
- * @param {App} app The associated application.
6486
+ * @param {Geometry} geometry The mask geometry, used to size the label map.
5396
6487
  */
5397
- constructor(app: App);
6488
+ constructor(geometry: Geometry);
6489
+ /**
6490
+ * Get all the segments.
6491
+ *
6492
+ * @returns {Map<number, Map<number, Uint8Array>>} The segment buffers,
6493
+ * indexed by segment number and slice index.
6494
+ */
6495
+ getAll(): Map<number, Map<number, Uint8Array>>;
6496
+ /**
6497
+ * Set the label map directly.
6498
+ * Used when the buffer already exists, for brush-painted masks.
6499
+ *
6500
+ * @param {Uint8Array} buffer The label map buffer.
6501
+ */
6502
+ setLabelMap(buffer: Uint8Array): void;
6503
+ /**
6504
+ * Add pixel data for one DICOM frame to the appropriate segment and slice.
6505
+ * Allocates a Uint8Array(sliceSize) on first use for each
6506
+ * (segNumber, sliceIndex) pair; merges if the same pair appears again.
6507
+ *
6508
+ * @param {number} segNumber The segment number.
6509
+ * @param {Uint8Array} pixelBuffer The raw DICOM pixel buffer.
6510
+ * @param {number} frameOffset Offset of this frame within pixelBuffer.
6511
+ * @param {number} sliceIndex The slice index in the full label map geometry.
6512
+ * @param {number} sliceSize Number of pixels per slice (ncols * nrows).
6513
+ * @param {number} value The value to write for non-zero pixels.
6514
+ */
6515
+ addFrame(segNumber: number, pixelBuffer: Uint8Array, frameOffset: number, sliceIndex: number, sliceSize: number, value: number): void;
6516
+ /**
6517
+ * Build and return the combined label map (lazy cached).
6518
+ * Iterates segments in insertion order so lower segment numbers win
6519
+ * at overlapping positions. Sets the hasOverlap flag if any voxel
6520
+ * already carries a different segment's value.
6521
+ *
6522
+ * @returns {Uint8Array} The full-volume label map.
6523
+ */
6524
+ getLabelMap(): Uint8Array;
6525
+ /**
6526
+ * Update the per-segment, per-slice buffers after a direct edit to the
6527
+ * shared label map (for example brush painting on a mask loaded from
6528
+ * DICOM, where the label map and the per-segment buffers are otherwise
6529
+ * two separate structures). No-op when this collection has no
6530
+ * per-segment data (brush-created masks), since the label map is
6531
+ * already the source of truth in that case.
6532
+ *
6533
+ * @param {number} offset The offset in the label map that changed.
6534
+ * @param {number} previousValue The segment number previously at offset.
6535
+ * @param {number} newValue The segment number now at offset.
6536
+ */
6537
+ updateAtOffset(offset: number, previousValue: number, newValue: number): void;
6538
+ /**
6539
+ * Re-index the per-segment, per-slice buffers after a slice insertion
6540
+ * (from Image#appendSlice) that shifted existing slice
6541
+ * content to make room for new slices. Unlike the shared label map
6542
+ * (which aliases the image buffer, so the raw byte-level shift already
6543
+ * covers it for free), `#segments` is keyed by slice index rather than
6544
+ * buffer offset, so an insertion before an existing slice leaves its
6545
+ * entries silently pointing at the wrong (pre-shift) slice index unless
6546
+ * they are explicitly re-keyed here.
6547
+ *
6548
+ * @param {number} sliceIndexThreshold Slices at or after this index
6549
+ * (numbering as it was *before* the insertion) are shifted.
6550
+ * @param {number} numberOfSlices Number of slices inserted.
6551
+ */
6552
+ shiftSlices(sliceIndexThreshold: number, numberOfSlices: number): void;
6553
+ /**
6554
+ * Get the value that a different, non-excluded segment holds at a given
6555
+ * label map offset. Used when deleting a segment to restore a voxel that
6556
+ * also belonged to another (overlapping) segment instead of losing that
6557
+ * other segment's presence there. Segments are checked in insertion
6558
+ * order, consistent with the first-wins policy used by {@link
6559
+ * SegmentCollection#getLabelMap}.
6560
+ *
6561
+ * @param {number} offset The offset in the label map.
6562
+ * @param {number} excludeSegmentNumber The segment number to ignore.
6563
+ * @returns {number} The other segment's stored value at that offset,
6564
+ * or 0 if no other segment covers it.
6565
+ */
6566
+ getOtherValueAtOffset(offset: number, excludeSegmentNumber: number): number;
6567
+ /**
6568
+ * Create a deep copy of this collection: per-segment/per-slice buffers
6569
+ * and the overlap flag are copied, the lazily-built label map and union
6570
+ * contour caches are left unset (they rebuild on demand from the copied
6571
+ * per-segment data, same as a freshly constructed collection).
6572
+ *
6573
+ * @returns {SegmentCollection} The copy.
6574
+ */
6575
+ clone(): SegmentCollection;
5398
6576
  /**
5399
- * Handle mouse wheel event.
6577
+ * Check whether any two segments share at least one voxel.
5400
6578
  *
5401
- * @param {WheelEvent} event The mouse wheel event.
6579
+ * @returns {boolean} True if overlap was detected.
5402
6580
  */
5403
- wheel(event: WheelEvent): void;
6581
+ getHasOverlap(): boolean;
6582
+ /**
6583
+ * Get the segment buffers. Using input image and segments since they
6584
+ * could have been modified (for example by brush).
6585
+ *
6586
+ * When per-segment data is available (MaskFactory path), builds ROI buffers
6587
+ * directly from #segments so that overlap pixels for every segment are
6588
+ * included. Falls back to label-map reconstruction for masks created via
6589
+ * setupSegmentCollection (brush path), where #segments is empty and the
6590
+ * label map is the only source of truth.
6591
+ *
6592
+ * @param {MaskSegment[]} segments The mask segments.
6593
+ * @returns {Record<string, Record<number, Uint8Array>>} The segment buffers,
6594
+ * indexed by segment index (segment.number - 1) and slice index.
6595
+ */
6596
+ getSegmentBuffers(segments: MaskSegment[]): Record<string, Record<number, Uint8Array>>;
6597
+ /**
6598
+ * Get the union ImageContour for the current visibility state,
6599
+ * building it if the set of hidden segments has changed.
6600
+ *
6601
+ * @param {MaskSegmentViewHelper|undefined} segmentViewHelper
6602
+ * Hidden-segment tracker.
6603
+ * @param {Size} imageSize The image size.
6604
+ * @returns {ImageContour} The union ImageContour.
6605
+ */
6606
+ getOrBuildUnionContour(segmentViewHelper: MaskSegmentViewHelper | undefined, imageSize: Size): ImageContour;
5404
6607
  #private;
5405
6608
  }
5406
6609
 
6610
+ /**
6611
+ * A simple sequence (VR=SQ) tag value.
6612
+ */
6613
+ export declare type SimpleSequenceValue = {
6614
+ /**
6615
+ * The sequence items.
6616
+ */
6617
+ value: SimpleTagValues[];
6618
+ /**
6619
+ * Undefined length flag.
6620
+ */
6621
+ undefinedLength?: boolean;
6622
+ };
6623
+
6624
+ /**
6625
+ * A simple (non sequence) tag value: either a single primitive
6626
+ * or, for multi-valued VRs, an array of primitives.
6627
+ */
6628
+ export declare type SimpleTagValue = string | number | string[] | number[];
6629
+
6630
+ /**
6631
+ * The meta data as simple tag values: indexed by tag name instead of
6632
+ * tag key, with direct values (no element object) for non sequence,
6633
+ * non merged tags.
6634
+ */
6635
+ export declare type SimpleTagValues = Record<string, SimpleTagValue | SimpleSequenceValue>;
6636
+
6637
+ /**
6638
+ * Simplify a polygon using the Ramer-Douglas-Peucker algorithm.
6639
+ * Ref: {@link https://en.wikipedia.org/wiki/Ramer%E2%80%93Douglas%E2%80%93Peucker_algorithm}.
6640
+ *
6641
+ * @param {Array.<{x: number, y: number}>} pts Input vertices.
6642
+ * @param {number} epsilon Max allowed deviation in pixels.
6643
+ * @returns {Array.<{x: number, y: number}>} Simplified vertices.
6644
+ */
6645
+ export declare function simplifyPolygon(pts: Array<{
6646
+ x: number;
6647
+ y: number;
6648
+ }>, epsilon: number): Array<{
6649
+ x: number;
6650
+ y: number;
6651
+ }>;
6652
+
6653
+ /**
6654
+ * @import {Matrix33} from '../math/matrix.js';
6655
+ * @import {Scalar2D} from '../math/scalar.js';
6656
+ */
5407
6657
  /**
5408
6658
  * Immutable Size class.
5409
6659
  * Warning: the input array is NOT cloned, modifying it will
@@ -5477,119 +6727,424 @@ export declare class Size {
5477
6727
  */
5478
6728
  getTotalSize(start?: number): number;
5479
6729
  /**
5480
- * Check for equality.
6730
+ * Check for equality.
6731
+ *
6732
+ * @param {Size} rhs The object to compare to.
6733
+ * @returns {boolean} True if both objects are equal.
6734
+ */
6735
+ equals(rhs: Size): boolean;
6736
+ /**
6737
+ * Check that an index is within bounds.
6738
+ *
6739
+ * @param {Index} index The index to check.
6740
+ * @param {number[]} dirs Optional list of directions to check.
6741
+ * @returns {boolean} True if the given coordinates are within bounds.
6742
+ */
6743
+ isInBounds(index: Index, dirs: number[]): boolean;
6744
+ /**
6745
+ * Convert an index to an offset in memory.
6746
+ *
6747
+ * @param {Index} index The index to convert.
6748
+ * @param {number} [start] Optional start dimension to base the offset on.
6749
+ * @returns {number} The offset or -1 if out of bounds.
6750
+ */
6751
+ indexToOffset(index: Index, start?: number): number;
6752
+ /**
6753
+ * Convert an offset in memory to an index.
6754
+ *
6755
+ * @param {number} offset The offset to convert.
6756
+ * @returns {Index} The index.
6757
+ */
6758
+ offsetToIndex(offset: number): Index;
6759
+ /**
6760
+ * Get the 2D base of this size.
6761
+ *
6762
+ * @returns {Scalar2D} The 2D base [0,1] as {x,y}.
6763
+ */
6764
+ get2D(): Scalar2D;
6765
+ /**
6766
+ * Normalise a point to this size.
6767
+ *
6768
+ * @param {Point} point The input point.
6769
+ * @param {Point} [extra] Optional point used to fill extra dimensions.
6770
+ * @returns {Point} The result point.
6771
+ */
6772
+ normalisePoint(point: Point, extra?: Point): Point;
6773
+ /**
6774
+ * Normalise an index to this size.
6775
+ *
6776
+ * @param {Index} index The input index.
6777
+ * @param {Index} [extra] Optional index used to fill extra dimensions.
6778
+ * @returns {Index} The result point.
6779
+ */
6780
+ normaliseIndex(index: Index, extra?: Index): Index;
6781
+ #private;
6782
+ }
6783
+
6784
+ /**
6785
+ * @import {Scalar2D} from '../math/scalar.js';
6786
+ */
6787
+ /**
6788
+ * Immutable Spacing class.
6789
+ * Warning: the input array is NOT cloned, modifying it will
6790
+ * modify the index values.
6791
+ */
6792
+ export declare class Spacing {
6793
+ /**
6794
+ * @param {number[]} values The spacing values.
6795
+ */
6796
+ constructor(values: number[]);
6797
+ /**
6798
+ * Get the spacing value at the given array index.
6799
+ *
6800
+ * @param {number} i The index to get.
6801
+ * @returns {number} The value.
6802
+ */
6803
+ get(i: number): number;
6804
+ /**
6805
+ * Get the length of the spacing.
6806
+ *
6807
+ * @returns {number} The length.
6808
+ */
6809
+ length(): number;
6810
+ /**
6811
+ * Get a string representation of the spacing.
6812
+ *
6813
+ * @returns {string} The spacing as a string.
6814
+ */
6815
+ toString(): string;
6816
+ /**
6817
+ * Get the values of this spacing.
6818
+ *
6819
+ * @returns {number[]} The array of values.
6820
+ */
6821
+ getValues(): number[];
6822
+ /**
6823
+ * Check for equality.
6824
+ *
6825
+ * @param {Spacing} rhs The object to compare to.
6826
+ * @returns {boolean} True if both objects are equal.
6827
+ */
6828
+ equals(rhs: Spacing): boolean;
6829
+ /**
6830
+ * Get the 2D base of this size.
6831
+ *
6832
+ * @returns {Scalar2D} The 2D base [col,row] as {x,y}.
6833
+ */
6834
+ get2D(): Scalar2D;
6835
+ #private;
6836
+ }
6837
+
6838
+ /**
6839
+ * Convert sRGB to CIE LAB (standard illuminant D65).
6840
+ *
6841
+ * @param {RGB} triplet 'sRGB' triplet as {r,g,b}.
6842
+ * @returns {object} CIE LAB triplet as {l,a,b}.
6843
+ */
6844
+ export declare function srgbToCielab(triplet: RGB): object;
6845
+
6846
+ /**
6847
+ * Stage controller: manages the link between the data view configs
6848
+ * and the stage (layer groups, layers, rendering).
6849
+ */
6850
+ export declare class StageController extends EventTarget {
6851
+ /**
6852
+ * @param {DataController} dataController The data controller.
6853
+ * @param {object} options The app options.
6854
+ */
6855
+ constructor(dataController: DataController, options: object);
6856
+ /**
6857
+ * Set the toolbox controller.
6858
+ *
6859
+ * @param {ToolboxController} tc The toolbox controller.
6860
+ */
6861
+ setToolboxController(tc: ToolboxController): void;
6862
+ /**
6863
+ * Set the add-to-undo-stack callback.
6864
+ *
6865
+ * @param {Function} fn The callback.
6866
+ */
6867
+ setAddToUndoStack(fn: Function): void;
6868
+ /**
6869
+ * Set the info data getter callback.
6870
+ *
6871
+ * @param {Function} fn A function `(dataId) => InfoData`.
6872
+ */
6873
+ setGetInfoData(fn: Function): void;
6874
+ /**
6875
+ * Get the layer group configuration from a data id.
6876
+ *
6877
+ * @param {string} dataId The data id.
6878
+ * @param {boolean} [excludeStarConfig] Exclude the star config
6879
+ * (default to false).
6880
+ * @returns {ViewConfig[]} The list of associated configs.
6881
+ */
6882
+ getViewConfigs(dataId: string, excludeStarConfig?: boolean): ViewConfig[];
6883
+ /**
6884
+ * Get the layer group configuration for a data id and group div id.
6885
+ *
6886
+ * @param {string} dataId The data id.
6887
+ * @param {string} groupDivId The layer group div id.
6888
+ * @param {boolean} [excludeStarConfig] Exclude the star config
6889
+ * (default to false).
6890
+ * @returns {ViewConfig|undefined} The associated config.
6891
+ */
6892
+ getViewConfig(dataId: string, groupDivId: string, excludeStarConfig?: boolean): ViewConfig | undefined;
6893
+ /**
6894
+ * Get the data view config.
6895
+ * Careful, returns a reference; do not modify without resetting.
6896
+ *
6897
+ * @returns {Record<string, ViewConfig[]>} The configuration list.
6898
+ */
6899
+ getDataViewConfigs(): Record<string, ViewConfig[]>;
6900
+ /**
6901
+ * Set the data view configuration.
6902
+ * Resets the stage and recreates all the views.
6903
+ *
6904
+ * @param {Record<string, ViewConfig[]>} configs The configuration list.
6905
+ */
6906
+ setDataViewConfigs(configs: Record<string, ViewConfig[]>): void;
6907
+ /**
6908
+ * Add a data view config.
6909
+ *
6910
+ * @param {string} dataId The data id.
6911
+ * @param {ViewConfig} config The view configuration.
6912
+ * @param {boolean} [doRender] Render data after configuration
6913
+ * add. Defaults to true.
6914
+ */
6915
+ addDataViewConfig(dataId: string, config: ViewConfig, doRender?: boolean): void;
6916
+ /**
6917
+ * Remove a data view config.
6918
+ * Removes the associated layer if found, removes
6919
+ * the layer group if empty.
6920
+ *
6921
+ * @param {string} dataId The data id.
6922
+ * @param {string} divId The div id.
6923
+ */
6924
+ removeDataViewConfig(dataId: string, divId: string): void;
6925
+ /**
6926
+ * Update an existing data view config.
6927
+ * Removes and re-creates the layer if found.
6928
+ *
6929
+ * @param {string} dataId The data id.
6930
+ * @param {string} divId The div id.
6931
+ * @param {ViewConfig} config The view configuration.
6932
+ */
6933
+ updateDataViewConfig(dataId: string, divId: string, config: ViewConfig): void;
6934
+ /**
6935
+ * Get the active layer group.
6936
+ *
6937
+ * @returns {LayerGroup|undefined} The layer group.
6938
+ */
6939
+ getActiveLayerGroup(): LayerGroup | undefined;
6940
+ /**
6941
+ * Set the active layer group.
6942
+ *
6943
+ * @param {number} index The layer group index.
6944
+ */
6945
+ setActiveLayerGroup(index: number): void;
6946
+ /**
6947
+ * Get a layer group by index.
6948
+ *
6949
+ * @param {number} index The index.
6950
+ * @returns {LayerGroup} The layer group.
6951
+ */
6952
+ getLayerGroup(index: number): LayerGroup;
6953
+ /**
6954
+ * Get the number of layer groups.
6955
+ *
6956
+ * @returns {number} The number of groups.
6957
+ */
6958
+ getNumberOfLayerGroups(): number;
6959
+ /**
6960
+ * Get the view layers associated to a data id.
6961
+ *
6962
+ * @param {string} dataId The data id.
6963
+ * @returns {ViewLayer[]} The layers.
6964
+ */
6965
+ getViewLayersByDataId(dataId: string): ViewLayer[];
6966
+ /**
6967
+ * Get a list of view layers according to an input callback function.
6968
+ *
6969
+ * @param {Function} [callbackFn] A function that takes
6970
+ * a ViewLayer as input and returns a boolean. If undefined,
6971
+ * returns all view layers.
6972
+ * @returns {ViewLayer[]} The layers that satisfy the callbackFn.
6973
+ */
6974
+ getViewLayers(callbackFn?: Function): ViewLayer[];
6975
+ /**
6976
+ * Get the draw layers associated to a data id.
6977
+ *
6978
+ * @param {string} dataId The data id.
6979
+ * @returns {DrawLayer[]} The layers.
6980
+ */
6981
+ getDrawLayersByDataId(dataId: string): DrawLayer[];
6982
+ /**
6983
+ * Get a list of draw layers according to an input callback function.
6984
+ *
6985
+ * @param {Function} [callbackFn] A function that takes
6986
+ * a DrawLayer as input and returns a boolean. If undefined,
6987
+ * returns all draw layers.
6988
+ * @returns {DrawLayer[]} The layers that satisfy the callbackFn.
6989
+ */
6990
+ getDrawLayers(callbackFn?: Function): DrawLayer[];
6991
+ /**
6992
+ * Get a layer group by div id.
6993
+ *
6994
+ * @param {string} divId The div id.
6995
+ * @returns {LayerGroup|undefined} The layer group.
6996
+ */
6997
+ getLayerGroupByDivId(divId: string): LayerGroup | undefined;
6998
+ /**
6999
+ * Get the active layer group scale on top of the base scale.
7000
+ *
7001
+ * @returns {Scalar3D} The scale as {x,y,z}.
7002
+ * @deprecated Since v0.37, please access from the active layer group.
7003
+ */
7004
+ getAddedScale(): Scalar3D;
7005
+ /**
7006
+ * Get the base scale of the active layer group.
7007
+ *
7008
+ * @returns {Scalar3D} The scale as {x,y,z}.
7009
+ * @deprecated Since v0.37, please access from the active layer group.
7010
+ */
7011
+ getBaseScale(): Scalar3D;
7012
+ /**
7013
+ * Get the layer offset of the active layer group.
7014
+ *
7015
+ * @returns {Scalar3D} The offset as {x,y,z}.
7016
+ * @deprecated Since v0.37, please access from the active layer group.
7017
+ */
7018
+ getOffset(): Scalar3D;
7019
+ /**
7020
+ * Empty the stage (remove all layer groups).
7021
+ */
7022
+ empty(): void;
7023
+ /**
7024
+ * Remove layers for a specific data id.
7025
+ *
7026
+ * @param {string} dataId The data id.
7027
+ */
7028
+ removeLayersByDataId(dataId: string): void;
7029
+ /**
7030
+ * Set the layer groups binders.
7031
+ *
7032
+ * @param {object[]} instances Binder instances.
7033
+ */
7034
+ setBinders(instances: object[]): void;
7035
+ /**
7036
+ * Fit the display to the data of each layer group.
7037
+ */
7038
+ fitToContainer(): void;
7039
+ /**
7040
+ * Draw all layer groups.
7041
+ */
7042
+ draw(): void;
7043
+ /**
7044
+ * Reset zoom and pan of the stage.
5481
7045
  *
5482
- * @param {Size} rhs The object to compare to.
5483
- * @returns {boolean} True if both objects are equal.
7046
+ * @deprecated Since v0.35, prefer resetZoomPan.
5484
7047
  */
5485
- equals(rhs: Size): boolean;
7048
+ resetLayout(): void;
5486
7049
  /**
5487
- * Check that an index is within bounds.
5488
- *
5489
- * @param {Index} index The index to check.
5490
- * @param {number[]} dirs Optional list of directions to check.
5491
- * @returns {boolean} True if the given coordinates are within bounds.
7050
+ * Reset the zoom and pan of the stage.
5492
7051
  */
5493
- isInBounds(index: Index, dirs: number[]): boolean;
7052
+ resetZoomPan(): void;
5494
7053
  /**
5495
- * Convert an index to an offset in memory.
5496
- *
5497
- * @param {Index} index The index to convert.
5498
- * @param {number} [start] Optional start dimension to base the offset on.
5499
- * @returns {number} The offset or -1 if out of bounds.
7054
+ * Reset the position and window level of the stage.
5500
7055
  */
5501
- indexToOffset(index: Index, start?: number): number;
7056
+ resetViews(): void;
5502
7057
  /**
5503
- * Convert an offset in memory to an index.
7058
+ * Set the imageSmoothing flag value. Default is false.
5504
7059
  *
5505
- * @param {number} offset The offset to convert.
5506
- * @returns {Index} The index.
7060
+ * @param {boolean} flag True to enable smoothing.
5507
7061
  */
5508
- offsetToIndex(offset: number): Index;
7062
+ setImageSmoothing(flag: boolean): void;
5509
7063
  /**
5510
- * Get the 2D base of this size.
7064
+ * Zoom the layers of the active layer group.
5511
7065
  *
5512
- * @returns {Scalar2D} The 2D base [0,1] as {x,y}.
7066
+ * @param {number} step The step to add to the current zoom.
7067
+ * @param {number} cx The zoom center X coordinate.
7068
+ * @param {number} cy The zoom center Y coordinate.
7069
+ * @deprecated Since v0.37, please access from the active layer group.
5513
7070
  */
5514
- get2D(): Scalar2D;
7071
+ zoom(step: number, cx: number, cy: number): void;
5515
7072
  /**
5516
- * Normalise a point to this size.
7073
+ * Apply a translation to the layers of the active layer group.
5517
7074
  *
5518
- * @param {Point} point The input point.
5519
- * @param {Point} [extra] Optional point used to fill extra dimensions.
5520
- * @returns {Point} The result point.
7075
+ * @param {number} tx The translation along X.
7076
+ * @param {number} ty The translation along Y.
5521
7077
  */
5522
- normalisePoint(point: Point, extra?: Point): Point;
7078
+ translate(tx: number, ty: number): void;
5523
7079
  /**
5524
- * Normalise an index to this size.
7080
+ * Render the current data.
5525
7081
  *
5526
- * @param {Index} index The input index.
5527
- * @param {Index} [extra] Optional index used to fill extra dimensions.
5528
- * @returns {Index} The result point.
7082
+ * @param {string} dataId The data id to render.
7083
+ * @param {ViewConfig[]} [viewConfigs] The list of configs to render.
5529
7084
  */
5530
- normaliseIndex(index: Index, extra?: Index): Index;
7085
+ render(dataId: string, viewConfigs?: ViewConfig[]): void;
5531
7086
  #private;
5532
7087
  }
5533
7088
 
5534
7089
  /**
5535
- * Immutable Spacing class.
5536
- * Warning: the input array is NOT cloned, modifying it will
5537
- * modify the index values.
7090
+ * Statistics storage class.
7091
+ * 'simple' statistics do not include median, p25 nor p75.
5538
7092
  */
5539
- export declare class Spacing {
7093
+ declare class Statistics {
5540
7094
  /**
5541
- * @param {number[]} values The spacing values.
7095
+ * @param {number} min The minimum.
7096
+ * @param {number} max The maximum.
7097
+ * @param {number} mean The mean.
7098
+ * @param {number} stdDev The standard deviation.
5542
7099
  */
5543
- constructor(values: number[]);
7100
+ constructor(min: number, max: number, mean: number, stdDev: number);
5544
7101
  /**
5545
- * Get the spacing value at the given array index.
7102
+ * Minimum.
5546
7103
  *
5547
- * @param {number} i The index to get.
5548
- * @returns {number} The value.
7104
+ * @type {number}
5549
7105
  */
5550
- get(i: number): number;
7106
+ min: number;
5551
7107
  /**
5552
- * Get the length of the spacing.
7108
+ * Maximum.
5553
7109
  *
5554
- * @returns {number} The length.
7110
+ * @type {number}
5555
7111
  */
5556
- length(): number;
7112
+ max: number;
5557
7113
  /**
5558
- * Get a string representation of the spacing.
7114
+ * Mean.
5559
7115
  *
5560
- * @returns {string} The spacing as a string.
7116
+ * @type {number}
5561
7117
  */
5562
- toString(): string;
7118
+ mean: number;
5563
7119
  /**
5564
- * Get the values of this spacing.
7120
+ * Standard deviation (population: divided by the number of values).
5565
7121
  *
5566
- * @returns {number[]} The array of values.
7122
+ * @type {number}
5567
7123
  */
5568
- getValues(): number[];
7124
+ stdDev: number;
5569
7125
  /**
5570
- * Check for equality.
7126
+ * Median.
5571
7127
  *
5572
- * @param {Spacing} rhs The object to compare to.
5573
- * @returns {boolean} True if both objects are equal.
7128
+ * @type {number|undefined}
5574
7129
  */
5575
- equals(rhs: Spacing): boolean;
7130
+ median: number | undefined;
5576
7131
  /**
5577
- * Get the 2D base of this size.
7132
+ * 25th percentile.
5578
7133
  *
5579
- * @returns {Scalar2D} The 2D base [col,row] as {x,y}.
7134
+ * @type {number|undefined}
5580
7135
  */
5581
- get2D(): Scalar2D;
5582
- #private;
7136
+ p25: number | undefined;
7137
+ /**
7138
+ * 75th percentile.
7139
+ *
7140
+ * @type {number|undefined}
7141
+ */
7142
+ p75: number | undefined;
5583
7143
  }
5584
7144
 
5585
7145
  /**
5586
- * Convert sRGB to CIE LAB (standard illuminant D65).
5587
- *
5588
- * @param {RGB} triplet 'sRGB' triplet as {r,g,b}.
5589
- * @returns {object} CIE LAB triplet as {l,a,b}.
7146
+ * @import {DataElement} from '../dicom/dataElement.js';
5590
7147
  */
5591
- export declare function srgbToCielab(triplet: RGB): object;
5592
-
5593
7148
  /**
5594
7149
  * Immutable tag.
5595
7150
  */
@@ -5612,7 +7167,7 @@ export declare class Tag {
5612
7167
  */
5613
7168
  getElement(): string;
5614
7169
  /**
5615
- * Get as string representation of the tag: 'key: name'.
7170
+ * Get as string representation of the tag: '(group,element)'.
5616
7171
  *
5617
7172
  * @returns {string} A string representing the tag.
5618
7173
  */
@@ -5630,12 +7185,6 @@ export declare class Tag {
5630
7185
  * @returns {string} The key as '########'.
5631
7186
  */
5632
7187
  getKey(): string;
5633
- /**
5634
- * Get the group name as defined in TagGroups.
5635
- *
5636
- * @returns {string} The name.
5637
- */
5638
- getGroupName(): string;
5639
7188
  /**
5640
7189
  * Does this tag have a VR.
5641
7190
  * Basically not the Item, ItemDelimitationItem nor
@@ -5653,27 +7202,45 @@ export declare class Tag {
5653
7202
  * ie if its group is an odd number.
5654
7203
  */
5655
7204
  isPrivate(): boolean;
7205
+ #private;
7206
+ }
7207
+
7208
+ /**
7209
+ * DICOM tag info: vr, multiplicity, name.
7210
+ */
7211
+ export declare class TagInfo {
7212
+ /**
7213
+ * @param {string} vr The tag Value Representation (VR).
7214
+ * @param {number} multiplicity The tag multiplicity.
7215
+ * @param {string} name The tag name.
7216
+ */
7217
+ constructor(vr: string, multiplicity: number, name: string);
5656
7218
  /**
5657
- * Get the tag Value Representation (VR) from the dicom dictionary.
7219
+ * Get the tag Value Representation (VR).
5658
7220
  *
5659
- * @returns {string|undefined} The VR.
7221
+ * @returns {string} The tag vr.
5660
7222
  */
5661
- getVrFromDictionary(): string | undefined;
7223
+ getVr(): string;
5662
7224
  /**
5663
- * Get the multiplicity from the dicom dictionary.
7225
+ * Get the tag multiplicity.
5664
7226
  *
5665
- * @returns {number|undefined} The multiplicity.
7227
+ * @returns {number} The multiplicity.
5666
7228
  */
5667
- getMultiplicityFromDictionary(): number | undefined;
7229
+ getMultiplicity(): number;
5668
7230
  /**
5669
- * Get the tag name from the dicom dictionary.
7231
+ * Get the tag name.
5670
7232
  *
5671
- * @returns {string|undefined} The VR.
7233
+ * @returns {string} The name.
5672
7234
  */
5673
- getNameFromDictionary(): string | undefined;
7235
+ getName(): string;
5674
7236
  #private;
5675
7237
  }
5676
7238
 
7239
+ /**
7240
+ * @import {LayerGroup} from '../gui/layerGroup.js';
7241
+ * @import {ViewLayer} from '../gui/viewLayer.js';
7242
+ * @import {DrawLayer} from '../gui/drawLayer.js';
7243
+ */
5677
7244
  /**
5678
7245
  * Toolbox controller.
5679
7246
  */
@@ -5717,9 +7284,10 @@ export declare class ToolboxController {
5717
7284
  *
5718
7285
  * @param {string} eventType The event type, for example
5719
7286
  * mousedown, touchstart...
5720
- * @returns {Function} The event handler.
7287
+ * @returns {EventListener|undefined} The event handler, undefined
7288
+ * if no tool is selected.
5721
7289
  */
5722
- getSelectedToolEventHandler(eventType: string): Function;
7290
+ getSelectedToolEventHandler(eventType: string): EventListener | undefined;
5723
7291
  /**
5724
7292
  * Set the selected tool.
5725
7293
  *
@@ -5791,11 +7359,9 @@ export declare class ToolConfig {
5791
7359
  * 'https://raw.githubusercontent.com/ivmartel/dwv/master/tests/data/bbmri-53323851.dcm'
5792
7360
  * ]);
5793
7361
  *
5794
- * @type {Object<string, any>}
7362
+ * @type {Record<string, any>}
5795
7363
  */
5796
- export declare const toolList: {
5797
- [x: string]: any;
5798
- };
7364
+ export declare const toolList: Record<string, any>;
5799
7365
 
5800
7366
  /**
5801
7367
  * List of client provided tool options to be added to
@@ -5809,7 +7375,6 @@ export declare const toolList: {
5809
7375
  * getName() {return 'love';}
5810
7376
  * static supports(mathShape) {return mathShape instanceof ROI;}
5811
7377
  * getNPoints() {return 1;}
5812
- * getTimeout() {return 0;}
5813
7378
  * setAnnotationMathShape(annotation, points) {
5814
7379
  * const px = points[0].getX();
5815
7380
  * const py = points[0].getY();
@@ -5862,26 +7427,81 @@ export declare const toolList: {
5862
7427
  * 'https://raw.githubusercontent.com/ivmartel/dwv/master/tests/data/bbmri-53323851.dcm'
5863
7428
  * ]);
5864
7429
  *
5865
- * @type {Object<string, Object<string, any>>}
7430
+ * @type {Record<string, Record<string, any>>}
5866
7431
  */
5867
- export declare const toolOptions: {
5868
- [x: string]: {
5869
- [x: string]: any;
5870
- };
5871
- };
7432
+ export declare const toolOptions: Record<string, Record<string, any>>;
5872
7433
 
5873
7434
  /**
5874
- * Class to store a value and a unit.
7435
+ * Translate writer rules indexed by tag or group name into
7436
+ * rules indexed by tag or group key, as expected by the writer.
7437
+ * A group name is translated into all the groups that have it
7438
+ * (for example 'Curve' gives '5000', '5002'...).
7439
+ * Warning: group names are not defined by the DICOM standard, they come
7440
+ * from the GDCM group name list (see `tagGroups`), which does not cover
7441
+ * all groups. Prefer group keys.
7442
+ * Rules already indexed by key (or `default`) are kept as is and
7443
+ * take precedence over translated ones. Unknown names are dropped.
7444
+ *
7445
+ * @param {Record<string, WriterRule>} rules The name based rules.
7446
+ * @returns {Record<string, WriterRule>} The key based rules.
7447
+ */
7448
+ export declare function translateWriterRules(rules: Record<string, WriterRule>): Record<string, WriterRule>;
7449
+
7450
+ /**
7451
+ * List of compatible typed arrays.
5875
7452
  */
5876
- export declare class Value {
7453
+ export declare type TypedArray = IntTypedArray | FloatTypedArray;
7454
+
7455
+ /**
7456
+ * Undo controller.
7457
+ */
7458
+ export declare class UndoController extends EventTarget {
5877
7459
  /**
5878
- * @type {number}
7460
+ * Add a command to the undo stack.
7461
+ *
7462
+ * @param {object} cmd The command to add.
7463
+ * @fires UndoStack#undoadd
7464
+ * @function
5879
7465
  */
5880
- value: number;
7466
+ addToUndoStack: (cmd: object) => void;
5881
7467
  /**
5882
- * @type {string|undefined}
7468
+ * Remove a command from the undo stack.
7469
+ *
7470
+ * @param {string} name The name of the command to remove.
7471
+ * @returns {boolean} True if the command was found and removed.
7472
+ * @fires UndoStack#undoremove
7473
+ * @function
5883
7474
  */
5884
- unit: string | undefined;
7475
+ removeFromUndoStack: (name: string) => boolean;
7476
+ /**
7477
+ * Undo the last command.
7478
+ *
7479
+ * @fires UndoStack#undo
7480
+ */
7481
+ undo(): void;
7482
+ /**
7483
+ * Redo the next command.
7484
+ *
7485
+ * @fires UndoStack#redo
7486
+ */
7487
+ redo(): void;
7488
+ /**
7489
+ * Get the undo stack size.
7490
+ *
7491
+ * @returns {number} The size of the stack.
7492
+ */
7493
+ getStackSize(): number;
7494
+ /**
7495
+ * Get the current undo stack index.
7496
+ *
7497
+ * @returns {number} The stack index.
7498
+ */
7499
+ getCurrentStackIndex(): number;
7500
+ /**
7501
+ * Reset the undo/redo history.
7502
+ */
7503
+ reset(): void;
7504
+ #private;
5885
7505
  }
5886
7506
 
5887
7507
  /**
@@ -5968,16 +7588,16 @@ export declare class Vector3D {
5968
7588
  * (either directly or with helper methods).
5969
7589
  *
5970
7590
  * @example
5971
- * import {DicomParser, createImage, createView} from '//esm.sh/dwv';
7591
+ * import {DicomParser, demoCreateImage, demoCreateView} from '//esm.sh/dwv';
5972
7592
  * // XMLHttpRequest onload callback
5973
7593
  * const onload = function (event) {
5974
7594
  * // parse the dicom buffer
5975
7595
  * const dicomParser = new DicomParser();
5976
7596
  * dicomParser.parse(event.target.response);
5977
7597
  * // create the image object
5978
- * const image = createImage(dicomParser.getDicomElements());
7598
+ * const image = demoCreateImage(dicomParser.getDicomElements());
5979
7599
  * // create the view
5980
- * const view = createView(dicomParser.getDicomElements(), image);
7600
+ * const view = demoCreateView(dicomParser.getDicomElements(), image);
5981
7601
  * // setup canvas
5982
7602
  * const canvas = document.createElement('canvas');
5983
7603
  * canvas.width = 256;
@@ -5999,7 +7619,7 @@ export declare class Vector3D {
5999
7619
  * request.onload = onload;
6000
7620
  * request.send();
6001
7621
  */
6002
- export declare class View {
7622
+ export declare class View extends EventTarget {
6003
7623
  /**
6004
7624
  * @param {Image} image The associated image.
6005
7625
  */
@@ -6029,6 +7649,29 @@ export declare class View {
6029
7649
  * @param {MaskSegmentViewHelper} helper The helper.
6030
7650
  */
6031
7651
  setMaskViewHelper(helper: MaskSegmentViewHelper): void;
7652
+ /**
7653
+ * Get the segment highlight.
7654
+ *
7655
+ * @returns {{segmentNumber: number, opacity: number}|undefined}
7656
+ * The highlighted segment number and its opacity factor.
7657
+ */
7658
+ getSegmentHighlight(): {
7659
+ segmentNumber: number;
7660
+ opacity: number;
7661
+ } | undefined;
7662
+ /**
7663
+ * Set the segment highlight: the opacity of the given segment
7664
+ * is multiplied by the input factor. Only one segment can be
7665
+ * highlighted at a time.
7666
+ * This only has an effect on segmentation views.
7667
+ *
7668
+ * @param {number} [segmentNumber] The segment number,
7669
+ * undefined to remove the highlight.
7670
+ * @param {number} [opacity] The opacity factor (between 0 and 1),
7671
+ * defaults to 1.
7672
+ * @fires View#segmenthighlightchange
7673
+ */
7674
+ setSegmentHighlight(segmentNumber?: number, opacity?: number): void;
6032
7675
  /**
6033
7676
  * Get the view orientation.
6034
7677
  *
@@ -6093,9 +7736,9 @@ export declare class View {
6093
7736
  /**
6094
7737
  * Get the window presets.
6095
7738
  *
6096
- * @returns {object} The window presets.
7739
+ * @returns {Record<string, WindowPreset>} The window presets.
6097
7740
  */
6098
- getWindowPresets(): object;
7741
+ getWindowPresets(): Record<string, WindowPreset>;
6099
7742
  /**
6100
7743
  * Get the window presets names.
6101
7744
  *
@@ -6105,15 +7748,15 @@ export declare class View {
6105
7748
  /**
6106
7749
  * Set the window presets.
6107
7750
  *
6108
- * @param {object} presets The window presets.
7751
+ * @param {Record<string, WindowPreset>} presets The window presets.
6109
7752
  */
6110
- setWindowPresets(presets: object): void;
7753
+ setWindowPresets(presets: Record<string, WindowPreset>): void;
6111
7754
  /**
6112
7755
  * Add window presets to the existing ones.
6113
7756
  *
6114
- * @param {object} presets The window presets.
7757
+ * @param {Record<string, WindowPreset>} presets The window presets.
6115
7758
  */
6116
- addWindowPresets(presets: object): void;
7759
+ addWindowPresets(presets: Record<string, WindowPreset>): void;
6117
7760
  /**
6118
7761
  * Get the current window level preset name.
6119
7762
  *
@@ -6228,22 +7871,6 @@ export declare class View {
6228
7871
  * @param {boolean} [silent] Flag to launch events with skipGenerate.
6229
7872
  */
6230
7873
  setWindowLevelPresetById(id: number, silent?: boolean): void;
6231
- /**
6232
- * Add an event listener to this class.
6233
- *
6234
- * @param {string} type The event type.
6235
- * @param {Function} callback The function associated with the provided
6236
- * event type, will be called with the fired event.
6237
- */
6238
- addEventListener(type: string, callback: Function): void;
6239
- /**
6240
- * Remove an event listener from this class.
6241
- *
6242
- * @param {string} type The event type.
6243
- * @param {Function} callback The function associated with the provided
6244
- * event type.
6245
- */
6246
- removeEventListener(type: string, callback: Function): void;
6247
7874
  /**
6248
7875
  * Get the image window/level that covers the full data range.
6249
7876
  * Warning: uses the latest set rescale LUT or the default linear one.
@@ -6279,6 +7906,16 @@ export declare class View {
6279
7906
  #private;
6280
7907
  }
6281
7908
 
7909
+ /**
7910
+ * @import {LayerGroup} from '../gui/layerGroup.js';
7911
+ * @import {ViewLayer} from '../gui/viewLayer.js';
7912
+ * @import {DrawLayer} from '../gui/drawLayer.js';
7913
+ * @import {Image} from '../image/image.js';
7914
+ * @import {Matrix33} from '../math/matrix.js';
7915
+ * @import {DataElement} from '../dicom/dataElement.js';
7916
+ * @import {Scalar3D} from '../math/scalar.js';
7917
+ * @import {Command} from '../command/undoStack.js';
7918
+ */
6282
7919
  /**
6283
7920
  * View configuration: mainly defines the ´divId´
6284
7921
  * of the associated HTML div.
@@ -6347,6 +7984,16 @@ export declare class ViewConfig {
6347
7984
  windowWidth: number | undefined;
6348
7985
  }
6349
7986
 
7987
+ /**
7988
+ * @import {View} from '../image/view.js';
7989
+ * @import {WindowLevel} from '../image/windowLevel.js';
7990
+ * @import {WindowPreset} from '../image/windowPreset.js';
7991
+ * @import {Point} from '../math/point.js';
7992
+ * @import {Scalar2D} from '../math/scalar.js';
7993
+ * @import {Matrix33} from '../math/matrix.js';
7994
+ * @import {ViewLayer} from '../gui/viewLayer.js';
7995
+ * @import {MaskSegmentViewHelper} from '../image/maskSegmentViewHelper.js';
7996
+ */
6350
7997
  /**
6351
7998
  * View controller.
6352
7999
  */
@@ -6404,10 +8051,10 @@ export declare class ViewController {
6404
8051
  /**
6405
8052
  * Add window/level presets to the view.
6406
8053
  *
6407
- * @param {object} presets A preset object.
8054
+ * @param {Record<string, WindowPreset>} presets A preset object.
6408
8055
  * @returns {object} The list of presets.
6409
8056
  */
6410
- addWindowLevelPresets(presets: object): object;
8057
+ addWindowLevelPresets(presets: Record<string, WindowPreset>): object;
6411
8058
  /**
6412
8059
  * Set the window level to the preset with the input name.
6413
8060
  *
@@ -6538,6 +8185,14 @@ export declare class ViewController {
6538
8185
  * or no quantifiable (for ex RGB).
6539
8186
  */
6540
8187
  getRescaledImageValue(position: Point): number | undefined;
8188
+ /**
8189
+ * Get the numbers of the mask segments at the input position.
8190
+ *
8191
+ * @param {Point} position The input position.
8192
+ * @returns {number[]} The list of segment numbers, empty if the image
8193
+ * is not a mask, for background or if out of bounds.
8194
+ */
8195
+ getSegmentNumbersAtPosition(position: Point): number[];
6541
8196
  /**
6542
8197
  * Get the image pixel unit.
6543
8198
  *
@@ -6761,6 +8416,28 @@ export declare class ViewController {
6761
8416
  * @param {MaskSegmentViewHelper} helper The helper.
6762
8417
  */
6763
8418
  setMaskViewHelper(helper: MaskSegmentViewHelper): void;
8419
+ /**
8420
+ * Get the segment highlight.
8421
+ *
8422
+ * @returns {{segmentNumber: number, opacity: number}|undefined}
8423
+ * The highlighted segment number and its opacity factor.
8424
+ */
8425
+ getSegmentHighlight(): {
8426
+ segmentNumber: number;
8427
+ opacity: number;
8428
+ } | undefined;
8429
+ /**
8430
+ * Set the segment highlight: the opacity of the given segment
8431
+ * is multiplied by the input factor. Only one segment can be
8432
+ * highlighted at a time.
8433
+ * This only has an effect on segmentation views.
8434
+ *
8435
+ * @param {number} [segmentNumber] The segment number,
8436
+ * undefined to remove the highlight.
8437
+ * @param {number} [opacity] The opacity factor (between 0 and 1),
8438
+ * defaults to 1.
8439
+ */
8440
+ setSegmentHighlight(segmentNumber?: number, opacity?: number): void;
6764
8441
  /**
6765
8442
  * Get the fill opacity relative to the global opacity.
6766
8443
  *
@@ -6804,8 +8481,16 @@ export declare class ViewController {
6804
8481
  #private;
6805
8482
  }
6806
8483
 
8484
+ /**
8485
+ * @import {Vector3D} from '../math/vector.js';
8486
+ * @import {Point, Point3D} from '../math/point.js';
8487
+ * @import {Scalar2D, Scalar3D} from '../math/scalar.js';
8488
+ */
6807
8489
  /**
6808
8490
  * View layer.
8491
+ *
8492
+ * Not an EventTarget in order to forward native DOM events while
8493
+ * preserving `preventDefault()` for tools (see '#fireDomEvent').
6809
8494
  */
6810
8495
  export declare class ViewLayer {
6811
8496
  /**
@@ -6859,10 +8544,10 @@ export declare class ViewLayer {
6859
8544
  /**
6860
8545
  * Handle an image set event.
6861
8546
  *
6862
- * @param {object} event The event.
8547
+ * @param {CustomEvent} event The event.
6863
8548
  * @function
6864
8549
  */
6865
- onimageset: (event: object) => void;
8550
+ onimageset: (event: CustomEvent) => void;
6866
8551
  /**
6867
8552
  * Bind this layer to the view image.
6868
8553
  */
@@ -6874,24 +8559,24 @@ export declare class ViewLayer {
6874
8559
  /**
6875
8560
  * Handle an image content change event.
6876
8561
  *
6877
- * @param {object} event The event.
8562
+ * @param {CustomEvent} event The event.
6878
8563
  * @function
6879
8564
  */
6880
- onimagecontentchange: (event: object) => void;
8565
+ onimagecontentchange: (event: CustomEvent) => void;
6881
8566
  /**
6882
8567
  * Handle an image change event.
6883
8568
  *
6884
- * @param {object} event The event.
8569
+ * @param {CustomEvent} event The event.
6885
8570
  * @function
6886
8571
  */
6887
- onimagegeometrychange: (event: object) => void;
8572
+ onimagegeometrychange: (event: CustomEvent) => void;
6888
8573
  /**
6889
8574
  * Handle an image resampled event.
6890
8575
  *
6891
- * @param {object} event The event.
8576
+ * @param {CustomEvent} event The event.
6892
8577
  * @function
6893
8578
  */
6894
- onimageresampled: (event: object) => void;
8579
+ onimageresampled: (event: CustomEvent) => void;
6895
8580
  /**
6896
8581
  * Get the id of the layer.
6897
8582
  *
@@ -6926,6 +8611,18 @@ export declare class ViewLayer {
6926
8611
  * @param {number} alpha The opacity ([0:1] range).
6927
8612
  */
6928
8613
  setOpacity(alpha: number): void;
8614
+ /**
8615
+ * Temporarily highlight a segment: its opacity progressively
8616
+ * dims and comes back to normal in one pulse. Only one
8617
+ * segment is highlighted at a time: a new call resets the
8618
+ * previous highlight.
8619
+ *
8620
+ * @param {number} segmentNumber The segment number.
8621
+ * @param {number} [duration] The highlight duration in milliseconds,
8622
+ * defaults to 750.
8623
+ * @returns {boolean} False if the layer is not a segmentation one.
8624
+ */
8625
+ highlightSegment(segmentNumber: number, duration?: number): boolean;
6929
8626
  /**
6930
8627
  * Get the fill opacity relative to the global opacity.
6931
8628
  *
@@ -7122,6 +8819,51 @@ export declare class ViewLayer {
7122
8819
  #private;
7123
8820
  }
7124
8821
 
8822
+ /**
8823
+ * Volume id candidate getter.
8824
+ */
8825
+ export declare type VolumeIdCandidate = {
8826
+ /**
8827
+ * The candidate name.
8828
+ */
8829
+ name: string;
8830
+ /**
8831
+ * The volume id getter.
8832
+ */
8833
+ getter: Function;
8834
+ /**
8835
+ * Flag to also use the candidate
8836
+ * while loading.
8837
+ */
8838
+ preLoad?: boolean;
8839
+ };
8840
+
8841
+ /**
8842
+ * @import {LayerGroup} from '../../gui/layerGroup.js';
8843
+ */
8844
+ /**
8845
+ * Mouse wheel handling: subclasses may override {@link WheelBehavior#onWheel}
8846
+ * (every event) and/or {@link WheelBehavior#onWheelTick}
8847
+ * (after tick threshold).
8848
+ */
8849
+ export declare class WheelBehavior {
8850
+ /**
8851
+ * Raw wheel event (every `wheel`); use with continuous effects such as zoom.
8852
+ *
8853
+ * @param {WheelEvent} _event The wheel event.
8854
+ * @param {LayerGroup|undefined} _layerGroup Layer group under the wheel.
8855
+ */
8856
+ onWheel(_event: WheelEvent, _layerGroup: LayerGroup | undefined): void;
8857
+ /**
8858
+ * Discrete wheel tick after accumulation; use for
8859
+ * slice scroll and similar stepped actions.
8860
+ *
8861
+ * @param {boolean} _up True when spin is in the positive direction.
8862
+ * @param {LayerGroup} _layerGroup Layer group under the wheel event.
8863
+ */
8864
+ onWheelTick(_up: boolean, _layerGroup: LayerGroup): void;
8865
+ }
8866
+
7125
8867
  /**
7126
8868
  * Window and Level also known as window width and center.
7127
8869
  */
@@ -7145,26 +8887,71 @@ export declare class WindowLevel {
7145
8887
  width: number;
7146
8888
  }
7147
8889
 
8890
+ /**
8891
+ * @import {WindowLevel} from './windowLevel.js';
8892
+ */
8893
+ /**
8894
+ * Window level preset: a named list of window levels.
8895
+ * The list holds a single window level unless the preset is 'perslice',
8896
+ * in which case it holds one window level per slice.
8897
+ */
8898
+ export declare class WindowPreset {
8899
+ /**
8900
+ * @param {string} name The preset name.
8901
+ * @param {WindowLevel[]} [wl] The list of window levels.
8902
+ * @param {boolean} [perslice] Flag for a per-slice window level list.
8903
+ */
8904
+ constructor(name: string, wl?: WindowLevel[], perslice?: boolean);
8905
+ /**
8906
+ * The preset name.
8907
+ *
8908
+ * @type {string}
8909
+ */
8910
+ name: string;
8911
+ /**
8912
+ * The list of window levels.
8913
+ *
8914
+ * @type {WindowLevel[]|undefined}
8915
+ */
8916
+ wl: WindowLevel[] | undefined;
8917
+ /**
8918
+ * Flag to indicate a per-slice window level list.
8919
+ *
8920
+ * @type {boolean|undefined}
8921
+ */
8922
+ perslice: boolean | undefined;
8923
+ }
8924
+
7148
8925
  /**
7149
8926
  * Writer rule.
7150
8927
  */
7151
8928
  export declare class WriterRule {
7152
8929
  /**
7153
- * @param {string} action The rule action.
8930
+ * @param {string} action The rule action, one of the
8931
+ * `WriterRuleActions` values.
7154
8932
  */
7155
8933
  constructor(action: string);
7156
8934
  /**
7157
- * Rule action: `copy`, `remove`, `clear` or `replace`.
8935
+ * Rule action, one of the `WriterRuleActions` values.
7158
8936
  *
7159
8937
  * @type {string}
7160
8938
  */
7161
8939
  action: string;
7162
8940
  /**
7163
8941
  * Optional value to use for replace action.
8942
+ * A single value or an array of values for multi-valued
8943
+ * elements (for example `['A', 'B']` or a list of sequence items).
7164
8944
  *
7165
8945
  * @type {any|undefined}
7166
8946
  */
7167
8947
  value: any | undefined;
7168
8948
  }
7169
8949
 
8950
+ export declare namespace WriterRuleActions {
8951
+ let copy: string;
8952
+ let remove: string;
8953
+ let clear: string;
8954
+ let replace: string;
8955
+ }
8956
+
7170
8957
  export { }