dwv 0.37.0-beta.2 → 0.37.0-beta.21

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,18 @@ 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 {NumberValue} from '../math/types.js';
15
+ * @import {ViewController} from '../app/viewController.js';
16
+ * @import {PlaneHelper} from './planeHelper.js';
17
+ * @import {DicomCode} from '../dicom/dicomCode.js';
18
+ */
15
19
  /**
16
20
  * Image annotation.
17
21
  */
@@ -29,7 +33,7 @@ export declare class Annotation {
29
33
  */
30
34
  trackingUid: string;
31
35
  /**
32
- * Referenced image SOP isntance UID.
36
+ * Referenced image SOP instance UID.
33
37
  *
34
38
  * @type {string}
35
39
  */
@@ -41,7 +45,9 @@ export declare class Annotation {
41
45
  */
42
46
  referencedSopClassUID: string;
43
47
  /**
44
- * Referenced frame number.
48
+ * Referenced frame number, 1-based as the DICOM
49
+ * Referenced Frame Number: frame number 1 is
50
+ * the first frame (time index 0).
45
51
  *
46
52
  * @type {number|undefined}
47
53
  */
@@ -67,11 +73,9 @@ export declare class Annotation {
67
73
  /**
68
74
  * Annotation quantification.
69
75
  *
70
- * @type {Object<string, Value>|undefined}
76
+ * @type {Record<string, NumberValue>|undefined}
71
77
  */
72
- quantification: {
73
- [x: string]: Value;
74
- } | undefined;
78
+ quantification: Record<string, NumberValue> | undefined;
75
79
  /**
76
80
  * Text expression. Can contain variables surrounded with '{}' that will
77
81
  * be extracted from the quantification object.
@@ -164,15 +168,23 @@ export declare class Annotation {
164
168
  * @returns {Point|undefined} The 3D centroid point.
165
169
  */
166
170
  getCentroid(): Point | undefined;
171
+ /**
172
+ * Check if a plane point is on the annotation math shape,
173
+ * within a tolerance.
174
+ *
175
+ * @param {Point2D} point The plane point to check.
176
+ * @param {number} [tolerance] Optional maximum distance to the shape,
177
+ * defaults to 0.
178
+ * @returns {boolean} True if the point is on the shape.
179
+ */
180
+ contains(point: Point2D, tolerance?: number): boolean;
167
181
  /**
168
182
  * Set the annotation text expression.
169
183
  *
170
- * @param {Object.<string, string>} labelText The list of label
184
+ * @param {Record<string, string>} labelText The list of label
171
185
  * texts indexed by modality.
172
186
  */
173
- setTextExpr(labelText: {
174
- [x: string]: string;
175
- }): void;
187
+ setTextExpr(labelText: Record<string, string>): void;
176
188
  /**
177
189
  * Get the annotation label text by applying the
178
190
  * text expression on the current quantification.
@@ -196,7 +208,7 @@ export declare class Annotation {
196
208
  /**
197
209
  * Annotation group.
198
210
  */
199
- export declare class AnnotationGroup {
211
+ export declare class AnnotationGroup extends EventTarget {
200
212
  /**
201
213
  * @param {Annotation[]} [list] Optional list, will
202
214
  * create new if not provided.
@@ -279,11 +291,9 @@ export declare class AnnotationGroup {
279
291
  /**
280
292
  * Get the meta data.
281
293
  *
282
- * @returns {Object<string, any>} The meta data.
294
+ * @returns {Record<string, any>} The meta data.
283
295
  */
284
- getMeta(): {
285
- [x: string]: any;
286
- };
296
+ getMeta(): Record<string, any>;
287
297
  /**
288
298
  * Check if this list contains a meta data value.
289
299
  *
@@ -305,22 +315,6 @@ export declare class AnnotationGroup {
305
315
  * @param {string|object} value The value of the meta data.
306
316
  */
307
317
  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
318
  #private;
325
319
  }
326
320
 
@@ -338,64 +332,50 @@ export declare class AnnotationGroupFactory {
338
332
  /**
339
333
  * Check dicom elements.
340
334
  *
341
- * @param {Object<string, DataElement>} dataElements The DICOM data elements.
335
+ * @param {Record<string, DataElement>} dataElements The DICOM data elements.
342
336
  * @returns {string|undefined} A possible warning.
343
337
  */
344
- checkElements(dataElements: {
345
- [x: string]: DataElement;
346
- }): string | undefined;
338
+ checkElements(dataElements: Record<string, DataElement>): string | undefined;
347
339
  /**
348
340
  * Get an {@link AnnotationGroup} object from the read DICOM file.
349
341
  *
350
- * @param {Object<string, DataElement>} dataElements The DICOM tags.
342
+ * @param {Record<string, DataElement>} dataElements The DICOM tags.
351
343
  * @returns {AnnotationGroup} A new annotation group.
352
344
  * @throws {Error} Error for missing or wrong data.
353
345
  */
354
- create(dataElements: {
355
- [x: string]: DataElement;
356
- }): AnnotationGroup;
346
+ create(dataElements: Record<string, DataElement>): AnnotationGroup;
357
347
  /**
358
348
  * Get an {@link CADReport} object from the read DICOM file.
359
349
  *
360
- * @param {Object<string, DataElement>} dataElements The DICOM tags.
350
+ * @param {Record<string, DataElement>} dataElements The DICOM tags.
361
351
  * @returns {CADReport|undefined} A new CAD report.
362
352
  */
363
- createCADReport(dataElements: {
364
- [x: string]: DataElement;
365
- }): CADReport | undefined;
353
+ createCADReport(dataElements: Record<string, DataElement>): CADReport | undefined;
366
354
  /**
367
355
  * Convert an annotation group into a DICOM SR object using the
368
356
  * TID 1500 template.
369
357
  *
370
358
  * @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.
359
+ * @param {SimpleTagValues} [extraTags] Optional list of extra tags.
360
+ * @returns {Record<string, DataElement>} A list of dicom elements.
373
361
  */
374
- toDicom(annotationGroup: AnnotationGroup, extraTags?: {
375
- [x: string]: any;
376
- }): {
377
- [x: string]: DataElement;
378
- };
362
+ toDicom(annotationGroup: AnnotationGroup, extraTags?: SimpleTagValues): Record<string, DataElement>;
379
363
  /**
380
364
  * Convert a CAD report into a DICOM CAD report SR object using
381
365
  * the TID 4100 template.
382
366
  *
383
367
  * @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.
368
+ * @param {SimpleTagValues} [extraTags] Optional list of extra tags.
369
+ * @returns {Record<string, DataElement>} A list of dicom elements.
386
370
  */
387
- toDicomCADReport(report: CADReport, extraTags?: {
388
- [x: string]: any;
389
- }): {
390
- [x: string]: DataElement;
391
- };
371
+ toDicomCADReport(report: CADReport, extraTags?: SimpleTagValues): Record<string, DataElement>;
392
372
  #private;
393
373
  }
394
374
 
395
375
  /**
396
376
  * List of ViewConfigs indexed by dataIds.
397
377
  *
398
- * @typedef {Object<string, ViewConfig[]>} DataViewConfigs
378
+ * @typedef {Record<string, ViewConfig[]>} DataViewConfigs
399
379
  */
400
380
  /**
401
381
  * Main application class.
@@ -414,12 +394,19 @@ export declare class AnnotationGroupFactory {
414
394
  * 'https://raw.githubusercontent.com/ivmartel/dwv/master/tests/data/bbmri-53323851.dcm'
415
395
  * ]);
416
396
  */
417
- export declare class App {
397
+ export declare class App extends EventTarget {
398
+ /**
399
+ * Get the data controller.
400
+ *
401
+ * @returns {DataController} The data controller.
402
+ */
403
+ getDataController(): DataController;
418
404
  /**
419
405
  * Get a DicomData.
420
406
  *
421
407
  * @param {string} dataId The data id.
422
408
  * @returns {DicomData|undefined} The data.
409
+ * @deprecated Since v0.37, please use via app.getDataController.
423
410
  */
424
411
  getData(dataId: string): DicomData | undefined;
425
412
  /**
@@ -435,12 +422,14 @@ export declare class App {
435
422
  *
436
423
  * @param {string} dataId The data id.
437
424
  * @param {Image} img The associated image.
425
+ * @deprecated Since v0.37, please use via app.getDataController.
438
426
  */
439
427
  setImage(dataId: string, img: Image_2): void;
440
428
  /**
441
429
  * Get the next data id.
442
430
  *
443
431
  * @returns {string} The data id.
432
+ * @deprecated Since v0.37, please use via app.getDataController.
444
433
  */
445
434
  getNextDataId(): string;
446
435
  /**
@@ -449,21 +438,22 @@ export declare class App {
449
438
  * @param {string} dataId The data id.
450
439
  * @param {DicomData} data The new data.
451
440
  * @returns {boolean} False if the data cannot be added.
441
+ * @deprecated Since v0.37, please use via app.getDataController.
452
442
  */
453
443
  addData(dataId: string, data: DicomData): boolean;
454
444
  /**
455
445
  * Get the meta data.
456
446
  *
457
447
  * @param {string} dataId The data id.
458
- * @returns {Object<string, DataElement>|undefined} The list of meta data.
448
+ * @returns {Record<string, DataElement>|undefined} The list of meta data.
449
+ * @deprecated Since v0.37, please use via app.getDataController.
459
450
  */
460
- getMetaData(dataId: string): {
461
- [x: string]: DataElement;
462
- } | undefined;
451
+ getMetaData(dataId: string): Record<string, DataElement> | undefined;
463
452
  /**
464
453
  * Get the list of ids in the data storage.
465
454
  *
466
455
  * @returns {string[]} The list of data ids.
456
+ * @deprecated Since v0.37, please use via app.getDataController.
467
457
  */
468
458
  getDataIds(): string[];
469
459
  /**
@@ -471,6 +461,7 @@ export declare class App {
471
461
  *
472
462
  * @param {string[]} uids A list of UIDs.
473
463
  * @returns {string[]} The list of dataIds that contain the UIDs.
464
+ * @deprecated Since v0.37, please use via app.getDataController.
474
465
  */
475
466
  getDataIdsFromSopUids(uids: string[]): string[];
476
467
  /**
@@ -478,6 +469,7 @@ export declare class App {
478
469
  *
479
470
  * @param {string} uid The SeriesInstanceUID.
480
471
  * @returns {string} The data id.
472
+ * @deprecated Since v0.37, please use via app.getDataController.
481
473
  */
482
474
  getDataIdFromSeriesUid(uid: string): string;
483
475
  /**
@@ -501,18 +493,21 @@ export declare class App {
501
493
  * Get the active layer group scale on top of the base scale.
502
494
  *
503
495
  * @returns {Scalar3D} The scale as {x,y,z}.
496
+ * @deprecated Since v0.37, please access from the active layer group.
504
497
  */
505
498
  getAddedScale(): Scalar3D;
506
499
  /**
507
500
  * Get the base scale of the active layer group.
508
501
  *
509
502
  * @returns {Scalar3D} The scale as {x,y,z}.
503
+ * @deprecated Since v0.37, please access from the active layer group.
510
504
  */
511
505
  getBaseScale(): Scalar3D;
512
506
  /**
513
507
  * Get the layer offset of the active layer group.
514
508
  *
515
509
  * @returns {Scalar3D} The offset as {x,y,z}.
510
+ * @deprecated Since v0.37, please access from the active layer group.
516
511
  */
517
512
  getOffset(): Scalar3D;
518
513
  /**
@@ -521,17 +516,33 @@ export declare class App {
521
516
  * @returns {ToolboxController} The controller.
522
517
  */
523
518
  getToolboxController(): ToolboxController;
519
+ /**
520
+ * Get the stage controller.
521
+ *
522
+ * @returns {StageController} The stage controller.
523
+ */
524
+ getStageController(): StageController;
525
+ /**
526
+ * Get the undo controller.
527
+ *
528
+ * @returns {UndoController} The undo controller.
529
+ */
530
+ getUndoController(): UndoController;
524
531
  /**
525
532
  * Get the active layer group.
526
533
  * The layer is available after the first loaded item.
527
534
  *
528
535
  * @returns {LayerGroup|undefined} The layer group.
536
+ * @deprecated Since v0.37, use
537
+ * `app.getStageController().getActiveLayerGroup()` instead.
529
538
  */
530
539
  getActiveLayerGroup(): LayerGroup | undefined;
531
540
  /**
532
541
  * Set the active layer group.
533
542
  *
534
543
  * @param {number} index The layer group index.
544
+ * @deprecated Since v0.37, use
545
+ * `app.getStageController().setActiveLayerGroup()` instead.
535
546
  */
536
547
  setActiveLayerGroup(index: number): void;
537
548
  /**
@@ -540,6 +551,8 @@ export declare class App {
540
551
  *
541
552
  * @param {string} dataId The data id.
542
553
  * @returns {ViewLayer[]} The layers.
554
+ * @deprecated Since v0.37, use
555
+ * `app.getStageController().getViewLayersByDataId()` instead.
543
556
  */
544
557
  getViewLayersByDataId(dataId: string): ViewLayer[];
545
558
  /**
@@ -550,6 +563,8 @@ export declare class App {
550
563
  * returns all view layers.
551
564
  * @returns {ViewLayer[]} The layers that
552
565
  * satisfy the callbackFn.
566
+ * @deprecated Since v0.37, use
567
+ * `app.getStageController().getViewLayers()` instead.
553
568
  */
554
569
  getViewLayers(callbackFn?: Function): ViewLayer[];
555
570
  /**
@@ -558,6 +573,8 @@ export declare class App {
558
573
  *
559
574
  * @param {string} dataId The data id.
560
575
  * @returns {DrawLayer[]} The layers.
576
+ * @deprecated Since v0.37, use
577
+ * `app.getStageController().getDrawLayersByDataId()` instead.
561
578
  */
562
579
  getDrawLayersByDataId(dataId: string): DrawLayer[];
563
580
  /**
@@ -568,6 +585,8 @@ export declare class App {
568
585
  * returns all draw layers.
569
586
  * @returns {DrawLayer[]} The layers that
570
587
  * satisfy the callbackFn.
588
+ * @deprecated Since v0.37, use
589
+ * `app.getStageController().getDrawLayers()` instead.
571
590
  */
572
591
  getDrawLayers(callbackFn?: Function): DrawLayer[];
573
592
  /**
@@ -576,12 +595,16 @@ export declare class App {
576
595
  *
577
596
  * @param {string} divId The div id.
578
597
  * @returns {LayerGroup|undefined} The layer group.
598
+ * @deprecated Since v0.37, use
599
+ * `app.getStageController().getLayerGroupByDivId()` instead.
579
600
  */
580
601
  getLayerGroupByDivId(divId: string): LayerGroup | undefined;
581
602
  /**
582
603
  * Get the number of layer groups.
583
604
  *
584
605
  * @returns {number} The number of groups.
606
+ * @deprecated Since v0.37, use
607
+ * `app.getStageController().getNumberOfLayerGroups()` instead.
585
608
  */
586
609
  getNumberOfLayerGroups(): number;
587
610
  /**
@@ -595,6 +618,7 @@ export declare class App {
595
618
  *
596
619
  * @param {Command} cmd The command to add.
597
620
  * @fires UndoStack#undoadd
621
+ * @deprecated Since v0.37, please use via app.getUndoController.
598
622
  * @function
599
623
  */
600
624
  addToUndoStack: (cmd: Command) => void;
@@ -604,6 +628,7 @@ export declare class App {
604
628
  * @param {string} name The name of the command to remove.
605
629
  * @returns {boolean} True if the command was found and removed.
606
630
  * @fires UndoStack#undoremove
631
+ * @deprecated Since v0.37, please use via app.getUndoController.
607
632
  * @function
608
633
  */
609
634
  removeFromUndoStack: (name: string) => boolean;
@@ -632,7 +657,7 @@ export declare class App {
632
657
  * button.disabled = false;
633
658
  * button.onclick = function () {
634
659
  * // render data #0
635
- * app.render(0);
660
+ * app.getStageController().render(0);
636
661
  * };
637
662
  * });
638
663
  * // load dicom data
@@ -653,30 +678,108 @@ export declare class App {
653
678
  resetLayout(): void;
654
679
  /**
655
680
  * Reset the zoom and pan of the stage.
681
+ *
682
+ * @deprecated Since v0.37, use
683
+ * `app.getStageController().resetZoomPan()` instead.
656
684
  */
657
685
  resetZoomPan(): void;
658
686
  /**
659
687
  * Reset the position and window level of the stage.
688
+ *
689
+ * @deprecated Since v0.37, use
690
+ * `app.getStageController().resetViews()` instead.
660
691
  */
661
692
  resetViews(): void;
662
693
  /**
663
- * Add an event listener to this class.
694
+ * Load start event.
664
695
  *
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.
696
+ * @event App#loadstart
697
+ * @type {CustomEvent}
698
+ * @property {object} detail The event detail.
699
+ * @property {string} detail.dataid The data id.
700
+ * @property {*} detail.source The load source: string for an url,
701
+ * File for a file.
668
702
  */
669
- addEventListener(type: string, callback: Function): void;
670
703
  /**
671
- * Remove an event listener from this class.
704
+ * Load progress event.
672
705
  *
673
- * @param {string} type The event type.
674
- * @param {Function} callback The function associated with the provided
675
- * event type.
706
+ * @event App#loadprogress
707
+ * @type {CustomEvent}
708
+ * @property {object} detail The event detail.
709
+ * @property {string} detail.dataid The data id.
710
+ * @property {*} detail.source The load source: string for an url,
711
+ * File for a file.
712
+ * @property {number} detail.loaded The loaded percentage.
713
+ * @property {number} detail.total The total percentage.
714
+ */
715
+ /**
716
+ * Load item event: fired when an item has been successfully loaded.
717
+ *
718
+ * @event App#loaditem
719
+ * @type {CustomEvent}
720
+ * @property {object} detail The event detail.
721
+ * @property {string} detail.dataid The data id.
722
+ * @property {*} detail.source The load source: string for an url,
723
+ * File for a file.
724
+ * @property {object} detail.data The loaded meta data.
725
+ * @property {boolean} detail.isfirstitem True if the item is the first
726
+ * one loaded for the data id.
727
+ */
728
+ /**
729
+ * Load event: fired when a load finishes successfully.
730
+ *
731
+ * @event App#load
732
+ * @type {CustomEvent}
733
+ * @property {object} detail The event detail.
734
+ * @property {string} detail.dataid The data id.
735
+ * @property {*} detail.source The load source: string for an url,
736
+ * File for a file.
737
+ */
738
+ /**
739
+ * Load end event: fired when the load finishes,
740
+ * successfully or not.
741
+ *
742
+ * @event App#loadend
743
+ * @type {CustomEvent}
744
+ * @property {object} detail The event detail.
745
+ * @property {string} detail.dataid The data id.
746
+ * @property {*} detail.source The load source: string for an url,
747
+ * File for a file.
748
+ */
749
+ /**
750
+ * Load error event.
751
+ *
752
+ * @event App#error
753
+ * @type {CustomEvent}
754
+ * @property {object} detail The event detail.
755
+ * @property {string} detail.dataid The data id.
756
+ * @property {*} detail.source The load source: string for an url,
757
+ * File for a file.
758
+ * @property {object} detail.error The error.
759
+ * @property {object} detail.target The event target.
760
+ */
761
+ /**
762
+ * Load timeout event.
763
+ *
764
+ * @event App#timeout
765
+ * @type {CustomEvent}
766
+ * @property {object} detail The event detail.
767
+ * @property {string} detail.dataid The data id.
768
+ * @property {*} detail.source The load source: an url as a string.
769
+ * @property {object} detail.target The event target.
770
+ */
771
+ /**
772
+ * Load abort event.
773
+ *
774
+ * @event App#abort
775
+ * @type {CustomEvent}
776
+ * @property {object} detail The event detail.
777
+ * @property {string} detail.dataid The data id.
778
+ * @property {*} detail.source The load source: string for an url,
779
+ * File for a file.
676
780
  */
677
- removeEventListener(type: string, callback: Function): void;
678
781
  /**
679
- * Load a list of files. Can be image files or a state file.
782
+ * Load a list of image files.
680
783
  *
681
784
  * @param {File[]} files The list of files to load.
682
785
  * @returns {string} The data ID, '-1' if problem.
@@ -690,7 +793,7 @@ export declare class App {
690
793
  */
691
794
  loadFiles: (files: File[]) => string;
692
795
  /**
693
- * Load a list of URLs. Can be image files or a state file.
796
+ * Load a list of image URLs.
694
797
  *
695
798
  * @param {string[]} urls The list of urls to load.
696
799
  * @param {object} [options] The options object, can contain:
@@ -745,6 +848,9 @@ export declare class App {
745
848
  /**
746
849
  * Fit the display to the data of each layer group.
747
850
  * To be called once the image is loaded.
851
+ *
852
+ * @deprecated Since v0.37, use
853
+ * `app.getStageController().fitToContainer()` instead.
748
854
  */
749
855
  fitToContainer(): void;
750
856
  /**
@@ -759,6 +865,8 @@ export declare class App {
759
865
  * Set the imageSmoothing flag value. Default is false.
760
866
  *
761
867
  * @param {boolean} flag True to enable smoothing.
868
+ * @deprecated Since v0.37, use
869
+ * `app.getStageController().setImageSmoothing()` instead.
762
870
  */
763
871
  setImageSmoothing(flag: boolean): void;
764
872
  /**
@@ -768,37 +876,40 @@ export declare class App {
768
876
  * @param {boolean} [excludeStarConfig] Exclude the star config
769
877
  * (default to false).
770
878
  * @returns {ViewConfig[]} The list of associated configs.
879
+ * @deprecated Since v0.37, use
880
+ * `app.getStageController().getViewConfigs()` instead.
771
881
  */
772
882
  getViewConfigs(dataId: string, excludeStarConfig?: boolean): ViewConfig[];
773
883
  /**
774
- * Get the layer group configuration for a data id and group
775
- * div id.
884
+ * Get the layer group configuration for a data id and group div id.
776
885
  *
777
886
  * @param {string} dataId The data id.
778
887
  * @param {string} groupDivId The layer group div id.
779
888
  * @param {boolean} [excludeStarConfig] Exclude the star config
780
889
  * (default to false).
781
890
  * @returns {ViewConfig|undefined} The associated config.
891
+ * @deprecated Since v0.37, use
892
+ * `app.getStageController().getViewConfig()` instead.
782
893
  */
783
894
  getViewConfig(dataId: string, groupDivId: string, excludeStarConfig?: boolean): ViewConfig | undefined;
784
895
  /**
785
896
  * Get the data view config.
786
- * Carefull, returns a reference, do not modify without resetting.
897
+ * Careful, returns a reference; do not modify without resetting.
787
898
  *
788
- * @returns {Object<string, ViewConfig[]>} The configuration list.
899
+ * @returns {Record<string, ViewConfig[]>} The configuration list.
900
+ * @deprecated Since v0.37, use
901
+ * `app.getStageController().getDataViewConfigs()` instead.
789
902
  */
790
- getDataViewConfigs(): {
791
- [x: string]: ViewConfig[];
792
- };
903
+ getDataViewConfigs(): Record<string, ViewConfig[]>;
793
904
  /**
794
905
  * Set the data view configuration.
795
906
  * Resets the stage and recreates all the views.
796
907
  *
797
- * @param {Object<string, ViewConfig[]>} configs The configuration list.
908
+ * @param {Record<string, ViewConfig[]>} configs The configuration list.
909
+ * @deprecated Since v0.37, use
910
+ * `app.getStageController().setDataViewConfigs()` instead.
798
911
  */
799
- setDataViewConfigs(configs: {
800
- [x: string]: ViewConfig[];
801
- }): void;
912
+ setDataViewConfigs(configs: Record<string, ViewConfig[]>): void;
802
913
  /**
803
914
  * Add a data view config.
804
915
  *
@@ -806,6 +917,8 @@ export declare class App {
806
917
  * @param {ViewConfig} config The view configuration.
807
918
  * @param {boolean} [doRender] Render data after configuration
808
919
  * add. Defaults to true.
920
+ * @deprecated Since v0.37, use
921
+ * `app.getStageController().addDataViewConfig()` instead.
809
922
  */
810
923
  addDataViewConfig(dataId: string, config: ViewConfig, doRender?: boolean): void;
811
924
  /**
@@ -815,6 +928,8 @@ export declare class App {
815
928
  *
816
929
  * @param {string} dataId The data id.
817
930
  * @param {string} divId The div id.
931
+ * @deprecated Since v0.37, use
932
+ * `app.getStageController().removeDataViewConfig()` instead.
818
933
  */
819
934
  removeDataViewConfig(dataId: string, divId: string): void;
820
935
  /**
@@ -824,6 +939,8 @@ export declare class App {
824
939
  * @param {string} dataId The data id.
825
940
  * @param {string} divId The div id.
826
941
  * @param {ViewConfig} config The view configuration.
942
+ * @deprecated Since v0.37, use
943
+ * `app.getStageController().updateDataViewConfig()` instead.
827
944
  */
828
945
  updateDataViewConfig(dataId: string, divId: string, config: ViewConfig): void;
829
946
  /**
@@ -837,6 +954,8 @@ export declare class App {
837
954
  *
838
955
  * @param {string} dataId The data id to render.
839
956
  * @param {ViewConfig[]} [viewConfigs] The list of configs to render.
957
+ * @deprecated Since v0.37, use
958
+ * `app.getStageController().render()` instead.
840
959
  */
841
960
  render(dataId: string, viewConfigs?: ViewConfig[]): void;
842
961
  /**
@@ -845,6 +964,7 @@ export declare class App {
845
964
  * @param {number} step The step to add to the current zoom.
846
965
  * @param {number} cx The zoom center X coordinate.
847
966
  * @param {number} cy The zoom center Y coordinate.
967
+ * @deprecated Since v0.37, please access from the active layer group.
848
968
  */
849
969
  zoom(step: number, cx: number, cy: number): void;
850
970
  /**
@@ -852,6 +972,7 @@ export declare class App {
852
972
  *
853
973
  * @param {number} tx The translation along X.
854
974
  * @param {number} ty The translation along Y.
975
+ * @deprecated Since v0.37, please access from the active layer group.
855
976
  */
856
977
  translate(tx: number, ty: number): void;
857
978
  /**
@@ -883,24 +1004,6 @@ export declare class App {
883
1004
  * of the desired view layer directly.
884
1005
  */
885
1006
  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
1007
  /**
905
1008
  * Handle resize: fit the display to the window.
906
1009
  * To be called once the image is loaded.
@@ -912,11 +1015,12 @@ export declare class App {
912
1015
  /**
913
1016
  * Key down callback. Meant to be used in tools.
914
1017
  *
915
- * @param {KeyboardEvent} event The key down event.
1018
+ * @param {object} event The KeyboardEvent down event
1019
+ * augmented with a context.
916
1020
  * @fires App#keydown
917
1021
  * @function
918
1022
  */
919
- onKeydown: (event: KeyboardEvent) => void;
1023
+ onKeydown: (event: object) => void;
920
1024
  /**
921
1025
  * Key down event handler example.
922
1026
  * - CRTL-Z: undo,
@@ -974,24 +1078,28 @@ export declare class App {
974
1078
  * Undo the last action.
975
1079
  *
976
1080
  * @fires UndoStack#undo
1081
+ * @deprecated Since v0.37, please use via app.getUndoController.
977
1082
  */
978
1083
  undo(): void;
979
1084
  /**
980
1085
  * Redo the last action.
981
1086
  *
982
1087
  * @fires UndoStack#redo
1088
+ * @deprecated Since v0.37, please use via app.getUndoController.
983
1089
  */
984
1090
  redo(): void;
985
1091
  /**
986
1092
  * Get the undo stack size.
987
1093
  *
988
1094
  * @returns {number} The size of the stack.
1095
+ * @deprecated Since v0.37, please use via app.getUndoController.
989
1096
  */
990
1097
  getStackSize(): number;
991
1098
  /**
992
1099
  * Get the current undo stack index.
993
1100
  *
994
1101
  * @returns {number} The stack index.
1102
+ * @deprecated Since v0.37, please use via app.getUndoController.
995
1103
  */
996
1104
  getCurrentStackIndex(): number;
997
1105
  /**
@@ -1023,13 +1131,6 @@ export declare class App {
1023
1131
  * @param {string} refDataId The reference data id.
1024
1132
  */
1025
1133
  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
1134
  #private;
1034
1135
  }
1035
1136
 
@@ -1038,28 +1139,22 @@ export declare class App {
1038
1139
  */
1039
1140
  export declare class AppOptions {
1040
1141
  /**
1041
- * @param {Object<string, ViewConfig[]>} [dataViewConfigs] Optional dataId
1142
+ * @param {Record<string, ViewConfig[]>} [dataViewConfigs] Optional dataId
1042
1143
  * indexed object containing the data view configurations.
1043
1144
  */
1044
- constructor(dataViewConfigs?: {
1045
- [x: string]: ViewConfig[];
1046
- });
1145
+ constructor(dataViewConfigs?: Record<string, ViewConfig[]>);
1047
1146
  /**
1048
1147
  * DataId indexed object containing the data view configurations.
1049
1148
  *
1050
- * @type {Object<string, ViewConfig[]>|undefined}
1149
+ * @type {Record<string, ViewConfig[]>|undefined}
1051
1150
  */
1052
- dataViewConfigs: {
1053
- [x: string]: ViewConfig[];
1054
- } | undefined;
1151
+ dataViewConfigs: Record<string, ViewConfig[]> | undefined;
1055
1152
  /**
1056
1153
  * Tool name indexed object containing individual tool configurations.
1057
1154
  *
1058
- * @type {Object<string, ToolConfig>|undefined}
1155
+ * @type {Record<string, ToolConfig>|undefined}
1059
1156
  */
1060
- tools: {
1061
- [x: string]: ToolConfig;
1062
- } | undefined;
1157
+ tools: Record<string, ToolConfig> | undefined;
1063
1158
  /**
1064
1159
  * Optional array of layerGroup binder names.
1065
1160
  *
@@ -1114,6 +1209,23 @@ export declare class BooleanResult {
1114
1209
  message: string | undefined;
1115
1210
  }
1116
1211
 
1212
+ /**
1213
+ * Extract polygon contours from a mask slice using Moore neighborhood tracing.
1214
+ * Returns one polygon per connected region with the given segment value.
1215
+ *
1216
+ * @param {Uint8Array} buffer The mask buffer (all slices).
1217
+ * @param {number} sliceOffset Byte offset of the slice in buffer.
1218
+ * @param {number} width Slice width in pixels.
1219
+ * @param {number} height Slice height in pixels.
1220
+ * @param {number} value Segment value to trace.
1221
+ * @returns {Array.<Array.<{x: number, y: number}>>} One polygon per
1222
+ * connected region.
1223
+ */
1224
+ export declare function bufferToPolygons(buffer: Uint8Array, sliceOffset: number, width: number, height: number, value: number): Array<Array<{
1225
+ x: number;
1226
+ y: number;
1227
+ }>>;
1228
+
1117
1229
  /**
1118
1230
  * Build a multipart message.
1119
1231
  *
@@ -1146,17 +1258,22 @@ export declare class CADReport {
1146
1258
  comment: string;
1147
1259
  }
1148
1260
 
1261
+ /**
1262
+ * @import {MaskImage} from '../image/maskImage.js';
1263
+ * @import {MaskSegment} from '../dicom/dicomSegment.js';
1264
+ * @import {RGB} from '../utils/colour.js';
1265
+ */
1149
1266
  /**
1150
1267
  * Change segment colour command.
1151
1268
  */
1152
1269
  export declare class ChangeSegmentColourCommand extends Command {
1153
1270
  /**
1154
- * @param {Image} mask The mask image.
1271
+ * @param {MaskImage} mask The mask image.
1155
1272
  * @param {MaskSegment} segment The segment to modify.
1156
1273
  * @param {RGB|number} newColour The new segment colour.
1157
1274
  * @param {boolean} [silent] Whether to send a creation event or not.
1158
1275
  */
1159
- constructor(mask: Image_2, segment: MaskSegment, newColour: RGB | number, silent?: boolean);
1276
+ constructor(mask: MaskImage, segment: MaskSegment, newColour: RGB | number, silent?: boolean);
1160
1277
  /**
1161
1278
  * Check if a command is valid and can be executed.
1162
1279
  *
@@ -1206,6 +1323,16 @@ export declare class Circle {
1206
1323
  * @returns {number} The radius of the circle.
1207
1324
  */
1208
1325
  getRadius(): number;
1326
+ /**
1327
+ * Check if a point is inside the circle, or within a tolerance
1328
+ * of its outline.
1329
+ *
1330
+ * @param {Point2D} point The point to check.
1331
+ * @param {number} [tolerance] Optional maximum distance to the outline
1332
+ * for an outside point, defaults to 0.
1333
+ * @returns {boolean} True if the point is in the circle.
1334
+ */
1335
+ contains(point: Point2D, tolerance?: number): boolean;
1209
1336
  /**
1210
1337
  * Check for equality.
1211
1338
  *
@@ -1247,11 +1374,9 @@ export declare class Circle {
1247
1374
  * @param {Index} index The index at which to get the
1248
1375
  * image values.
1249
1376
  * @param {string[]} flags A list of stat values to calculate.
1250
- * @returns {Object<string, Value>} A quantification object.
1377
+ * @returns {Record<string, NumberValue>} A quantification object.
1251
1378
  */
1252
- quantify(viewController: ViewController, index: Index, flags: string[]): {
1253
- [x: string]: Value;
1254
- };
1379
+ quantify(viewController: ViewController, index: Index, flags: string[]): Record<string, NumberValue>;
1255
1380
  #private;
1256
1381
  }
1257
1382
 
@@ -1306,55 +1431,128 @@ export declare class Command {
1306
1431
  undo(): void;
1307
1432
  }
1308
1433
 
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
1434
  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[];
1435
+ let wlPresets: Record<string, Record<string, WindowLevel>>;
1436
+ let labelTexts: Record<string, Record<string, string>>;
1437
+ let privateBValueRules: PrivateBValueRule[];
1352
1438
  let openRoiDialog: any;
1439
+ let highlightAnnotation: any;
1440
+ let highlightSegment: any;
1353
1441
  let getVolumeIdTagValue: any;
1354
1442
  let getPostLoadVolumeIdTagValue: any;
1443
+ let volumeIdCandidates: VolumeIdCandidate[];
1355
1444
  let getTagPixelUnit: any;
1356
1445
  }
1357
1446
 
1447
+ /**
1448
+ * DicomData controller.
1449
+ */
1450
+ export declare class DataController extends EventTarget {
1451
+ /**
1452
+ * Get the next data id.
1453
+ *
1454
+ * @returns {string} The data id.
1455
+ */
1456
+ getNextDataId(): string;
1457
+ /**
1458
+ * Get the list of ids in the data storage.
1459
+ *
1460
+ * @returns {string[]} The list of data ids.
1461
+ */
1462
+ getDataIds(): string[];
1463
+ /**
1464
+ * Reset the class: empty the data storage.
1465
+ */
1466
+ reset(): void;
1467
+ /**
1468
+ * Get a data at a given index.
1469
+ *
1470
+ * @param {string} dataId The data id.
1471
+ * @returns {DicomData|undefined} The DICOM data.
1472
+ */
1473
+ get(dataId: string): DicomData | undefined;
1474
+ /**
1475
+ * Get the list of dataIds that contain the input UIDs.
1476
+ *
1477
+ * @param {string[]} uids A list of UIDs.
1478
+ * @returns {string[]} The list of dataIds that contain the UIDs.
1479
+ */
1480
+ getDataIdsFromSopUids(uids: string[]): string[];
1481
+ /**
1482
+ * Get the first data id with the given SeriesInstanceUID.
1483
+ *
1484
+ * @param {string} uid The SeriesInstanceUID.
1485
+ * @returns {string} The data id.
1486
+ */
1487
+ getDataIdFromSeriesUid(uid: string): string;
1488
+ /**
1489
+ * Set the image at a given index.
1490
+ *
1491
+ * @param {string} dataId The data id.
1492
+ * @param {Image} image The image to set.
1493
+ */
1494
+ setImage(dataId: string, image: Image_2): void;
1495
+ /**
1496
+ * Add a new data.
1497
+ *
1498
+ * @param {string} dataId The data id.
1499
+ * @param {DicomData} data The data.
1500
+ * @returns {boolean} False if the data cannot be added.
1501
+ */
1502
+ add(dataId: string, data: DicomData): boolean;
1503
+ /**
1504
+ * Remove a data from the list.
1505
+ *
1506
+ * @param {string} dataId The data id.
1507
+ */
1508
+ remove(dataId: string): void;
1509
+ /**
1510
+ * Stash a data from the list.
1511
+ *
1512
+ * @param {string} dataId The data id.
1513
+ */
1514
+ stash(dataId: string): void;
1515
+ /**
1516
+ * Unstash a data from the list.
1517
+ *
1518
+ * @param {string} dataId The data id.
1519
+ */
1520
+ unstash(dataId: string): void;
1521
+ /**
1522
+ * Get the list of ids in the stashed data storage.
1523
+ *
1524
+ * @returns {string[]} The list of data ids.
1525
+ */
1526
+ getStashedDataIds(): string[];
1527
+ /**
1528
+ * Get a stashed data at a given index.
1529
+ *
1530
+ * @param {string} dataId The data id.
1531
+ * @returns {DicomData|undefined} The DICOM data.
1532
+ */
1533
+ getStashed(dataId: string): DicomData | undefined;
1534
+ /**
1535
+ * Update the current data.
1536
+ *
1537
+ * @param {string} dataId The data id.
1538
+ * @param {DicomData} data The data.
1539
+ */
1540
+ update(dataId: string, data: DicomData): void;
1541
+ /**
1542
+ * Mark a data a complete (fully loaded).
1543
+ *
1544
+ * @param {string} dataId The data id.
1545
+ * @returns {{imageHasChanged}} An object with an imageHasChanged property.
1546
+ */
1547
+ markDataAsComplete(dataId: string): {
1548
+ imageHasChanged: any;
1549
+ };
1550
+ #private;
1551
+ }
1552
+
1553
+ /**
1554
+ * @import {Tag} from './dicomTag.js';
1555
+ */
1358
1556
  /**
1359
1557
  * DICOM data element.
1360
1558
  */
@@ -1413,36 +1611,61 @@ export declare class DataElement {
1413
1611
  items: any[];
1414
1612
  }
1415
1613
 
1614
+ /**
1615
+ * Default private b-value tag rules. Tested in order.
1616
+ * Rules are either `{manufacturer, key}` or `{uidPrefix, key}`.
1617
+ * Can be used to extend `custom.privateBValueRules`.
1618
+ *
1619
+ * @type {PrivateBValueRule[]}
1620
+ */
1621
+ export declare const defaultPrivateBValueRules: PrivateBValueRule[];
1622
+
1416
1623
  /**
1417
1624
  * Default tool list.
1418
1625
  *
1419
- * @type {Object<string, any>}
1626
+ * @type {Record<string, any>}
1420
1627
  */
1421
- export declare const defaultToolList: {
1422
- [x: string]: any;
1423
- };
1628
+ export declare const defaultToolList: Record<string, any>;
1424
1629
 
1425
1630
  /**
1426
1631
  * Default tool options.
1427
1632
  *
1428
- * @type {Object<string, Object<string, any>>}
1633
+ * @type {Record<string, Record<string, any>>}
1429
1634
  */
1430
- export declare const defaultToolOptions: {
1431
- [x: string]: {
1432
- [x: string]: any;
1433
- };
1434
- };
1635
+ export declare const defaultToolOptions: Record<string, Record<string, any>>;
1636
+
1637
+ /**
1638
+ * Ordered list of candidate volume id getters. Since the tag that
1639
+ * actually discriminates volumes is not known until the full data
1640
+ * is loaded, `guessVolumeIndices` tries these in order and keeps the
1641
+ * first one that produces a valid, consistent per-volume grouping.
1642
+ * It is used for the files of a series (see `DicomSliceDataList`)
1643
+ * and for the frames of a multi-frame file (see
1644
+ * `getSortedFramesGeometry`).
1645
+ * Most explicit/reliable discriminators come first, AcquisitionTime
1646
+ * (the historical default) comes last.
1647
+ * Candidates flagged with `preLoad` are also used while loading
1648
+ * (see `getVolumeIdTagValue`): they must not vary between the
1649
+ * slices of a single volume.
1650
+ *
1651
+ * @type {VolumeIdCandidate[]}
1652
+ */
1653
+ export declare const defaultVolumeIdCandidates: VolumeIdCandidate[];
1435
1654
 
1655
+ /**
1656
+ * @import {MaskImage} from '../image/maskImage.js';
1657
+ * @import {MaskSegment} from '../dicom/dicomSegment.js';
1658
+ */
1436
1659
  /**
1437
1660
  * Delete segment command.
1438
1661
  */
1439
1662
  export declare class DeleteSegmentCommand extends Command {
1440
1663
  /**
1441
- * @param {Image} mask The mask image.
1664
+ * @param {MaskImage} mask The mask image.
1442
1665
  * @param {MaskSegment} segment The segment to remove.
1443
1666
  * @param {boolean} [silent] Whether to send a creation event or not.
1444
1667
  */
1445
- constructor(mask: Image_2, segment: MaskSegment, silent?: boolean);
1668
+ constructor(mask: MaskImage, segment: MaskSegment, silent?: boolean);
1446
1669
  /**
1447
1670
  * Check if a command is valid and can be executed.
1448
1671
  *
@@ -1464,6 +1687,45 @@ export declare class DeleteSegmentCommand extends Command {
1464
1687
  #private;
1465
1688
  }
1466
1689
 
1690
+ /**
1691
+ * Demo Image creation from DICOM elements: takes
1692
+ * elements and first element of the pixel buffer
1693
+ * to create an image.
1694
+ *
1695
+ * Warning: not to be used in production code.
1696
+ *
1697
+ * @param {Record<string, DataElement>} elements The DICOM elements.
1698
+ * @returns {Image} The Image object.
1699
+ */
1700
+ export declare function demoCreateImage(elements: Record<string, DataElement>): Image_2;
1701
+
1702
+ /**
1703
+ * Demo mask Image creation from DICOM elements: takes
1704
+ * elements and first element of the pixel buffer
1705
+ * to create an image.
1706
+ *
1707
+ * Warning: not to be used in production code.
1708
+ *
1709
+ * @param {Record<string, DataElement>} elements The DICOM elements.
1710
+ * @returns {MaskImage} The mask Image object.
1711
+ */
1712
+ export declare function demoCreateMaskImage(elements: Record<string, DataElement>): MaskImage;
1713
+
1714
+ /**
1715
+ * Demo View creation from DICOM elements and image.
1716
+ *
1717
+ * Warning: not to be used in production code.
1718
+ *
1719
+ * @param {Record<string, DataElement>} elements The DICOM elements.
1720
+ * @param {Image} image The associated image.
1721
+ * @returns {View} The View object.
1722
+ */
1723
+ export declare function demoCreateView(elements: Record<string, DataElement>, image: Image_2): View;
1724
+
1725
+ /**
1726
+ * @import {Point} from '../math/point.js';
1727
+ * @import {NumberValue} from '../math/types.js';
1728
+ */
1467
1729
  /**
1468
1730
  * Diameter type.
1469
1731
  */
@@ -1471,9 +1733,9 @@ export declare class Diameter {
1471
1733
  /**
1472
1734
  * The scaled diameter value.
1473
1735
  *
1474
- * @type {Value}
1736
+ * @type {NumberValue}
1475
1737
  */
1476
- diameter: Value;
1738
+ diameter: NumberValue;
1477
1739
  /**
1478
1740
  * The offset of the pixel at the start
1479
1741
  * of the line used to calculate this diameter.
@@ -1561,19 +1823,15 @@ export declare class DicomCode {
1561
1823
  */
1562
1824
  export declare class DicomData {
1563
1825
  /**
1564
- * @param {Object<string, DataElement>} meta The DICOM meta data.
1826
+ * @param {Record<string, DataElement>} meta The DICOM meta data.
1565
1827
  */
1566
- constructor(meta: {
1567
- [x: string]: DataElement;
1568
- });
1828
+ constructor(meta: Record<string, DataElement>);
1569
1829
  /**
1570
1830
  * DICOM meta data.
1571
1831
  *
1572
- * @type {Object<string, DataElement>}
1832
+ * @type {Record<string, DataElement>}
1573
1833
  */
1574
- meta: {
1575
- [x: string]: DataElement;
1576
- };
1834
+ meta: Record<string, DataElement>;
1577
1835
  /**
1578
1836
  * Image extracted from meta data.
1579
1837
  *
@@ -1581,7 +1839,7 @@ export declare class DicomData {
1581
1839
  */
1582
1840
  image: Image_2 | undefined;
1583
1841
  /**
1584
- * Annotattion group extracted from meta data.
1842
+ * Annotation group extracted from meta data.
1585
1843
  *
1586
1844
  * @type {AnnotationGroup|undefined}
1587
1845
  */
@@ -1593,11 +1851,20 @@ export declare class DicomData {
1593
1851
  */
1594
1852
  buffer: any | undefined;
1595
1853
  /**
1596
- * Number of files/urls associated to the data.
1854
+ * Number of load items (files, urls, buffers...) associated
1855
+ * to the data.
1597
1856
  *
1598
1857
  * @type {number}
1599
1858
  */
1600
- numberOfFiles: number;
1859
+ numberOfItems: number;
1860
+ /**
1861
+ * Frame number, set when the buffer only contains one frame
1862
+ * of a multi-frame data: frames are sent one by one and assembled
1863
+ * by the image (see Image.appendSlice).
1864
+ *
1865
+ * @type {number|undefined}
1866
+ */
1867
+ frameNumber: number | undefined;
1601
1868
  /**
1602
1869
  * List of data creation warning.
1603
1870
  *
@@ -1623,7 +1890,7 @@ export declare class DicomData {
1623
1890
  */
1624
1891
  hasDuplicateOrigin(): boolean;
1625
1892
  /**
1626
- * Append slice and update meta data.
1893
+ * Append data and update meta data.
1627
1894
  *
1628
1895
  * @param {DicomData} data The data to append.
1629
1896
  */
@@ -1680,11 +1947,9 @@ export declare class DicomParser {
1680
1947
  /**
1681
1948
  * Get the DICOM data elements.
1682
1949
  *
1683
- * @returns {Object<string, DataElement>} The data elements.
1950
+ * @returns {Record<string, DataElement>} The data elements.
1684
1951
  */
1685
- getDicomElements(): {
1686
- [x: string]: DataElement;
1687
- };
1952
+ getDicomElements(): Record<string, DataElement>;
1688
1953
  /**
1689
1954
  * Safely get an elements' first value from the parsed elements.
1690
1955
  *
@@ -1806,29 +2071,55 @@ export declare class DicomWriter {
1806
2071
  * @param {boolean} flag True to activate the check and fix.
1807
2072
  */
1808
2073
  setFixUnknownVR(flag: boolean): void;
2074
+ /**
2075
+ * Set the list of private tags (odd group number) to write.
2076
+ * All other private tags are not written, including the ones
2077
+ * in sequence items. Takes precedence over the writing rules,
2078
+ * whitelisted tags still go through them.
2079
+ * The private creator of each whitelisted tag is also kept:
2080
+ * for example, whitelisting '0019100C' also keeps '00190010'.
2081
+ * Use an empty list to remove all private tags and undefined
2082
+ * to keep them all (default).
2083
+ *
2084
+ * @param {string[]|undefined} keys The list of private tag keys
2085
+ * (as '########').
2086
+ */
2087
+ setPrivateTagsWhitelist(keys: string[] | undefined): void;
1809
2088
  /**
1810
2089
  * Set the writing rules.
1811
2090
  * List of writer rules indexed by either `default`,
1812
- * tagKey, tagName or groupName.
2091
+ * tag key (for example '00100010') or group key (for example '0010').
2092
+ * Keys can be ranges using 'x' as any hex digit, as in the DICOM
2093
+ * standard repeating groups notation: for example '60xx3000'
2094
+ * (tag range) or '50xx' (group range). Note that 'x' matches any
2095
+ * hex digit: '60xx' also matches odd (private) groups.
1813
2096
  * 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.
2097
+ * First checked by tag key, tag range, group key and then group range,
2098
+ * if nothing is found the default rule is applied. If several ranges
2099
+ * match, the most specific one (with less 'x') is used, and, for same
2100
+ * specificity, the first one in the rules order.
2101
+ * Rules are also applied to the elements of sequence items.
2102
+ * Use `translateWriterRules` to convert tag or group name based rules.
2103
+ * Rules with an unknown action are ignored (with a warning), the
2104
+ * next matching rule is then used. If there is no valid default
2105
+ * rule, the default is to copy.
2106
+ *
2107
+ * @param {Record<string, WriterRule>} rules The input rules.
1818
2108
  * @param {boolean} [addMissingTags] If true, explicit tags that
1819
2109
  * have replace rule and a value will be
1820
2110
  * added if missing. Defaults to false.
1821
2111
  */
1822
- setRules(rules: {
1823
- [x: string]: WriterRule;
1824
- }, addMissingTags?: boolean): void;
2112
+ setRules(rules: Record<string, WriterRule>, addMissingTags?: boolean): void;
1825
2113
  /**
1826
2114
  * Use a TextEncoder instead of the default text decoder.
1827
2115
  */
1828
2116
  useSpecialTextEncoder(): void;
1829
2117
  /**
1830
2118
  * Get the element to write according to the class rules.
1831
- * Priority order: tagName, groupName, default.
2119
+ * Priority order: tag key, tag range, group key, group range, default.
2120
+ * Non whitelisted private tags are removed if a whitelist
2121
+ * is set, whatever the rules.
2122
+ * For sequences, rules are also applied to the item elements.
1832
2123
  *
1833
2124
  * @param {DataElement} element The element to check.
1834
2125
  * @returns {DataElement|null} The element to write, can be null.
@@ -1837,50 +2128,125 @@ export declare class DicomWriter {
1837
2128
  /**
1838
2129
  * Get the ArrayBuffer corresponding to input DICOM elements.
1839
2130
  *
1840
- * @param {Object<string, DataElement>} dataElements The elements to write.
2131
+ * @param {Record<string, DataElement>} dataElements The elements to write.
1841
2132
  * @returns {ArrayBuffer} The elements as a buffer.
1842
2133
  */
1843
- getBuffer(dataElements: {
1844
- [x: string]: DataElement;
1845
- }): ArrayBuffer;
2134
+ getBuffer(dataElements: Record<string, DataElement>): ArrayBuffer;
1846
2135
  #private;
1847
2136
  }
1848
2137
 
1849
2138
  /**
1850
- * Draw controller.
2139
+ * Draw brush command.
1851
2140
  */
1852
- export declare class DrawController {
2141
+ export declare class DrawBrushCommand extends Command {
1853
2142
  /**
1854
- * @param {AnnotationGroup} [group] Optional annotation group.
2143
+ * @param {DrawBrushCommandProperties} properties The command properties.
1855
2144
  */
1856
- constructor(group?: AnnotationGroup);
2145
+ constructor(properties: DrawBrushCommandProperties);
1857
2146
  /**
1858
- * Get an annotation.
2147
+ * Get the original values before applying brush.
1859
2148
  *
1860
- * @param {string} uid The annotation UID.
1861
- * @returns {Annotation|undefined} The annotation.
2149
+ * @returns {Array|undefined} Lists of original value iterators,
2150
+ * undefined when erasing.
1862
2151
  */
1863
- getAnnotation(uid: string): Annotation | undefined;
2152
+ getOriginalValuesLists(): any[] | undefined;
1864
2153
  /**
1865
- * Get the annotation group.
2154
+ * Get the execute event.
1866
2155
  *
1867
- * @returns {AnnotationGroup} The list.
2156
+ * @returns {CustomEvent} The event.
1868
2157
  */
1869
- getAnnotationGroup(): AnnotationGroup;
2158
+ getExecuteEvent(): CustomEvent;
1870
2159
  /**
1871
- * Check if the annotation group is editable.
2160
+ * Handle an execute event.
1872
2161
  *
1873
- * @returns {boolean} True if editable.
2162
+ * @param {CustomEvent} _event The execute event with type and id.
1874
2163
  */
1875
- isAnnotationGroupEditable(): boolean;
2164
+ onExecute(_event: CustomEvent): void;
1876
2165
  /**
1877
- * Set the annotation group editability.
2166
+ * Handle an undo event.
1878
2167
  *
1879
- * @param {boolean} flag True to make the annotation group editable.
2168
+ * @param {CustomEvent} _event The undo event with type and id.
1880
2169
  */
1881
- setAnnotationGroupEditable(flag: boolean): void;
2170
+ onUndo(_event: CustomEvent): void;
2171
+ #private;
2172
+ }
2173
+
2174
+ /**
2175
+ * @import {MaskImage} from '../image/maskImage.js';
2176
+ */
2177
+ export declare class DrawBrushCommandProperties {
1882
2178
  /**
1883
- * Add an annotation.
2179
+ * @type {MaskImage}
2180
+ */
2181
+ mask: MaskImage;
2182
+ /**
2183
+ * @type {string}
2184
+ */
2185
+ dataId: string;
2186
+ /**
2187
+ * @type {number[][]}
2188
+ */
2189
+ offsetsLists: number[][];
2190
+ /**
2191
+ * @type {string}
2192
+ */
2193
+ mode: string;
2194
+ /**
2195
+ * @type {number}
2196
+ */
2197
+ segmentNumber: number;
2198
+ /**
2199
+ * @type {string}
2200
+ */
2201
+ srclayerid: string;
2202
+ /**
2203
+ * @type {Array}
2204
+ */
2205
+ originalValuesLists: any[];
2206
+ /**
2207
+ * @type {boolean}
2208
+ */
2209
+ isSilent: boolean;
2210
+ }
2211
+
2212
+ /**
2213
+ * @import {Annotation} from '../image/annotation.js';
2214
+ */
2215
+ /**
2216
+ * Draw controller.
2217
+ */
2218
+ export declare class DrawController {
2219
+ /**
2220
+ * @param {AnnotationGroup} [group] Optional annotation group.
2221
+ */
2222
+ constructor(group?: AnnotationGroup);
2223
+ /**
2224
+ * Get an annotation.
2225
+ *
2226
+ * @param {string} uid The annotation UID.
2227
+ * @returns {Annotation|undefined} The annotation.
2228
+ */
2229
+ getAnnotation(uid: string): Annotation | undefined;
2230
+ /**
2231
+ * Get the annotation group.
2232
+ *
2233
+ * @returns {AnnotationGroup} The list.
2234
+ */
2235
+ getAnnotationGroup(): AnnotationGroup;
2236
+ /**
2237
+ * Check if the annotation group is editable.
2238
+ *
2239
+ * @returns {boolean} True if editable.
2240
+ */
2241
+ isAnnotationGroupEditable(): boolean;
2242
+ /**
2243
+ * Set the annotation group editability.
2244
+ *
2245
+ * @param {boolean} flag True to make the annotation group editable.
2246
+ */
2247
+ setAnnotationGroupEditable(flag: boolean): void;
2248
+ /**
2249
+ * Add an annotation.
1884
2250
  *
1885
2251
  * @param {Annotation} annotation The annotation to add.
1886
2252
  */
@@ -1941,6 +2307,17 @@ export declare class DrawController {
1941
2307
  #private;
1942
2308
  }
1943
2309
 
2310
+ /**
2311
+ * @import {Point, Point2D, Point3D} from '../math/point.js';
2312
+ * @import {Vector3D} from '../math/vector.js';
2313
+ * @import {Scalar2D, Scalar3D} from '../math/scalar.js';
2314
+ * @import {Index} from '../math/index.js';
2315
+ * @import {Image} from '../image/image.js';
2316
+ * @import {PlaneHelper} from '../image/planeHelper.js';
2317
+ * @import {Annotation} from '../image/annotation.js';
2318
+ * @import {AnnotationGroup} from '../image/annotationGroup.js';
2319
+ * @import {DrawShapeHandler} from '../tools/shapes/drawShapeHandler.js';
2320
+ */
1944
2321
  /**
1945
2322
  * Debug function to output the layer hierarchy as text.
1946
2323
  *
@@ -1950,6 +2327,9 @@ export declare class DrawController {
1950
2327
  */
1951
2328
  /**
1952
2329
  * Draw layer.
2330
+ *
2331
+ * Not an EventTarget in order to forward native DOM events while
2332
+ * preserving `preventDefault()` for tools (see '#fireDomEvent').
1953
2333
  */
1954
2334
  export declare class DrawLayer {
1955
2335
  /**
@@ -2123,6 +2503,17 @@ export declare class DrawLayer {
2123
2503
  * @param {Scalar2D} fitOffset The fit offset as {x,y}.
2124
2504
  */
2125
2505
  fitToContainer(containerSize: Scalar2D, divToWorldSizeRatio: number, fitOffset: Scalar2D): void;
2506
+ /**
2507
+ * Get the top most visible annotation at the current position
2508
+ * that contains the input plane point.
2509
+ *
2510
+ * @param {Point2D} planePoint The plane point, in the reference
2511
+ * view layer plane coordinates.
2512
+ * @param {number} [tolerance] Optional maximum distance to a shape,
2513
+ * in plane coordinates, defaults to 0.
2514
+ * @returns {Annotation|undefined} The annotation, undefined if none.
2515
+ */
2516
+ getAnnotationAt(planePoint: Point2D, tolerance?: number): Annotation | undefined;
2126
2517
  /**
2127
2518
  * Check the visibility of an annotation.
2128
2519
  *
@@ -2139,6 +2530,18 @@ export declare class DrawLayer {
2139
2530
  * @returns {boolean} False if the annotation shape cannot be found.
2140
2531
  */
2141
2532
  setAnnotationVisibility(id: string, visible?: boolean): boolean;
2533
+ /**
2534
+ * Temporarily highlight an annotation: its opacity progressively
2535
+ * dims to 20% and comes back to normal in one pulse. Only one
2536
+ * annotation is highlighted at a time: a new call resets the
2537
+ * previous highlight.
2538
+ *
2539
+ * @param {string} id The id of the annotation.
2540
+ * @param {number} [duration] The highlight duration in milliseconds,
2541
+ * defaults to 500.
2542
+ * @returns {boolean} False if the annotation shape cannot be found.
2543
+ */
2544
+ highlightAnnotation(id: string, duration?: number): boolean;
2142
2545
  /**
2143
2546
  * Set the visibility of all labels.
2144
2547
  *
@@ -2215,16 +2618,11 @@ export declare class DrawLayer {
2215
2618
  /**
2216
2619
  * Draw shape handler: handle action on existing shapes.
2217
2620
  */
2218
- export declare class DrawShapeHandler {
2219
- /**
2220
- * @callback eventFn@callback eventFn
2221
- * @param {object} event The event.
2222
- */
2621
+ export declare class DrawShapeHandler extends EventTarget {
2223
2622
  /**
2224
2623
  * @param {App} app The associated application.
2225
- * @param {Function} eventCallback Event callback.
2226
2624
  */
2227
- constructor(app: App, eventCallback: Function);
2625
+ constructor(app: App);
2228
2626
  /**
2229
2627
  * Set the draw editor shape.
2230
2628
  *
@@ -2310,6 +2708,15 @@ export declare class Ellipse {
2310
2708
  * @returns {number} The radius of the ellipse on the vertical axe.
2311
2709
  */
2312
2710
  getB(): number;
2711
+ /**
2712
+ * Check if a point is inside the ellipse, the ellipse radii being
2713
+ * extended by a tolerance.
2714
+ *
2715
+ * @param {Point2D} point The point to check.
2716
+ * @param {number} [tolerance] Optional radius extension, defaults to 0.
2717
+ * @returns {boolean} True if the point is in the ellipse.
2718
+ */
2719
+ contains(point: Point2D, tolerance?: number): boolean;
2313
2720
  /**
2314
2721
  * Check for equality.
2315
2722
  *
@@ -2351,11 +2758,9 @@ export declare class Ellipse {
2351
2758
  * @param {Index} index The index at which to get the
2352
2759
  * image values.
2353
2760
  * @param {string[]} flags A list of stat values to calculate.
2354
- * @returns {Object<string, Value>} A quantification object.
2761
+ * @returns {Record<string, NumberValue>} A quantification object.
2355
2762
  */
2356
- quantify(viewController: ViewController, index: Index, flags: string[]): {
2357
- [x: string]: Value;
2358
- };
2763
+ quantify(viewController: ViewController, index: Index, flags: string[]): Record<string, NumberValue>;
2359
2764
  #private;
2360
2765
  }
2361
2766
 
@@ -2368,6 +2773,11 @@ export declare class Ellipse {
2368
2773
  */
2369
2774
  export declare function equalWl(wl0: WindowLevel, wl1: WindowLevel): boolean;
2370
2775
 
2776
+ /**
2777
+ * List of compatible float typed arrays.
2778
+ */
2779
+ export declare type FloatTypedArray = Float32Array | Float64Array;
2780
+
2371
2781
  /**
2372
2782
  * 2D/3D Geometry class.
2373
2783
  */
@@ -2378,9 +2788,10 @@ export declare class Geometry {
2378
2788
  * @param {Spacing} spacing The object spacing.
2379
2789
  * @param {Matrix33} [orientation] The object orientation (3*3 matrix,
2380
2790
  * default to 3*3 identity).
2381
- * @param {number} [time] Optional time index.
2791
+ * @param {SourcedNumberValue} [time] Optional time: a volume id or, without
2792
+ * source, a frame index (for example `{value: 2}`).
2382
2793
  */
2383
- constructor(origins: Point3D[], size: Size, spacing: Spacing, orientation?: Matrix33, time?: number);
2794
+ constructor(origins: Point3D[], size: Size, spacing: Spacing, orientation?: Matrix33, time?: SourcedNumberValue);
2384
2795
  /**
2385
2796
  * Clone the geometry.
2386
2797
  *
@@ -2388,17 +2799,42 @@ export declare class Geometry {
2388
2799
  */
2389
2800
  clone(): Geometry;
2390
2801
  /**
2391
- * Get the time value that was passed at construction.
2802
+ * Get the time that was passed at construction.
2392
2803
  *
2393
- * @returns {number} The time value.
2804
+ * @returns {SourcedNumberValue|undefined} The time.
2394
2805
  */
2395
- getInitialTime(): number;
2806
+ getInitialTime(): SourcedNumberValue | undefined;
2396
2807
  /**
2397
2808
  * Set the initial time.
2398
2809
  *
2399
- * @param {number} time The new time.
2810
+ * @param {SourcedNumberValue} time The new time: a volume id or, without
2811
+ * source, a frame index.
2812
+ */
2813
+ setInitialTime(time: SourcedNumberValue): void;
2814
+ /**
2815
+ * Get the volume ids: the time of each volume, sorted by ascending
2816
+ * value, the array index being the volume index. Times are volume
2817
+ * ids if they have a source.
2818
+ *
2819
+ * @returns {SourcedNumberValue[]|undefined} The volume ids, undefined if the
2820
+ * times are not volume ids.
2821
+ */
2822
+ getVolumeIds(): SourcedNumberValue[] | undefined;
2823
+ /**
2824
+ * Set the volume ids of a geometry without times (for example a
2825
+ * resampled one): the volumes all have the current origins.
2826
+ *
2827
+ * @param {SourcedNumberValue[]} volumeIds The volume ids, sorted by ascending
2828
+ * value, one per volume (fourth dimension).
2829
+ */
2830
+ setVolumeIds(volumeIds: SourcedNumberValue[]): void;
2831
+ /**
2832
+ * Get the index of a volume id value.
2833
+ *
2834
+ * @param {number} value The volume id value.
2835
+ * @returns {number} The volume index, -1 if not found.
2400
2836
  */
2401
- setInitialTime(time: number): void;
2837
+ getVolumeIndex(value: number): number;
2402
2838
  /**
2403
2839
  * Get the total number of slices.
2404
2840
  * Can be different from what is stored in the size object
@@ -2410,7 +2846,7 @@ export declare class Geometry {
2410
2846
  /**
2411
2847
  * Check if a time point has associated slices.
2412
2848
  *
2413
- * @param {number} time The time point to check.
2849
+ * @param {number} time The time value to check.
2414
2850
  * @returns {boolean} True if slices are present.
2415
2851
  */
2416
2852
  hasSlicesAtTime(time: number): boolean;
@@ -2418,10 +2854,19 @@ export declare class Geometry {
2418
2854
  * Get the number of slices stored for time points preceding
2419
2855
  * the input one.
2420
2856
  *
2421
- * @param {number} time The time point to check.
2857
+ * @param {number} time The time value to check.
2422
2858
  * @returns {number|undefined} The count.
2423
2859
  */
2424
2860
  getCurrentNumberOfSlicesBeforeTime(time: number): number | undefined;
2861
+ /**
2862
+ * Check that all time points have the same origins as the
2863
+ * initial time point (same number and same values in the
2864
+ * same order).
2865
+ *
2866
+ * @returns {BooleanResult} Result with success set to true if
2867
+ * the time origins are consistent.
2868
+ */
2869
+ checkTimeOrigins(): BooleanResult;
2425
2870
  /**
2426
2871
  * Get the object origin.
2427
2872
  * This should be the lowest origin to ease calculations (?).
@@ -2435,6 +2880,10 @@ export declare class Geometry {
2435
2880
  * @returns {Point3D[]} The object origins.
2436
2881
  */
2437
2882
  getOrigins(): Point3D[];
2883
+ /**
2884
+ * Sort origins by Z position ascending.
2885
+ */
2886
+ sortOrigins(): void;
2438
2887
  /**
2439
2888
  * Check if a point is in the origin list.
2440
2889
  *
@@ -2480,7 +2929,7 @@ export declare class Geometry {
2480
2929
  */
2481
2930
  getOrientation(): Matrix33;
2482
2931
  /**
2483
- * Get the slice position of a point in the current slice layout.
2932
+ * Get the slice position of an origin in the current slice layout.
2484
2933
  * Slice indices increase with decreasing origins (high index -> low origin),
2485
2934
  * this simplified the handling of reconstruction since it means
2486
2935
  * the displayed data is in the same 'direction' as the extracted data.
@@ -2488,11 +2937,25 @@ export declare class Geometry {
2488
2937
  * This implies that the index to world and reverse method do some flipping
2489
2938
  * magic...
2490
2939
  *
2491
- * @param {Point3D} point The point to evaluate.
2492
- * @param {number} [time] Optional time index.
2940
+ * Limitation: the codirectional (before/after) refinement below is a
2941
+ * strict sign check on the normal-projected residual, with no
2942
+ * tolerance - unlike worldToIndex's magnitude-based half-spacing
2943
+ * gate. That is safe for this method's one real caller
2944
+ * (Image#appendSlice, which only ever compares exact, already-known
2945
+ * slice origins - a clean, large residual, never close to zero),
2946
+ * but this method should not be used for an arbitrary point with a
2947
+ * large in-plane offset from its closest origin (eg a click
2948
+ * position): float noise in that offset, amplified by a
2949
+ * lower-precision orientation (eg gantry-tilt direction cosines
2950
+ * with few decimal digits), can flip the sign of a residual that
2951
+ * should be exactly zero. Use worldToIndex (or a plain
2952
+ * Point3D#getClosest) instead for that case.
2953
+ *
2954
+ * @param {Point3D} origin The origin to locate.
2955
+ * @param {number} [time] Optional time value.
2493
2956
  * @returns {number} The slice index.
2494
2957
  */
2495
- getSliceIndex(point: Point3D, time?: number): number;
2958
+ getSliceIndex(origin: Point3D, time?: number): number;
2496
2959
  /**
2497
2960
  * Check if another geometry is compatible with this one, ie that
2498
2961
  * slices with these geometries can be merged into one volume.
@@ -2501,12 +2964,12 @@ export declare class Geometry {
2501
2964
  * @returns {BooleanResult} Result with success set to true if
2502
2965
  * the geometry is compatible.
2503
2966
  */
2504
- canAppend(rhs: Geometry): BooleanResult;
2967
+ canAppendSlice(rhs: Geometry): BooleanResult;
2505
2968
  /**
2506
2969
  * Check if an origin can be appended to this geometry.
2507
2970
  *
2508
2971
  * @param {Point3D} origin The origin to append.
2509
- * @param {number} [time] Optional time index.
2972
+ * @param {number} [time] Optional time value.
2510
2973
  * @returns {BooleanResult} Result with success set to true if
2511
2974
  * the origin is compatible.
2512
2975
  */
@@ -2516,16 +2979,17 @@ export declare class Geometry {
2516
2979
  *
2517
2980
  * @param {Point3D} origin The origin to append.
2518
2981
  * @param {number} index The index at which to append.
2519
- * @param {number} [time] Optional time index.
2982
+ * @param {number} [time] Optional time value.
2520
2983
  */
2521
2984
  appendOrigin(origin: Point3D, index: number, time?: number): void;
2522
2985
  /**
2523
2986
  * Append a frame to the geometry.
2524
2987
  *
2525
2988
  * @param {Point3D} origin The origin to append.
2526
- * @param {number} time Optional time index.
2989
+ * @param {SourcedNumberValue} time The frame time: a volume id or, without
2990
+ * source, a frame index.
2527
2991
  */
2528
- appendFrame(origin: Point3D, time: number): void;
2992
+ appendFrame(origin: Point3D, time: SourcedNumberValue): void;
2529
2993
  /**
2530
2994
  * Get a string representation of the geometry.
2531
2995
  *
@@ -2539,6 +3003,16 @@ export declare class Geometry {
2539
3003
  * @returns {boolean} True if both objects are equal.
2540
3004
  */
2541
3005
  equals(rhs: Geometry): boolean;
3006
+ /**
3007
+ * Check for similarity for origin and orientation, equality
3008
+ * for size and spacing.
3009
+ *
3010
+ * @param {Geometry} rhs The object to compare to.
3011
+ * @param {number} [tol] Optional number comparison tolerance,
3012
+ * defaults to Number.EPSILON.
3013
+ * @returns {boolean} True if both objects are equal.
3014
+ */
3015
+ isSimilar(rhs: Geometry, tol?: number): boolean;
2542
3016
  /**
2543
3017
  * Check that a point is within bounds.
2544
3018
  *
@@ -2578,6 +3052,18 @@ export declare class Geometry {
2578
3052
  /**
2579
3053
  * Convert world coordinates into an index.
2580
3054
  *
3055
+ * Always returns an index, even for a point outside the geometry:
3056
+ * this does not itself mean the point is in bounds, use
3057
+ * isIndexInBounds/isInBounds for that. In-plane (row/column), an
3058
+ * out-of-bounds point extrapolates freely (eg -5 or size+12). On the
3059
+ * scroll axis, a point close to a real per-slice origin snaps to it;
3060
+ * further away, it is pinned to just past the first/last known
3061
+ * origin (ie the origins array length, or -1) rather than left to
3062
+ * drift arbitrarily far via linear extrapolation - except when there
3063
+ * are few or no real origins to compare against (eg a root geometry
3064
+ * with only its first slice known), where it still falls back to
3065
+ * that unclamped extrapolation.
3066
+ *
2581
3067
  * @param {Point} point The point to convert.
2582
3068
  * @returns {Index} The corresponding index.
2583
3069
  */
@@ -2593,42 +3079,63 @@ export declare class Geometry {
2593
3079
  }
2594
3080
 
2595
3081
  /**
2596
- * Get the meta data as simple elements:
3082
+ * Get the meta data as simple tag values:
2597
3083
  * - indexed by tag names instead of tag keys,
2598
3084
  * - no element object, just value if not sequence nor merged item.
2599
3085
  *
2600
- * @param {Object<string, DataElement>} metaData The meta data
3086
+ * @param {Record<string, DataElement>} dataElements The data elements
2601
3087
  * index by tag keys.
2602
- * @returns {Object<string, any>} The simple elements.
3088
+ * @returns {SimpleTagValues} The simple tag values.
2603
3089
  */
2604
- export declare function getAsSimpleElements(metaData: {
2605
- [x: string]: DataElement;
2606
- }): {
2607
- [x: string]: any;
2608
- };
3090
+ export declare function getAsSimpleTagValues(dataElements: Record<string, DataElement>): SimpleTagValues;
3091
+
3092
+ /**
3093
+ * Get the default DICOM RT Structure Set tags as an object.
3094
+ *
3095
+ * @returns {SimpleTagValues} The default tags.
3096
+ */
3097
+ export declare function getDefaultDicomRTStructJson(): SimpleTagValues;
2609
3098
 
2610
3099
  /**
2611
3100
  * Get the default DICOM seg tags as an object.
2612
3101
  *
2613
- * @returns {object} The default tags.
3102
+ * @returns {SimpleTagValues} The default tags.
2614
3103
  */
2615
- export declare function getDefaultDicomSegJson(): object;
3104
+ export declare function getDefaultDicomSegJson(): SimpleTagValues;
2616
3105
 
2617
3106
  /**
2618
3107
  * Get a simple dicom element item from a content item object.
2619
3108
  *
2620
3109
  * @param {DicomSRContent} content The content item object.
2621
- * @returns {Object<string, any>} The item as a list of (key, value) pairs.
3110
+ * @returns {SimpleTagValues} The item as a list of (key, value) pairs.
2622
3111
  */
2623
- export declare function getDicomSRContentItem(content: DicomSRContent): {
2624
- [x: string]: any;
2625
- };
3112
+ export declare function getDicomSRContentItem(content: DicomSRContent): SimpleTagValues;
3113
+
3114
+ /**
3115
+ * Get the DICOM tag group name as defined in TagGroups.
3116
+ *
3117
+ * @param {Tag} tag The DICOM tag.
3118
+ * @returns {string|undefined} The group name.
3119
+ */
3120
+ export declare function getDicomTagGroupName(tag: Tag): string | undefined;
3121
+
3122
+ /**
3123
+ * Get the DICOM tag info for a tag using the
3124
+ * local DICOM tag dictionary.
3125
+ *
3126
+ * @param {Tag} tag The DICOM tag.
3127
+ * @returns {TagInfo|undefined} The info.
3128
+ */
3129
+ export declare function getDicomTagInfo(tag: Tag): TagInfo | undefined;
2626
3130
 
3131
+ /**
3132
+ * @import {IntTypedArray, TypedArray} from '../math/types.js';
3133
+ */
2627
3134
  /**
2628
3135
  * List of DICOM data elements indexed via a 8 character string formed from
2629
3136
  * the group and element numbers.
2630
3137
  *
2631
- * @typedef {Object<string, DataElement>} DataElements
3138
+ * @typedef {Record<string, DataElement>} DataElements
2632
3139
  */
2633
3140
  /**
2634
3141
  * Get the version of the library.
@@ -2643,15 +3150,11 @@ export declare function getDwvVersion(): string;
2643
3150
  * tag names instead of keys and direct values (no value property) for
2644
3151
  * simple tags. See synthetic test data (in tests/dicom) for examples.
2645
3152
  *
2646
- * @param {Object<string, any>} simpleTags The 'simple' DICOM
3153
+ * @param {SimpleTagValues} simpleTags The 'simple' DICOM
2647
3154
  * tags object.
2648
- * @returns {Object<string, DataElement>} The DICOM elements.
3155
+ * @returns {Record<string, DataElement>} The DICOM elements.
2649
3156
  */
2650
- export declare function getElementsFromJSONTags(simpleTags: {
2651
- [x: string]: any;
2652
- }): {
2653
- [x: string]: DataElement;
2654
- };
3157
+ export declare function getElementsFromSimpleTagValues(simpleTags: SimpleTagValues): Record<string, DataElement>;
2655
3158
 
2656
3159
  /**
2657
3160
  * Get the indices that form a ellpise.
@@ -2676,31 +3179,27 @@ export declare function getLayerDetailsFromEvent(event: object): object;
2676
3179
  /**
2677
3180
  * Get the manufacturer.
2678
3181
  *
2679
- * @param {Object<string, DataElement>} elements The DICOM tags.
3182
+ * @param {Record<string, DataElement>} elements The DICOM tags.
2680
3183
  * @returns {string|undefined} The manufacturer.
2681
3184
  */
2682
- export declare function getManufacturer(elements: {
2683
- [x: string]: DataElement;
2684
- }): string | undefined;
3185
+ export declare function getManufacturer(elements: Record<string, DataElement>): string | undefined;
2685
3186
 
2686
3187
  /**
2687
3188
  * Get the offset of an input mouse event.
2688
3189
  *
2689
- * @param {object} event The event to get the offset from.
3190
+ * @param {MouseEvent} event The event to get the offset from.
2690
3191
  * @returns {Point2D} The 2D point.
2691
3192
  */
2692
- export declare function getMousePoint(event: object): Point2D;
3193
+ export declare function getMousePoint(event: MouseEvent): Point2D;
2693
3194
 
2694
3195
  /**
2695
3196
  * Get the normalised manufacturer.
2696
3197
  *
2697
- * @param {Object<string, DataElement>} elements The DICOM tags.
3198
+ * @param {Record<string, DataElement>} elements The DICOM tags.
2698
3199
  * @returns {string|undefined} The manufacturer as a unique
2699
3200
  * all lower case string.
2700
3201
  */
2701
- export declare function getNormalisedManufacturer(elements: {
2702
- [x: string]: DataElement;
2703
- }): string | undefined;
3202
+ export declare function getNormalisedManufacturer(elements: Record<string, DataElement>): string | undefined;
2704
3203
 
2705
3204
  /**
2706
3205
  * Get the name of an image orientation patient.
@@ -2732,12 +3231,23 @@ export declare function getRectangleIndices(center: Index, size: number[], dir:
2732
3231
  /**
2733
3232
  * Get the referenced series UID from the data elements.
2734
3233
  *
2735
- * @param {Object<string, DataElement>} dataElements The data elements.
3234
+ * @param {Record<string, DataElement>} dataElements The data elements.
3235
+ * @returns {string|undefined} The referenced series UID.
3236
+ */
3237
+ export declare function getReferencedSeriesUID(dataElements: Record<string, DataElement>): string | undefined;
3238
+
3239
+ /**
3240
+ * Get the referenced series UID from an RT Structure Set.
3241
+ *
3242
+ * Path: ReferencedFrameOfReferenceSequence (3006,0010) →
3243
+ * RTReferencedStudySequence (3006,0012) →
3244
+ * RTReferencedSeriesSequence (3006,0014) →
3245
+ * SeriesInstanceUID (0020,000E).
3246
+ *
3247
+ * @param {Record<string, DataElement>} dataElements The data elements.
2736
3248
  * @returns {string|undefined} The referenced series UID.
2737
3249
  */
2738
- export declare function getReferencedSeriesUID(dataElements: {
2739
- [x: string]: DataElement;
2740
- }): string | undefined;
3250
+ export declare function getReferencedSeriesUIDFromRTStruct(dataElements: Record<string, DataElement>): string | undefined;
2741
3251
 
2742
3252
  /**
2743
3253
  * Get patient orientation label in the reverse direction.
@@ -2747,6 +3257,14 @@ export declare function getReferencedSeriesUID(dataElements: {
2747
3257
  */
2748
3258
  export declare function getReverseOrientation(ori: string): string;
2749
3259
 
3260
+ /**
3261
+ * Get a list of {@link RTROI} objects from RTSTRUCT DICOM elements.
3262
+ *
3263
+ * @param {Record<string, DataElement>} dataElements The DICOM data elements.
3264
+ * @returns {RTROI[]} The list of RT ROIs.
3265
+ */
3266
+ export declare function getRTStructFromElements(dataElements: Record<string, DataElement>): RTROI[];
3267
+
2750
3268
  /**
2751
3269
  * Get a segmentation DICOM code.
2752
3270
  *
@@ -2757,12 +3275,10 @@ export declare function getSegmentationCode(): DicomCode;
2757
3275
  /**
2758
3276
  * Get a content item object from a dicom element.
2759
3277
  *
2760
- * @param {Object<string, DataElement>} dataElements The dicom element.
3278
+ * @param {Record<string, DataElement>} dataElements The dicom element.
2761
3279
  * @returns {DicomSRContent} A content item object.
2762
3280
  */
2763
- export declare function getSRContent(dataElements: {
2764
- [x: string]: DataElement;
2765
- }): DicomSRContent;
3281
+ export declare function getSRContent(dataElements: Record<string, DataElement>): DicomSRContent;
2766
3282
 
2767
3283
  /**
2768
3284
  * Split a group-element key used to store DICOM elements.
@@ -2775,10 +3291,10 @@ export declare function getTagFromKey(key: string): Tag;
2775
3291
  /**
2776
3292
  * Get the offsets of an input touch event.
2777
3293
  *
2778
- * @param {object} event The event to get the offset from.
3294
+ * @param {TouchEvent} event The event to get the offset from.
2779
3295
  * @returns {Point2D[]} The array of points.
2780
3296
  */
2781
- export declare function getTouchPoints(event: object): Point2D[];
3297
+ export declare function getTouchPoints(event: TouchEvent): Point2D[];
2782
3298
 
2783
3299
  /**
2784
3300
  * Get the appropriate TypedArray in function of arguments.
@@ -2788,10 +3304,9 @@ export declare function getTouchPoints(event: object): Point2D[];
2788
3304
  * @param {number} pixelRepresentation The pixel representation,
2789
3305
  * 0:unsigned;1:signed.
2790
3306
  * @param {number} size The size of the new array.
2791
- * @returns {Uint8Array|Int8Array|Uint16Array|Int16Array|Uint32Array|Int32Array}
2792
- * The good typed array.
3307
+ * @returns {IntTypedArray} The good typed array.
2793
3308
  */
2794
- export declare function getTypedArray(bitsAllocated: number, pixelRepresentation: number, size: number): Uint8Array | Int8Array | Uint16Array | Int16Array | Uint32Array | Int32Array;
3309
+ export declare function getTypedArray(bitsAllocated: number, pixelRepresentation: number, size: number): IntTypedArray;
2795
3310
 
2796
3311
  /**
2797
3312
  * Get a UID for a DICOM tag.
@@ -2846,6 +3361,91 @@ export declare function hasDicomPrefix(buffer: ArrayBuffer): boolean;
2846
3361
  */
2847
3362
  export declare function hexToRgb(hexStr: string): RGB;
2848
3363
 
3364
+ /**
3365
+ * @import {NumberRange} from './number.js';
3366
+ */
3367
+ /**
3368
+ * Histogram entry.
3369
+ *
3370
+ * @typedef {object} HistogramEntry@typedef {object} HistogramEntry
3371
+ * @property {number} value The value.
3372
+ * @property {number} count The number of occurrences.
3373
+ */
3374
+ /**
3375
+ * Histogram of values: number of occurrences per distinct value.
3376
+ */
3377
+ export declare class Histogram {
3378
+ /**
3379
+ * Add occurrences of a value.
3380
+ *
3381
+ * @param {number} value The value.
3382
+ * @param {number} [count] The number of occurrences, defaults to 1.
3383
+ */
3384
+ add(value: number, count?: number): void;
3385
+ /**
3386
+ * Get the total number of counted values.
3387
+ *
3388
+ * @returns {number} The total count.
3389
+ */
3390
+ getTotal(): number;
3391
+ /**
3392
+ * Get the histogram entries sorted by ascending value.
3393
+ *
3394
+ * @returns {HistogramEntry[]} The entries.
3395
+ */
3396
+ getEntries(): HistogramEntry[];
3397
+ /**
3398
+ * Get the value range.
3399
+ *
3400
+ * @returns {NumberRange|undefined} The range, undefined if empty.
3401
+ */
3402
+ getRange(): NumberRange | undefined;
3403
+ /**
3404
+ * Get the number of values in [min, max).
3405
+ *
3406
+ * @param {number} [min] Inclusive lower bound, unbounded if undefined.
3407
+ * @param {number} [max] Exclusive upper bound, unbounded if undefined.
3408
+ * @returns {number} The count.
3409
+ */
3410
+ getCountInRange(min?: number, max?: number): number;
3411
+ /**
3412
+ * Get the percentage of counts that fall in each interval defined by
3413
+ * interior thresholds.
3414
+ *
3415
+ * For thresholds `[1, 5]`, the intervals are `[min, 1)`, `[1, 5)` and
3416
+ * `[5, max]`, where `min` / `max` are the histogram range.
3417
+ *
3418
+ * @param {number[]} thresholds Interior cut points in ascending order.
3419
+ * @returns {number[]} The percentages in [0, 100], one per interval
3420
+ * (`thresholds.length + 1` entries), all 0 for an empty histogram.
3421
+ */
3422
+ getIntervalPercentages(thresholds: number[]): number[];
3423
+ /**
3424
+ * Get the statistics of the values: minimum, maximum, mean,
3425
+ * standard deviation, median, 25th and 75th percentiles.
3426
+ * Gives the same results as `getStats` (`math/stats.js`) on the full
3427
+ * list of values.
3428
+ *
3429
+ * @returns {Statistics|undefined} The statistics, undefined if empty.
3430
+ */
3431
+ getStats(): Statistics | undefined;
3432
+ #private;
3433
+ }
3434
+
3435
+ /**
3436
+ * Histogram entry.
3437
+ */
3438
+ declare type HistogramEntry = {
3439
+ /**
3440
+ * The value.
3441
+ */
3442
+ value: number;
3443
+ /**
3444
+ * The number of occurrences.
3445
+ */
3446
+ count: number;
3447
+ };
3448
+
2849
3449
  export declare namespace i18n {
2850
3450
  /**
2851
3451
  * Get the translated text.
@@ -2864,14 +3464,14 @@ export declare namespace i18n {
2864
3464
  * - planar configuration (default RGBRGB...).
2865
3465
  *
2866
3466
  * @example
2867
- * import {DicomParser, createImage} from '//esm.sh/dwv';
3467
+ * import {DicomParser, demoCreateImage} from '//esm.sh/dwv';
2868
3468
  * // XMLHttpRequest onload callback
2869
3469
  * const onload = function (event) {
2870
3470
  * // parse the dicom buffer
2871
3471
  * const dicomParser = new DicomParser();
2872
3472
  * dicomParser.parse(event.target.response);
2873
3473
  * // create the image object
2874
- * const image = createImage(dicomParser.getDicomElements());
3474
+ * const image = demoCreateImage(dicomParser.getDicomElements());
2875
3475
  * // result div
2876
3476
  * const div = document.getElementById('dwv');
2877
3477
  * // display the image size
@@ -2895,13 +3495,13 @@ export declare namespace i18n {
2895
3495
  * request.onload = onload;
2896
3496
  * request.send();
2897
3497
  */
2898
- declare class Image_2 {
3498
+ declare class Image_2 extends EventTarget {
2899
3499
  /**
2900
3500
  * @param {Geometry} geometry The geometry of the image.
2901
3501
  * @param {TypedArray} buffer The image data as a one dimensional buffer.
2902
3502
  * @param {string[]} [imageUids] An array of Uids indexed to slice number.
2903
3503
  */
2904
- constructor(geometry: Geometry, buffer: Int8Array | Uint8Array | Int16Array | Uint16Array | Int32Array | Uint32Array, imageUids?: string[]);
3504
+ constructor(geometry: Geometry, buffer: TypedArray, imageUids?: string[]);
2905
3505
  /**
2906
3506
  * Set the image complete flag.
2907
3507
  *
@@ -2914,6 +3514,22 @@ declare class Image_2 {
2914
3514
  * @returns {boolean} True if the data is complete.
2915
3515
  */
2916
3516
  getComplete(): boolean;
3517
+ /**
3518
+ * Get the initial index, used as default position by views:
3519
+ * the middle of the image (first frame for 4D).
3520
+ *
3521
+ * @returns {Index} The index.
3522
+ */
3523
+ getInitialIndex(): Index;
3524
+ /**
3525
+ * Check whether the image has overlapping segments. Always false for a
3526
+ * plain image; {@link MaskImage} overrides this with a real check.
3527
+ *
3528
+ * @returns {boolean} False.
3529
+ * @deprecated Since v0.37, please use `instanceof MaskImage` and
3530
+ * `MaskImage#getHasOverlap` instead.
3531
+ */
3532
+ getHasOverlap(): boolean;
2917
3533
  /**
2918
3534
  * Get the image UID at a given index.
2919
3535
  *
@@ -2954,7 +3570,7 @@ declare class Image_2 {
2954
3570
  * @todo Dangerous...
2955
3571
  * @returns {TypedArray} The data buffer of the image.
2956
3572
  */
2957
- getBuffer(): Int8Array | Uint8Array | Int16Array | Uint16Array | Int32Array | Uint32Array;
3573
+ getBuffer(): TypedArray;
2958
3574
  /**
2959
3575
  * Can the image values be quantified?
2960
3576
  *
@@ -2974,6 +3590,13 @@ declare class Image_2 {
2974
3590
  * @returns {boolean} True if the data is monochrome.
2975
3591
  */
2976
3592
  isMonochrome(): boolean;
3593
+ /**
3594
+ * Check is the image is a mask.
3595
+ *
3596
+ * @returns {boolean} True if mask.
3597
+ * @deprecated Since v0.37, please use `instanceof MaskImage` instead.
3598
+ */
3599
+ isMask(): boolean;
2977
3600
  /**
2978
3601
  * Can the data be scrolled?
2979
3602
  *
@@ -3069,19 +3692,15 @@ declare class Image_2 {
3069
3692
  /**
3070
3693
  * Get the meta information of the image.
3071
3694
  *
3072
- * @returns {Object<string, any>} The meta information of the image.
3695
+ * @returns {Record<string, any>} The meta information of the image.
3073
3696
  */
3074
- getMeta(): {
3075
- [x: string]: any;
3076
- };
3697
+ getMeta(): Record<string, any>;
3077
3698
  /**
3078
3699
  * Set the meta information of the image.
3079
3700
  *
3080
- * @param {Object<string, any>} rhs The meta information of the image.
3701
+ * @param {Record<string, any>} rhs The meta information of the image.
3081
3702
  */
3082
- setMeta(rhs: {
3083
- [x: string]: any;
3084
- }): void;
3703
+ setMeta(rhs: Record<string, any>): void;
3085
3704
  /**
3086
3705
  * Get value at offset. Warning: No size check...
3087
3706
  *
@@ -3089,14 +3708,6 @@ declare class Image_2 {
3089
3708
  * @returns {number} The value at offset.
3090
3709
  */
3091
3710
  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
3711
  /**
3101
3712
  * Check if the input values are in the buffer.
3102
3713
  * Could loop through the whole volume, can get long for big data...
@@ -3112,6 +3723,15 @@ declare class Image_2 {
3112
3723
  * @returns {Image} A clone of this image.
3113
3724
  */
3114
3725
  clone(): Image_2;
3726
+ /**
3727
+ * Replace the inner buffer wholesale (as opposed to editing its content
3728
+ * in place). Primarily intended for subclass use, where a private
3729
+ * (`#`) field on this class isn't reachable directly.
3730
+ *
3731
+ * @param {TypedArray} newBuffer The new buffer.
3732
+ * @fires Image#imagecontentchange
3733
+ */
3734
+ replaceBuffer(newBuffer: TypedArray): void;
3115
3735
  /**
3116
3736
  * Check if another image can be appended to this one.
3117
3737
  *
@@ -3119,7 +3739,7 @@ declare class Image_2 {
3119
3739
  * @returns {BooleanResult} Result with success set to true if
3120
3740
  * the image can be appended.
3121
3741
  */
3122
- canAppend(rhs: Image_2): BooleanResult;
3742
+ canAppendSlice(rhs: Image_2): BooleanResult;
3123
3743
  /**
3124
3744
  * Append a slice to the image.
3125
3745
  *
@@ -3137,10 +3757,11 @@ declare class Image_2 {
3137
3757
  /**
3138
3758
  * Append a frame to the image.
3139
3759
  *
3140
- * @param {number} time The frame time value.
3760
+ * @param {SourcedNumberValue} time The frame time: a volume id or, without
3761
+ * source, a frame index.
3141
3762
  * @param {Point3D} origin The origin of the frame.
3142
3763
  */
3143
- appendFrame(time: number, origin: Point3D): void;
3764
+ appendFrame(time: SourcedNumberValue, origin: Point3D): void;
3144
3765
  /**
3145
3766
  * Get the data range.
3146
3767
  *
@@ -3156,53 +3777,9 @@ declare class Image_2 {
3156
3777
  /**
3157
3778
  * Get the histogram.
3158
3779
  *
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
3780
+ * @returns {ImageHistogram} The histogram.
3204
3781
  */
3205
- setAtOffsetsWithIterator(offsetsLists: number[][], value: number | any[]): void;
3782
+ getHistogram(): ImageHistogram;
3206
3783
  /**
3207
3784
  * Get the value of the image at a specific coordinate.
3208
3785
  *
@@ -3249,6 +3826,17 @@ declare class Image_2 {
3249
3826
  * Warning: No size check...
3250
3827
  */
3251
3828
  getRescaledValueAtOffset(offset: number): number;
3829
+ /**
3830
+ * Get the rescaled values of all volumes (fourth dimension) at
3831
+ * a position.
3832
+ *
3833
+ * @param {Point} position The world position, only its first
3834
+ * three dimensions are used.
3835
+ * @returns {VolumeValue[]} The values with their unit and volume id,
3836
+ * ordered by volume index, empty if the position is out of bounds
3837
+ * or if the image cannot be quantified (more than one component).
3838
+ */
3839
+ getRescaledValuesAtPosition(position: Point): VolumeValue[];
3252
3840
  /**
3253
3841
  * Calculate the data range of the image.
3254
3842
  * WARNING: for speed reasons, only calculated on the first frame...
@@ -3263,12 +3851,6 @@ declare class Image_2 {
3263
3851
  * @returns {object} The range {min, max}.
3264
3852
  */
3265
3853
  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
3854
  /**
3273
3855
  * Convolute the image with a given 2D kernel.
3274
3856
  *
@@ -3287,7 +3869,7 @@ declare class Image_2 {
3287
3869
  * @param {TypedArray} buffer The buffer to convolute.
3288
3870
  * @param {number} startOffset The index to start at.
3289
3871
  */
3290
- convoluteBuffer(weights: number[], buffer: Int8Array | Uint8Array | Int16Array | Uint16Array | Int32Array | Uint32Array, startOffset: number): void;
3872
+ convoluteBuffer(weights: number[], buffer: TypedArray, startOffset: number): void;
3291
3873
  /**
3292
3874
  * Transform an image using a specific operator.
3293
3875
  * WARNING: no size check!
@@ -3308,52 +3890,168 @@ declare class Image_2 {
3308
3890
  */
3309
3891
  compose(rhs: Image_2, operator: Function): Image_2;
3310
3892
  /**
3311
- * Initialize the contour buffer.
3312
- * Should be called on every segmentation image, or any image where
3313
- * contour rendering needs to be supported.
3893
+ * Return if this image has been resampled.
3894
+ *
3895
+ * @returns {boolean} If the image has been resampled.
3314
3896
  */
3315
- initializeContour(): void;
3897
+ isResampled(): boolean;
3898
+ /**
3899
+ * Resample this image to a new orientation.
3900
+ *
3901
+ * @param {Matrix33} orientation The orientation to resample to.
3902
+ * @param {boolean|undefined} interpolated Default true, if true use bilinear
3903
+ * sampling, otherwise use nearest neighbor.
3904
+ * @param {Point|undefined} centerOfRotation World space center of rotation.
3905
+ */
3906
+ resample(orientation: Matrix33, interpolated?: boolean | undefined, centerOfRotation?: Point | undefined): void;
3907
+ /**
3908
+ * Revert a resampled image to its original state.
3909
+ */
3910
+ revert(): void;
3911
+ #private;
3912
+ }
3913
+ export { Image_2 as Image }
3914
+
3915
+ /**
3916
+ * Image contour buffer manager.
3917
+ * Caches per-pixel distance-to-border values for contour rendering.
3918
+ * Stores 3 distance values per pixel (one per orientation: x, y, z).
3919
+ */
3920
+ export declare class ImageContour {
3921
+ /**
3922
+ * Initialize the contour buffer.
3923
+ * Should be called on every segmentation image, or any image where
3924
+ * contour rendering needs to be supported.
3925
+ *
3926
+ * @param {Uint8Array} imageBuffer The image data buffer.
3927
+ * @param {Size} imageSize The image size.
3928
+ */
3929
+ initialize(imageBuffer: Uint8Array, imageSize: Size): void;
3316
3930
  /**
3317
3931
  * Get whether or not the contour buffer has been initialized.
3318
3932
  *
3319
3933
  * @returns {boolean} True if buffer has been initialized.
3320
3934
  */
3321
- countourIsInitialized(): boolean;
3935
+ isInitialized(): boolean;
3936
+ /**
3937
+ * Re-allocate contour buffer memory after an image buffer resize.
3938
+ * Updates the stored image buffer and size references.
3939
+ *
3940
+ * @param {Uint8Array} imageBuffer The new image data buffer.
3941
+ * @param {Size} imageSize The new image size.
3942
+ */
3943
+ realloc(imageBuffer: Uint8Array, imageSize: Size): void;
3944
+ /**
3945
+ * Shift contour buffer content to make room for an inserted slice.
3946
+ *
3947
+ * @param {number} contourIndexOffset Start offset of the slice to shift.
3948
+ * @param {number} contourSliceSize Size of one contour slice.
3949
+ * @param {number} contourMaxOffset End offset of content to shift.
3950
+ */
3951
+ shiftSlice(contourIndexOffset: number, contourSliceSize: number, contourMaxOffset: number): void;
3952
+ /**
3953
+ * Reset contour buffer for the values around an offset.
3954
+ * Prevents certain artifacts, especially at small brush sizes
3955
+ * and when erasing.
3956
+ *
3957
+ * @param {number} offset The offset to reset.
3958
+ */
3959
+ resetAroundOffset(offset: number): void;
3322
3960
  /**
3323
- * Calculate the distance to the nearest border pixel.
3961
+ * Calculate the distance to the nearest border pixel
3324
3962
  * (or return the cached distance).
3963
+ * Returns 0 if the contour buffer is not initialized.
3325
3964
  *
3326
3965
  * @param {number} index Index/offset of the pixel to check.
3327
3966
  * @param {Matrix33} viewOrientation The orientation of the view.
3328
3967
  * @returns {number} The distance to the nearest border pixel or 0.
3329
3968
  */
3330
- getContourDistance(index: number, viewOrientation: Matrix33): number;
3969
+ getDistance(index: number, viewOrientation: Matrix33): number;
3970
+ #private;
3971
+ }
3972
+
3973
+ /**
3974
+ * @import {RescaleSlopeAndIntercept} from './rsi.js';
3975
+ * @import {NumberRange} from '../math/number.js';
3976
+ * @import {Statistics} from '../math/stats.js';
3977
+ */
3978
+ /**
3979
+ * Histogram of image values.
3980
+ *
3981
+ * Raw (stored) values are counted in one {@link Histogram} per rescale
3982
+ * slope and intercept (RSI). Values are rescaled when read. An image
3983
+ * with a constant RSI only has one histogram.
3984
+ */
3985
+ export declare class ImageHistogram {
3331
3986
  /**
3332
- * Recalculate labels.
3987
+ * @param {string} [unit] The unit of the rescaled values.
3333
3988
  */
3334
- recalculateLabels(): void;
3989
+ constructor(unit?: string);
3335
3990
  /**
3336
- * Return if this image has been resampled.
3991
+ * Get the unit of the rescaled values.
3337
3992
  *
3338
- * @returns {boolean} If the image has been resampled.
3993
+ * @returns {string|undefined} The unit, undefined if not known.
3339
3994
  */
3340
- isResampled(): boolean;
3995
+ getUnit(): string | undefined;
3341
3996
  /**
3342
- * Resample this image to a new orientation.
3997
+ * Get the raw value histogram for an RSI, creating it if needed.
3343
3998
  *
3344
- * @param {Matrix33} orientation The orientation to resample to.
3345
- * @param {boolean|undefined} interpolated Default true, if true use bilinear
3346
- * sampling, otherwise use nearest neighbor.
3347
- * @param {Point|undefined} centerOfRotation World space center of rotation.
3999
+ * @param {RescaleSlopeAndIntercept} rsi The RSI of the raw values.
4000
+ * @returns {Histogram} The raw value histogram.
3348
4001
  */
3349
- resample(orientation: Matrix33, interpolated?: boolean | undefined, centerOfRotation?: Point | undefined): void;
4002
+ getHistogram(rsi: RescaleSlopeAndIntercept): Histogram;
3350
4003
  /**
3351
- * Revert a resampled image to its original state.
4004
+ * Add one raw value.
4005
+ *
4006
+ * @param {number} rawValue The raw value.
4007
+ * @param {RescaleSlopeAndIntercept} rsi The RSI of the raw value.
3352
4008
  */
3353
- revert(): void;
4009
+ add(rawValue: number, rsi: RescaleSlopeAndIntercept): void;
4010
+ /**
4011
+ * Get the total number of counted values.
4012
+ *
4013
+ * @returns {number} The total count.
4014
+ */
4015
+ getTotal(): number;
4016
+ /**
4017
+ * Get the value range (raw values).
4018
+ *
4019
+ * @returns {NumberRange|undefined} The range, undefined if empty.
4020
+ */
4021
+ getRange(): NumberRange | undefined;
4022
+ /**
4023
+ * Get the histogram of the rescaled values: raw values of each RSI
4024
+ * are rescaled and equal rescaled values merged.
4025
+ *
4026
+ * @returns {Histogram} The rescaled value histogram.
4027
+ */
4028
+ getRescaledHistogram(): Histogram;
4029
+ /**
4030
+ * Get the rescaled value range.
4031
+ *
4032
+ * @returns {NumberRange|undefined} The range, undefined if empty.
4033
+ */
4034
+ getRescaledRange(): NumberRange | undefined;
4035
+ /**
4036
+ * Get the percentage of counts that fall in each interval defined by
4037
+ * interior rescaled thresholds,
4038
+ * see {@link Histogram#getIntervalPercentages}.
4039
+ *
4040
+ * @param {number[]} thresholds Interior rescaled cut points in ascending
4041
+ * order.
4042
+ * @returns {number[]} The percentages in [0, 100], one per interval
4043
+ * (`thresholds.length + 1` entries), all 0 for an empty histogram.
4044
+ */
4045
+ getIntervalPercentages(thresholds: number[]): number[];
4046
+ /**
4047
+ * Get the statistics of the rescaled values,
4048
+ * see {@link Histogram#getStats}.
4049
+ *
4050
+ * @returns {Statistics|undefined} The statistics, undefined if empty.
4051
+ */
4052
+ getStats(): Statistics | undefined;
3354
4053
  #private;
3355
4054
  }
3356
- export { Image_2 as Image }
3357
4055
 
3358
4056
  /**
3359
4057
  * Immutable index.
@@ -3450,15 +4148,13 @@ export declare class Index {
3450
4148
  /**
3451
4149
  * DICOM Header info data.
3452
4150
  */
3453
- export declare class InfoData {
4151
+ export declare class InfoData extends EventTarget {
3454
4152
  /**
3455
4153
  * @param {App} app The associated application.
3456
4154
  * @param {string} dataId The associated data id.
3457
- * @param {Object<string, InfoDataItem[]>} configs The info data config.
4155
+ * @param {Record<string, InfoDataItem[]>} configs The info data config.
3458
4156
  */
3459
- constructor(app: App, dataId: string, configs: {
3460
- [x: string]: InfoDataItem[];
3461
- });
4157
+ constructor(app: App, dataId: string, configs: Record<string, InfoDataItem[]>);
3462
4158
  /**
3463
4159
  * Reset the data.
3464
4160
  */
@@ -3466,17 +4162,23 @@ export declare class InfoData {
3466
4162
  /**
3467
4163
  * Handle a new loaded item event.
3468
4164
  *
3469
- * @param {Object<string, DataElement>} data The item meta data.
4165
+ * @param {Record<string, DataElement>} data The item meta data.
3470
4166
  */
3471
- addItemMeta(data: {
3472
- [x: string]: DataElement;
3473
- }): void;
4167
+ addItemMeta(data: Record<string, DataElement>): void;
3474
4168
  /**
3475
4169
  * Handle a changed slice event.
3476
4170
  *
3477
- * @param {object} event The slicechange event.
4171
+ * @param {CustomEvent} event The slicechange event.
4172
+ * @deprecated Since v0.37, please use onPositionChange.
3478
4173
  */
3479
- onSliceChange: (event: object) => void;
4174
+ onSliceChange: (event: CustomEvent) => void;
4175
+ /**
4176
+ * Handle a changed position event: updates the tags on slice change
4177
+ * and the position event items.
4178
+ *
4179
+ * @param {CustomEvent} event The positionchange event.
4180
+ */
4181
+ onPositionChange: (event: CustomEvent) => void;
3480
4182
  /**
3481
4183
  * Is this class listening to app events.
3482
4184
  *
@@ -3491,25 +4193,13 @@ export declare class InfoData {
3491
4193
  * Toggle info listeners.
3492
4194
  */
3493
4195
  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
4196
  #private;
3511
4197
  }
3512
4198
 
4199
+ /**
4200
+ * @import {App} from '../app/application.js';
4201
+ * @import {DataElement} from '../dicom/dataElement.js';
4202
+ */
3513
4203
  /**
3514
4204
  * Info data item class.
3515
4205
  */
@@ -3542,6 +4232,11 @@ export declare class InfoDataItem {
3542
4232
  value: string;
3543
4233
  }
3544
4234
 
4235
+ /**
4236
+ * List of compatible integer typed arrays.
4237
+ */
4238
+ export declare type IntTypedArray = (Uint8Array | Int8Array | Uint16Array | Int16Array | Uint32Array | Int32Array);
4239
+
3545
4240
  /**
3546
4241
  * Check if two rgb objects are equal.
3547
4242
  *
@@ -3570,9 +4265,9 @@ export declare class Label {
3570
4265
  /**
3571
4266
  * The volume of the labeled segment.
3572
4267
  *
3573
- * @type {Value}
4268
+ * @type {NumberValue}
3574
4269
  */
3575
- volume: Value;
4270
+ volume: NumberValue;
3576
4271
  /**
3577
4272
  * The voxel count of the labeled segment.
3578
4273
  *
@@ -3588,9 +4283,9 @@ export declare class Label {
3588
4283
  /**
3589
4284
  * The scaled height of the segment.
3590
4285
  *
3591
- * @type {Value}
4286
+ * @type {NumberValue}
3592
4287
  */
3593
- height: Value;
4288
+ height: NumberValue;
3594
4289
  /**
3595
4290
  * The segment label id.
3596
4291
  *
@@ -3603,8 +4298,34 @@ export declare class Label {
3603
4298
  * @type {number}
3604
4299
  */
3605
4300
  largestSliceZ: number;
4301
+ /**
4302
+ * The minimum Z index of the segment.
4303
+ *
4304
+ * @type {number}
4305
+ */
4306
+ minZ: number;
4307
+ /**
4308
+ * The maximum Z index of the segment.
4309
+ *
4310
+ * @type {number}
4311
+ */
4312
+ maxZ: number;
3606
4313
  }
3607
4314
 
4315
+ /**
4316
+ * Histogram of the segment voxels of a label.
4317
+ */
4318
+ export declare type LabelHistogram = {
4319
+ /**
4320
+ * The label.
4321
+ */
4322
+ label: Label;
4323
+ /**
4324
+ * The label histogram.
4325
+ */
4326
+ histogram: ImageHistogram;
4327
+ };
4328
+
3608
4329
  /**
3609
4330
  * CIE LAB value (L: [0, 100], a: [-128, 127], b: [-128, 127]) to
3610
4331
  * unsigned int CIE LAB ([0, 65535]).
@@ -3630,7 +4351,7 @@ export declare function labToUintLab(triplet: object): object;
3630
4351
  * - planePos = viewController.getOffset3DFromPlaneOffset(pos)
3631
4352
  * no need yet for a planePos to displayPos...
3632
4353
  */
3633
- export declare class LayerGroup {
4354
+ export declare class LayerGroup extends EventTarget {
3634
4355
  /**
3635
4356
  * @param {HTMLElement} containerDiv The associated HTML div.
3636
4357
  * @param {boolean} [withInfoLayer] Optional with info layer flag,
@@ -3937,10 +4658,10 @@ export declare class LayerGroup {
3937
4658
  /**
3938
4659
  * Update layers (but not the event source layer) to a position change.
3939
4660
  *
3940
- * @param {object} event The position change event.
4661
+ * @param {CustomEvent} event The position change event.
3941
4662
  * @function
3942
4663
  */
3943
- updateLayersToPositionChange: (event: object) => void;
4664
+ updateLayersToPositionChange: (event: CustomEvent) => void;
3944
4665
  /**
3945
4666
  * Calculate the div to world size ratio needed to fit
3946
4667
  * the largest data.
@@ -4016,22 +4737,6 @@ export declare class LayerGroup {
4016
4737
  * @param {boolean} flag Whether to display the layer or not.
4017
4738
  */
4018
4739
  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
4740
  #private;
4036
4741
  }
4037
4742
 
@@ -4044,21 +4749,45 @@ export declare namespace logger {
4044
4749
  let ERROR: number;
4045
4750
  }
4046
4751
  let level: number;
4752
+ /**
4753
+ * Log a trace message.
4754
+ *
4755
+ * @param {string} msg The message to log.
4756
+ */
4047
4757
  export function trace(msg: string): void;
4758
+ /**
4759
+ * Log a debug message.
4760
+ * Careful: depends on console settings.
4761
+ *
4762
+ * @param {string} msg The message to log.
4763
+ */
4048
4764
  export function debug(msg: string): void;
4765
+ /**
4766
+ * Log an info message.
4767
+ *
4768
+ * @param {string} msg The message to log.
4769
+ */
4049
4770
  export function info(msg: string): void;
4771
+ /**
4772
+ * Log a warn message.
4773
+ *
4774
+ * @param {string} msg The message to log.
4775
+ */
4050
4776
  export function warn(msg: string): void;
4777
+ /**
4778
+ * Log an error message.
4779
+ *
4780
+ * @param {string} msg The message to log.
4781
+ */
4051
4782
  export function error(msg: string): void;
4052
4783
  }
4053
4784
 
4054
4785
  /**
4055
4786
  * List of available lookup tables (lut).
4056
4787
  *
4057
- * @type {Object<string, ColourMap>}
4788
+ * @type {Record<string, ColourMap>}
4058
4789
  */
4059
- export declare const luts: {
4060
- [x: string]: ColourMap;
4061
- };
4790
+ export declare const luts: Record<string, ColourMap>;
4062
4791
 
4063
4792
  /**
4064
4793
  * Mask {@link Image} factory.
@@ -4074,41 +4803,177 @@ export declare class MaskFactory {
4074
4803
  /**
4075
4804
  * Check dicom elements.
4076
4805
  *
4077
- * @param {Object<string, DataElement>} _dicomElements The DICOM tags.
4806
+ * @param {Record<string, DataElement>} _dicomElements The DICOM tags.
4078
4807
  * @returns {string|undefined} A possible warning.
4079
4808
  */
4080
- checkElements(_dicomElements: {
4081
- [x: string]: DataElement;
4082
- }): string | undefined;
4809
+ checkElements(_dicomElements: Record<string, DataElement>): string | undefined;
4083
4810
  /**
4084
- * Get an {@link Image} object from the read DICOM file.
4811
+ * Get a {@link MaskImage} object from the read DICOM file.
4085
4812
  *
4086
- * @param {Object<string, DataElement>} dataElements The DICOM tags.
4087
- * @param {Uint8Array | Int8Array |
4088
- * Uint16Array | Int16Array |
4089
- * Uint32Array | Int32Array} pixelBuffer The pixel buffer.
4813
+ * @param {Record<string, DataElement>} dataElements The DICOM tags.
4814
+ * @param {Uint8Array} pixelBuffer The pixel buffer.
4090
4815
  * @param {Image} [refImage] Reference image, code will use its
4091
4816
  * origins if present (best) or try to calculate them.
4092
- * @returns {Image} A new Image.
4817
+ * @returns {MaskImage} A new mask image.
4093
4818
  * @throws {Error} Error for missing or wrong data.
4094
4819
  */
4095
- create(dataElements: {
4096
- [x: string]: DataElement;
4097
- }, pixelBuffer: Uint8Array | Int8Array | Uint16Array | Int16Array | Uint32Array | Int32Array, refImage?: Image_2): Image_2;
4820
+ create(dataElements: Record<string, DataElement>, pixelBuffer: Uint8Array, refImage?: Image_2): MaskImage;
4098
4821
  /**
4099
4822
  * Convert a mask image into a DICOM segmentation object.
4100
4823
  *
4101
- * @param {Image} image The mask image.
4824
+ * @param {MaskImage} image The mask image.
4102
4825
  * @param {MaskSegment[]} segments The mask segments.
4103
4826
  * @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.
4827
+ * @param {SimpleTagValues} [extraTags] Optional list of extra tags.
4828
+ * @returns {Record<string, DataElement>} A list of dicom elements.
4106
4829
  */
4107
- toDicom(image: Image_2, segments: MaskSegment[], sourceImage: Image_2, extraTags?: {
4108
- [x: string]: any;
4109
- }): {
4110
- [x: string]: DataElement;
4111
- };
4830
+ toDicom(image: MaskImage, segments: MaskSegment[], sourceImage: Image_2, extraTags?: SimpleTagValues): Record<string, DataElement>;
4831
+ #private;
4832
+ }
4833
+
4834
+ /**
4835
+ * Mask (segmentation) image class.
4836
+ * Extends {@link Image} with a {@link SegmentCollection} and the
4837
+ * segment-aware behavior built on top of it: per-segment/per-slice
4838
+ * bookkeeping, the brush tool's offset-editing methods, and per-segment
4839
+ * labeling statistics (volume/centroid/diameter).
4840
+ */
4841
+ export declare class MaskImage extends Image_2 {
4842
+ /**
4843
+ * @param {Geometry} geometry The geometry of the image.
4844
+ * @param {Uint8Array} buffer The mask data as a one dimensional buffer:
4845
+ * one byte per voxel, 0 for background, the segment number otherwise.
4846
+ * @param {string[]} [imageUids] An array of Uids indexed to slice number.
4847
+ * @param {SegmentCollection} [segmentCollection] The segment collection,
4848
+ * for a mask already parsed from DICOM (its own label map already
4849
+ * aliases `buffer`). When omitted (brush-created masks), a fresh
4850
+ * collection is created and its label map is aliased to `buffer`.
4851
+ */
4852
+ constructor(geometry: Geometry, buffer: Uint8Array, imageUids?: string[], segmentCollection?: SegmentCollection);
4853
+ /**
4854
+ * Initialize the contour buffer.
4855
+ * Should be called on every segmentation image, or any image where
4856
+ * contour rendering needs to be supported.
4857
+ */
4858
+ initializeContour(): void;
4859
+ /**
4860
+ * Get the image contour. Should only be available
4861
+ * for segmentation images, but can be initialized
4862
+ * for any Uint8Array image.
4863
+ *
4864
+ * @returns {ImageContour} The image contour.
4865
+ */
4866
+ getContour(): ImageContour;
4867
+ /**
4868
+ * Get the segment collection.
4869
+ *
4870
+ * @returns {SegmentCollection} The segment collection.
4871
+ */
4872
+ getSegmentCollection(): SegmentCollection;
4873
+ /**
4874
+ * Get the UID of the series referenced by the mask, if any.
4875
+ *
4876
+ * @returns {string|undefined} The UID.
4877
+ */
4878
+ getMaskReferencedSeriesUID(): string | undefined;
4879
+ /**
4880
+ * Get the numbers of the segments present at an index.
4881
+ * When segments overlap, all the segments at the index are returned,
4882
+ * not only the one stored in the buffer (first wins).
4883
+ *
4884
+ * @param {Index} index The index, no bounds check.
4885
+ * @returns {number[]} The sorted list of segment numbers,
4886
+ * empty for background.
4887
+ */
4888
+ getSegmentNumbersAtIndex(index: Index): number[];
4889
+ /**
4890
+ * Get the offsets where the buffer equals the input value.
4891
+ * Loops through the whole volume, can get long for big data...
4892
+ *
4893
+ * @param {number|RGB} value The value to check.
4894
+ * @returns {number[]} The list of offsets.
4895
+ */
4896
+ getOffsets(value: number | RGB): number[];
4897
+ /**
4898
+ * Set the inner buffer values at given offsets.
4899
+ *
4900
+ * @param {number[]} offsets List of offsets where to set the data.
4901
+ * @param {number|RGB} value The value to set at the given offsets.
4902
+ * @fires Image#imagecontentchange
4903
+ */
4904
+ setAtOffsets(offsets: number[], value: number | RGB): void;
4905
+ /**
4906
+ * Set the inner buffer values at given offsets, each to its own value.
4907
+ * Used when a single uniform value cannot be used across all offsets,
4908
+ * for example restoring the segment still present at a voxel that used
4909
+ * to be hidden by an overlapping, now deleted, segment.
4910
+ *
4911
+ * @param {number[]} offsets List of offsets where to set the data.
4912
+ * @param {number[]} values Per-offset values, same length as offsets.
4913
+ * @fires Image#imagecontentchange
4914
+ */
4915
+ setAtOffsetsWithValues(offsets: number[], values: number[]): void;
4916
+ /**
4917
+ * Set the inner buffer values at given offsets.
4918
+ *
4919
+ * @param {number[][]} offsetsLists List of offset lists where
4920
+ * to set the data.
4921
+ * @param {number} value The value to set at the given offsets.
4922
+ * @returns {Array} A list of objects representing the original values before
4923
+ * replacing them.
4924
+ * @fires Image#imagecontentchange
4925
+ */
4926
+ setAtOffsetsAndGetOriginals(offsetsLists: number[][], value: number): any[];
4927
+ /**
4928
+ * Set the inner buffer values at given offsets.
4929
+ *
4930
+ * @param {number[][]} offsetsLists List of offset lists
4931
+ * where to set the data.
4932
+ * @param {number|Array} value The value to set at the given offsets.
4933
+ * @fires Image#imagecontentchange
4934
+ */
4935
+ setAtOffsetsWithIterator(offsetsLists: number[][], value: number | any[]): void;
4936
+ /**
4937
+ * Get the labels from the last labeling (see
4938
+ * {@link MaskImage#recalculateLabels}).
4939
+ *
4940
+ * @returns {Label[]|undefined} The labels, undefined if not calculated.
4941
+ */
4942
+ getLabels(): Label[] | undefined;
4943
+ /**
4944
+ * Recalculate labels.
4945
+ *
4946
+ * @fires Image#labelingstart
4947
+ * @fires Image#labelschanged
4948
+ */
4949
+ recalculateLabels(): void;
4950
+ /**
4951
+ * Clone the mask image.
4952
+ *
4953
+ * @returns {MaskImage} A clone of this mask image.
4954
+ */
4955
+ clone(): MaskImage;
4956
+ /**
4957
+ * Get per-volume histograms of reference-image intensities for one segment.
4958
+ *
4959
+ * For each volume of `image`, counts how often each intensity
4960
+ * appears in voxels belonging to the given segment of this mask.
4961
+ * Segmentations are 3D: the same mask is applied to every volume.
4962
+ * Raw values are counted per rescale slope and intercept and rescaled
4963
+ * when read from the {@link ImageHistogram}.
4964
+ *
4965
+ * If labels are available (see {@link MaskImage#getLabels}), each entry
4966
+ * also has `labelHistograms`: one histogram per label of the segment, made of
4967
+ * the segment voxels between the label min and max Z. Since labels
4968
+ * of the same segment that share slices cannot be separated this way,
4969
+ * `labelHistograms` is not provided in that case.
4970
+ *
4971
+ * @param {Image} image The reference image (intensities).
4972
+ * @param {string} segmentId Segment tracking UID, or segment number as
4973
+ * string.
4974
+ * @returns {SegmentHistogram[]} One entry per volume.
4975
+ */
4976
+ getHistogramBySegment(image: Image_2, segmentId: string): SegmentHistogram[];
4112
4977
  #private;
4113
4978
  }
4114
4979
 
@@ -4186,8 +5051,24 @@ export declare class MaskSegment {
4186
5051
  * @type {string|undefined}
4187
5052
  */
4188
5053
  trackingId: string | undefined;
5054
+ /**
5055
+ * RT ROI interpreted type (3006,00A4), only used for RTSTRUCT segments.
5056
+ *
5057
+ * @type {string|undefined}
5058
+ */
5059
+ interpretedType: string | undefined;
5060
+ /**
5061
+ * RT ROI interpreter name (3006,00A6), only used for RTSTRUCT segments.
5062
+ *
5063
+ * @type {string|undefined}
5064
+ */
5065
+ roiInterpreter: string | undefined;
4189
5066
  }
4190
5067
 
5068
+ /**
5069
+ * @import {MaskImage} from './maskImage.js';
5070
+ * @import {MaskSegment} from '../dicom/dicomSegment.js';
5071
+ */
4191
5072
  /**
4192
5073
  * Mask segment helper: helps handling the segments list,
4193
5074
  * but does *NOT* update the associated mask (use special commands
@@ -4195,15 +5076,15 @@ export declare class MaskSegment {
4195
5076
  */
4196
5077
  export declare class MaskSegmentHelper {
4197
5078
  /**
4198
- * @param {Image} mask The associated mask image.
5079
+ * @param {MaskImage} mask The associated mask image.
4199
5080
  */
4200
- constructor(mask: Image_2);
5081
+ constructor(mask: MaskImage);
4201
5082
  /**
4202
5083
  * Get the associated mask image.
4203
5084
  *
4204
- * @returns {Image} The mask image.
5085
+ * @returns {MaskImage} The mask image.
4205
5086
  */
4206
- getMask(): Image_2;
5087
+ getMask(): MaskImage;
4207
5088
  /**
4208
5089
  * Check if a segment is part of the segments list.
4209
5090
  *
@@ -4264,7 +5145,7 @@ export declare class MaskSegmentHelper {
4264
5145
  *
4265
5146
  * @typedef Overlap@typedef Overlap
4266
5147
  * @property {string} label The segment label.
4267
- * @property {Object.<number, OverlapCount>} overlap A Dictionary
5148
+ * @property {Record<number, OverlapCount>} overlap A Dictionary
4268
5149
  * containing the counts. The key is the segment number of the overlapping
4269
5150
  * segment.
4270
5151
  * @property {number} count The voxel volume of this segment.
@@ -4276,7 +5157,7 @@ export declare class MaskSegmentHelper {
4276
5157
  * The value is a Dictionary of all of the segments in the second set
4277
5158
  * that overlap with the key segment.
4278
5159
  *
4279
- * @typedef {Object.<number, Overlap>} OverlapMap
5160
+ * @typedef {Record<number, Overlap>} OverlapMap
4280
5161
  */
4281
5162
  /**
4282
5163
  * Find the overlap for each segment between two segmentation masks.
@@ -4287,39 +5168,35 @@ export declare class MaskSegmentHelper {
4287
5168
  * @returns {OverlapMap} The overlapping voxel counts. First level is the
4288
5169
  * segments from this image, second level is the compare image segments.
4289
5170
  */
4290
- findOverlap(rhs: MaskSegmentHelper): {
4291
- [x: number]: {
5171
+ findOverlap(rhs: MaskSegmentHelper): Record<number, {
5172
+ /**
5173
+ * The segment label.
5174
+ */
5175
+ label: string;
5176
+ /**
5177
+ * A Dictionary
5178
+ * containing the counts. The key is the segment number of the overlapping
5179
+ * segment.
5180
+ */
5181
+ overlap: Record<number, {
4292
5182
  /**
4293
5183
  * The segment label.
4294
5184
  */
4295
5185
  label: string;
4296
5186
  /**
4297
- * A Dictionary
4298
- * containing the counts. The key is the segment number of the overlapping
4299
- * segment.
5187
+ * The number of overlapping voxels.
4300
5188
  */
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
- };
5189
+ count: number;
4317
5190
  /**
4318
- * The voxel volume of this segment.
5191
+ * The overlap percentage between 0 and 100.
4319
5192
  */
4320
- count: number;
4321
- };
4322
- };
5193
+ percentage: number;
5194
+ }>;
5195
+ /**
5196
+ * The voxel volume of this segment.
5197
+ */
5198
+ count: number;
5199
+ }>;
4323
5200
  #private;
4324
5201
  }
4325
5202
 
@@ -4349,6 +5226,9 @@ export declare class MaskSegmentViewHelper {
4349
5226
  #private;
4350
5227
  }
4351
5228
 
5229
+ /**
5230
+ * @import {TypedArray} from './types.js';
5231
+ */
4352
5232
  /**
4353
5233
  * Immutable 3x3 Matrix.
4354
5234
  */
@@ -4417,16 +5297,10 @@ export declare class Matrix33 {
4417
5297
  /**
4418
5298
  * Multiply this matrix by a 3D typed array.
4419
5299
  *
4420
- * @typedef {(
4421
- * Uint8Array | Int8Array |
4422
- * Uint16Array | Int16Array |
4423
- * Uint32Array | Int32Array
4424
- * )} TypedArray
4425
- *
4426
5300
  * @param {TypedArray} sourceArray The input 3D array.
4427
5301
  * @param {TypedArray} outArray The array to write to.
4428
5302
  */
4429
- multiplyTypedArray3D(sourceArray: Int8Array | Uint8Array | Int16Array | Uint16Array | Int32Array | Uint32Array, outArray: Int8Array | Uint8Array | Int16Array | Uint16Array | Int32Array | Uint32Array): void;
5303
+ multiplyTypedArray3D(sourceArray: TypedArray, outArray: TypedArray): void;
4430
5304
  /**
4431
5305
  * Multiply this matrix by a 3D vector.
4432
5306
  *
@@ -4483,15 +5357,43 @@ export declare class Matrix33 {
4483
5357
  #private;
4484
5358
  }
4485
5359
 
5360
+ /**
5361
+ * Merge two mask images into a new combined mask image.
5362
+ *
5363
+ * Segments from mask2 that share a segment number with mask1 are renumbered
5364
+ * (bumped to the next available number) to avoid conflicts. Both masks must
5365
+ * share the same spacing and orientation; the wider of the two geometries
5366
+ * (the one with more slices) is used as the merged geometry, so a mask
5367
+ * that only covers a sub-range of the other's slices does not get clipped.
5368
+ * Brush-painted masks (no per-segment SegmentCollection data) are supported.
5369
+ *
5370
+ * The returned image can be saved with the standard
5371
+ * `new MaskFactory().toDicom(merged, undefined, sourceImage)` workflow.
5372
+ *
5373
+ * @param {MaskImage} mask1 The first mask (provides meta).
5374
+ * @param {MaskImage} mask2 The second mask to merge into mask1.
5375
+ * @returns {MaskImage} The new merged mask image.
5376
+ */
5377
+ export declare function mergeMaskImages(mask1: MaskImage, mask2: MaskImage): MaskImage;
5378
+
5379
+ /**
5380
+ * Merge a simple tag value list into another. Mutates the
5381
+ * first input.
5382
+ *
5383
+ * @param {SimpleTagValues} list1 Base list, will be modified.
5384
+ * @param {SimpleTagValues} list2 List to merge into list1.
5385
+ */
5386
+ export declare function mergeTagValues(list1: SimpleTagValues, list2: SimpleTagValues): void;
5387
+
4486
5388
  export declare namespace NormalisedManufacturers {
4487
5389
  let GE: string;
4488
5390
  let SIEMENS: string;
4489
5391
  let PHILIPS: string;
4490
- let HITASHI: string;
5392
+ let HITACHI: string;
4491
5393
  }
4492
5394
 
4493
5395
  /**
4494
- * Number range.
5396
+ * Number range: [min, max].
4495
5397
  */
4496
5398
  export declare class NumberRange {
4497
5399
  /**
@@ -4509,12 +5411,36 @@ export declare class NumberRange {
4509
5411
  max: number;
4510
5412
  }
4511
5413
 
4512
- export declare namespace Orientation {
5414
+ /**
5415
+ * Number value and its unit.
5416
+ */
5417
+ export declare type NumberValue = {
5418
+ /**
5419
+ * The value.
5420
+ */
5421
+ value: number;
5422
+ /**
5423
+ * The value unit, passed to `i18n.t` for
5424
+ * display: an i18n key (for example 'unit.mm') or a plain unit
5425
+ * (for example 'HU').
5426
+ */
5427
+ unit?: string;
5428
+ };
5429
+
5430
+ export declare namespace Orientation {
4513
5431
  let Axial: string;
4514
5432
  let Coronal: string;
4515
5433
  let Sagittal: string;
4516
5434
  }
4517
5435
 
5436
+ /**
5437
+ * @import {Point} from '../math/point.js';
5438
+ * @import {Index} from '../math/index.js';
5439
+ * @import {Geometry} from '../image/geometry.js';
5440
+ * @import {Matrix33} from '../math/matrix.js';
5441
+ * @import {Spacing} from './spacing.js';
5442
+ * @import {Scalar2D, Scalar3D} from '../math/scalar.js';
5443
+ */
4518
5444
  /**
4519
5445
  * Plane geometry helper.
4520
5446
  */
@@ -4782,6 +5708,14 @@ export declare class Point2D {
4782
5708
  * @returns {Point2D} The centroid point.
4783
5709
  */
4784
5710
  getCentroid(): Point2D;
5711
+ /**
5712
+ * Check if a point is at this point, within a tolerance.
5713
+ *
5714
+ * @param {Point2D} point The point to check.
5715
+ * @param {number} [tolerance] Optional maximum distance, defaults to 0.
5716
+ * @returns {boolean} True if the point is within tolerance.
5717
+ */
5718
+ contains(point: Point2D, tolerance?: number): boolean;
4785
5719
  /**
4786
5720
  * Check for Point2D equality.
4787
5721
  *
@@ -5055,6 +5989,30 @@ export declare class PositionHelper {
5055
5989
  */
5056
5990
  export declare function precisionRound(number: number, precision: number): number;
5057
5991
 
5992
+ /**
5993
+ * Private diffusion b-value tag rule: either `{manufacturer, key}`
5994
+ * or `{uidPrefix, key}`.
5995
+ */
5996
+ export declare type PrivateBValueRule = {
5997
+ /**
5998
+ * The normalised manufacturer.
5999
+ */
6000
+ manufacturer?: string;
6001
+ /**
6002
+ * The SOP instance UID prefix.
6003
+ */
6004
+ uidPrefix?: string;
6005
+ /**
6006
+ * The private tag key.
6007
+ */
6008
+ key: string;
6009
+ };
6010
+
6011
+ /**
6012
+ * @import {Point2D} from '../math/point.js';
6013
+ * @import {NumberValue} from './types.js';
6014
+ * @import {ViewController} from '../app/viewController.js';
6015
+ */
5058
6016
  /**
5059
6017
  * Protractor shape: 3 points from which to calculate an angle.
5060
6018
  */
@@ -5084,16 +6042,23 @@ export declare class Protractor {
5084
6042
  * @returns {Point2D} THe centroid point.
5085
6043
  */
5086
6044
  getCentroid(): Point2D;
6045
+ /**
6046
+ * Check if a point is on one of the protractor lines, within a tolerance.
6047
+ *
6048
+ * @param {Point2D} point The point to check.
6049
+ * @param {number} [tolerance] Optional maximum distance to the lines,
6050
+ * defaults to 0.
6051
+ * @returns {boolean} True if the point is on the protractor.
6052
+ */
6053
+ contains(point: Point2D, tolerance?: number): boolean;
5087
6054
  /**
5088
6055
  * Quantify a path according to view information.
5089
6056
  *
5090
6057
  * @param {ViewController} _viewController The associated view controller.
5091
6058
  * @param {string[]} _flags A list of stat values to calculate.
5092
- * @returns {Object<string, Value>} A quantification object.
6059
+ * @returns {Record<string, NumberValue>} A quantification object.
5093
6060
  */
5094
- quantify(_viewController: ViewController, _flags: string[]): {
5095
- [x: string]: Value;
5096
- };
6061
+ quantify(_viewController: ViewController, _flags: string[]): Record<string, NumberValue>;
5097
6062
  #private;
5098
6063
  }
5099
6064
 
@@ -5177,6 +6142,16 @@ export declare class Rectangle {
5177
6142
  * @returns {Point2D} The centroid point.
5178
6143
  */
5179
6144
  getCentroid(): Point2D;
6145
+ /**
6146
+ * Check if a point is inside the rectangle, or within a tolerance
6147
+ * of its outline.
6148
+ *
6149
+ * @param {Point2D} point The point to check.
6150
+ * @param {number} [tolerance] Optional maximum distance to the outline
6151
+ * for an outside point, defaults to 0.
6152
+ * @returns {boolean} True if the point is in the rectangle.
6153
+ */
6154
+ contains(point: Point2D, tolerance?: number): boolean;
5180
6155
  /**
5181
6156
  * Quantify a rectangle according to view information.
5182
6157
  *
@@ -5184,11 +6159,9 @@ export declare class Rectangle {
5184
6159
  * @param {Index} index The index at which to get the
5185
6160
  * image values.
5186
6161
  * @param {string[]} flags A list of stat values to calculate.
5187
- * @returns {Object<string, Value>} A quantification object.
6162
+ * @returns {Record<string, NumberValue>} A quantification object.
5188
6163
  */
5189
- quantify(viewController: ViewController, index: Index, flags: string[]): {
5190
- [x: string]: Value;
5191
- };
6164
+ quantify(viewController: ViewController, index: Index, flags: string[]): Record<string, NumberValue>;
5192
6165
  #private;
5193
6166
  }
5194
6167
 
@@ -5254,6 +6227,9 @@ export declare class ResponseEvaluation {
5254
6227
  measure: number;
5255
6228
  }
5256
6229
 
6230
+ /**
6231
+ * @import {Scalar3D} from '../math/scalar.js';
6232
+ */
5257
6233
  /**
5258
6234
  * RGB colour class.
5259
6235
  */
@@ -5341,6 +6317,168 @@ export declare class ROI {
5341
6317
  * @returns {Point2D|undefined} The centroid point.
5342
6318
  */
5343
6319
  getCentroid(): Point2D | undefined;
6320
+ /**
6321
+ * Check if a point is inside the roi (seen as a closed polygon),
6322
+ * or within a tolerance of its outline.
6323
+ *
6324
+ * @param {Point2D} point The point to check.
6325
+ * @param {number} [tolerance] Optional maximum distance to the outline
6326
+ * for an outside point, defaults to 0.
6327
+ * @returns {boolean} True if the point is in the roi.
6328
+ */
6329
+ contains(point: Point2D, tolerance?: number): boolean;
6330
+ #private;
6331
+ }
6332
+
6333
+ /**
6334
+ * An RT Region of Interest with its display colour and contours.
6335
+ */
6336
+ export declare class RTROI {
6337
+ /**
6338
+ * ROI number as stored in the DICOM file.
6339
+ *
6340
+ * @type {number}
6341
+ */
6342
+ number: number;
6343
+ /**
6344
+ * ROI name.
6345
+ *
6346
+ * @type {string}
6347
+ */
6348
+ name: string;
6349
+ /**
6350
+ * Display colour as {r, g, b} values in [0, 255].
6351
+ *
6352
+ * @type {{r: number, g: number, b: number}}
6353
+ */
6354
+ colour: {
6355
+ r: number;
6356
+ g: number;
6357
+ b: number;
6358
+ };
6359
+ /**
6360
+ * ROI generation algorithm (e.g. 'MANUAL', 'SEMIAUTOMATIC', 'AUTOMATIC').
6361
+ *
6362
+ * @type {string|undefined}
6363
+ */
6364
+ generationAlgorithm: string | undefined;
6365
+ /**
6366
+ * RT ROI interpreted type (e.g. 'GTV', 'CTV', 'PTV', 'ORGAN').
6367
+ *
6368
+ * @type {string|undefined}
6369
+ */
6370
+ interpretedType: string | undefined;
6371
+ /**
6372
+ * Name of the person who interpreted the ROI.
6373
+ *
6374
+ * @type {string|undefined}
6375
+ */
6376
+ roiInterpreter: string | undefined;
6377
+ /**
6378
+ * List of contours belonging to this ROI.
6379
+ *
6380
+ * @type {RTROIContour[]}
6381
+ */
6382
+ contours: RTROIContour[];
6383
+ }
6384
+
6385
+ /**
6386
+ * A single planar contour of an RT ROI.
6387
+ */
6388
+ export declare class RTROIContour {
6389
+ /**
6390
+ * Contour geometric type (e.g. 'CLOSED_PLANAR').
6391
+ *
6392
+ * @type {string}
6393
+ */
6394
+ type: string;
6395
+ /**
6396
+ * Flat array of 3D patient-space coordinates in mm:
6397
+ * [x0,y0,z0, x1,y1,z1, ...].
6398
+ *
6399
+ * @type {number[]}
6400
+ */
6401
+ points3D: number[];
6402
+ }
6403
+
6404
+ /**
6405
+ * {@link Image} factory for DICOM RT Structure Set (RTSTRUCT).
6406
+ *
6407
+ * Rasterizes ROI contour polygons into a PALETTE COLOR mask image using
6408
+ * the same geometry as the reference CT/MR image so that the result can
6409
+ * be rendered by the existing mask pipeline.
6410
+ */
6411
+ export declare class RtStructFactory {
6412
+ /**
6413
+ * Get a warning string if elements are not as expected.
6414
+ *
6415
+ * @returns {string|undefined} The warning.
6416
+ */
6417
+ getWarning(): string | undefined;
6418
+ /**
6419
+ * Check dicom elements.
6420
+ *
6421
+ * @param {Record<string, DataElement>} _dataElements The DICOM data elements.
6422
+ * @returns {string|undefined} A possible warning.
6423
+ */
6424
+ checkElements(_dataElements: Record<string, DataElement>): string | undefined;
6425
+ /**
6426
+ * Get a {@link MaskImage} from RTSTRUCT DICOM elements.
6427
+ *
6428
+ * Contours are rasterized into a Uint8Array whose voxel values are
6429
+ * segment numbers (0 = background, 1..N = ROI index).
6430
+ * A PALETTE COLOR colour map maps each segment number to the ROI's
6431
+ * display colour.
6432
+ *
6433
+ * @param {Record<string, DataElement>} dataElements The DICOM data elements.
6434
+ * @param {Image} refImage The reference image (CT/MR) that was loaded first.
6435
+ * @returns {MaskImage} The mask image.
6436
+ * @throws {Error} If the reference image geometry cannot be used.
6437
+ */
6438
+ create(dataElements: Record<string, DataElement>, refImage: Image_2): MaskImage;
6439
+ /**
6440
+ * Convert a {@link MaskImage} into DICOM RT Structure Set elements.
6441
+ *
6442
+ * Traces each segment's pixel regions per slice using Moore neighborhood
6443
+ * contour tracing, simplifies with Ramer-Douglas-Peucker, then maps the
6444
+ * 2D pixel coordinates back to 3D patient-space coordinates.
6445
+ *
6446
+ * @param {MaskImage} image The mask image.
6447
+ * @param {MaskSegment[]} [segments] The mask segments; if omitted, taken
6448
+ * from image meta.
6449
+ * @param {Image} [sourceImage] Source image (provides StudyInstanceUID).
6450
+ * @param {SimpleTagValues} [extraTags] Optional extra tags to merge.
6451
+ * @returns {Record<string, DataElement>} The DICOM data elements.
6452
+ */
6453
+ toDicom(image: MaskImage, segments?: MaskSegment[], sourceImage?: Image_2, extraTags?: SimpleTagValues): Record<string, DataElement>;
6454
+ #private;
6455
+ }
6456
+
6457
+ /**
6458
+ * @import {App} from '../app/application.js';
6459
+ */
6460
+ /**
6461
+ * Run filter command.
6462
+ */
6463
+ export declare class RunFilterCommand extends Command {
6464
+ /**
6465
+ * @param {object} filter The filter to run.
6466
+ * @param {string} dataId The data to filter.
6467
+ * @param {App} app The associated application.
6468
+ */
6469
+ constructor(filter: object, dataId: string, app: App);
6470
+ /**
6471
+ * Handle an execute event.
6472
+ *
6473
+ * @param {object} _event The execute event with type and id.
6474
+ */
6475
+ onExecute(_event: object): void;
6476
+ /**
6477
+ * Handle an undo event.
6478
+ *
6479
+ * @param {object} _event The undo event with type and id.
6480
+ */
6481
+ onUndo(_event: object): void;
5344
6482
  #private;
5345
6483
  }
5346
6484
 
@@ -5387,23 +6525,208 @@ export declare class Scalar3D {
5387
6525
  }
5388
6526
 
5389
6527
  /**
5390
- * Scroll wheel class: provides a wheel event handler
5391
- * that scroll the corresponding data.
6528
+ * Slice / dimension scrolling on wheel ticks.
6529
+ */
6530
+ export declare class ScrollWheelBehavior extends WheelBehavior {
6531
+ }
6532
+
6533
+ /**
6534
+ * Collection of mask segments: stores per-segment, per-slice pixel data
6535
+ * and segment metadata. Builds the combined label map on demand.
6536
+ * TODO: check if mergeable with MaskSegmentHelper.
5392
6537
  */
5393
- export declare class ScrollWheel {
6538
+ export declare class SegmentCollection {
5394
6539
  /**
5395
- * @param {App} app The associated application.
6540
+ * @param {Geometry} geometry The mask geometry, used to size the label map.
5396
6541
  */
5397
- constructor(app: App);
6542
+ constructor(geometry: Geometry);
6543
+ /**
6544
+ * Get all the segments.
6545
+ *
6546
+ * @returns {Map<number, Map<number, Uint8Array>>} The segment buffers,
6547
+ * indexed by segment number and slice index.
6548
+ */
6549
+ getAll(): Map<number, Map<number, Uint8Array>>;
6550
+ /**
6551
+ * Set the label map directly.
6552
+ * Used when the buffer already exists, for brush-painted masks.
6553
+ *
6554
+ * @param {Uint8Array} buffer The label map buffer.
6555
+ */
6556
+ setLabelMap(buffer: Uint8Array): void;
6557
+ /**
6558
+ * Add pixel data for one DICOM frame to the appropriate segment and slice.
6559
+ * Allocates a Uint8Array(sliceSize) on first use for each
6560
+ * (segNumber, sliceIndex) pair; merges if the same pair appears again.
6561
+ *
6562
+ * @param {number} segNumber The segment number.
6563
+ * @param {Uint8Array} pixelBuffer The raw DICOM pixel buffer.
6564
+ * @param {number} frameOffset Offset of this frame within pixelBuffer.
6565
+ * @param {number} sliceIndex The slice index in the full label map geometry.
6566
+ * @param {number} sliceSize Number of pixels per slice (ncols * nrows).
6567
+ * @param {number} value The value to write for non-zero pixels.
6568
+ */
6569
+ addFrame(segNumber: number, pixelBuffer: Uint8Array, frameOffset: number, sliceIndex: number, sliceSize: number, value: number): void;
6570
+ /**
6571
+ * Build and return the combined label map (lazy cached).
6572
+ * Iterates segments in insertion order so lower segment numbers win
6573
+ * at overlapping positions. Sets the hasOverlap flag if any voxel
6574
+ * already carries a different segment's value.
6575
+ *
6576
+ * @returns {Uint8Array} The full-volume label map.
6577
+ */
6578
+ getLabelMap(): Uint8Array;
6579
+ /**
6580
+ * Update the per-segment, per-slice buffers after a direct edit to the
6581
+ * shared label map (for example brush painting on a mask loaded from
6582
+ * DICOM, where the label map and the per-segment buffers are otherwise
6583
+ * two separate structures). No-op when this collection has no
6584
+ * per-segment data (brush-created masks), since the label map is
6585
+ * already the source of truth in that case.
6586
+ *
6587
+ * @param {number} offset The offset in the label map that changed.
6588
+ * @param {number} previousValue The segment number previously at offset.
6589
+ * @param {number} newValue The segment number now at offset.
6590
+ */
6591
+ updateAtOffset(offset: number, previousValue: number, newValue: number): void;
6592
+ /**
6593
+ * Re-index the per-segment, per-slice buffers after a slice insertion
6594
+ * (from Image#appendSlice) that shifted existing slice
6595
+ * content to make room for new slices. Unlike the shared label map
6596
+ * (which aliases the image buffer, so the raw byte-level shift already
6597
+ * covers it for free), `#segments` is keyed by slice index rather than
6598
+ * buffer offset, so an insertion before an existing slice leaves its
6599
+ * entries silently pointing at the wrong (pre-shift) slice index unless
6600
+ * they are explicitly re-keyed here.
6601
+ *
6602
+ * @param {number} sliceIndexThreshold Slices at or after this index
6603
+ * (numbering as it was *before* the insertion) are shifted.
6604
+ * @param {number} numberOfSlices Number of slices inserted.
6605
+ */
6606
+ shiftSlices(sliceIndexThreshold: number, numberOfSlices: number): void;
6607
+ /**
6608
+ * Get the value that a different, non-excluded segment holds at a given
6609
+ * label map offset. Used when deleting a segment to restore a voxel that
6610
+ * also belonged to another (overlapping) segment instead of losing that
6611
+ * other segment's presence there. Segments are checked in insertion
6612
+ * order, consistent with the first-wins policy used by {@link
6613
+ * SegmentCollection#getLabelMap}.
6614
+ *
6615
+ * @param {number} offset The offset in the label map.
6616
+ * @param {number} excludeSegmentNumber The segment number to ignore.
6617
+ * @returns {number} The other segment's stored value at that offset,
6618
+ * or 0 if no other segment covers it.
6619
+ */
6620
+ getOtherValueAtOffset(offset: number, excludeSegmentNumber: number): number;
6621
+ /**
6622
+ * Create a deep copy of this collection: per-segment/per-slice buffers
6623
+ * and the overlap flag are copied, the lazily-built label map and union
6624
+ * contour caches are left unset (they rebuild on demand from the copied
6625
+ * per-segment data, same as a freshly constructed collection).
6626
+ *
6627
+ * @returns {SegmentCollection} The copy.
6628
+ */
6629
+ clone(): SegmentCollection;
6630
+ /**
6631
+ * Check whether any two segments share at least one voxel.
6632
+ *
6633
+ * @returns {boolean} True if overlap was detected.
6634
+ */
6635
+ getHasOverlap(): boolean;
6636
+ /**
6637
+ * Get the segment buffers. Using input image and segments since they
6638
+ * could have been modified (for example by brush).
6639
+ *
6640
+ * When per-segment data is available (MaskFactory path), builds ROI buffers
6641
+ * directly from #segments so that overlap pixels for every segment are
6642
+ * included. Falls back to label-map reconstruction for masks created via
6643
+ * setupSegmentCollection (brush path), where #segments is empty and the
6644
+ * label map is the only source of truth.
6645
+ *
6646
+ * @param {MaskSegment[]} segments The mask segments.
6647
+ * @returns {Record<string, Record<number, Uint8Array>>} The segment buffers,
6648
+ * indexed by segment index (segment.number - 1) and slice index.
6649
+ */
6650
+ getSegmentBuffers(segments: MaskSegment[]): Record<string, Record<number, Uint8Array>>;
5398
6651
  /**
5399
- * Handle mouse wheel event.
6652
+ * Get the union ImageContour for the current visibility state,
6653
+ * building it if the set of hidden segments has changed.
5400
6654
  *
5401
- * @param {WheelEvent} event The mouse wheel event.
6655
+ * @param {MaskSegmentViewHelper|undefined} segmentViewHelper
6656
+ * Hidden-segment tracker.
6657
+ * @param {Size} imageSize The image size.
6658
+ * @returns {ImageContour} The union ImageContour.
5402
6659
  */
5403
- wheel(event: WheelEvent): void;
6660
+ getOrBuildUnionContour(segmentViewHelper: MaskSegmentViewHelper | undefined, imageSize: Size): ImageContour;
5404
6661
  #private;
5405
6662
  }
5406
6663
 
6664
+ /**
6665
+ * Histogram of the voxels of a segment for one volume.
6666
+ */
6667
+ export declare type SegmentHistogram = {
6668
+ /**
6669
+ * The volume index.
6670
+ */
6671
+ volume: number;
6672
+ /**
6673
+ * The segment histogram.
6674
+ */
6675
+ histogram: ImageHistogram;
6676
+ /**
6677
+ * One histogram per label
6678
+ * of the segment, if available.
6679
+ */
6680
+ labelHistograms?: LabelHistogram[];
6681
+ };
6682
+
6683
+ /**
6684
+ * A simple sequence (VR=SQ) tag value.
6685
+ */
6686
+ export declare type SimpleSequenceValue = {
6687
+ /**
6688
+ * The sequence items.
6689
+ */
6690
+ value: SimpleTagValues[];
6691
+ /**
6692
+ * Undefined length flag.
6693
+ */
6694
+ undefinedLength?: boolean;
6695
+ };
6696
+
6697
+ /**
6698
+ * A simple (non sequence) tag value: either a single primitive
6699
+ * or, for multi-valued VRs, an array of primitives.
6700
+ */
6701
+ export declare type SimpleTagValue = string | number | string[] | number[];
6702
+
6703
+ /**
6704
+ * The meta data as simple tag values: indexed by tag name instead of
6705
+ * tag key, with direct values (no element object) for non sequence,
6706
+ * non merged tags.
6707
+ */
6708
+ export declare type SimpleTagValues = Record<string, SimpleTagValue | SimpleSequenceValue>;
6709
+
6710
+ /**
6711
+ * Simplify a polygon using the Ramer-Douglas-Peucker algorithm.
6712
+ * Ref: {@link https://en.wikipedia.org/wiki/Ramer%E2%80%93Douglas%E2%80%93Peucker_algorithm}.
6713
+ *
6714
+ * @param {Array.<{x: number, y: number}>} pts Input vertices.
6715
+ * @param {number} epsilon Max allowed deviation in pixels.
6716
+ * @returns {Array.<{x: number, y: number}>} Simplified vertices.
6717
+ */
6718
+ export declare function simplifyPolygon(pts: Array<{
6719
+ x: number;
6720
+ y: number;
6721
+ }>, epsilon: number): Array<{
6722
+ x: number;
6723
+ y: number;
6724
+ }>;
6725
+
6726
+ /**
6727
+ * @import {Matrix33} from '../math/matrix.js';
6728
+ * @import {Scalar2D} from '../math/scalar.js';
6729
+ */
5407
6730
  /**
5408
6731
  * Immutable Size class.
5409
6732
  * Warning: the input array is NOT cloned, modifying it will
@@ -5492,104 +6815,423 @@ export declare class Size {
5492
6815
  */
5493
6816
  isInBounds(index: Index, dirs: number[]): boolean;
5494
6817
  /**
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.
6818
+ * Convert an index to an offset in memory.
6819
+ *
6820
+ * @param {Index} index The index to convert.
6821
+ * @param {number} [start] Optional start dimension to base the offset on.
6822
+ * @returns {number} The offset or -1 if out of bounds.
6823
+ */
6824
+ indexToOffset(index: Index, start?: number): number;
6825
+ /**
6826
+ * Convert an offset in memory to an index.
6827
+ *
6828
+ * @param {number} offset The offset to convert.
6829
+ * @returns {Index} The index.
6830
+ */
6831
+ offsetToIndex(offset: number): Index;
6832
+ /**
6833
+ * Get the 2D base of this size.
6834
+ *
6835
+ * @returns {Scalar2D} The 2D base [0,1] as {x,y}.
6836
+ */
6837
+ get2D(): Scalar2D;
6838
+ /**
6839
+ * Normalise a point to this size.
6840
+ *
6841
+ * @param {Point} point The input point.
6842
+ * @param {Point} [extra] Optional point used to fill extra dimensions.
6843
+ * @returns {Point} The result point.
6844
+ */
6845
+ normalisePoint(point: Point, extra?: Point): Point;
6846
+ /**
6847
+ * Normalise an index to this size.
6848
+ *
6849
+ * @param {Index} index The input index.
6850
+ * @param {Index} [extra] Optional index used to fill extra dimensions.
6851
+ * @returns {Index} The result point.
6852
+ */
6853
+ normaliseIndex(index: Index, extra?: Index): Index;
6854
+ #private;
6855
+ }
6856
+
6857
+ /**
6858
+ * Number value with its source, as for example a volume id: the value
6859
+ * of the volume (fourth dimension) index, for example
6860
+ * `{source: 'EchoTime', value: 4.6, tagKey: '00180081', unit: 'unit.ms'}`.
6861
+ * A number value with:
6862
+ * - source: the name of the value source, for example the volume id
6863
+ * candidate that produced it,
6864
+ * - tagKey: the key of the DICOM tag the value is read from.
6865
+ */
6866
+ export declare type SourcedNumberValue = NumberValue & {
6867
+ source?: string;
6868
+ tagKey?: string;
6869
+ };
6870
+
6871
+ /**
6872
+ * @import {Scalar2D} from '../math/scalar.js';
6873
+ */
6874
+ /**
6875
+ * Immutable Spacing class.
6876
+ * Warning: the input array is NOT cloned, modifying it will
6877
+ * modify the index values.
6878
+ */
6879
+ export declare class Spacing {
6880
+ /**
6881
+ * @param {number[]} values The spacing values.
6882
+ */
6883
+ constructor(values: number[]);
6884
+ /**
6885
+ * Get the spacing value at the given array index.
6886
+ *
6887
+ * @param {number} i The index to get.
6888
+ * @returns {number} The value.
6889
+ */
6890
+ get(i: number): number;
6891
+ /**
6892
+ * Get the length of the spacing.
6893
+ *
6894
+ * @returns {number} The length.
6895
+ */
6896
+ length(): number;
6897
+ /**
6898
+ * Get a string representation of the spacing.
6899
+ *
6900
+ * @returns {string} The spacing as a string.
6901
+ */
6902
+ toString(): string;
6903
+ /**
6904
+ * Get the values of this spacing.
6905
+ *
6906
+ * @returns {number[]} The array of values.
6907
+ */
6908
+ getValues(): number[];
6909
+ /**
6910
+ * Check for equality.
6911
+ *
6912
+ * @param {Spacing} rhs The object to compare to.
6913
+ * @returns {boolean} True if both objects are equal.
6914
+ */
6915
+ equals(rhs: Spacing): boolean;
6916
+ /**
6917
+ * Get the 2D base of this size.
6918
+ *
6919
+ * @returns {Scalar2D} The 2D base [col,row] as {x,y}.
6920
+ */
6921
+ get2D(): Scalar2D;
6922
+ #private;
6923
+ }
6924
+
6925
+ /**
6926
+ * Convert sRGB to CIE LAB (standard illuminant D65).
6927
+ *
6928
+ * @param {RGB} triplet 'sRGB' triplet as {r,g,b}.
6929
+ * @returns {object} CIE LAB triplet as {l,a,b}.
6930
+ */
6931
+ export declare function srgbToCielab(triplet: RGB): object;
6932
+
6933
+ /**
6934
+ * Stage controller: manages the link between the data view configs
6935
+ * and the stage (layer groups, layers, rendering).
6936
+ */
6937
+ export declare class StageController extends EventTarget {
6938
+ /**
6939
+ * @param {DataController} dataController The data controller.
6940
+ * @param {object} options The app options.
6941
+ */
6942
+ constructor(dataController: DataController, options: object);
6943
+ /**
6944
+ * Set the toolbox controller.
6945
+ *
6946
+ * @param {ToolboxController} tc The toolbox controller.
6947
+ */
6948
+ setToolboxController(tc: ToolboxController): void;
6949
+ /**
6950
+ * Set the add-to-undo-stack callback.
6951
+ *
6952
+ * @param {Function} fn The callback.
6953
+ */
6954
+ setAddToUndoStack(fn: Function): void;
6955
+ /**
6956
+ * Set the info data getter callback.
6957
+ *
6958
+ * @param {Function} fn A function `(dataId) => InfoData`.
6959
+ */
6960
+ setGetInfoData(fn: Function): void;
6961
+ /**
6962
+ * Get the layer group configuration from a data id.
6963
+ *
6964
+ * @param {string} dataId The data id.
6965
+ * @param {boolean} [excludeStarConfig] Exclude the star config
6966
+ * (default to false).
6967
+ * @returns {ViewConfig[]} The list of associated configs.
6968
+ */
6969
+ getViewConfigs(dataId: string, excludeStarConfig?: boolean): ViewConfig[];
6970
+ /**
6971
+ * Get the layer group configuration for a data id and group div id.
6972
+ *
6973
+ * @param {string} dataId The data id.
6974
+ * @param {string} groupDivId The layer group div id.
6975
+ * @param {boolean} [excludeStarConfig] Exclude the star config
6976
+ * (default to false).
6977
+ * @returns {ViewConfig|undefined} The associated config.
6978
+ */
6979
+ getViewConfig(dataId: string, groupDivId: string, excludeStarConfig?: boolean): ViewConfig | undefined;
6980
+ /**
6981
+ * Get the data view config.
6982
+ * Careful, returns a reference; do not modify without resetting.
6983
+ *
6984
+ * @returns {Record<string, ViewConfig[]>} The configuration list.
6985
+ */
6986
+ getDataViewConfigs(): Record<string, ViewConfig[]>;
6987
+ /**
6988
+ * Set the data view configuration.
6989
+ * Resets the stage and recreates all the views.
6990
+ *
6991
+ * @param {Record<string, ViewConfig[]>} configs The configuration list.
6992
+ */
6993
+ setDataViewConfigs(configs: Record<string, ViewConfig[]>): void;
6994
+ /**
6995
+ * Add a data view config.
6996
+ *
6997
+ * @param {string} dataId The data id.
6998
+ * @param {ViewConfig} config The view configuration.
6999
+ * @param {boolean} [doRender] Render data after configuration
7000
+ * add. Defaults to true.
7001
+ */
7002
+ addDataViewConfig(dataId: string, config: ViewConfig, doRender?: boolean): void;
7003
+ /**
7004
+ * Remove a data view config.
7005
+ * Removes the associated layer if found, removes
7006
+ * the layer group if empty.
7007
+ *
7008
+ * @param {string} dataId The data id.
7009
+ * @param {string} divId The div id.
7010
+ */
7011
+ removeDataViewConfig(dataId: string, divId: string): void;
7012
+ /**
7013
+ * Update an existing data view config.
7014
+ * Removes and re-creates the layer if found.
7015
+ *
7016
+ * @param {string} dataId The data id.
7017
+ * @param {string} divId The div id.
7018
+ * @param {ViewConfig} config The view configuration.
7019
+ */
7020
+ updateDataViewConfig(dataId: string, divId: string, config: ViewConfig): void;
7021
+ /**
7022
+ * Get the active layer group.
7023
+ *
7024
+ * @returns {LayerGroup|undefined} The layer group.
7025
+ */
7026
+ getActiveLayerGroup(): LayerGroup | undefined;
7027
+ /**
7028
+ * Set the active layer group.
7029
+ *
7030
+ * @param {number} index The layer group index.
7031
+ */
7032
+ setActiveLayerGroup(index: number): void;
7033
+ /**
7034
+ * Get a layer group by index.
7035
+ *
7036
+ * @param {number} index The index.
7037
+ * @returns {LayerGroup} The layer group.
7038
+ */
7039
+ getLayerGroup(index: number): LayerGroup;
7040
+ /**
7041
+ * Get the number of layer groups.
7042
+ *
7043
+ * @returns {number} The number of groups.
7044
+ */
7045
+ getNumberOfLayerGroups(): number;
7046
+ /**
7047
+ * Get the view layers associated to a data id.
7048
+ *
7049
+ * @param {string} dataId The data id.
7050
+ * @returns {ViewLayer[]} The layers.
7051
+ */
7052
+ getViewLayersByDataId(dataId: string): ViewLayer[];
7053
+ /**
7054
+ * Get a list of view layers according to an input callback function.
7055
+ *
7056
+ * @param {Function} [callbackFn] A function that takes
7057
+ * a ViewLayer as input and returns a boolean. If undefined,
7058
+ * returns all view layers.
7059
+ * @returns {ViewLayer[]} The layers that satisfy the callbackFn.
7060
+ */
7061
+ getViewLayers(callbackFn?: Function): ViewLayer[];
7062
+ /**
7063
+ * Get the draw layers associated to a data id.
7064
+ *
7065
+ * @param {string} dataId The data id.
7066
+ * @returns {DrawLayer[]} The layers.
7067
+ */
7068
+ getDrawLayersByDataId(dataId: string): DrawLayer[];
7069
+ /**
7070
+ * Get a list of draw layers according to an input callback function.
7071
+ *
7072
+ * @param {Function} [callbackFn] A function that takes
7073
+ * a DrawLayer as input and returns a boolean. If undefined,
7074
+ * returns all draw layers.
7075
+ * @returns {DrawLayer[]} The layers that satisfy the callbackFn.
7076
+ */
7077
+ getDrawLayers(callbackFn?: Function): DrawLayer[];
7078
+ /**
7079
+ * Get a layer group by div id.
7080
+ *
7081
+ * @param {string} divId The div id.
7082
+ * @returns {LayerGroup|undefined} The layer group.
7083
+ */
7084
+ getLayerGroupByDivId(divId: string): LayerGroup | undefined;
7085
+ /**
7086
+ * Get the active layer group scale on top of the base scale.
7087
+ *
7088
+ * @returns {Scalar3D} The scale as {x,y,z}.
7089
+ * @deprecated Since v0.37, please access from the active layer group.
7090
+ */
7091
+ getAddedScale(): Scalar3D;
7092
+ /**
7093
+ * Get the base scale of the active layer group.
7094
+ *
7095
+ * @returns {Scalar3D} The scale as {x,y,z}.
7096
+ * @deprecated Since v0.37, please access from the active layer group.
7097
+ */
7098
+ getBaseScale(): Scalar3D;
7099
+ /**
7100
+ * Get the layer offset of the active layer group.
7101
+ *
7102
+ * @returns {Scalar3D} The offset as {x,y,z}.
7103
+ * @deprecated Since v0.37, please access from the active layer group.
7104
+ */
7105
+ getOffset(): Scalar3D;
7106
+ /**
7107
+ * Empty the stage (remove all layer groups).
7108
+ */
7109
+ empty(): void;
7110
+ /**
7111
+ * Remove layers for a specific data id.
7112
+ *
7113
+ * @param {string} dataId The data id.
7114
+ */
7115
+ removeLayersByDataId(dataId: string): void;
7116
+ /**
7117
+ * Set the layer groups binders.
7118
+ *
7119
+ * @param {object[]} instances Binder instances.
7120
+ */
7121
+ setBinders(instances: object[]): void;
7122
+ /**
7123
+ * Fit the display to the data of each layer group.
7124
+ */
7125
+ fitToContainer(): void;
7126
+ /**
7127
+ * Draw all layer groups.
7128
+ */
7129
+ draw(): void;
7130
+ /**
7131
+ * Reset zoom and pan of the stage.
7132
+ *
7133
+ * @deprecated Since v0.35, prefer resetZoomPan.
7134
+ */
7135
+ resetLayout(): void;
7136
+ /**
7137
+ * Reset the zoom and pan of the stage.
7138
+ */
7139
+ resetZoomPan(): void;
7140
+ /**
7141
+ * Reset the position and window level of the stage.
5500
7142
  */
5501
- indexToOffset(index: Index, start?: number): number;
7143
+ resetViews(): void;
5502
7144
  /**
5503
- * Convert an offset in memory to an index.
7145
+ * Set the imageSmoothing flag value. Default is false.
5504
7146
  *
5505
- * @param {number} offset The offset to convert.
5506
- * @returns {Index} The index.
7147
+ * @param {boolean} flag True to enable smoothing.
5507
7148
  */
5508
- offsetToIndex(offset: number): Index;
7149
+ setImageSmoothing(flag: boolean): void;
5509
7150
  /**
5510
- * Get the 2D base of this size.
7151
+ * Zoom the layers of the active layer group.
5511
7152
  *
5512
- * @returns {Scalar2D} The 2D base [0,1] as {x,y}.
7153
+ * @param {number} step The step to add to the current zoom.
7154
+ * @param {number} cx The zoom center X coordinate.
7155
+ * @param {number} cy The zoom center Y coordinate.
7156
+ * @deprecated Since v0.37, please access from the active layer group.
5513
7157
  */
5514
- get2D(): Scalar2D;
7158
+ zoom(step: number, cx: number, cy: number): void;
5515
7159
  /**
5516
- * Normalise a point to this size.
7160
+ * Apply a translation to the layers of the active layer group.
5517
7161
  *
5518
- * @param {Point} point The input point.
5519
- * @param {Point} [extra] Optional point used to fill extra dimensions.
5520
- * @returns {Point} The result point.
7162
+ * @param {number} tx The translation along X.
7163
+ * @param {number} ty The translation along Y.
5521
7164
  */
5522
- normalisePoint(point: Point, extra?: Point): Point;
7165
+ translate(tx: number, ty: number): void;
5523
7166
  /**
5524
- * Normalise an index to this size.
7167
+ * Render the current data.
5525
7168
  *
5526
- * @param {Index} index The input index.
5527
- * @param {Index} [extra] Optional index used to fill extra dimensions.
5528
- * @returns {Index} The result point.
7169
+ * @param {string} dataId The data id to render.
7170
+ * @param {ViewConfig[]} [viewConfigs] The list of configs to render.
5529
7171
  */
5530
- normaliseIndex(index: Index, extra?: Index): Index;
7172
+ render(dataId: string, viewConfigs?: ViewConfig[]): void;
5531
7173
  #private;
5532
7174
  }
5533
7175
 
5534
7176
  /**
5535
- * Immutable Spacing class.
5536
- * Warning: the input array is NOT cloned, modifying it will
5537
- * modify the index values.
7177
+ * Statistics storage class.
7178
+ * 'simple' statistics do not include median, p25 nor p75.
5538
7179
  */
5539
- export declare class Spacing {
7180
+ declare class Statistics {
5540
7181
  /**
5541
- * @param {number[]} values The spacing values.
7182
+ * @param {number} min The minimum.
7183
+ * @param {number} max The maximum.
7184
+ * @param {number} mean The mean.
7185
+ * @param {number} stdDev The standard deviation.
5542
7186
  */
5543
- constructor(values: number[]);
7187
+ constructor(min: number, max: number, mean: number, stdDev: number);
5544
7188
  /**
5545
- * Get the spacing value at the given array index.
7189
+ * Minimum.
5546
7190
  *
5547
- * @param {number} i The index to get.
5548
- * @returns {number} The value.
7191
+ * @type {number}
5549
7192
  */
5550
- get(i: number): number;
7193
+ min: number;
5551
7194
  /**
5552
- * Get the length of the spacing.
7195
+ * Maximum.
5553
7196
  *
5554
- * @returns {number} The length.
7197
+ * @type {number}
5555
7198
  */
5556
- length(): number;
7199
+ max: number;
5557
7200
  /**
5558
- * Get a string representation of the spacing.
7201
+ * Mean.
5559
7202
  *
5560
- * @returns {string} The spacing as a string.
7203
+ * @type {number}
5561
7204
  */
5562
- toString(): string;
7205
+ mean: number;
5563
7206
  /**
5564
- * Get the values of this spacing.
7207
+ * Standard deviation (population: divided by the number of values).
5565
7208
  *
5566
- * @returns {number[]} The array of values.
7209
+ * @type {number}
5567
7210
  */
5568
- getValues(): number[];
7211
+ stdDev: number;
5569
7212
  /**
5570
- * Check for equality.
7213
+ * Median.
5571
7214
  *
5572
- * @param {Spacing} rhs The object to compare to.
5573
- * @returns {boolean} True if both objects are equal.
7215
+ * @type {number|undefined}
5574
7216
  */
5575
- equals(rhs: Spacing): boolean;
7217
+ median: number | undefined;
5576
7218
  /**
5577
- * Get the 2D base of this size.
7219
+ * 25th percentile.
5578
7220
  *
5579
- * @returns {Scalar2D} The 2D base [col,row] as {x,y}.
7221
+ * @type {number|undefined}
5580
7222
  */
5581
- get2D(): Scalar2D;
5582
- #private;
7223
+ p25: number | undefined;
7224
+ /**
7225
+ * 75th percentile.
7226
+ *
7227
+ * @type {number|undefined}
7228
+ */
7229
+ p75: number | undefined;
5583
7230
  }
5584
7231
 
5585
7232
  /**
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}.
7233
+ * @import {DataElement} from '../dicom/dataElement.js';
5590
7234
  */
5591
- export declare function srgbToCielab(triplet: RGB): object;
5592
-
5593
7235
  /**
5594
7236
  * Immutable tag.
5595
7237
  */
@@ -5612,7 +7254,7 @@ export declare class Tag {
5612
7254
  */
5613
7255
  getElement(): string;
5614
7256
  /**
5615
- * Get as string representation of the tag: 'key: name'.
7257
+ * Get as string representation of the tag: '(group,element)'.
5616
7258
  *
5617
7259
  * @returns {string} A string representing the tag.
5618
7260
  */
@@ -5630,12 +7272,6 @@ export declare class Tag {
5630
7272
  * @returns {string} The key as '########'.
5631
7273
  */
5632
7274
  getKey(): string;
5633
- /**
5634
- * Get the group name as defined in TagGroups.
5635
- *
5636
- * @returns {string} The name.
5637
- */
5638
- getGroupName(): string;
5639
7275
  /**
5640
7276
  * Does this tag have a VR.
5641
7277
  * Basically not the Item, ItemDelimitationItem nor
@@ -5653,27 +7289,45 @@ export declare class Tag {
5653
7289
  * ie if its group is an odd number.
5654
7290
  */
5655
7291
  isPrivate(): boolean;
7292
+ #private;
7293
+ }
7294
+
7295
+ /**
7296
+ * DICOM tag info: vr, multiplicity, name.
7297
+ */
7298
+ export declare class TagInfo {
7299
+ /**
7300
+ * @param {string} vr The tag Value Representation (VR).
7301
+ * @param {number} multiplicity The tag multiplicity.
7302
+ * @param {string} name The tag name.
7303
+ */
7304
+ constructor(vr: string, multiplicity: number, name: string);
5656
7305
  /**
5657
- * Get the tag Value Representation (VR) from the dicom dictionary.
7306
+ * Get the tag Value Representation (VR).
5658
7307
  *
5659
- * @returns {string|undefined} The VR.
7308
+ * @returns {string} The tag vr.
5660
7309
  */
5661
- getVrFromDictionary(): string | undefined;
7310
+ getVr(): string;
5662
7311
  /**
5663
- * Get the multiplicity from the dicom dictionary.
7312
+ * Get the tag multiplicity.
5664
7313
  *
5665
- * @returns {number|undefined} The multiplicity.
7314
+ * @returns {number} The multiplicity.
5666
7315
  */
5667
- getMultiplicityFromDictionary(): number | undefined;
7316
+ getMultiplicity(): number;
5668
7317
  /**
5669
- * Get the tag name from the dicom dictionary.
7318
+ * Get the tag name.
5670
7319
  *
5671
- * @returns {string|undefined} The VR.
7320
+ * @returns {string} The name.
5672
7321
  */
5673
- getNameFromDictionary(): string | undefined;
7322
+ getName(): string;
5674
7323
  #private;
5675
7324
  }
5676
7325
 
7326
+ /**
7327
+ * @import {LayerGroup} from '../gui/layerGroup.js';
7328
+ * @import {ViewLayer} from '../gui/viewLayer.js';
7329
+ * @import {DrawLayer} from '../gui/drawLayer.js';
7330
+ */
5677
7331
  /**
5678
7332
  * Toolbox controller.
5679
7333
  */
@@ -5717,9 +7371,10 @@ export declare class ToolboxController {
5717
7371
  *
5718
7372
  * @param {string} eventType The event type, for example
5719
7373
  * mousedown, touchstart...
5720
- * @returns {Function} The event handler.
7374
+ * @returns {EventListener|undefined} The event handler, undefined
7375
+ * if no tool is selected.
5721
7376
  */
5722
- getSelectedToolEventHandler(eventType: string): Function;
7377
+ getSelectedToolEventHandler(eventType: string): EventListener | undefined;
5723
7378
  /**
5724
7379
  * Set the selected tool.
5725
7380
  *
@@ -5791,11 +7446,9 @@ export declare class ToolConfig {
5791
7446
  * 'https://raw.githubusercontent.com/ivmartel/dwv/master/tests/data/bbmri-53323851.dcm'
5792
7447
  * ]);
5793
7448
  *
5794
- * @type {Object<string, any>}
7449
+ * @type {Record<string, any>}
5795
7450
  */
5796
- export declare const toolList: {
5797
- [x: string]: any;
5798
- };
7451
+ export declare const toolList: Record<string, any>;
5799
7452
 
5800
7453
  /**
5801
7454
  * List of client provided tool options to be added to
@@ -5809,7 +7462,6 @@ export declare const toolList: {
5809
7462
  * getName() {return 'love';}
5810
7463
  * static supports(mathShape) {return mathShape instanceof ROI;}
5811
7464
  * getNPoints() {return 1;}
5812
- * getTimeout() {return 0;}
5813
7465
  * setAnnotationMathShape(annotation, points) {
5814
7466
  * const px = points[0].getX();
5815
7467
  * const py = points[0].getY();
@@ -5862,26 +7514,81 @@ export declare const toolList: {
5862
7514
  * 'https://raw.githubusercontent.com/ivmartel/dwv/master/tests/data/bbmri-53323851.dcm'
5863
7515
  * ]);
5864
7516
  *
5865
- * @type {Object<string, Object<string, any>>}
7517
+ * @type {Record<string, Record<string, any>>}
5866
7518
  */
5867
- export declare const toolOptions: {
5868
- [x: string]: {
5869
- [x: string]: any;
5870
- };
5871
- };
7519
+ export declare const toolOptions: Record<string, Record<string, any>>;
7520
+
7521
+ /**
7522
+ * Translate writer rules indexed by tag or group name into
7523
+ * rules indexed by tag or group key, as expected by the writer.
7524
+ * A group name is translated into all the groups that have it
7525
+ * (for example 'Curve' gives '5000', '5002'...).
7526
+ * Warning: group names are not defined by the DICOM standard, they come
7527
+ * from the GDCM group name list (see `tagGroups`), which does not cover
7528
+ * all groups. Prefer group keys.
7529
+ * Rules already indexed by key (or `default`) are kept as is and
7530
+ * take precedence over translated ones. Unknown names are dropped.
7531
+ *
7532
+ * @param {Record<string, WriterRule>} rules The name based rules.
7533
+ * @returns {Record<string, WriterRule>} The key based rules.
7534
+ */
7535
+ export declare function translateWriterRules(rules: Record<string, WriterRule>): Record<string, WriterRule>;
7536
+
7537
+ /**
7538
+ * List of compatible typed arrays.
7539
+ */
7540
+ export declare type TypedArray = IntTypedArray | FloatTypedArray;
5872
7541
 
5873
7542
  /**
5874
- * Class to store a value and a unit.
7543
+ * Undo controller.
5875
7544
  */
5876
- export declare class Value {
7545
+ export declare class UndoController extends EventTarget {
5877
7546
  /**
5878
- * @type {number}
7547
+ * Add a command to the undo stack.
7548
+ *
7549
+ * @param {object} cmd The command to add.
7550
+ * @fires UndoStack#undoadd
7551
+ * @function
5879
7552
  */
5880
- value: number;
7553
+ addToUndoStack: (cmd: object) => void;
5881
7554
  /**
5882
- * @type {string|undefined}
7555
+ * Remove a command from the undo stack.
7556
+ *
7557
+ * @param {string} name The name of the command to remove.
7558
+ * @returns {boolean} True if the command was found and removed.
7559
+ * @fires UndoStack#undoremove
7560
+ * @function
7561
+ */
7562
+ removeFromUndoStack: (name: string) => boolean;
7563
+ /**
7564
+ * Undo the last command.
7565
+ *
7566
+ * @fires UndoStack#undo
7567
+ */
7568
+ undo(): void;
7569
+ /**
7570
+ * Redo the next command.
7571
+ *
7572
+ * @fires UndoStack#redo
7573
+ */
7574
+ redo(): void;
7575
+ /**
7576
+ * Get the undo stack size.
7577
+ *
7578
+ * @returns {number} The size of the stack.
7579
+ */
7580
+ getStackSize(): number;
7581
+ /**
7582
+ * Get the current undo stack index.
7583
+ *
7584
+ * @returns {number} The stack index.
5883
7585
  */
5884
- unit: string | undefined;
7586
+ getCurrentStackIndex(): number;
7587
+ /**
7588
+ * Reset the undo/redo history.
7589
+ */
7590
+ reset(): void;
7591
+ #private;
5885
7592
  }
5886
7593
 
5887
7594
  /**
@@ -5968,16 +7675,16 @@ export declare class Vector3D {
5968
7675
  * (either directly or with helper methods).
5969
7676
  *
5970
7677
  * @example
5971
- * import {DicomParser, createImage, createView} from '//esm.sh/dwv';
7678
+ * import {DicomParser, demoCreateImage, demoCreateView} from '//esm.sh/dwv';
5972
7679
  * // XMLHttpRequest onload callback
5973
7680
  * const onload = function (event) {
5974
7681
  * // parse the dicom buffer
5975
7682
  * const dicomParser = new DicomParser();
5976
7683
  * dicomParser.parse(event.target.response);
5977
7684
  * // create the image object
5978
- * const image = createImage(dicomParser.getDicomElements());
7685
+ * const image = demoCreateImage(dicomParser.getDicomElements());
5979
7686
  * // create the view
5980
- * const view = createView(dicomParser.getDicomElements(), image);
7687
+ * const view = demoCreateView(dicomParser.getDicomElements(), image);
5981
7688
  * // setup canvas
5982
7689
  * const canvas = document.createElement('canvas');
5983
7690
  * canvas.width = 256;
@@ -5999,7 +7706,7 @@ export declare class Vector3D {
5999
7706
  * request.onload = onload;
6000
7707
  * request.send();
6001
7708
  */
6002
- export declare class View {
7709
+ export declare class View extends EventTarget {
6003
7710
  /**
6004
7711
  * @param {Image} image The associated image.
6005
7712
  */
@@ -6029,6 +7736,29 @@ export declare class View {
6029
7736
  * @param {MaskSegmentViewHelper} helper The helper.
6030
7737
  */
6031
7738
  setMaskViewHelper(helper: MaskSegmentViewHelper): void;
7739
+ /**
7740
+ * Get the segment highlight.
7741
+ *
7742
+ * @returns {{segmentNumber: number, opacity: number}|undefined}
7743
+ * The highlighted segment number and its opacity factor.
7744
+ */
7745
+ getSegmentHighlight(): {
7746
+ segmentNumber: number;
7747
+ opacity: number;
7748
+ } | undefined;
7749
+ /**
7750
+ * Set the segment highlight: the opacity of the given segment
7751
+ * is multiplied by the input factor. Only one segment can be
7752
+ * highlighted at a time.
7753
+ * This only has an effect on segmentation views.
7754
+ *
7755
+ * @param {number} [segmentNumber] The segment number,
7756
+ * undefined to remove the highlight.
7757
+ * @param {number} [opacity] The opacity factor (between 0 and 1),
7758
+ * defaults to 1.
7759
+ * @fires View#segmenthighlightchange
7760
+ */
7761
+ setSegmentHighlight(segmentNumber?: number, opacity?: number): void;
6032
7762
  /**
6033
7763
  * Get the view orientation.
6034
7764
  *
@@ -6093,9 +7823,9 @@ export declare class View {
6093
7823
  /**
6094
7824
  * Get the window presets.
6095
7825
  *
6096
- * @returns {object} The window presets.
7826
+ * @returns {Record<string, WindowPreset>} The window presets.
6097
7827
  */
6098
- getWindowPresets(): object;
7828
+ getWindowPresets(): Record<string, WindowPreset>;
6099
7829
  /**
6100
7830
  * Get the window presets names.
6101
7831
  *
@@ -6105,15 +7835,15 @@ export declare class View {
6105
7835
  /**
6106
7836
  * Set the window presets.
6107
7837
  *
6108
- * @param {object} presets The window presets.
7838
+ * @param {Record<string, WindowPreset>} presets The window presets.
6109
7839
  */
6110
- setWindowPresets(presets: object): void;
7840
+ setWindowPresets(presets: Record<string, WindowPreset>): void;
6111
7841
  /**
6112
7842
  * Add window presets to the existing ones.
6113
7843
  *
6114
- * @param {object} presets The window presets.
7844
+ * @param {Record<string, WindowPreset>} presets The window presets.
6115
7845
  */
6116
- addWindowPresets(presets: object): void;
7846
+ addWindowPresets(presets: Record<string, WindowPreset>): void;
6117
7847
  /**
6118
7848
  * Get the current window level preset name.
6119
7849
  *
@@ -6228,22 +7958,6 @@ export declare class View {
6228
7958
  * @param {boolean} [silent] Flag to launch events with skipGenerate.
6229
7959
  */
6230
7960
  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
7961
  /**
6248
7962
  * Get the image window/level that covers the full data range.
6249
7963
  * Warning: uses the latest set rescale LUT or the default linear one.
@@ -6279,6 +7993,16 @@ export declare class View {
6279
7993
  #private;
6280
7994
  }
6281
7995
 
7996
+ /**
7997
+ * @import {LayerGroup} from '../gui/layerGroup.js';
7998
+ * @import {ViewLayer} from '../gui/viewLayer.js';
7999
+ * @import {DrawLayer} from '../gui/drawLayer.js';
8000
+ * @import {Image} from '../image/image.js';
8001
+ * @import {Matrix33} from '../math/matrix.js';
8002
+ * @import {DataElement} from '../dicom/dataElement.js';
8003
+ * @import {Scalar3D} from '../math/scalar.js';
8004
+ * @import {Command} from '../command/undoStack.js';
8005
+ */
6282
8006
  /**
6283
8007
  * View configuration: mainly defines the ´divId´
6284
8008
  * of the associated HTML div.
@@ -6347,6 +8071,16 @@ export declare class ViewConfig {
6347
8071
  windowWidth: number | undefined;
6348
8072
  }
6349
8073
 
8074
+ /**
8075
+ * @import {View} from '../image/view.js';
8076
+ * @import {WindowLevel} from '../image/windowLevel.js';
8077
+ * @import {WindowPreset} from '../image/windowPreset.js';
8078
+ * @import {Point} from '../math/point.js';
8079
+ * @import {Scalar2D} from '../math/scalar.js';
8080
+ * @import {Matrix33} from '../math/matrix.js';
8081
+ * @import {ViewLayer} from '../gui/viewLayer.js';
8082
+ * @import {MaskSegmentViewHelper} from '../image/maskSegmentViewHelper.js';
8083
+ */
6350
8084
  /**
6351
8085
  * View controller.
6352
8086
  */
@@ -6404,10 +8138,10 @@ export declare class ViewController {
6404
8138
  /**
6405
8139
  * Add window/level presets to the view.
6406
8140
  *
6407
- * @param {object} presets A preset object.
8141
+ * @param {Record<string, WindowPreset>} presets A preset object.
6408
8142
  * @returns {object} The list of presets.
6409
8143
  */
6410
- addWindowLevelPresets(presets: object): object;
8144
+ addWindowLevelPresets(presets: Record<string, WindowPreset>): object;
6411
8145
  /**
6412
8146
  * Set the window level to the preset with the input name.
6413
8147
  *
@@ -6538,6 +8272,14 @@ export declare class ViewController {
6538
8272
  * or no quantifiable (for ex RGB).
6539
8273
  */
6540
8274
  getRescaledImageValue(position: Point): number | undefined;
8275
+ /**
8276
+ * Get the numbers of the mask segments at the input position.
8277
+ *
8278
+ * @param {Point} position The input position.
8279
+ * @returns {number[]} The list of segment numbers, empty if the image
8280
+ * is not a mask, for background or if out of bounds.
8281
+ */
8282
+ getSegmentNumbersAtPosition(position: Point): number[];
6541
8283
  /**
6542
8284
  * Get the image pixel unit.
6543
8285
  *
@@ -6681,6 +8423,13 @@ export declare class ViewController {
6681
8423
  * @returns {Index} The index.
6682
8424
  */
6683
8425
  getIndexFromPosition(point: Point): Index;
8426
+ /**
8427
+ * Get the world position of an index.
8428
+ *
8429
+ * @param {Index} index The index.
8430
+ * @returns {Point} The position.
8431
+ */
8432
+ getPositionFromIndex(index: Index): Point;
6684
8433
  /**
6685
8434
  * Set the current index.
6686
8435
  *
@@ -6761,6 +8510,28 @@ export declare class ViewController {
6761
8510
  * @param {MaskSegmentViewHelper} helper The helper.
6762
8511
  */
6763
8512
  setMaskViewHelper(helper: MaskSegmentViewHelper): void;
8513
+ /**
8514
+ * Get the segment highlight.
8515
+ *
8516
+ * @returns {{segmentNumber: number, opacity: number}|undefined}
8517
+ * The highlighted segment number and its opacity factor.
8518
+ */
8519
+ getSegmentHighlight(): {
8520
+ segmentNumber: number;
8521
+ opacity: number;
8522
+ } | undefined;
8523
+ /**
8524
+ * Set the segment highlight: the opacity of the given segment
8525
+ * is multiplied by the input factor. Only one segment can be
8526
+ * highlighted at a time.
8527
+ * This only has an effect on segmentation views.
8528
+ *
8529
+ * @param {number} [segmentNumber] The segment number,
8530
+ * undefined to remove the highlight.
8531
+ * @param {number} [opacity] The opacity factor (between 0 and 1),
8532
+ * defaults to 1.
8533
+ */
8534
+ setSegmentHighlight(segmentNumber?: number, opacity?: number): void;
6764
8535
  /**
6765
8536
  * Get the fill opacity relative to the global opacity.
6766
8537
  *
@@ -6804,8 +8575,16 @@ export declare class ViewController {
6804
8575
  #private;
6805
8576
  }
6806
8577
 
8578
+ /**
8579
+ * @import {Vector3D} from '../math/vector.js';
8580
+ * @import {Point, Point3D} from '../math/point.js';
8581
+ * @import {Scalar2D, Scalar3D} from '../math/scalar.js';
8582
+ */
6807
8583
  /**
6808
8584
  * View layer.
8585
+ *
8586
+ * Not an EventTarget in order to forward native DOM events while
8587
+ * preserving `preventDefault()` for tools (see '#fireDomEvent').
6809
8588
  */
6810
8589
  export declare class ViewLayer {
6811
8590
  /**
@@ -6859,10 +8638,10 @@ export declare class ViewLayer {
6859
8638
  /**
6860
8639
  * Handle an image set event.
6861
8640
  *
6862
- * @param {object} event The event.
8641
+ * @param {CustomEvent} event The event.
6863
8642
  * @function
6864
8643
  */
6865
- onimageset: (event: object) => void;
8644
+ onimageset: (event: CustomEvent) => void;
6866
8645
  /**
6867
8646
  * Bind this layer to the view image.
6868
8647
  */
@@ -6874,24 +8653,24 @@ export declare class ViewLayer {
6874
8653
  /**
6875
8654
  * Handle an image content change event.
6876
8655
  *
6877
- * @param {object} event The event.
8656
+ * @param {CustomEvent} event The event.
6878
8657
  * @function
6879
8658
  */
6880
- onimagecontentchange: (event: object) => void;
8659
+ onimagecontentchange: (event: CustomEvent) => void;
6881
8660
  /**
6882
8661
  * Handle an image change event.
6883
8662
  *
6884
- * @param {object} event The event.
8663
+ * @param {CustomEvent} event The event.
6885
8664
  * @function
6886
8665
  */
6887
- onimagegeometrychange: (event: object) => void;
8666
+ onimagegeometrychange: (event: CustomEvent) => void;
6888
8667
  /**
6889
8668
  * Handle an image resampled event.
6890
8669
  *
6891
- * @param {object} event The event.
8670
+ * @param {CustomEvent} event The event.
6892
8671
  * @function
6893
8672
  */
6894
- onimageresampled: (event: object) => void;
8673
+ onimageresampled: (event: CustomEvent) => void;
6895
8674
  /**
6896
8675
  * Get the id of the layer.
6897
8676
  *
@@ -6926,6 +8705,18 @@ export declare class ViewLayer {
6926
8705
  * @param {number} alpha The opacity ([0:1] range).
6927
8706
  */
6928
8707
  setOpacity(alpha: number): void;
8708
+ /**
8709
+ * Temporarily highlight a segment: its opacity progressively
8710
+ * dims and comes back to normal in one pulse. Only one
8711
+ * segment is highlighted at a time: a new call resets the
8712
+ * previous highlight.
8713
+ *
8714
+ * @param {number} segmentNumber The segment number.
8715
+ * @param {number} [duration] The highlight duration in milliseconds,
8716
+ * defaults to 750.
8717
+ * @returns {boolean} False if the layer is not a segmentation one.
8718
+ */
8719
+ highlightSegment(segmentNumber: number, duration?: number): boolean;
6929
8720
  /**
6930
8721
  * Get the fill opacity relative to the global opacity.
6931
8722
  *
@@ -7122,6 +8913,75 @@ export declare class ViewLayer {
7122
8913
  #private;
7123
8914
  }
7124
8915
 
8916
+ /**
8917
+ * Volume id candidate getter.
8918
+ */
8919
+ export declare type VolumeIdCandidate = {
8920
+ /**
8921
+ * The candidate name.
8922
+ */
8923
+ name: string;
8924
+ /**
8925
+ * The volume id getter:
8926
+ * `(elements) => SourcedNumberValue|undefined`, the returned volume id
8927
+ * does not need a source (the candidate name is used).
8928
+ */
8929
+ getter: Function;
8930
+ /**
8931
+ * Flag to also use the candidate
8932
+ * while loading.
8933
+ */
8934
+ preLoad?: boolean;
8935
+ /**
8936
+ * Flag to make the volume id values
8937
+ * relative to the smallest one, for example to get times since
8938
+ * the first acquisition instead of timestamps. Not applied while
8939
+ * loading.
8940
+ */
8941
+ relative?: boolean;
8942
+ };
8943
+
8944
+ /**
8945
+ * Pixel value of one volume.
8946
+ */
8947
+ export declare type VolumeValue = {
8948
+ /**
8949
+ * The volume id: with name and unit
8950
+ * if the image has volume ids, else just the volume index.
8951
+ */
8952
+ volumeId: SourcedNumberValue;
8953
+ /**
8954
+ * The rescaled pixel value and its unit.
8955
+ */
8956
+ pixValue: NumberValue;
8957
+ };
8958
+
8959
+ /**
8960
+ * @import {LayerGroup} from '../../gui/layerGroup.js';
8961
+ */
8962
+ /**
8963
+ * Mouse wheel handling: subclasses may override {@link WheelBehavior#onWheel}
8964
+ * (every event) and/or {@link WheelBehavior#onWheelTick}
8965
+ * (after tick threshold).
8966
+ */
8967
+ export declare class WheelBehavior {
8968
+ /**
8969
+ * Raw wheel event (every `wheel`); use with continuous effects such as zoom.
8970
+ *
8971
+ * @param {WheelEvent} _event The wheel event.
8972
+ * @param {LayerGroup|undefined} _layerGroup Layer group under the wheel.
8973
+ */
8974
+ onWheel(_event: WheelEvent, _layerGroup: LayerGroup | undefined): void;
8975
+ /**
8976
+ * Discrete wheel tick after accumulation; use for
8977
+ * slice scroll and similar stepped actions.
8978
+ *
8979
+ * @param {boolean} _up True when spin is in the positive direction.
8980
+ * @param {LayerGroup} _layerGroup Layer group under the wheel event.
8981
+ */
8982
+ onWheelTick(_up: boolean, _layerGroup: LayerGroup): void;
8983
+ }
8984
+
7125
8985
  /**
7126
8986
  * Window and Level also known as window width and center.
7127
8987
  */
@@ -7145,26 +9005,71 @@ export declare class WindowLevel {
7145
9005
  width: number;
7146
9006
  }
7147
9007
 
9008
+ /**
9009
+ * @import {WindowLevel} from './windowLevel.js';
9010
+ */
9011
+ /**
9012
+ * Window level preset: a named list of window levels.
9013
+ * The list holds a single window level unless the preset is 'perslice',
9014
+ * in which case it holds one window level per slice.
9015
+ */
9016
+ export declare class WindowPreset {
9017
+ /**
9018
+ * @param {string} name The preset name.
9019
+ * @param {WindowLevel[]} [wl] The list of window levels.
9020
+ * @param {boolean} [perslice] Flag for a per-slice window level list.
9021
+ */
9022
+ constructor(name: string, wl?: WindowLevel[], perslice?: boolean);
9023
+ /**
9024
+ * The preset name.
9025
+ *
9026
+ * @type {string}
9027
+ */
9028
+ name: string;
9029
+ /**
9030
+ * The list of window levels.
9031
+ *
9032
+ * @type {WindowLevel[]|undefined}
9033
+ */
9034
+ wl: WindowLevel[] | undefined;
9035
+ /**
9036
+ * Flag to indicate a per-slice window level list.
9037
+ *
9038
+ * @type {boolean|undefined}
9039
+ */
9040
+ perslice: boolean | undefined;
9041
+ }
9042
+
7148
9043
  /**
7149
9044
  * Writer rule.
7150
9045
  */
7151
9046
  export declare class WriterRule {
7152
9047
  /**
7153
- * @param {string} action The rule action.
9048
+ * @param {string} action The rule action, one of the
9049
+ * `WriterRuleActions` values.
7154
9050
  */
7155
9051
  constructor(action: string);
7156
9052
  /**
7157
- * Rule action: `copy`, `remove`, `clear` or `replace`.
9053
+ * Rule action, one of the `WriterRuleActions` values.
7158
9054
  *
7159
9055
  * @type {string}
7160
9056
  */
7161
9057
  action: string;
7162
9058
  /**
7163
9059
  * Optional value to use for replace action.
9060
+ * A single value or an array of values for multi-valued
9061
+ * elements (for example `['A', 'B']` or a list of sequence items).
7164
9062
  *
7165
9063
  * @type {any|undefined}
7166
9064
  */
7167
9065
  value: any | undefined;
7168
9066
  }
7169
9067
 
9068
+ export declare namespace WriterRuleActions {
9069
+ let copy: string;
9070
+ let remove: string;
9071
+ let clear: string;
9072
+ let replace: string;
9073
+ }
9074
+
7170
9075
  export { }