dwv 0.37.0-beta.9 → 0.37.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/dwv.d.ts CHANGED
@@ -11,9 +11,7 @@ import Konva from 'konva';
11
11
  export declare function addTagsToDictionary(group: string, tags: Record<string, string[]>): void;
12
12
 
13
13
  /**
14
- * @import {Point2D} from '../math/point.js';
15
- * @import {Index} from '../math/index.js';
16
- * @import {NumberValue} from '../math/number.js';
14
+ * @import {NumberValue} from '../math/types.js';
17
15
  * @import {ViewController} from '../app/viewController.js';
18
16
  * @import {PlaneHelper} from './planeHelper.js';
19
17
  * @import {DicomCode} from '../dicom/dicomCode.js';
@@ -47,7 +45,9 @@ export declare class Annotation {
47
45
  */
48
46
  referencedSopClassUID: string;
49
47
  /**
50
- * 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).
51
51
  *
52
52
  * @type {number|undefined}
53
53
  */
@@ -168,6 +168,16 @@ export declare class Annotation {
168
168
  * @returns {Point|undefined} The 3D centroid point.
169
169
  */
170
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;
171
181
  /**
172
182
  * Set the annotation text expression.
173
183
  *
@@ -346,19 +356,19 @@ export declare class AnnotationGroupFactory {
346
356
  * TID 1500 template.
347
357
  *
348
358
  * @param {AnnotationGroup} annotationGroup The annotation group.
349
- * @param {Record<string, any>} [extraTags] Optional list of extra tags.
359
+ * @param {SimpleTagValues} [extraTags] Optional list of extra tags.
350
360
  * @returns {Record<string, DataElement>} A list of dicom elements.
351
361
  */
352
- toDicom(annotationGroup: AnnotationGroup, extraTags?: Record<string, any>): Record<string, DataElement>;
362
+ toDicom(annotationGroup: AnnotationGroup, extraTags?: SimpleTagValues): Record<string, DataElement>;
353
363
  /**
354
364
  * Convert a CAD report into a DICOM CAD report SR object using
355
365
  * the TID 4100 template.
356
366
  *
357
367
  * @param {CADReport} report The CAD report.
358
- * @param {Record<string, any>} [extraTags] Optional list of extra tags.
368
+ * @param {SimpleTagValues} [extraTags] Optional list of extra tags.
359
369
  * @returns {Record<string, DataElement>} A list of dicom elements.
360
370
  */
361
- toDicomCADReport(report: CADReport, extraTags?: Record<string, any>): Record<string, DataElement>;
371
+ toDicomCADReport(report: CADReport, extraTags?: SimpleTagValues): Record<string, DataElement>;
362
372
  #private;
363
373
  }
364
374
 
@@ -687,7 +697,6 @@ export declare class App extends EventTarget {
687
697
  * @type {CustomEvent}
688
698
  * @property {object} detail The event detail.
689
699
  * @property {string} detail.dataid The data id.
690
- * @property {string} detail.loadtype The load type: image or state.
691
700
  * @property {*} detail.source The load source: string for an url,
692
701
  * File for a file.
693
702
  */
@@ -698,7 +707,6 @@ export declare class App extends EventTarget {
698
707
  * @type {CustomEvent}
699
708
  * @property {object} detail The event detail.
700
709
  * @property {string} detail.dataid The data id.
701
- * @property {string} detail.loadtype The load type: image or state.
702
710
  * @property {*} detail.source The load source: string for an url,
703
711
  * File for a file.
704
712
  * @property {number} detail.loaded The loaded percentage.
@@ -711,7 +719,6 @@ export declare class App extends EventTarget {
711
719
  * @type {CustomEvent}
712
720
  * @property {object} detail The event detail.
713
721
  * @property {string} detail.dataid The data id.
714
- * @property {string} detail.loadtype The load type: image or state.
715
722
  * @property {*} detail.source The load source: string for an url,
716
723
  * File for a file.
717
724
  * @property {object} detail.data The loaded meta data.
@@ -725,7 +732,6 @@ export declare class App extends EventTarget {
725
732
  * @type {CustomEvent}
726
733
  * @property {object} detail The event detail.
727
734
  * @property {string} detail.dataid The data id.
728
- * @property {string} detail.loadtype The load type: image or state.
729
735
  * @property {*} detail.source The load source: string for an url,
730
736
  * File for a file.
731
737
  */
@@ -737,7 +743,6 @@ export declare class App extends EventTarget {
737
743
  * @type {CustomEvent}
738
744
  * @property {object} detail The event detail.
739
745
  * @property {string} detail.dataid The data id.
740
- * @property {string} detail.loadtype The load type: image or state.
741
746
  * @property {*} detail.source The load source: string for an url,
742
747
  * File for a file.
743
748
  */
@@ -748,7 +753,6 @@ export declare class App extends EventTarget {
748
753
  * @type {CustomEvent}
749
754
  * @property {object} detail The event detail.
750
755
  * @property {string} detail.dataid The data id.
751
- * @property {string} detail.loadtype The load type: image or state.
752
756
  * @property {*} detail.source The load source: string for an url,
753
757
  * File for a file.
754
758
  * @property {object} detail.error The error.
@@ -761,7 +765,6 @@ export declare class App extends EventTarget {
761
765
  * @type {CustomEvent}
762
766
  * @property {object} detail The event detail.
763
767
  * @property {string} detail.dataid The data id.
764
- * @property {string} detail.loadtype The load type: image or state.
765
768
  * @property {*} detail.source The load source: an url as a string.
766
769
  * @property {object} detail.target The event target.
767
770
  */
@@ -772,12 +775,11 @@ export declare class App extends EventTarget {
772
775
  * @type {CustomEvent}
773
776
  * @property {object} detail The event detail.
774
777
  * @property {string} detail.dataid The data id.
775
- * @property {string} detail.loadtype The load type: image or state.
776
778
  * @property {*} detail.source The load source: string for an url,
777
779
  * File for a file.
778
780
  */
779
781
  /**
780
- * Load a list of files. Can be image files or a state file.
782
+ * Load a list of image files.
781
783
  *
782
784
  * @param {File[]} files The list of files to load.
783
785
  * @returns {string} The data ID, '-1' if problem.
@@ -791,7 +793,7 @@ export declare class App extends EventTarget {
791
793
  */
792
794
  loadFiles: (files: File[]) => string;
793
795
  /**
794
- * Load a list of URLs. Can be image files or a state file.
796
+ * Load a list of image URLs.
795
797
  *
796
798
  * @param {string[]} urls The list of urls to load.
797
799
  * @param {object} [options] The options object, can contain:
@@ -1002,24 +1004,6 @@ export declare class App extends EventTarget {
1002
1004
  * of the desired view layer directly.
1003
1005
  */
1004
1006
  setOpacity(alpha: number): void;
1005
- /**
1006
- * Set the drawings of the active layer group.
1007
- *
1008
- * @deprecated Since v0.34, please switch to DICOM SR annotations.
1009
- * @param {Array} drawings An array of drawings.
1010
- * @param {Array} drawingsDetails An array of drawings details.
1011
- * @param {string} dataId The converted data id.
1012
- */
1013
- setDrawings(drawings: any[], drawingsDetails: any[], dataId: string): void;
1014
- /**
1015
- * Apply a JSON state to this app.
1016
- *
1017
- * @deprecated Since v0.34, please switch to DICOM SR
1018
- * for annotations.
1019
- * @param {string} jsonState The state of the app as a JSON string.
1020
- * @param {string} dataId The state data id.
1021
- */
1022
- applyJsonState(jsonState: string, dataId: string): void;
1023
1007
  /**
1024
1008
  * Handle resize: fit the display to the window.
1025
1009
  * To be called once the image is loaded.
@@ -1275,7 +1259,27 @@ export declare class CADReport {
1275
1259
  }
1276
1260
 
1277
1261
  /**
1278
- * @import {Image} from '../image/image.js';
1262
+ * Canvas size checker: calls `canCreateCanvas` and caches its
1263
+ * results. The browser canvas size limits do not change during a session,
1264
+ * a size smaller than a valid one is valid and a size larger than
1265
+ * an invalid one is invalid.
1266
+ *
1267
+ * Meant to be shared by the view layers of a stage.
1268
+ */
1269
+ export declare class CanvasSizeChecker {
1270
+ /**
1271
+ * Test if a canvas with the input size can be created.
1272
+ *
1273
+ * @param {Scalar2D} size The canvas size as {x,y}.
1274
+ * @param {Document} doc The document used to create the test canvases.
1275
+ * @returns {boolean} True if the canvas can be created.
1276
+ */
1277
+ canCreate(size: Scalar2D, doc: Document): boolean;
1278
+ #private;
1279
+ }
1280
+
1281
+ /**
1282
+ * @import {MaskImage} from '../image/maskImage.js';
1279
1283
  * @import {MaskSegment} from '../dicom/dicomSegment.js';
1280
1284
  * @import {RGB} from '../utils/colour.js';
1281
1285
  */
@@ -1284,12 +1288,12 @@ export declare class CADReport {
1284
1288
  */
1285
1289
  export declare class ChangeSegmentColourCommand extends Command {
1286
1290
  /**
1287
- * @param {Image} mask The mask image.
1291
+ * @param {MaskImage} mask The mask image.
1288
1292
  * @param {MaskSegment} segment The segment to modify.
1289
1293
  * @param {RGB|number} newColour The new segment colour.
1290
1294
  * @param {boolean} [silent] Whether to send a creation event or not.
1291
1295
  */
1292
- constructor(mask: Image_2, segment: MaskSegment, newColour: RGB | number, silent?: boolean);
1296
+ constructor(mask: MaskImage, segment: MaskSegment, newColour: RGB | number, silent?: boolean);
1293
1297
  /**
1294
1298
  * Check if a command is valid and can be executed.
1295
1299
  *
@@ -1339,6 +1343,16 @@ export declare class Circle {
1339
1343
  * @returns {number} The radius of the circle.
1340
1344
  */
1341
1345
  getRadius(): number;
1346
+ /**
1347
+ * Check if a point is inside the circle, or within a tolerance
1348
+ * of its outline.
1349
+ *
1350
+ * @param {Point2D} point The point to check.
1351
+ * @param {number} [tolerance] Optional maximum distance to the outline
1352
+ * for an outside point, defaults to 0.
1353
+ * @returns {boolean} True if the point is in the circle.
1354
+ */
1355
+ contains(point: Point2D, tolerance?: number): boolean;
1342
1356
  /**
1343
1357
  * Check for equality.
1344
1358
  *
@@ -1437,42 +1451,16 @@ export declare class Command {
1437
1451
  undo(): void;
1438
1452
  }
1439
1453
 
1440
- /**
1441
- * Create an Image from DICOM elements.
1442
- *
1443
- * @param {Record<string, DataElement>} elements The DICOM elements.
1444
- * @returns {Image} The Image object.
1445
- */
1446
- export declare function createImage(elements: Record<string, DataElement>): Image_2;
1447
-
1448
- /**
1449
- * Create a mask Image from DICOM elements.
1450
- *
1451
- * @param {Record<string, DataElement>} elements The DICOM elements.
1452
- * @returns {Image} The mask Image object.
1453
- */
1454
- export declare function createMaskImage(elements: Record<string, DataElement>): Image_2;
1455
-
1456
- /**
1457
- * Create a View from DICOM elements and image.
1458
- *
1459
- * @param {Record<string, DataElement>} elements The DICOM elements.
1460
- * @param {Image} image The associated image.
1461
- * @returns {View} The View object.
1462
- */
1463
- export declare function createView(elements: Record<string, DataElement>, image: Image_2): View;
1464
-
1465
1454
  export declare namespace custom {
1466
1455
  let wlPresets: Record<string, Record<string, WindowLevel>>;
1467
1456
  let labelTexts: Record<string, Record<string, string>>;
1468
- let privateBValueRules: object[];
1457
+ let privateBValueRules: PrivateBValueRule[];
1469
1458
  let openRoiDialog: any;
1459
+ let highlightAnnotation: any;
1460
+ let highlightSegment: any;
1470
1461
  let getVolumeIdTagValue: any;
1471
1462
  let getPostLoadVolumeIdTagValue: any;
1472
- let postLoadVolumeIdCandidates: {
1473
- name: string;
1474
- getter: Function;
1475
- }[];
1463
+ let volumeIdCandidates: VolumeIdCandidate[];
1476
1464
  let getTagPixelUnit: any;
1477
1465
  }
1478
1466
 
@@ -1643,6 +1631,27 @@ export declare class DataElement {
1643
1631
  items: any[];
1644
1632
  }
1645
1633
 
1634
+ /**
1635
+ * @import {Tag} from './dicomTag.js';
1636
+ */
1637
+ /**
1638
+ * Dump the DICOM tags to a string in the same way as the
1639
+ * DCMTK `dcmdump` command (https://support.dcmtk.org/docs-dcmrt/dcmdump.html).
1640
+ *
1641
+ * @param {Record<string, DataElement>} dicomElements The dicom elements.
1642
+ * @returns {string} The dumped file.
1643
+ */
1644
+ export declare function dcmdump(dicomElements: Record<string, DataElement>): string;
1645
+
1646
+ /**
1647
+ * Default private b-value tag rules. Tested in order.
1648
+ * Rules are either `{manufacturer, key}` or `{uidPrefix, key}`.
1649
+ * Can be used to extend `custom.privateBValueRules`.
1650
+ *
1651
+ * @type {PrivateBValueRule[]}
1652
+ */
1653
+ export declare const defaultPrivateBValueRules: PrivateBValueRule[];
1654
+
1646
1655
  /**
1647
1656
  * Default tool list.
1648
1657
  *
@@ -1658,7 +1667,29 @@ export declare const defaultToolList: Record<string, any>;
1658
1667
  export declare const defaultToolOptions: Record<string, Record<string, any>>;
1659
1668
 
1660
1669
  /**
1661
- * @import {Image} from '../image/image.js';
1670
+ * Ordered list of candidate volume id getters. Since the tag that
1671
+ * actually discriminates volumes is not known until the full data
1672
+ * is loaded, `guessVolumeIndices` tries these in order and keeps the
1673
+ * first one that produces a valid, consistent per-volume grouping.
1674
+ * It is used for the files of a series (see `DicomSliceDataList`)
1675
+ * and for the frames of a multi-frame file (see
1676
+ * `getSortedFramesGeometry`).
1677
+ * Most explicit/reliable discriminators come first, AcquisitionTime
1678
+ * (the historical default) comes last.
1679
+ * Candidates flagged with `preLoad` are also used while loading
1680
+ * (see `getVolumeIdTagValue`): they must not vary between the
1681
+ * slices of a single volume.
1682
+ * Candidates either read an index (an id without unit, for example
1683
+ * TemporalPositionIdentifier) or a value (for example EchoTime).
1684
+ * The associated value of indices is guessed once all data is loaded
1685
+ * (see `getVolumeValues`), values have none.
1686
+ *
1687
+ * @type {VolumeIdCandidate[]}
1688
+ */
1689
+ export declare const defaultVolumeIdCandidates: VolumeIdCandidate[];
1690
+
1691
+ /**
1692
+ * @import {MaskImage} from '../image/maskImage.js';
1662
1693
  * @import {MaskSegment} from '../dicom/dicomSegment.js';
1663
1694
  */
1664
1695
  /**
@@ -1666,11 +1697,11 @@ export declare const defaultToolOptions: Record<string, Record<string, any>>;
1666
1697
  */
1667
1698
  export declare class DeleteSegmentCommand extends Command {
1668
1699
  /**
1669
- * @param {Image} mask The mask image.
1700
+ * @param {MaskImage} mask The mask image.
1670
1701
  * @param {MaskSegment} segment The segment to remove.
1671
1702
  * @param {boolean} [silent] Whether to send a creation event or not.
1672
1703
  */
1673
- constructor(mask: Image_2, segment: MaskSegment, silent?: boolean);
1704
+ constructor(mask: MaskImage, segment: MaskSegment, silent?: boolean);
1674
1705
  /**
1675
1706
  * Check if a command is valid and can be executed.
1676
1707
  *
@@ -1692,9 +1723,44 @@ export declare class DeleteSegmentCommand extends Command {
1692
1723
  #private;
1693
1724
  }
1694
1725
 
1726
+ /**
1727
+ * Demo Image creation from DICOM elements: takes
1728
+ * elements and first element of the pixel buffer
1729
+ * to create an image.
1730
+ *
1731
+ * Warning: not to be used in production code.
1732
+ *
1733
+ * @param {Record<string, DataElement>} elements The DICOM elements.
1734
+ * @returns {Image} The Image object.
1735
+ */
1736
+ export declare function demoCreateImage(elements: Record<string, DataElement>): Image_2;
1737
+
1738
+ /**
1739
+ * Demo mask Image creation from DICOM elements: takes
1740
+ * elements and first element of the pixel buffer
1741
+ * to create an image.
1742
+ *
1743
+ * Warning: not to be used in production code.
1744
+ *
1745
+ * @param {Record<string, DataElement>} elements The DICOM elements.
1746
+ * @returns {MaskImage} The mask Image object.
1747
+ */
1748
+ export declare function demoCreateMaskImage(elements: Record<string, DataElement>): MaskImage;
1749
+
1750
+ /**
1751
+ * Demo View creation from DICOM elements and image.
1752
+ *
1753
+ * Warning: not to be used in production code.
1754
+ *
1755
+ * @param {Record<string, DataElement>} elements The DICOM elements.
1756
+ * @param {Image} image The associated image.
1757
+ * @returns {View} The View object.
1758
+ */
1759
+ export declare function demoCreateView(elements: Record<string, DataElement>, image: Image_2): View;
1760
+
1695
1761
  /**
1696
1762
  * @import {Point} from '../math/point.js';
1697
- * @import {NumberValue} from '../math/number.js';
1763
+ * @import {NumberValue} from '../math/types.js';
1698
1764
  */
1699
1765
  /**
1700
1766
  * Diameter type.
@@ -1743,7 +1809,7 @@ export declare class Diameters {
1743
1809
  /**
1744
1810
  * DICOM code: item of a basic code sequence.
1745
1811
  *
1746
- * Ref: {@link https://dicom.nema.org/medical/dicom/2022a/output/chtml/part03/sect_8.8.html}.
1812
+ * Ref: {@link https://dicom.nema.org/medical/dicom/2024a/output/chtml/part03/sect_8.8.html}.
1747
1813
  */
1748
1814
  export declare class DicomCode {
1749
1815
  /**
@@ -1809,7 +1875,7 @@ export declare class DicomData {
1809
1875
  */
1810
1876
  image: Image_2 | undefined;
1811
1877
  /**
1812
- * Annotattion group extracted from meta data.
1878
+ * Annotation group extracted from meta data.
1813
1879
  *
1814
1880
  * @type {AnnotationGroup|undefined}
1815
1881
  */
@@ -1821,11 +1887,20 @@ export declare class DicomData {
1821
1887
  */
1822
1888
  buffer: any | undefined;
1823
1889
  /**
1824
- * Number of files/urls associated to the data.
1890
+ * Number of load items (files, urls, buffers...) associated
1891
+ * to the data.
1825
1892
  *
1826
1893
  * @type {number}
1827
1894
  */
1828
- numberOfFiles: number;
1895
+ numberOfItems: number;
1896
+ /**
1897
+ * Frame number, set when the buffer only contains one frame
1898
+ * of a multi-frame data: frames are sent one by one and assembled
1899
+ * by the image (see Image.appendSlice).
1900
+ *
1901
+ * @type {number|undefined}
1902
+ */
1903
+ frameNumber: number | undefined;
1829
1904
  /**
1830
1905
  * List of data creation warning.
1831
1906
  *
@@ -1851,7 +1926,7 @@ export declare class DicomData {
1851
1926
  */
1852
1927
  hasDuplicateOrigin(): boolean;
1853
1928
  /**
1854
- * Append slice and update meta data.
1929
+ * Append data and update meta data.
1855
1930
  *
1856
1931
  * @param {DicomData} data The data to append.
1857
1932
  */
@@ -1932,7 +2007,7 @@ export declare class DicomParser {
1932
2007
  /**
1933
2008
  * DICOM SR content: item of a SR content sequence.
1934
2009
  *
1935
- * Ref: {@link https://dicom.nema.org/medical/dicom/2022a/output/chtml/part03/sect_C.17.3.html}.
2010
+ * Ref: {@link https://dicom.nema.org/medical/dicom/2024a/output/chtml/part03/sect_C.17.3.html}.
1936
2011
  */
1937
2012
  export declare class DicomSRContent {
1938
2013
  /**
@@ -2032,13 +2107,38 @@ export declare class DicomWriter {
2032
2107
  * @param {boolean} flag True to activate the check and fix.
2033
2108
  */
2034
2109
  setFixUnknownVR(flag: boolean): void;
2110
+ /**
2111
+ * Set the list of private tags (odd group number) to write.
2112
+ * All other private tags are not written, including the ones
2113
+ * in sequence items. Takes precedence over the writing rules,
2114
+ * whitelisted tags still go through them.
2115
+ * The private creator of each whitelisted tag is also kept:
2116
+ * for example, whitelisting '0019100C' also keeps '00190010'.
2117
+ * Use an empty list to remove all private tags and undefined
2118
+ * to keep them all (default).
2119
+ *
2120
+ * @param {string[]|undefined} keys The list of private tag keys
2121
+ * (as '########').
2122
+ */
2123
+ setPrivateTagsWhitelist(keys: string[] | undefined): void;
2035
2124
  /**
2036
2125
  * Set the writing rules.
2037
2126
  * List of writer rules indexed by either `default`,
2038
- * tagKey, tagName or groupName.
2127
+ * tag key (for example '00100010') or group key (for example '0010').
2128
+ * Keys can be ranges using 'x' as any hex digit, as in the DICOM
2129
+ * standard repeating groups notation: for example '60xx3000'
2130
+ * (tag range) or '50xx' (group range). Note that 'x' matches any
2131
+ * hex digit: '60xx' also matches odd (private) groups.
2039
2132
  * Each DICOM element will be checked to see if a rule is applicable.
2040
- * First checked by tagKey, tagName and then by groupName,
2041
- * if nothing is found the default rule is applied.
2133
+ * First checked by tag key, tag range, group key and then group range,
2134
+ * if nothing is found the default rule is applied. If several ranges
2135
+ * match, the most specific one (with less 'x') is used, and, for same
2136
+ * specificity, the first one in the rules order.
2137
+ * Rules are also applied to the elements of sequence items.
2138
+ * Use `translateWriterRules` to convert tag or group name based rules.
2139
+ * Rules with an unknown action are ignored (with a warning), the
2140
+ * next matching rule is then used. If there is no valid default
2141
+ * rule, the default is to copy.
2042
2142
  *
2043
2143
  * @param {Record<string, WriterRule>} rules The input rules.
2044
2144
  * @param {boolean} [addMissingTags] If true, explicit tags that
@@ -2052,7 +2152,10 @@ export declare class DicomWriter {
2052
2152
  useSpecialTextEncoder(): void;
2053
2153
  /**
2054
2154
  * Get the element to write according to the class rules.
2055
- * Priority order: tagName, groupName, default.
2155
+ * Priority order: tag key, tag range, group key, group range, default.
2156
+ * Non whitelisted private tags are removed if a whitelist
2157
+ * is set, whatever the rules.
2158
+ * For sequences, rules are also applied to the item elements.
2056
2159
  *
2057
2160
  * @param {DataElement} element The element to check.
2058
2161
  * @returns {DataElement|null} The element to write, can be null.
@@ -2105,13 +2208,13 @@ export declare class DrawBrushCommand extends Command {
2105
2208
  }
2106
2209
 
2107
2210
  /**
2108
- * @import {Image} from '../image/image.js';
2211
+ * @import {MaskImage} from '../image/maskImage.js';
2109
2212
  */
2110
2213
  export declare class DrawBrushCommandProperties {
2111
2214
  /**
2112
- * @type {Image}
2215
+ * @type {MaskImage}
2113
2216
  */
2114
- mask: Image_2;
2217
+ mask: MaskImage;
2115
2218
  /**
2116
2219
  * @type {string}
2117
2220
  */
@@ -2241,11 +2344,13 @@ export declare class DrawController {
2241
2344
  }
2242
2345
 
2243
2346
  /**
2244
- * @import {Point, Point3D} from '../math/point.js';
2347
+ * @import {Point, Point2D, Point3D} from '../math/point.js';
2245
2348
  * @import {Vector3D} from '../math/vector.js';
2246
2349
  * @import {Scalar2D, Scalar3D} from '../math/scalar.js';
2350
+ * @import {Index} from '../math/index.js';
2247
2351
  * @import {Image} from '../image/image.js';
2248
2352
  * @import {PlaneHelper} from '../image/planeHelper.js';
2353
+ * @import {Annotation} from '../image/annotation.js';
2249
2354
  * @import {AnnotationGroup} from '../image/annotationGroup.js';
2250
2355
  * @import {DrawShapeHandler} from '../tools/shapes/drawShapeHandler.js';
2251
2356
  */
@@ -2434,6 +2539,17 @@ export declare class DrawLayer {
2434
2539
  * @param {Scalar2D} fitOffset The fit offset as {x,y}.
2435
2540
  */
2436
2541
  fitToContainer(containerSize: Scalar2D, divToWorldSizeRatio: number, fitOffset: Scalar2D): void;
2542
+ /**
2543
+ * Get the top most visible annotation at the current position
2544
+ * that contains the input plane point.
2545
+ *
2546
+ * @param {Point2D} planePoint The plane point, in the reference
2547
+ * view layer plane coordinates.
2548
+ * @param {number} [tolerance] Optional maximum distance to a shape,
2549
+ * in plane coordinates, defaults to 0.
2550
+ * @returns {Annotation|undefined} The annotation, undefined if none.
2551
+ */
2552
+ getAnnotationAt(planePoint: Point2D, tolerance?: number): Annotation | undefined;
2437
2553
  /**
2438
2554
  * Check the visibility of an annotation.
2439
2555
  *
@@ -2450,6 +2566,18 @@ export declare class DrawLayer {
2450
2566
  * @returns {boolean} False if the annotation shape cannot be found.
2451
2567
  */
2452
2568
  setAnnotationVisibility(id: string, visible?: boolean): boolean;
2569
+ /**
2570
+ * Temporarily highlight an annotation: its opacity progressively
2571
+ * dims to 20% and comes back to normal in one pulse. Only one
2572
+ * annotation is highlighted at a time: a new call resets the
2573
+ * previous highlight.
2574
+ *
2575
+ * @param {string} id The id of the annotation.
2576
+ * @param {number} [duration] The highlight duration in milliseconds,
2577
+ * defaults to 500.
2578
+ * @returns {boolean} False if the annotation shape cannot be found.
2579
+ */
2580
+ highlightAnnotation(id: string, duration?: number): boolean;
2453
2581
  /**
2454
2582
  * Set the visibility of all labels.
2455
2583
  *
@@ -2616,6 +2744,15 @@ export declare class Ellipse {
2616
2744
  * @returns {number} The radius of the ellipse on the vertical axe.
2617
2745
  */
2618
2746
  getB(): number;
2747
+ /**
2748
+ * Check if a point is inside the ellipse, the ellipse radii being
2749
+ * extended by a tolerance.
2750
+ *
2751
+ * @param {Point2D} point The point to check.
2752
+ * @param {number} [tolerance] Optional radius extension, defaults to 0.
2753
+ * @returns {boolean} True if the point is in the ellipse.
2754
+ */
2755
+ contains(point: Point2D, tolerance?: number): boolean;
2619
2756
  /**
2620
2757
  * Check for equality.
2621
2758
  *
@@ -2672,6 +2809,11 @@ export declare class Ellipse {
2672
2809
  */
2673
2810
  export declare function equalWl(wl0: WindowLevel, wl1: WindowLevel): boolean;
2674
2811
 
2812
+ /**
2813
+ * List of compatible float typed arrays.
2814
+ */
2815
+ export declare type FloatTypedArray = Float32Array | Float64Array;
2816
+
2675
2817
  /**
2676
2818
  * 2D/3D Geometry class.
2677
2819
  */
@@ -2682,9 +2824,10 @@ export declare class Geometry {
2682
2824
  * @param {Spacing} spacing The object spacing.
2683
2825
  * @param {Matrix33} [orientation] The object orientation (3*3 matrix,
2684
2826
  * default to 3*3 identity).
2685
- * @param {number} [time] Optional time index.
2827
+ * @param {VolumeId} [time] Optional time: a volume id or, without
2828
+ * source, a frame index (for example `{id: {value: 2}}`).
2686
2829
  */
2687
- constructor(origins: Point3D[], size: Size, spacing: Spacing, orientation?: Matrix33, time?: number);
2830
+ constructor(origins: Point3D[], size: Size, spacing: Spacing, orientation?: Matrix33, time?: VolumeId);
2688
2831
  /**
2689
2832
  * Clone the geometry.
2690
2833
  *
@@ -2692,17 +2835,62 @@ export declare class Geometry {
2692
2835
  */
2693
2836
  clone(): Geometry;
2694
2837
  /**
2695
- * Get the time value that was passed at construction.
2838
+ * Get the time that was passed at construction.
2696
2839
  *
2697
- * @returns {number} The time value.
2840
+ * @returns {VolumeId|undefined} The time.
2698
2841
  */
2699
- getInitialTime(): number;
2842
+ getInitialTime(): VolumeId | undefined;
2700
2843
  /**
2701
2844
  * Set the initial time.
2702
2845
  *
2703
- * @param {number} time The new time.
2846
+ * @param {VolumeId} time The new time: a volume id or, without
2847
+ * source, a frame index.
2848
+ */
2849
+ setInitialTime(time: VolumeId): void;
2850
+ /**
2851
+ * Set the associated values of the volume ids, for example once
2852
+ * guessed after load (see dicomVolume getVolumeValues).
2853
+ *
2854
+ * @param {SourcedNumberValue[]} values The associated values, one per
2855
+ * volume id, in volume id order.
2856
+ * @throws {Error} If the number of values is not the number of
2857
+ * volume ids.
2704
2858
  */
2705
- setInitialTime(time: number): void;
2859
+ setVolumeValues(values: SourcedNumberValue[]): void;
2860
+ /**
2861
+ * Get the volume ids: the time of each volume, sorted by ascending
2862
+ * id, the array index being the volume index. Times are volume
2863
+ * ids if their id has a source.
2864
+ *
2865
+ * @returns {VolumeId[]|undefined} The volume ids, undefined if the
2866
+ * times are not volume ids.
2867
+ */
2868
+ getVolumeIds(): VolumeId[] | undefined;
2869
+ /**
2870
+ * Set the volume ids of a geometry without times (for example a
2871
+ * resampled one): the volumes all have the current origins.
2872
+ *
2873
+ * @param {VolumeId[]} volumeIds The volume ids, sorted by ascending
2874
+ * id, one per volume (fourth dimension).
2875
+ */
2876
+ setVolumeIds(volumeIds: VolumeId[]): void;
2877
+ /**
2878
+ * Get the index of a volume id.
2879
+ *
2880
+ * @param {number} id The volume id.
2881
+ * @returns {number} The volume index, -1 if not found.
2882
+ */
2883
+ getVolumeIndex(id: number): number;
2884
+ /**
2885
+ * Check if the volume of this geometry can follow the one of another
2886
+ * geometry: both volume ids have the same origin and the input
2887
+ * volume id value is one of this geometry.
2888
+ *
2889
+ * @param {Geometry} geometry The geometry to follow.
2890
+ * @param {number} value The volume id value to follow.
2891
+ * @returns {boolean} True if the volume can follow.
2892
+ */
2893
+ canSyncVolume(geometry: Geometry, value: number): boolean;
2706
2894
  /**
2707
2895
  * Get the total number of slices.
2708
2896
  * Can be different from what is stored in the size object
@@ -2714,7 +2902,7 @@ export declare class Geometry {
2714
2902
  /**
2715
2903
  * Check if a time point has associated slices.
2716
2904
  *
2717
- * @param {number} time The time point to check.
2905
+ * @param {number} time The time id to check.
2718
2906
  * @returns {boolean} True if slices are present.
2719
2907
  */
2720
2908
  hasSlicesAtTime(time: number): boolean;
@@ -2722,10 +2910,19 @@ export declare class Geometry {
2722
2910
  * Get the number of slices stored for time points preceding
2723
2911
  * the input one.
2724
2912
  *
2725
- * @param {number} time The time point to check.
2913
+ * @param {number} time The time id to check.
2726
2914
  * @returns {number|undefined} The count.
2727
2915
  */
2728
2916
  getCurrentNumberOfSlicesBeforeTime(time: number): number | undefined;
2917
+ /**
2918
+ * Check that all time points have the same origins as the
2919
+ * initial time point (same number and same values in the
2920
+ * same order).
2921
+ *
2922
+ * @returns {BooleanResult} Result with success set to true if
2923
+ * the time origins are consistent.
2924
+ */
2925
+ checkTimeOrigins(): BooleanResult;
2729
2926
  /**
2730
2927
  * Get the object origin.
2731
2928
  * This should be the lowest origin to ease calculations (?).
@@ -2739,6 +2936,10 @@ export declare class Geometry {
2739
2936
  * @returns {Point3D[]} The object origins.
2740
2937
  */
2741
2938
  getOrigins(): Point3D[];
2939
+ /**
2940
+ * Sort origins by Z position ascending.
2941
+ */
2942
+ sortOrigins(): void;
2742
2943
  /**
2743
2944
  * Check if a point is in the origin list.
2744
2945
  *
@@ -2784,7 +2985,7 @@ export declare class Geometry {
2784
2985
  */
2785
2986
  getOrientation(): Matrix33;
2786
2987
  /**
2787
- * Get the slice position of a point in the current slice layout.
2988
+ * Get the slice position of an origin in the current slice layout.
2788
2989
  * Slice indices increase with decreasing origins (high index -> low origin),
2789
2990
  * this simplified the handling of reconstruction since it means
2790
2991
  * the displayed data is in the same 'direction' as the extracted data.
@@ -2792,11 +2993,25 @@ export declare class Geometry {
2792
2993
  * This implies that the index to world and reverse method do some flipping
2793
2994
  * magic...
2794
2995
  *
2795
- * @param {Point3D} point The point to evaluate.
2796
- * @param {number} [time] Optional time index.
2996
+ * Limitation: the codirectional (before/after) refinement below is a
2997
+ * strict sign check on the normal-projected residual, with no
2998
+ * tolerance - unlike worldToIndex's magnitude-based half-spacing
2999
+ * gate. That is safe for this method's one real caller
3000
+ * (Image#appendSlice, which only ever compares exact, already-known
3001
+ * slice origins - a clean, large residual, never close to zero),
3002
+ * but this method should not be used for an arbitrary point with a
3003
+ * large in-plane offset from its closest origin (eg a click
3004
+ * position): float noise in that offset, amplified by a
3005
+ * lower-precision orientation (eg gantry-tilt direction cosines
3006
+ * with few decimal digits), can flip the sign of a residual that
3007
+ * should be exactly zero. Use worldToIndex (or a plain
3008
+ * Point3D#getClosest) instead for that case.
3009
+ *
3010
+ * @param {Point3D} origin The origin to locate.
3011
+ * @param {number} [time] Optional time id.
2797
3012
  * @returns {number} The slice index.
2798
3013
  */
2799
- getSliceIndex(point: Point3D, time?: number): number;
3014
+ getSliceIndex(origin: Point3D, time?: number): number;
2800
3015
  /**
2801
3016
  * Check if another geometry is compatible with this one, ie that
2802
3017
  * slices with these geometries can be merged into one volume.
@@ -2805,12 +3020,12 @@ export declare class Geometry {
2805
3020
  * @returns {BooleanResult} Result with success set to true if
2806
3021
  * the geometry is compatible.
2807
3022
  */
2808
- canAppend(rhs: Geometry): BooleanResult;
3023
+ canAppendSlice(rhs: Geometry): BooleanResult;
2809
3024
  /**
2810
3025
  * Check if an origin can be appended to this geometry.
2811
3026
  *
2812
3027
  * @param {Point3D} origin The origin to append.
2813
- * @param {number} [time] Optional time index.
3028
+ * @param {number} [time] Optional time id.
2814
3029
  * @returns {BooleanResult} Result with success set to true if
2815
3030
  * the origin is compatible.
2816
3031
  */
@@ -2820,16 +3035,17 @@ export declare class Geometry {
2820
3035
  *
2821
3036
  * @param {Point3D} origin The origin to append.
2822
3037
  * @param {number} index The index at which to append.
2823
- * @param {number} [time] Optional time index.
3038
+ * @param {number} [time] Optional time id.
2824
3039
  */
2825
3040
  appendOrigin(origin: Point3D, index: number, time?: number): void;
2826
3041
  /**
2827
3042
  * Append a frame to the geometry.
2828
3043
  *
2829
3044
  * @param {Point3D} origin The origin to append.
2830
- * @param {number} time Optional time index.
3045
+ * @param {VolumeId} time The frame time: a volume id or, without
3046
+ * source, a frame index.
2831
3047
  */
2832
- appendFrame(origin: Point3D, time: number): void;
3048
+ appendFrame(origin: Point3D, time: VolumeId): void;
2833
3049
  /**
2834
3050
  * Get a string representation of the geometry.
2835
3051
  *
@@ -2892,6 +3108,18 @@ export declare class Geometry {
2892
3108
  /**
2893
3109
  * Convert world coordinates into an index.
2894
3110
  *
3111
+ * Always returns an index, even for a point outside the geometry:
3112
+ * this does not itself mean the point is in bounds, use
3113
+ * isIndexInBounds/isInBounds for that. In-plane (row/column), an
3114
+ * out-of-bounds point extrapolates freely (eg -5 or size+12). On the
3115
+ * scroll axis, a point close to a real per-slice origin snaps to it;
3116
+ * further away, it is pinned to just past the first/last known
3117
+ * origin (ie the origins array length, or -1) rather than left to
3118
+ * drift arbitrarily far via linear extrapolation - except when there
3119
+ * are few or no real origins to compare against (eg a root geometry
3120
+ * with only its first slice known), where it still falls back to
3121
+ * that unclamped extrapolation.
3122
+ *
2895
3123
  * @param {Point} point The point to convert.
2896
3124
  * @returns {Index} The corresponding index.
2897
3125
  */
@@ -2907,38 +3135,58 @@ export declare class Geometry {
2907
3135
  }
2908
3136
 
2909
3137
  /**
2910
- * Get the meta data as simple elements:
3138
+ * Get the meta data as simple tag values:
2911
3139
  * - indexed by tag names instead of tag keys,
2912
3140
  * - no element object, just value if not sequence nor merged item.
2913
3141
  *
2914
- * @param {Record<string, DataElement>} metaData The meta data
3142
+ * @param {Record<string, DataElement>} dataElements The data elements
2915
3143
  * index by tag keys.
2916
- * @returns {Record<string, any>} The simple elements.
3144
+ * @returns {SimpleTagValues} The simple tag values.
2917
3145
  */
2918
- export declare function getAsSimpleElements(metaData: Record<string, DataElement>): Record<string, any>;
3146
+ export declare function getAsSimpleTagValues(dataElements: Record<string, DataElement>): SimpleTagValues;
2919
3147
 
2920
3148
  /**
2921
3149
  * Get the default DICOM RT Structure Set tags as an object.
2922
3150
  *
2923
- * @returns {object} The default tags.
3151
+ * @returns {SimpleTagValues} The default tags.
2924
3152
  */
2925
- export declare function getDefaultDicomRTStructJson(): object;
3153
+ export declare function getDefaultDicomRTStructJson(): SimpleTagValues;
2926
3154
 
2927
3155
  /**
2928
3156
  * Get the default DICOM seg tags as an object.
2929
3157
  *
2930
- * @returns {object} The default tags.
3158
+ * @returns {SimpleTagValues} The default tags.
2931
3159
  */
2932
- export declare function getDefaultDicomSegJson(): object;
3160
+ export declare function getDefaultDicomSegJson(): SimpleTagValues;
2933
3161
 
2934
3162
  /**
2935
3163
  * Get a simple dicom element item from a content item object.
2936
3164
  *
2937
3165
  * @param {DicomSRContent} content The content item object.
2938
- * @returns {Record<string, any>} The item as a list of (key, value) pairs.
3166
+ * @returns {SimpleTagValues} The item as a list of (key, value) pairs.
3167
+ */
3168
+ export declare function getDicomSRContentItem(content: DicomSRContent): SimpleTagValues;
3169
+
3170
+ /**
3171
+ * Get the DICOM tag group name as defined in TagGroups.
3172
+ *
3173
+ * @param {Tag} tag The DICOM tag.
3174
+ * @returns {string|undefined} The group name.
2939
3175
  */
2940
- export declare function getDicomSRContentItem(content: DicomSRContent): Record<string, any>;
3176
+ export declare function getDicomTagGroupName(tag: Tag): string | undefined;
2941
3177
 
3178
+ /**
3179
+ * Get the DICOM tag info for a tag using the
3180
+ * local DICOM tag dictionary.
3181
+ *
3182
+ * @param {Tag} tag The DICOM tag.
3183
+ * @returns {TagInfo|undefined} The info.
3184
+ */
3185
+ export declare function getDicomTagInfo(tag: Tag): TagInfo | undefined;
3186
+
3187
+ /**
3188
+ * @import {IntTypedArray, TypedArray} from '../math/types.js';
3189
+ */
2942
3190
  /**
2943
3191
  * List of DICOM data elements indexed via a 8 character string formed from
2944
3192
  * the group and element numbers.
@@ -2958,11 +3206,11 @@ export declare function getDwvVersion(): string;
2958
3206
  * tag names instead of keys and direct values (no value property) for
2959
3207
  * simple tags. See synthetic test data (in tests/dicom) for examples.
2960
3208
  *
2961
- * @param {Record<string, any>} simpleTags The 'simple' DICOM
3209
+ * @param {SimpleTagValues} simpleTags The 'simple' DICOM
2962
3210
  * tags object.
2963
3211
  * @returns {Record<string, DataElement>} The DICOM elements.
2964
3212
  */
2965
- export declare function getElementsFromJSONTags(simpleTags: Record<string, any>): Record<string, DataElement>;
3213
+ export declare function getElementsFromSimpleTagValues(simpleTags: SimpleTagValues): Record<string, DataElement>;
2966
3214
 
2967
3215
  /**
2968
3216
  * Get the indices that form a ellpise.
@@ -3112,10 +3360,9 @@ export declare function getTouchPoints(event: TouchEvent): Point2D[];
3112
3360
  * @param {number} pixelRepresentation The pixel representation,
3113
3361
  * 0:unsigned;1:signed.
3114
3362
  * @param {number} size The size of the new array.
3115
- * @returns {Uint8Array|Int8Array|Uint16Array|Int16Array|Uint32Array|Int32Array}
3116
- * The good typed array.
3363
+ * @returns {IntTypedArray} The good typed array.
3117
3364
  */
3118
- export declare function getTypedArray(bitsAllocated: number, pixelRepresentation: number, size: number): Uint8Array | Int8Array | Uint16Array | Int16Array | Uint32Array | Int32Array;
3365
+ export declare function getTypedArray(bitsAllocated: number, pixelRepresentation: number, size: number): IntTypedArray;
3119
3366
 
3120
3367
  /**
3121
3368
  * Get a UID for a DICOM tag.
@@ -3123,7 +3370,7 @@ export declare function getTypedArray(bitsAllocated: number, pixelRepresentation
3123
3370
  * Note: Use {@link https://github.com/uuidjs/uuid}?
3124
3371
  *
3125
3372
  * Ref:
3126
- * - {@link http://dicom.nema.org/medical/dicom/2022a/output/chtml/part05/chapter_9.html},
3373
+ * - {@link http://dicom.nema.org/medical/dicom/2024a/output/chtml/part05/chapter_9.html},
3127
3374
  * - {@link http://dicomiseasy.blogspot.com/2011/12/chapter-4-dicom-objects-in-chapter-3.html},
3128
3375
  * - {@link https://stackoverflow.com/questions/46304306/how-to-generate-unique-dicom-uid}.
3129
3376
  *
@@ -3155,7 +3402,7 @@ export declare function handleURLsFromWeasisXMLManifest(uri: string, callback: F
3155
3402
  * Check that an input buffer includes the DICOM prefix 'DICM'
3156
3403
  * after the 128 bytes preamble.
3157
3404
  *
3158
- * Ref: [DICOM File Meta]{@link https://dicom.nema.org/medical/dicom/2022a/output/chtml/part10/chapter_7.html#sect_7.1}.
3405
+ * Ref: [DICOM File Meta]{@link https://dicom.nema.org/medical/dicom/2024a/output/chtml/part10/chapter_7.html#sect_7.1}.
3159
3406
  *
3160
3407
  * @param {ArrayBuffer} buffer The buffer to check.
3161
3408
  * @returns {boolean} True if the buffer includes the prefix.
@@ -3170,6 +3417,96 @@ export declare function hasDicomPrefix(buffer: ArrayBuffer): boolean;
3170
3417
  */
3171
3418
  export declare function hexToRgb(hexStr: string): RGB;
3172
3419
 
3420
+ /**
3421
+ * @import {NumberRange} from './number.js';
3422
+ */
3423
+ /**
3424
+ * Histogram entry.
3425
+ *
3426
+ * @typedef {object} HistogramEntry@typedef {object} HistogramEntry
3427
+ * @property {number} value The value.
3428
+ * @property {number} count The number of occurrences.
3429
+ */
3430
+ /**
3431
+ * Histogram of values: number of occurrences per distinct value.
3432
+ */
3433
+ export declare class Histogram {
3434
+ /**
3435
+ * Add occurrences of a value.
3436
+ *
3437
+ * @param {number} value The value.
3438
+ * @param {number} [count] The number of occurrences, defaults to 1.
3439
+ */
3440
+ add(value: number, count?: number): void;
3441
+ /**
3442
+ * Get the total number of counted values.
3443
+ *
3444
+ * @returns {number} The total count.
3445
+ */
3446
+ getTotal(): number;
3447
+ /**
3448
+ * Get the histogram entries sorted by ascending value.
3449
+ *
3450
+ * @returns {HistogramEntry[]} The entries.
3451
+ */
3452
+ getEntries(): HistogramEntry[];
3453
+ /**
3454
+ * Get the value range.
3455
+ *
3456
+ * @returns {NumberRange|undefined} The range, undefined if empty.
3457
+ */
3458
+ getRange(): NumberRange | undefined;
3459
+ /**
3460
+ * Get the number of values in [min, max).
3461
+ *
3462
+ * @param {number} [min] Inclusive lower bound, unbounded if undefined.
3463
+ * @param {number} [max] Exclusive upper bound, unbounded if undefined.
3464
+ * @returns {number} The count.
3465
+ */
3466
+ getCountInRange(min?: number, max?: number): number;
3467
+ /**
3468
+ * Get the percentage of counts that fall in each interval defined by
3469
+ * consecutive thresholds, relative to the total count in the intervals
3470
+ * (values outside all intervals are not taken into account).
3471
+ *
3472
+ * For thresholds `[1, 5, 10]`, the intervals are `[1, 5)` and `[5, 10)`.
3473
+ * An undefined first or last threshold makes the interval unbounded:
3474
+ * for `[undefined, 5, undefined]`, the intervals are `[min, 5)` and
3475
+ * `[5, max]`, where `min` / `max` are the histogram range.
3476
+ *
3477
+ * @param {Array<number|undefined>} thresholds Interval bounds in
3478
+ * ascending order, the first and last can be undefined.
3479
+ * @returns {number[]} The percentages in [0, 100], one per interval
3480
+ * (`thresholds.length - 1` entries), all 0 if no value falls
3481
+ * in the intervals.
3482
+ */
3483
+ getIntervalPercentages(thresholds: Array<number | undefined>): number[];
3484
+ /**
3485
+ * Get the statistics of the values: minimum, maximum, mean,
3486
+ * standard deviation, median, 25th and 75th percentiles.
3487
+ * Gives the same results as `getStats` (`math/stats.js`) on the full
3488
+ * list of values.
3489
+ *
3490
+ * @returns {Statistics|undefined} The statistics, undefined if empty.
3491
+ */
3492
+ getStats(): Statistics | undefined;
3493
+ #private;
3494
+ }
3495
+
3496
+ /**
3497
+ * Histogram entry.
3498
+ */
3499
+ declare type HistogramEntry = {
3500
+ /**
3501
+ * The value.
3502
+ */
3503
+ value: number;
3504
+ /**
3505
+ * The number of occurrences.
3506
+ */
3507
+ count: number;
3508
+ };
3509
+
3173
3510
  export declare namespace i18n {
3174
3511
  /**
3175
3512
  * Get the translated text.
@@ -3188,14 +3525,14 @@ export declare namespace i18n {
3188
3525
  * - planar configuration (default RGBRGB...).
3189
3526
  *
3190
3527
  * @example
3191
- * import {DicomParser, createImage} from '//esm.sh/dwv';
3528
+ * import {DicomParser, demoCreateImage} from '//esm.sh/dwv';
3192
3529
  * // XMLHttpRequest onload callback
3193
3530
  * const onload = function (event) {
3194
3531
  * // parse the dicom buffer
3195
3532
  * const dicomParser = new DicomParser();
3196
3533
  * dicomParser.parse(event.target.response);
3197
3534
  * // create the image object
3198
- * const image = createImage(dicomParser.getDicomElements());
3535
+ * const image = demoCreateImage(dicomParser.getDicomElements());
3199
3536
  * // result div
3200
3537
  * const div = document.getElementById('dwv');
3201
3538
  * // display the image size
@@ -3225,7 +3562,7 @@ declare class Image_2 extends EventTarget {
3225
3562
  * @param {TypedArray} buffer The image data as a one dimensional buffer.
3226
3563
  * @param {string[]} [imageUids] An array of Uids indexed to slice number.
3227
3564
  */
3228
- constructor(geometry: Geometry, buffer: Int8Array | Uint8Array | Int16Array | Uint16Array | Int32Array | Uint32Array, imageUids?: string[]);
3565
+ constructor(geometry: Geometry, buffer: TypedArray, imageUids?: string[]);
3229
3566
  /**
3230
3567
  * Set the image complete flag.
3231
3568
  *
@@ -3239,26 +3576,19 @@ declare class Image_2 extends EventTarget {
3239
3576
  */
3240
3577
  getComplete(): boolean;
3241
3578
  /**
3242
- * Set up a segment collection from the existing image buffer.
3243
- * Used for brush-painted masks (not created via MaskFactory).
3244
- */
3245
- setupSegmentCollection(): void;
3246
- /**
3247
- * Set the segment collection.
3248
- *
3249
- * @param {SegmentCollection} collection The segment collection.
3250
- */
3251
- setSegmentCollection(collection: SegmentCollection): void;
3252
- /**
3253
- * Get the segment collection.
3579
+ * Get the initial index, used as default position by views:
3580
+ * the middle of the image (first frame for 4D).
3254
3581
  *
3255
- * @returns {SegmentCollection|undefined} The segment collection.
3582
+ * @returns {Index} The index.
3256
3583
  */
3257
- getSegmentCollection(): SegmentCollection | undefined;
3584
+ getInitialIndex(): Index;
3258
3585
  /**
3259
- * Check whether the mask has overlapping segments.
3586
+ * Check whether the image has overlapping segments. Always false for a
3587
+ * plain image; {@link MaskImage} overrides this with a real check.
3260
3588
  *
3261
- * @returns {boolean} True if any two segments share at least one voxel.
3589
+ * @returns {boolean} False.
3590
+ * @deprecated Since v0.37, please use `instanceof MaskImage` and
3591
+ * `MaskImage#getHasOverlap` instead.
3262
3592
  */
3263
3593
  getHasOverlap(): boolean;
3264
3594
  /**
@@ -3301,7 +3631,7 @@ declare class Image_2 extends EventTarget {
3301
3631
  * @todo Dangerous...
3302
3632
  * @returns {TypedArray} The data buffer of the image.
3303
3633
  */
3304
- getBuffer(): Int8Array | Uint8Array | Int16Array | Uint16Array | Int32Array | Uint32Array;
3634
+ getBuffer(): TypedArray;
3305
3635
  /**
3306
3636
  * Can the image values be quantified?
3307
3637
  *
@@ -3325,14 +3655,9 @@ declare class Image_2 extends EventTarget {
3325
3655
  * Check is the image is a mask.
3326
3656
  *
3327
3657
  * @returns {boolean} True if mask.
3658
+ * @deprecated Since v0.37, please use `instanceof MaskImage` instead.
3328
3659
  */
3329
3660
  isMask(): boolean;
3330
- /**
3331
- * Get the UID of the series referenced by the mask, if any.
3332
- *
3333
- * @returns {string|undefined} The UID.
3334
- */
3335
- getMaskReferencedSeriesUID(): string | undefined;
3336
3661
  /**
3337
3662
  * Can the data be scrolled?
3338
3663
  *
@@ -3444,14 +3769,6 @@ declare class Image_2 extends EventTarget {
3444
3769
  * @returns {number} The value at offset.
3445
3770
  */
3446
3771
  getValueAtOffset(offset: number): number;
3447
- /**
3448
- * Get the offsets where the buffer equals the input value.
3449
- * Loops through the whole volume, can get long for big data...
3450
- *
3451
- * @param {number|RGB} value The value to check.
3452
- * @returns {number[]} The list of offsets.
3453
- */
3454
- getOffsets(value: number | RGB): number[];
3455
3772
  /**
3456
3773
  * Check if the input values are in the buffer.
3457
3774
  * Could loop through the whole volume, can get long for big data...
@@ -3467,6 +3784,15 @@ declare class Image_2 extends EventTarget {
3467
3784
  * @returns {Image} A clone of this image.
3468
3785
  */
3469
3786
  clone(): Image_2;
3787
+ /**
3788
+ * Replace the inner buffer wholesale (as opposed to editing its content
3789
+ * in place). Primarily intended for subclass use, where a private
3790
+ * (`#`) field on this class isn't reachable directly.
3791
+ *
3792
+ * @param {TypedArray} newBuffer The new buffer.
3793
+ * @fires Image#imagecontentchange
3794
+ */
3795
+ replaceBuffer(newBuffer: TypedArray): void;
3470
3796
  /**
3471
3797
  * Check if another image can be appended to this one.
3472
3798
  *
@@ -3474,7 +3800,7 @@ declare class Image_2 extends EventTarget {
3474
3800
  * @returns {BooleanResult} Result with success set to true if
3475
3801
  * the image can be appended.
3476
3802
  */
3477
- canAppend(rhs: Image_2): BooleanResult;
3803
+ canAppendSlice(rhs: Image_2): BooleanResult;
3478
3804
  /**
3479
3805
  * Append a slice to the image.
3480
3806
  *
@@ -3492,10 +3818,11 @@ declare class Image_2 extends EventTarget {
3492
3818
  /**
3493
3819
  * Append a frame to the image.
3494
3820
  *
3495
- * @param {number} time The frame time value.
3821
+ * @param {VolumeId} time The frame time: a volume id or, without
3822
+ * source, a frame index.
3496
3823
  * @param {Point3D} origin The origin of the frame.
3497
3824
  */
3498
- appendFrame(time: number, origin: Point3D): void;
3825
+ appendFrame(time: VolumeId, origin: Point3D): void;
3499
3826
  /**
3500
3827
  * Get the data range.
3501
3828
  *
@@ -3511,37 +3838,9 @@ declare class Image_2 extends EventTarget {
3511
3838
  /**
3512
3839
  * Get the histogram.
3513
3840
  *
3514
- * @returns {Array} The histogram.
3841
+ * @returns {ImageHistogram} The histogram.
3515
3842
  */
3516
- getHistogram(): any[];
3517
- /**
3518
- * Set the inner buffer values at given offsets.
3519
- *
3520
- * @param {number[]} offsets List of offsets where to set the data.
3521
- * @param {number|RGB} value The value to set at the given offsets.
3522
- * @fires Image#imagecontentchange
3523
- */
3524
- setAtOffsets(offsets: number[], value: number | RGB): void;
3525
- /**
3526
- * Set the inner buffer values at given offsets.
3527
- *
3528
- * @param {number[][]} offsetsLists List of offset lists where
3529
- * to set the data.
3530
- * @param {number} value The value to set at the given offsets.
3531
- * @returns {Array} A list of objects representing the original values before
3532
- * replacing them.
3533
- * @fires Image#imagecontentchange
3534
- */
3535
- setAtOffsetsAndGetOriginals(offsetsLists: number[][], value: number): any[];
3536
- /**
3537
- * Set the inner buffer values at given offsets.
3538
- *
3539
- * @param {number[][]} offsetsLists List of offset lists
3540
- * where to set the data.
3541
- * @param {number|Array} value The value to set at the given offsets.
3542
- * @fires Image#imagecontentchange
3543
- */
3544
- setAtOffsetsWithIterator(offsetsLists: number[][], value: number | any[]): void;
3843
+ getHistogram(): ImageHistogram;
3545
3844
  /**
3546
3845
  * Get the value of the image at a specific coordinate.
3547
3846
  *
@@ -3588,6 +3887,17 @@ declare class Image_2 extends EventTarget {
3588
3887
  * Warning: No size check...
3589
3888
  */
3590
3889
  getRescaledValueAtOffset(offset: number): number;
3890
+ /**
3891
+ * Get the rescaled values of all volumes (fourth dimension) at
3892
+ * a position.
3893
+ *
3894
+ * @param {Point} position The world position, only its first
3895
+ * three dimensions are used.
3896
+ * @returns {VolumeValue[]} The values with their unit and volume id,
3897
+ * ordered by volume index, empty if the position is out of bounds
3898
+ * or if the image cannot be quantified (more than one component).
3899
+ */
3900
+ getRescaledValuesAtPosition(position: Point): VolumeValue[];
3591
3901
  /**
3592
3902
  * Calculate the data range of the image.
3593
3903
  * WARNING: for speed reasons, only calculated on the first frame...
@@ -3602,12 +3912,6 @@ declare class Image_2 extends EventTarget {
3602
3912
  * @returns {object} The range {min, max}.
3603
3913
  */
3604
3914
  calculateRescaledDataRange(): object;
3605
- /**
3606
- * Calculate the histogram of the image.
3607
- *
3608
- * @returns {object} The histogram, data range and rescaled data range.
3609
- */
3610
- calculateHistogram(): object;
3611
3915
  /**
3612
3916
  * Convolute the image with a given 2D kernel.
3613
3917
  *
@@ -3626,7 +3930,7 @@ declare class Image_2 extends EventTarget {
3626
3930
  * @param {TypedArray} buffer The buffer to convolute.
3627
3931
  * @param {number} startOffset The index to start at.
3628
3932
  */
3629
- convoluteBuffer(weights: number[], buffer: Int8Array | Uint8Array | Int16Array | Uint16Array | Int32Array | Uint32Array, startOffset: number): void;
3933
+ convoluteBuffer(weights: number[], buffer: TypedArray, startOffset: number): void;
3630
3934
  /**
3631
3935
  * Transform an image using a specific operator.
3632
3936
  * WARNING: no size check!
@@ -3646,27 +3950,6 @@ declare class Image_2 extends EventTarget {
3646
3950
  * Note: Uses the raw buffer values.
3647
3951
  */
3648
3952
  compose(rhs: Image_2, operator: Function): Image_2;
3649
- /**
3650
- * Initialize the contour buffer.
3651
- * Should be called on every segmentation image, or any image where
3652
- * contour rendering needs to be supported.
3653
- */
3654
- initializeContour(): void;
3655
- /**
3656
- * Get the image contour. Should only be available
3657
- * for segmentation images, but can be initialized
3658
- * for any Uint8Array image.
3659
- *
3660
- * @returns {ImageContour} The image contour.
3661
- */
3662
- getContour(): ImageContour;
3663
- /**
3664
- * Recalculate labels.
3665
- *
3666
- * @fires Image#labelingstart
3667
- * @fires Image#labelschanged
3668
- */
3669
- recalculateLabels(): void;
3670
3953
  /**
3671
3954
  * Return if this image has been resampled.
3672
3955
  *
@@ -3748,6 +4031,90 @@ export declare class ImageContour {
3748
4031
  #private;
3749
4032
  }
3750
4033
 
4034
+ /**
4035
+ * @import {RescaleSlopeAndIntercept} from './rsi.js';
4036
+ * @import {NumberRange} from '../math/number.js';
4037
+ * @import {Statistics} from '../math/stats.js';
4038
+ */
4039
+ /**
4040
+ * Histogram of image values.
4041
+ *
4042
+ * Raw (stored) values are counted in one {@link Histogram} per rescale
4043
+ * slope and intercept (RSI). Values are rescaled when read. An image
4044
+ * with a constant RSI only has one histogram.
4045
+ */
4046
+ export declare class ImageHistogram {
4047
+ /**
4048
+ * @param {string} [unit] The unit of the rescaled values.
4049
+ */
4050
+ constructor(unit?: string);
4051
+ /**
4052
+ * Get the unit of the rescaled values.
4053
+ *
4054
+ * @returns {string|undefined} The unit, undefined if not known.
4055
+ */
4056
+ getUnit(): string | undefined;
4057
+ /**
4058
+ * Get the raw value histogram for an RSI, creating it if needed.
4059
+ *
4060
+ * @param {RescaleSlopeAndIntercept} rsi The RSI of the raw values.
4061
+ * @returns {Histogram} The raw value histogram.
4062
+ */
4063
+ getHistogram(rsi: RescaleSlopeAndIntercept): Histogram;
4064
+ /**
4065
+ * Add one raw value.
4066
+ *
4067
+ * @param {number} rawValue The raw value.
4068
+ * @param {RescaleSlopeAndIntercept} rsi The RSI of the raw value.
4069
+ */
4070
+ add(rawValue: number, rsi: RescaleSlopeAndIntercept): void;
4071
+ /**
4072
+ * Get the total number of counted values.
4073
+ *
4074
+ * @returns {number} The total count.
4075
+ */
4076
+ getTotal(): number;
4077
+ /**
4078
+ * Get the value range (raw values).
4079
+ *
4080
+ * @returns {NumberRange|undefined} The range, undefined if empty.
4081
+ */
4082
+ getRange(): NumberRange | undefined;
4083
+ /**
4084
+ * Get the histogram of the rescaled values: raw values of each RSI
4085
+ * are rescaled and equal rescaled values merged.
4086
+ *
4087
+ * @returns {Histogram} The rescaled value histogram.
4088
+ */
4089
+ getRescaledHistogram(): Histogram;
4090
+ /**
4091
+ * Get the rescaled value range.
4092
+ *
4093
+ * @returns {NumberRange|undefined} The range, undefined if empty.
4094
+ */
4095
+ getRescaledRange(): NumberRange | undefined;
4096
+ /**
4097
+ * Get the percentage of counts that fall in each interval defined by
4098
+ * consecutive rescaled thresholds,
4099
+ * see {@link Histogram#getIntervalPercentages}.
4100
+ *
4101
+ * @param {Array<number|undefined>} thresholds Rescaled interval bounds
4102
+ * in ascending order, the first and last can be undefined.
4103
+ * @returns {number[]} The percentages in [0, 100], one per interval
4104
+ * (`thresholds.length - 1` entries), all 0 if no value falls
4105
+ * in the intervals.
4106
+ */
4107
+ getIntervalPercentages(thresholds: Array<number | undefined>): number[];
4108
+ /**
4109
+ * Get the statistics of the rescaled values,
4110
+ * see {@link Histogram#getStats}.
4111
+ *
4112
+ * @returns {Statistics|undefined} The statistics, undefined if empty.
4113
+ */
4114
+ getStats(): Statistics | undefined;
4115
+ #private;
4116
+ }
4117
+
3751
4118
  /**
3752
4119
  * Immutable index.
3753
4120
  * Warning: the input array is NOT cloned, modifying it will
@@ -3864,8 +4231,16 @@ export declare class InfoData extends EventTarget {
3864
4231
  * Handle a changed slice event.
3865
4232
  *
3866
4233
  * @param {CustomEvent} event The slicechange event.
4234
+ * @deprecated Since v0.37, please use onPositionChange.
3867
4235
  */
3868
4236
  onSliceChange: (event: CustomEvent) => void;
4237
+ /**
4238
+ * Handle a changed position event: updates the tags on slice change
4239
+ * and the position event items.
4240
+ *
4241
+ * @param {CustomEvent} event The positionchange event.
4242
+ */
4243
+ onPositionChange: (event: CustomEvent) => void;
3869
4244
  /**
3870
4245
  * Is this class listening to app events.
3871
4246
  *
@@ -3919,6 +4294,11 @@ export declare class InfoDataItem {
3919
4294
  value: string;
3920
4295
  }
3921
4296
 
4297
+ /**
4298
+ * List of compatible integer typed arrays.
4299
+ */
4300
+ export declare type IntTypedArray = (Uint8Array | Int8Array | Uint16Array | Int16Array | Uint32Array | Int32Array);
4301
+
3922
4302
  /**
3923
4303
  * Check if two rgb objects are equal.
3924
4304
  *
@@ -3980,8 +4360,34 @@ export declare class Label {
3980
4360
  * @type {number}
3981
4361
  */
3982
4362
  largestSliceZ: number;
4363
+ /**
4364
+ * The minimum Z index of the segment.
4365
+ *
4366
+ * @type {number}
4367
+ */
4368
+ minZ: number;
4369
+ /**
4370
+ * The maximum Z index of the segment.
4371
+ *
4372
+ * @type {number}
4373
+ */
4374
+ maxZ: number;
3983
4375
  }
3984
4376
 
4377
+ /**
4378
+ * Histogram of the segment voxels of a label.
4379
+ */
4380
+ export declare type LabelHistogram = {
4381
+ /**
4382
+ * The label.
4383
+ */
4384
+ label: Label;
4385
+ /**
4386
+ * The label histogram.
4387
+ */
4388
+ histogram: ImageHistogram;
4389
+ };
4390
+
3985
4391
  /**
3986
4392
  * CIE LAB value (L: [0, 100], a: [-128, 127], b: [-128, 127]) to
3987
4393
  * unsigned int CIE LAB ([0, 65535]).
@@ -4012,8 +4418,10 @@ export declare class LayerGroup extends EventTarget {
4012
4418
  * @param {HTMLElement} containerDiv The associated HTML div.
4013
4419
  * @param {boolean} [withInfoLayer] Optional with info layer flag,
4014
4420
  * default to false.
4421
+ * @param {CanvasSizeChecker} [canvasSizeChecker] Optional canvas size
4422
+ * checker, shared with the view layers; defaults to a new one.
4015
4423
  */
4016
- constructor(containerDiv: HTMLElement, withInfoLayer?: boolean);
4424
+ constructor(containerDiv: HTMLElement, withInfoLayer?: boolean, canvasSizeChecker?: CanvasSizeChecker);
4017
4425
  /**
4018
4426
  * Get the position helper.
4019
4427
  *
@@ -4429,68 +4837,214 @@ export declare namespace logger {
4429
4837
  *
4430
4838
  * @param {string} msg The message to log.
4431
4839
  */
4432
- export function warn(msg: string): void;
4840
+ export function warn(msg: string): void;
4841
+ /**
4842
+ * Log an error message.
4843
+ *
4844
+ * @param {string} msg The message to log.
4845
+ */
4846
+ export function error(msg: string): void;
4847
+ }
4848
+
4849
+ /**
4850
+ * List of available lookup tables (lut).
4851
+ *
4852
+ * @type {Record<string, ColourMap>}
4853
+ */
4854
+ export declare const luts: Record<string, ColourMap>;
4855
+
4856
+ /**
4857
+ * Mask {@link Image} factory.
4858
+ */
4859
+ export declare class MaskFactory {
4860
+ /**
4861
+ * Get a warning string if elements are not as expected.
4862
+ * Created by checkElements.
4863
+ *
4864
+ * @returns {string|undefined} The warning.
4865
+ */
4866
+ getWarning(): string | undefined;
4867
+ /**
4868
+ * Check dicom elements.
4869
+ *
4870
+ * @param {Record<string, DataElement>} _dicomElements The DICOM tags.
4871
+ * @returns {string|undefined} A possible warning.
4872
+ */
4873
+ checkElements(_dicomElements: Record<string, DataElement>): string | undefined;
4874
+ /**
4875
+ * Get a {@link MaskImage} object from the read DICOM file.
4876
+ *
4877
+ * @param {Record<string, DataElement>} dataElements The DICOM tags.
4878
+ * @param {Uint8Array} pixelBuffer The pixel buffer.
4879
+ * @param {Image} [refImage] Reference image, code will use its
4880
+ * origins if present (best) or try to calculate them.
4881
+ * @returns {MaskImage} A new mask image.
4882
+ * @throws {Error} Error for missing or wrong data.
4883
+ */
4884
+ create(dataElements: Record<string, DataElement>, pixelBuffer: Uint8Array, refImage?: Image_2): MaskImage;
4885
+ /**
4886
+ * Convert a mask image into a DICOM segmentation object.
4887
+ *
4888
+ * @param {MaskImage} image The mask image.
4889
+ * @param {MaskSegment[]} segments The mask segments.
4890
+ * @param {Image} sourceImage The source image.
4891
+ * @param {SimpleTagValues} [extraTags] Optional list of extra tags.
4892
+ * @returns {Record<string, DataElement>} A list of dicom elements.
4893
+ */
4894
+ toDicom(image: MaskImage, segments: MaskSegment[], sourceImage: Image_2, extraTags?: SimpleTagValues): Record<string, DataElement>;
4895
+ #private;
4896
+ }
4897
+
4898
+ /**
4899
+ * Mask (segmentation) image class.
4900
+ * Extends {@link Image} with a {@link SegmentCollection} and the
4901
+ * segment-aware behavior built on top of it: per-segment/per-slice
4902
+ * bookkeeping, the brush tool's offset-editing methods, and per-segment
4903
+ * labeling statistics (volume/centroid/diameter).
4904
+ */
4905
+ export declare class MaskImage extends Image_2 {
4906
+ /**
4907
+ * @param {Geometry} geometry The geometry of the image.
4908
+ * @param {Uint8Array} buffer The mask data as a one dimensional buffer:
4909
+ * one byte per voxel, 0 for background, the segment number otherwise.
4910
+ * @param {string[]} [imageUids] An array of Uids indexed to slice number.
4911
+ * @param {SegmentCollection} [segmentCollection] The segment collection,
4912
+ * for a mask already parsed from DICOM (its own label map already
4913
+ * aliases `buffer`). When omitted (brush-created masks), a fresh
4914
+ * collection is created and its label map is aliased to `buffer`.
4915
+ */
4916
+ constructor(geometry: Geometry, buffer: Uint8Array, imageUids?: string[], segmentCollection?: SegmentCollection);
4917
+ /**
4918
+ * Initialize the contour buffer.
4919
+ * Should be called on every segmentation image, or any image where
4920
+ * contour rendering needs to be supported.
4921
+ */
4922
+ initializeContour(): void;
4923
+ /**
4924
+ * Get the image contour. Should only be available
4925
+ * for segmentation images, but can be initialized
4926
+ * for any Uint8Array image.
4927
+ *
4928
+ * @returns {ImageContour} The image contour.
4929
+ */
4930
+ getContour(): ImageContour;
4931
+ /**
4932
+ * Get the segment collection.
4933
+ *
4934
+ * @returns {SegmentCollection} The segment collection.
4935
+ */
4936
+ getSegmentCollection(): SegmentCollection;
4937
+ /**
4938
+ * Get the UID of the series referenced by the mask, if any.
4939
+ *
4940
+ * @returns {string|undefined} The UID.
4941
+ */
4942
+ getMaskReferencedSeriesUID(): string | undefined;
4943
+ /**
4944
+ * Get the numbers of the segments present at an index.
4945
+ * When segments overlap, all the segments at the index are returned,
4946
+ * not only the one stored in the buffer (first wins).
4947
+ *
4948
+ * @param {Index} index The index, no bounds check.
4949
+ * @returns {number[]} The sorted list of segment numbers,
4950
+ * empty for background.
4951
+ */
4952
+ getSegmentNumbersAtIndex(index: Index): number[];
4953
+ /**
4954
+ * Get the offsets where the buffer equals the input value.
4955
+ * Loops through the whole volume, can get long for big data...
4956
+ *
4957
+ * @param {number|RGB} value The value to check.
4958
+ * @returns {number[]} The list of offsets.
4959
+ */
4960
+ getOffsets(value: number | RGB): number[];
4961
+ /**
4962
+ * Set the inner buffer values at given offsets.
4963
+ *
4964
+ * @param {number[]} offsets List of offsets where to set the data.
4965
+ * @param {number|RGB} value The value to set at the given offsets.
4966
+ * @fires Image#imagecontentchange
4967
+ */
4968
+ setAtOffsets(offsets: number[], value: number | RGB): void;
4969
+ /**
4970
+ * Set the inner buffer values at given offsets, each to its own value.
4971
+ * Used when a single uniform value cannot be used across all offsets,
4972
+ * for example restoring the segment still present at a voxel that used
4973
+ * to be hidden by an overlapping, now deleted, segment.
4974
+ *
4975
+ * @param {number[]} offsets List of offsets where to set the data.
4976
+ * @param {number[]} values Per-offset values, same length as offsets.
4977
+ * @fires Image#imagecontentchange
4978
+ */
4979
+ setAtOffsetsWithValues(offsets: number[], values: number[]): void;
4980
+ /**
4981
+ * Set the inner buffer values at given offsets.
4982
+ *
4983
+ * @param {number[][]} offsetsLists List of offset lists where
4984
+ * to set the data.
4985
+ * @param {number} value The value to set at the given offsets.
4986
+ * @returns {Array} A list of objects representing the original values before
4987
+ * replacing them.
4988
+ * @fires Image#imagecontentchange
4989
+ */
4990
+ setAtOffsetsAndGetOriginals(offsetsLists: number[][], value: number): any[];
4433
4991
  /**
4434
- * Log an error message.
4992
+ * Set the inner buffer values at given offsets.
4435
4993
  *
4436
- * @param {string} msg The message to log.
4994
+ * @param {number[][]} offsetsLists List of offset lists
4995
+ * where to set the data.
4996
+ * @param {number|Array} value The value to set at the given offsets.
4997
+ * @fires Image#imagecontentchange
4437
4998
  */
4438
- export function error(msg: string): void;
4439
- }
4440
-
4441
- /**
4442
- * List of available lookup tables (lut).
4443
- *
4444
- * @type {Record<string, ColourMap>}
4445
- */
4446
- export declare const luts: Record<string, ColourMap>;
4447
-
4448
- /**
4449
- * Mask {@link Image} factory.
4450
- */
4451
- export declare class MaskFactory {
4999
+ setAtOffsetsWithIterator(offsetsLists: number[][], value: number | any[]): void;
4452
5000
  /**
4453
- * Get a warning string if elements are not as expected.
4454
- * Created by checkElements.
5001
+ * Get the labels from the last labeling (see
5002
+ * {@link MaskImage#recalculateLabels}).
4455
5003
  *
4456
- * @returns {string|undefined} The warning.
5004
+ * @returns {Label[]|undefined} The labels, undefined if not calculated.
4457
5005
  */
4458
- getWarning(): string | undefined;
5006
+ getLabels(): Label[] | undefined;
4459
5007
  /**
4460
- * Check dicom elements.
5008
+ * Recalculate labels.
4461
5009
  *
4462
- * @param {Record<string, DataElement>} _dicomElements The DICOM tags.
4463
- * @returns {string|undefined} A possible warning.
5010
+ * @fires Image#labelingstart
5011
+ * @fires Image#labelschanged
4464
5012
  */
4465
- checkElements(_dicomElements: Record<string, DataElement>): string | undefined;
5013
+ recalculateLabels(): void;
4466
5014
  /**
4467
- * Get an {@link Image} object from the read DICOM file.
5015
+ * Clone the mask image.
4468
5016
  *
4469
- * @param {Record<string, DataElement>} dataElements The DICOM tags.
4470
- * @param {Uint8Array} pixelBuffer The pixel buffer.
4471
- * @param {Image} [refImage] Reference image, code will use its
4472
- * origins if present (best) or try to calculate them.
4473
- * @returns {Image} A new Image.
4474
- * @throws {Error} Error for missing or wrong data.
5017
+ * @returns {MaskImage} A clone of this mask image.
4475
5018
  */
4476
- create(dataElements: Record<string, DataElement>, pixelBuffer: Uint8Array, refImage?: Image_2): Image_2;
5019
+ clone(): MaskImage;
4477
5020
  /**
4478
- * Convert a mask image into a DICOM segmentation object.
5021
+ * Get per-volume histograms of reference-image intensities for one segment.
4479
5022
  *
4480
- * @param {Image} image The mask image.
4481
- * @param {MaskSegment[]} segments The mask segments.
4482
- * @param {Image} sourceImage The source image.
4483
- * @param {Record<string, any>} [extraTags] Optional list of extra tags.
4484
- * @returns {Record<string, DataElement>} A list of dicom elements.
5023
+ * For each volume of `image`, counts how often each intensity
5024
+ * appears in voxels belonging to the given segment of this mask.
5025
+ * Segmentations are 3D: the same mask is applied to every volume.
5026
+ * Raw values are counted per rescale slope and intercept and rescaled
5027
+ * when read from the {@link ImageHistogram}.
5028
+ *
5029
+ * If labels are available (see {@link MaskImage#getLabels}), each entry
5030
+ * also has `labelHistograms`: one histogram per label of the segment, made of
5031
+ * the segment voxels between the label min and max Z. Since labels
5032
+ * of the same segment that share slices cannot be separated this way,
5033
+ * `labelHistograms` is not provided in that case.
5034
+ *
5035
+ * @param {Image} image The reference image (intensities).
5036
+ * @param {string} segmentId Segment tracking UID, or segment number as
5037
+ * string.
5038
+ * @returns {SegmentHistogram[]} One entry per volume.
4485
5039
  */
4486
- toDicom(image: Image_2, segments: MaskSegment[], sourceImage: Image_2, extraTags?: Record<string, any>): Record<string, DataElement>;
5040
+ getHistogramBySegment(image: Image_2, segmentId: string): SegmentHistogram[];
4487
5041
  #private;
4488
5042
  }
4489
5043
 
4490
5044
  /**
4491
5045
  * DICOM (mask) segment: item of a SegmentSequence (0062,0002).
4492
5046
  *
4493
- * Ref: {@link https://dicom.nema.org/medical/dicom/2022a/output/chtml/part03/sect_C.8.20.4.html}.
5047
+ * Ref: {@link https://dicom.nema.org/medical/dicom/2024a/output/chtml/part03/sect_C.8.20.4.html}.
4494
5048
  */
4495
5049
  export declare class MaskSegment {
4496
5050
  /**
@@ -4576,7 +5130,7 @@ export declare class MaskSegment {
4576
5130
  }
4577
5131
 
4578
5132
  /**
4579
- * @import {Image} from './image.js';
5133
+ * @import {MaskImage} from './maskImage.js';
4580
5134
  * @import {MaskSegment} from '../dicom/dicomSegment.js';
4581
5135
  */
4582
5136
  /**
@@ -4586,15 +5140,15 @@ export declare class MaskSegment {
4586
5140
  */
4587
5141
  export declare class MaskSegmentHelper {
4588
5142
  /**
4589
- * @param {Image} mask The associated mask image.
5143
+ * @param {MaskImage} mask The associated mask image.
4590
5144
  */
4591
- constructor(mask: Image_2);
5145
+ constructor(mask: MaskImage);
4592
5146
  /**
4593
5147
  * Get the associated mask image.
4594
5148
  *
4595
- * @returns {Image} The mask image.
5149
+ * @returns {MaskImage} The mask image.
4596
5150
  */
4597
- getMask(): Image_2;
5151
+ getMask(): MaskImage;
4598
5152
  /**
4599
5153
  * Check if a segment is part of the segments list.
4600
5154
  *
@@ -4736,6 +5290,9 @@ export declare class MaskSegmentViewHelper {
4736
5290
  #private;
4737
5291
  }
4738
5292
 
5293
+ /**
5294
+ * @import {TypedArray} from './types.js';
5295
+ */
4739
5296
  /**
4740
5297
  * Immutable 3x3 Matrix.
4741
5298
  */
@@ -4775,15 +5332,6 @@ export declare class Matrix33 {
4775
5332
  * @returns {boolean} True if both matrices are similar.
4776
5333
  */
4777
5334
  isSimilar(rhs: Matrix33, tol?: number): boolean;
4778
- /**
4779
- * Check for Matrix33 similarity with progressive tolerance (up to 10*tol).
4780
- *
4781
- * @param {Matrix33} rhs The other matrix to compare to.
4782
- * @param {number} [tol] Optional number comparison tolerance,
4783
- * defaults to Number.EPSILON.
4784
- * @returns {boolean} True if both matrices are similar.
4785
- */
4786
- isSimilarProgressive(rhs: Matrix33, tol?: number): boolean;
4787
5335
  /**
4788
5336
  * Get a string representation of the Matrix33.
4789
5337
  *
@@ -4813,16 +5361,10 @@ export declare class Matrix33 {
4813
5361
  /**
4814
5362
  * Multiply this matrix by a 3D typed array.
4815
5363
  *
4816
- * @typedef {(
4817
- * Uint8Array | Int8Array |
4818
- * Uint16Array | Int16Array |
4819
- * Uint32Array | Int32Array
4820
- * )} TypedArray
4821
- *
4822
5364
  * @param {TypedArray} sourceArray The input 3D array.
4823
5365
  * @param {TypedArray} outArray The array to write to.
4824
5366
  */
4825
- multiplyTypedArray3D(sourceArray: Int8Array | Uint8Array | Int16Array | Uint16Array | Int32Array | Uint32Array, outArray: Int8Array | Uint8Array | Int16Array | Uint16Array | Int32Array | Uint32Array): void;
5367
+ multiplyTypedArray3D(sourceArray: TypedArray, outArray: TypedArray): void;
4826
5368
  /**
4827
5369
  * Multiply this matrix by a 3D vector.
4828
5370
  *
@@ -4884,23 +5426,34 @@ export declare class Matrix33 {
4884
5426
  *
4885
5427
  * Segments from mask2 that share a segment number with mask1 are renumbered
4886
5428
  * (bumped to the next available number) to avoid conflicts. Both masks must
4887
- * reference the same geometry (same spatial volume).
5429
+ * share the same spacing and orientation; the wider of the two geometries
5430
+ * (the one with more slices) is used as the merged geometry, so a mask
5431
+ * that only covers a sub-range of the other's slices does not get clipped.
4888
5432
  * Brush-painted masks (no per-segment SegmentCollection data) are supported.
4889
5433
  *
4890
5434
  * The returned image can be saved with the standard
4891
5435
  * `new MaskFactory().toDicom(merged, undefined, sourceImage)` workflow.
4892
5436
  *
4893
- * @param {Image} mask1 The first mask (provides base geometry and meta).
4894
- * @param {Image} mask2 The second mask to merge into mask1.
4895
- * @returns {Image} The new merged mask image.
5437
+ * @param {MaskImage} mask1 The first mask (provides meta).
5438
+ * @param {MaskImage} mask2 The second mask to merge into mask1.
5439
+ * @returns {MaskImage} The new merged mask image.
5440
+ */
5441
+ export declare function mergeMaskImages(mask1: MaskImage, mask2: MaskImage): MaskImage;
5442
+
5443
+ /**
5444
+ * Merge a simple tag value list into another. Mutates the
5445
+ * first input.
5446
+ *
5447
+ * @param {SimpleTagValues} list1 Base list, will be modified.
5448
+ * @param {SimpleTagValues} list2 List to merge into list1.
4896
5449
  */
4897
- export declare function mergeMaskImages(mask1: Image_2, mask2: Image_2): Image_2;
5450
+ export declare function mergeTagValues(list1: SimpleTagValues, list2: SimpleTagValues): void;
4898
5451
 
4899
5452
  export declare namespace NormalisedManufacturers {
4900
5453
  let GE: string;
4901
5454
  let SIEMENS: string;
4902
5455
  let PHILIPS: string;
4903
- let HITASHI: string;
5456
+ let HITACHI: string;
4904
5457
  }
4905
5458
 
4906
5459
  /**
@@ -4923,18 +5476,20 @@ export declare class NumberRange {
4923
5476
  }
4924
5477
 
4925
5478
  /**
4926
- * Class to store a number value and a unit.
5479
+ * Number value and its unit.
4927
5480
  */
4928
- export declare class NumberValue {
5481
+ export declare type NumberValue = {
4929
5482
  /**
4930
- * @type {number}
5483
+ * The value.
4931
5484
  */
4932
5485
  value: number;
4933
5486
  /**
4934
- * @type {string|undefined}
5487
+ * The value unit, passed to `i18n.t` for
5488
+ * display: an i18n key (for example 'unit.mm') or a plain unit
5489
+ * (for example 'HU').
4935
5490
  */
4936
- unit: string | undefined;
4937
- }
5491
+ unit?: string;
5492
+ };
4938
5493
 
4939
5494
  export declare namespace Orientation {
4940
5495
  let Axial: string;
@@ -5055,6 +5610,13 @@ export declare class PlaneHelper {
5055
5610
  * @returns {number[]} The 2 cosines vectors (3D).
5056
5611
  */
5057
5612
  getCosines(): number[];
5613
+ /**
5614
+ * Get the cosines of this plane as saved in annotations by
5615
+ * previous versions, see getLegacyTargetOrientation.
5616
+ *
5617
+ * @returns {number[]} The 2 cosines vectors (3D).
5618
+ */
5619
+ getLegacyCosines(): number[];
5058
5620
  /**
5059
5621
  * Get a list of points that define the plane at input position,
5060
5622
  * given this classes orientation.
@@ -5217,6 +5779,14 @@ export declare class Point2D {
5217
5779
  * @returns {Point2D} The centroid point.
5218
5780
  */
5219
5781
  getCentroid(): Point2D;
5782
+ /**
5783
+ * Check if a point is at this point, within a tolerance.
5784
+ *
5785
+ * @param {Point2D} point The point to check.
5786
+ * @param {number} [tolerance] Optional maximum distance, defaults to 0.
5787
+ * @returns {boolean} True if the point is within tolerance.
5788
+ */
5789
+ contains(point: Point2D, tolerance?: number): boolean;
5220
5790
  /**
5221
5791
  * Check for Point2D equality.
5222
5792
  *
@@ -5490,9 +6060,28 @@ export declare class PositionHelper {
5490
6060
  */
5491
6061
  export declare function precisionRound(number: number, precision: number): number;
5492
6062
 
6063
+ /**
6064
+ * Private diffusion b-value tag rule: either `{manufacturer, key}`
6065
+ * or `{uidPrefix, key}`.
6066
+ */
6067
+ export declare type PrivateBValueRule = {
6068
+ /**
6069
+ * The normalised manufacturer.
6070
+ */
6071
+ manufacturer?: string;
6072
+ /**
6073
+ * The SOP instance UID prefix.
6074
+ */
6075
+ uidPrefix?: string;
6076
+ /**
6077
+ * The private tag key.
6078
+ */
6079
+ key: string;
6080
+ };
6081
+
5493
6082
  /**
5494
6083
  * @import {Point2D} from '../math/point.js';
5495
- * @import {NumberValue} from './number.js';
6084
+ * @import {NumberValue} from './types.js';
5496
6085
  * @import {ViewController} from '../app/viewController.js';
5497
6086
  */
5498
6087
  /**
@@ -5524,6 +6113,15 @@ export declare class Protractor {
5524
6113
  * @returns {Point2D} THe centroid point.
5525
6114
  */
5526
6115
  getCentroid(): Point2D;
6116
+ /**
6117
+ * Check if a point is on one of the protractor lines, within a tolerance.
6118
+ *
6119
+ * @param {Point2D} point The point to check.
6120
+ * @param {number} [tolerance] Optional maximum distance to the lines,
6121
+ * defaults to 0.
6122
+ * @returns {boolean} True if the point is on the protractor.
6123
+ */
6124
+ contains(point: Point2D, tolerance?: number): boolean;
5527
6125
  /**
5528
6126
  * Quantify a path according to view information.
5529
6127
  *
@@ -5615,6 +6213,16 @@ export declare class Rectangle {
5615
6213
  * @returns {Point2D} The centroid point.
5616
6214
  */
5617
6215
  getCentroid(): Point2D;
6216
+ /**
6217
+ * Check if a point is inside the rectangle, or within a tolerance
6218
+ * of its outline.
6219
+ *
6220
+ * @param {Point2D} point The point to check.
6221
+ * @param {number} [tolerance] Optional maximum distance to the outline
6222
+ * for an outside point, defaults to 0.
6223
+ * @returns {boolean} True if the point is in the rectangle.
6224
+ */
6225
+ contains(point: Point2D, tolerance?: number): boolean;
5618
6226
  /**
5619
6227
  * Quantify a rectangle according to view information.
5620
6228
  *
@@ -5780,6 +6388,16 @@ export declare class ROI {
5780
6388
  * @returns {Point2D|undefined} The centroid point.
5781
6389
  */
5782
6390
  getCentroid(): Point2D | undefined;
6391
+ /**
6392
+ * Check if a point is inside the roi (seen as a closed polygon),
6393
+ * or within a tolerance of its outline.
6394
+ *
6395
+ * @param {Point2D} point The point to check.
6396
+ * @param {number} [tolerance] Optional maximum distance to the outline
6397
+ * for an outside point, defaults to 0.
6398
+ * @returns {boolean} True if the point is in the roi.
6399
+ */
6400
+ contains(point: Point2D, tolerance?: number): boolean;
5783
6401
  #private;
5784
6402
  }
5785
6403
 
@@ -5876,7 +6494,7 @@ export declare class RtStructFactory {
5876
6494
  */
5877
6495
  checkElements(_dataElements: Record<string, DataElement>): string | undefined;
5878
6496
  /**
5879
- * Get a mask {@link Image} from RTSTRUCT DICOM elements.
6497
+ * Get a {@link MaskImage} from RTSTRUCT DICOM elements.
5880
6498
  *
5881
6499
  * Contours are rasterized into a Uint8Array whose voxel values are
5882
6500
  * segment numbers (0 = background, 1..N = ROI index).
@@ -5885,25 +6503,25 @@ export declare class RtStructFactory {
5885
6503
  *
5886
6504
  * @param {Record<string, DataElement>} dataElements The DICOM data elements.
5887
6505
  * @param {Image} refImage The reference image (CT/MR) that was loaded first.
5888
- * @returns {Image} The mask image.
6506
+ * @returns {MaskImage} The mask image.
5889
6507
  * @throws {Error} If the reference image geometry cannot be used.
5890
6508
  */
5891
- create(dataElements: Record<string, DataElement>, refImage: Image_2): Image_2;
6509
+ create(dataElements: Record<string, DataElement>, refImage: Image_2): MaskImage;
5892
6510
  /**
5893
- * Convert a mask {@link Image} into DICOM RT Structure Set elements.
6511
+ * Convert a {@link MaskImage} into DICOM RT Structure Set elements.
5894
6512
  *
5895
6513
  * Traces each segment's pixel regions per slice using Moore neighborhood
5896
6514
  * contour tracing, simplifies with Ramer-Douglas-Peucker, then maps the
5897
6515
  * 2D pixel coordinates back to 3D patient-space coordinates.
5898
6516
  *
5899
- * @param {Image} image The mask image.
6517
+ * @param {MaskImage} image The mask image.
5900
6518
  * @param {MaskSegment[]} [segments] The mask segments; if omitted, taken
5901
6519
  * from image meta.
5902
6520
  * @param {Image} [sourceImage] Source image (provides StudyInstanceUID).
5903
- * @param {Record<string, any>} [extraTags] Optional extra tags to merge.
6521
+ * @param {SimpleTagValues} [extraTags] Optional extra tags to merge.
5904
6522
  * @returns {Record<string, DataElement>} The DICOM data elements.
5905
6523
  */
5906
- toDicom(image: Image_2, segments?: MaskSegment[], sourceImage?: Image_2, extraTags?: Record<string, any>): Record<string, DataElement>;
6524
+ toDicom(image: MaskImage, segments?: MaskSegment[], sourceImage?: Image_2, extraTags?: SimpleTagValues): Record<string, DataElement>;
5907
6525
  #private;
5908
6526
  }
5909
6527
 
@@ -6029,6 +6647,57 @@ export declare class SegmentCollection {
6029
6647
  * @returns {Uint8Array} The full-volume label map.
6030
6648
  */
6031
6649
  getLabelMap(): Uint8Array;
6650
+ /**
6651
+ * Update the per-segment, per-slice buffers after a direct edit to the
6652
+ * shared label map (for example brush painting on a mask loaded from
6653
+ * DICOM, where the label map and the per-segment buffers are otherwise
6654
+ * two separate structures). No-op when this collection has no
6655
+ * per-segment data (brush-created masks), since the label map is
6656
+ * already the source of truth in that case.
6657
+ *
6658
+ * @param {number} offset The offset in the label map that changed.
6659
+ * @param {number} previousValue The segment number previously at offset.
6660
+ * @param {number} newValue The segment number now at offset.
6661
+ */
6662
+ updateAtOffset(offset: number, previousValue: number, newValue: number): void;
6663
+ /**
6664
+ * Re-index the per-segment, per-slice buffers after a slice insertion
6665
+ * (from Image#appendSlice) that shifted existing slice
6666
+ * content to make room for new slices. Unlike the shared label map
6667
+ * (which aliases the image buffer, so the raw byte-level shift already
6668
+ * covers it for free), `#segments` is keyed by slice index rather than
6669
+ * buffer offset, so an insertion before an existing slice leaves its
6670
+ * entries silently pointing at the wrong (pre-shift) slice index unless
6671
+ * they are explicitly re-keyed here.
6672
+ *
6673
+ * @param {number} sliceIndexThreshold Slices at or after this index
6674
+ * (numbering as it was *before* the insertion) are shifted.
6675
+ * @param {number} numberOfSlices Number of slices inserted.
6676
+ */
6677
+ shiftSlices(sliceIndexThreshold: number, numberOfSlices: number): void;
6678
+ /**
6679
+ * Get the value that a different, non-excluded segment holds at a given
6680
+ * label map offset. Used when deleting a segment to restore a voxel that
6681
+ * also belonged to another (overlapping) segment instead of losing that
6682
+ * other segment's presence there. Segments are checked in insertion
6683
+ * order, consistent with the first-wins policy used by {@link
6684
+ * SegmentCollection#getLabelMap}.
6685
+ *
6686
+ * @param {number} offset The offset in the label map.
6687
+ * @param {number} excludeSegmentNumber The segment number to ignore.
6688
+ * @returns {number} The other segment's stored value at that offset,
6689
+ * or 0 if no other segment covers it.
6690
+ */
6691
+ getOtherValueAtOffset(offset: number, excludeSegmentNumber: number): number;
6692
+ /**
6693
+ * Create a deep copy of this collection: per-segment/per-slice buffers
6694
+ * and the overlap flag are copied, the lazily-built label map and union
6695
+ * contour caches are left unset (they rebuild on demand from the copied
6696
+ * per-segment data, same as a freshly constructed collection).
6697
+ *
6698
+ * @returns {SegmentCollection} The copy.
6699
+ */
6700
+ clone(): SegmentCollection;
6032
6701
  /**
6033
6702
  * Check whether any two segments share at least one voxel.
6034
6703
  *
@@ -6063,6 +6732,52 @@ export declare class SegmentCollection {
6063
6732
  #private;
6064
6733
  }
6065
6734
 
6735
+ /**
6736
+ * Histogram of the voxels of a segment for one volume.
6737
+ */
6738
+ export declare type SegmentHistogram = {
6739
+ /**
6740
+ * The volume index.
6741
+ */
6742
+ volume: number;
6743
+ /**
6744
+ * The segment histogram.
6745
+ */
6746
+ histogram: ImageHistogram;
6747
+ /**
6748
+ * One histogram per label
6749
+ * of the segment, if available.
6750
+ */
6751
+ labelHistograms?: LabelHistogram[];
6752
+ };
6753
+
6754
+ /**
6755
+ * A simple sequence (VR=SQ) tag value.
6756
+ */
6757
+ export declare type SimpleSequenceValue = {
6758
+ /**
6759
+ * The sequence items.
6760
+ */
6761
+ value: SimpleTagValues[];
6762
+ /**
6763
+ * Undefined length flag.
6764
+ */
6765
+ undefinedLength?: boolean;
6766
+ };
6767
+
6768
+ /**
6769
+ * A simple (non sequence) tag value: either a single primitive
6770
+ * or, for multi-valued VRs, an array of primitives.
6771
+ */
6772
+ export declare type SimpleTagValue = string | number | string[] | number[];
6773
+
6774
+ /**
6775
+ * The meta data as simple tag values: indexed by tag name instead of
6776
+ * tag key, with direct values (no element object) for non sequence,
6777
+ * non merged tags.
6778
+ */
6779
+ export declare type SimpleTagValues = Record<string, SimpleTagValue | SimpleSequenceValue>;
6780
+
6066
6781
  /**
6067
6782
  * Simplify a polygon using the Ramer-Douglas-Peucker algorithm.
6068
6783
  * Ref: {@link https://en.wikipedia.org/wiki/Ramer%E2%80%93Douglas%E2%80%93Peucker_algorithm}.
@@ -6210,6 +6925,31 @@ export declare class Size {
6210
6925
  #private;
6211
6926
  }
6212
6927
 
6928
+ /**
6929
+ * Number value and its unit, with its source, for example
6930
+ * `{value: 4.6, unit: 'unit.ms', source: 'EchoTime', tagKey: '00180081'}`.
6931
+ */
6932
+ export declare type SourcedNumberValue = {
6933
+ /**
6934
+ * The value.
6935
+ */
6936
+ value: number;
6937
+ /**
6938
+ * The value unit, see NumberValue.
6939
+ */
6940
+ unit?: string;
6941
+ /**
6942
+ * The name of the value source, for
6943
+ * example the volume id candidate that produced it.
6944
+ */
6945
+ source?: string;
6946
+ /**
6947
+ * The key of the DICOM tag the value is
6948
+ * read from.
6949
+ */
6950
+ tagKey?: string;
6951
+ };
6952
+
6213
6953
  /**
6214
6954
  * @import {Scalar2D} from '../math/scalar.js';
6215
6955
  */
@@ -6515,6 +7255,62 @@ export declare class StageController extends EventTarget {
6515
7255
  #private;
6516
7256
  }
6517
7257
 
7258
+ /**
7259
+ * Statistics storage class.
7260
+ * 'simple' statistics do not include median, p25 nor p75.
7261
+ */
7262
+ declare class Statistics {
7263
+ /**
7264
+ * @param {number} min The minimum.
7265
+ * @param {number} max The maximum.
7266
+ * @param {number} mean The mean.
7267
+ * @param {number} stdDev The standard deviation.
7268
+ */
7269
+ constructor(min: number, max: number, mean: number, stdDev: number);
7270
+ /**
7271
+ * Minimum.
7272
+ *
7273
+ * @type {number}
7274
+ */
7275
+ min: number;
7276
+ /**
7277
+ * Maximum.
7278
+ *
7279
+ * @type {number}
7280
+ */
7281
+ max: number;
7282
+ /**
7283
+ * Mean.
7284
+ *
7285
+ * @type {number}
7286
+ */
7287
+ mean: number;
7288
+ /**
7289
+ * Standard deviation (population: divided by the number of values).
7290
+ *
7291
+ * @type {number}
7292
+ */
7293
+ stdDev: number;
7294
+ /**
7295
+ * Median.
7296
+ *
7297
+ * @type {number|undefined}
7298
+ */
7299
+ median: number | undefined;
7300
+ /**
7301
+ * 25th percentile.
7302
+ *
7303
+ * @type {number|undefined}
7304
+ */
7305
+ p25: number | undefined;
7306
+ /**
7307
+ * 75th percentile.
7308
+ *
7309
+ * @type {number|undefined}
7310
+ */
7311
+ p75: number | undefined;
7312
+ }
7313
+
6518
7314
  /**
6519
7315
  * @import {DataElement} from '../dicom/dataElement.js';
6520
7316
  */
@@ -6540,7 +7336,7 @@ export declare class Tag {
6540
7336
  */
6541
7337
  getElement(): string;
6542
7338
  /**
6543
- * Get as string representation of the tag: 'key: name'.
7339
+ * Get as string representation of the tag: '(group,element)'.
6544
7340
  *
6545
7341
  * @returns {string} A string representing the tag.
6546
7342
  */
@@ -6558,12 +7354,6 @@ export declare class Tag {
6558
7354
  * @returns {string} The key as '########'.
6559
7355
  */
6560
7356
  getKey(): string;
6561
- /**
6562
- * Get the group name as defined in TagGroups.
6563
- *
6564
- * @returns {string} The name.
6565
- */
6566
- getGroupName(): string;
6567
7357
  /**
6568
7358
  * Does this tag have a VR.
6569
7359
  * Basically not the Item, ItemDelimitationItem nor
@@ -6575,46 +7365,56 @@ export declare class Tag {
6575
7365
  /**
6576
7366
  * Is the tag group a private tag group ?
6577
7367
  *
6578
- * See: {@link http://dicom.nema.org/medical/dicom/2022a/output/html/part05.html#sect_7.8}.
7368
+ * See: {@link http://dicom.nema.org/medical/dicom/2024a/output/html/part05.html#sect_7.8}.
6579
7369
  *
6580
7370
  * @returns {boolean} True if the tag group is private,
6581
7371
  * ie if its group is an odd number.
6582
7372
  */
6583
7373
  isPrivate(): boolean;
7374
+ #private;
7375
+ }
7376
+
7377
+ /**
7378
+ * DICOM tag info: vr, multiplicity, name.
7379
+ */
7380
+ export declare class TagInfo {
7381
+ /**
7382
+ * @param {string} vr The tag Value Representation (VR).
7383
+ * @param {number} multiplicity The tag multiplicity.
7384
+ * @param {string} name The tag name.
7385
+ */
7386
+ constructor(vr: string, multiplicity: number, name: string);
6584
7387
  /**
6585
- * Get the tag Value Representation (VR) from the dicom dictionary.
7388
+ * Get the tag Value Representation (VR).
6586
7389
  *
6587
- * @returns {string|undefined} The VR.
7390
+ * @returns {string} The tag vr.
6588
7391
  */
6589
- getVrFromDictionary(): string | undefined;
7392
+ getVr(): string;
6590
7393
  /**
6591
- * Get the multiplicity from the dicom dictionary.
7394
+ * Get the tag multiplicity.
6592
7395
  *
6593
- * @returns {number|undefined} The multiplicity.
7396
+ * @returns {number} The multiplicity.
6594
7397
  */
6595
- getMultiplicityFromDictionary(): number | undefined;
7398
+ getMultiplicity(): number;
6596
7399
  /**
6597
- * Get the tag name from the dicom dictionary.
7400
+ * Get the tag name.
6598
7401
  *
6599
- * @returns {string|undefined} The VR.
7402
+ * @returns {string} The name.
6600
7403
  */
6601
- getNameFromDictionary(): string | undefined;
7404
+ getName(): string;
6602
7405
  #private;
6603
7406
  }
6604
7407
 
6605
- /**
6606
- * @import {LayerGroup} from '../gui/layerGroup.js';
6607
- * @import {ViewLayer} from '../gui/viewLayer.js';
6608
- * @import {DrawLayer} from '../gui/drawLayer.js';
6609
- */
6610
7408
  /**
6611
7409
  * Toolbox controller.
6612
7410
  */
6613
7411
  export declare class ToolboxController {
6614
7412
  /**
6615
7413
  * @param {object} toolList The list of tool objects.
7414
+ * @param {DocumentFragment} [rootDocument] Optional root document
7415
+ * to listen to for keyboard shortcuts, defaults to `document`.
6616
7416
  */
6617
- constructor(toolList: object);
7417
+ constructor(toolList: object, rootDocument?: DocumentFragment);
6618
7418
  /**
6619
7419
  * Initialise.
6620
7420
  */
@@ -6623,6 +7423,11 @@ export declare class ToolboxController {
6623
7423
  * Enable or disable shortcuts. The 'init' methods enables shortcuts
6624
7424
  * by default. Call this method after init to disable shortcuts.
6625
7425
  *
7426
+ * Shortcuts are keydown events listened to on the root document
7427
+ * in the bubbling phase and passed to the selected tool. Events
7428
+ * with a prevented default or coming from editable elements
7429
+ * (input, select, text area, content editable) are ignored.
7430
+ *
6626
7431
  * @param {boolean} flag True to enable shortcuts.
6627
7432
  */
6628
7433
  enableShortcuts(flag: boolean): void;
@@ -6650,9 +7455,10 @@ export declare class ToolboxController {
6650
7455
  *
6651
7456
  * @param {string} eventType The event type, for example
6652
7457
  * mousedown, touchstart...
6653
- * @returns {EventListener} The event handler.
7458
+ * @returns {EventListener|undefined} The event handler, undefined
7459
+ * if no tool is selected.
6654
7460
  */
6655
- getSelectedToolEventHandler(eventType: string): EventListener;
7461
+ getSelectedToolEventHandler(eventType: string): EventListener | undefined;
6656
7462
  /**
6657
7463
  * Set the selected tool.
6658
7464
  *
@@ -6796,6 +7602,27 @@ export declare const toolList: Record<string, any>;
6796
7602
  */
6797
7603
  export declare const toolOptions: Record<string, Record<string, any>>;
6798
7604
 
7605
+ /**
7606
+ * Translate writer rules indexed by tag or group name into
7607
+ * rules indexed by tag or group key, as expected by the writer.
7608
+ * A group name is translated into all the groups that have it
7609
+ * (for example 'Curve' gives '5000', '5002'...).
7610
+ * Warning: group names are not defined by the DICOM standard, they come
7611
+ * from the GDCM group name list (see `tagGroups`), which does not cover
7612
+ * all groups. Prefer group keys.
7613
+ * Rules already indexed by key (or `default`) are kept as is and
7614
+ * take precedence over translated ones. Unknown names are dropped.
7615
+ *
7616
+ * @param {Record<string, WriterRule>} rules The name based rules.
7617
+ * @returns {Record<string, WriterRule>} The key based rules.
7618
+ */
7619
+ export declare function translateWriterRules(rules: Record<string, WriterRule>): Record<string, WriterRule>;
7620
+
7621
+ /**
7622
+ * List of compatible typed arrays.
7623
+ */
7624
+ export declare type TypedArray = IntTypedArray | FloatTypedArray;
7625
+
6799
7626
  /**
6800
7627
  * Undo controller.
6801
7628
  */
@@ -6932,16 +7759,16 @@ export declare class Vector3D {
6932
7759
  * (either directly or with helper methods).
6933
7760
  *
6934
7761
  * @example
6935
- * import {DicomParser, createImage, createView} from '//esm.sh/dwv';
7762
+ * import {DicomParser, demoCreateImage, demoCreateView} from '//esm.sh/dwv';
6936
7763
  * // XMLHttpRequest onload callback
6937
7764
  * const onload = function (event) {
6938
7765
  * // parse the dicom buffer
6939
7766
  * const dicomParser = new DicomParser();
6940
7767
  * dicomParser.parse(event.target.response);
6941
7768
  * // create the image object
6942
- * const image = createImage(dicomParser.getDicomElements());
7769
+ * const image = demoCreateImage(dicomParser.getDicomElements());
6943
7770
  * // create the view
6944
- * const view = createView(dicomParser.getDicomElements(), image);
7771
+ * const view = demoCreateView(dicomParser.getDicomElements(), image);
6945
7772
  * // setup canvas
6946
7773
  * const canvas = document.createElement('canvas');
6947
7774
  * canvas.width = 256;
@@ -6993,6 +7820,29 @@ export declare class View extends EventTarget {
6993
7820
  * @param {MaskSegmentViewHelper} helper The helper.
6994
7821
  */
6995
7822
  setMaskViewHelper(helper: MaskSegmentViewHelper): void;
7823
+ /**
7824
+ * Get the segment highlight.
7825
+ *
7826
+ * @returns {{segmentNumber: number, opacity: number}|undefined}
7827
+ * The highlighted segment number and its opacity factor.
7828
+ */
7829
+ getSegmentHighlight(): {
7830
+ segmentNumber: number;
7831
+ opacity: number;
7832
+ } | undefined;
7833
+ /**
7834
+ * Set the segment highlight: the opacity of the given segment
7835
+ * is multiplied by the input factor. Only one segment can be
7836
+ * highlighted at a time.
7837
+ * This only has an effect on segmentation views.
7838
+ *
7839
+ * @param {number} [segmentNumber] The segment number,
7840
+ * undefined to remove the highlight.
7841
+ * @param {number} [opacity] The opacity factor (between 0 and 1),
7842
+ * defaults to 1.
7843
+ * @fires View#segmenthighlightchange
7844
+ */
7845
+ setSegmentHighlight(segmentNumber?: number, opacity?: number): void;
6996
7846
  /**
6997
7847
  * Get the view orientation.
6998
7848
  *
@@ -7413,6 +8263,14 @@ export declare class ViewController {
7413
8263
  * @returns {Index} The current index.
7414
8264
  */
7415
8265
  getCurrentIndex(): Index;
8266
+ /**
8267
+ * Check if the volume of this view can follow the one of another view.
8268
+ *
8269
+ * @param {ViewController} viewController The view controller to follow.
8270
+ * @param {number} value The volume id value to follow.
8271
+ * @returns {boolean} True if the volume can follow.
8272
+ */
8273
+ canSyncVolume(viewController: ViewController, value: number): boolean;
7416
8274
  /**
7417
8275
  * Get the SOP image UID of the current image.
7418
8276
  *
@@ -7506,6 +8364,14 @@ export declare class ViewController {
7506
8364
  * or no quantifiable (for ex RGB).
7507
8365
  */
7508
8366
  getRescaledImageValue(position: Point): number | undefined;
8367
+ /**
8368
+ * Get the numbers of the mask segments at the input position.
8369
+ *
8370
+ * @param {Point} position The input position.
8371
+ * @returns {number[]} The list of segment numbers, empty if the image
8372
+ * is not a mask, for background or if out of bounds.
8373
+ */
8374
+ getSegmentNumbersAtPosition(position: Point): number[];
7509
8375
  /**
7510
8376
  * Get the image pixel unit.
7511
8377
  *
@@ -7649,6 +8515,13 @@ export declare class ViewController {
7649
8515
  * @returns {Index} The index.
7650
8516
  */
7651
8517
  getIndexFromPosition(point: Point): Index;
8518
+ /**
8519
+ * Get the world position of an index.
8520
+ *
8521
+ * @param {Index} index The index.
8522
+ * @returns {Point} The position.
8523
+ */
8524
+ getPositionFromIndex(index: Index): Point;
7652
8525
  /**
7653
8526
  * Set the current index.
7654
8527
  *
@@ -7729,6 +8602,28 @@ export declare class ViewController {
7729
8602
  * @param {MaskSegmentViewHelper} helper The helper.
7730
8603
  */
7731
8604
  setMaskViewHelper(helper: MaskSegmentViewHelper): void;
8605
+ /**
8606
+ * Get the segment highlight.
8607
+ *
8608
+ * @returns {{segmentNumber: number, opacity: number}|undefined}
8609
+ * The highlighted segment number and its opacity factor.
8610
+ */
8611
+ getSegmentHighlight(): {
8612
+ segmentNumber: number;
8613
+ opacity: number;
8614
+ } | undefined;
8615
+ /**
8616
+ * Set the segment highlight: the opacity of the given segment
8617
+ * is multiplied by the input factor. Only one segment can be
8618
+ * highlighted at a time.
8619
+ * This only has an effect on segmentation views.
8620
+ *
8621
+ * @param {number} [segmentNumber] The segment number,
8622
+ * undefined to remove the highlight.
8623
+ * @param {number} [opacity] The opacity factor (between 0 and 1),
8624
+ * defaults to 1.
8625
+ */
8626
+ setSegmentHighlight(segmentNumber?: number, opacity?: number): void;
7732
8627
  /**
7733
8628
  * Get the fill opacity relative to the global opacity.
7734
8629
  *
@@ -7787,8 +8682,10 @@ export declare class ViewLayer {
7787
8682
  /**
7788
8683
  * @param {HTMLElement} containerDiv The layer div, its id will be used
7789
8684
  * as this layer id.
8685
+ * @param {CanvasSizeChecker} [canvasSizeChecker] Optional canvas size
8686
+ * checker, to share with other layers; defaults to a new one.
7790
8687
  */
7791
- constructor(containerDiv: HTMLElement);
8688
+ constructor(containerDiv: HTMLElement, canvasSizeChecker?: CanvasSizeChecker);
7792
8689
  /**
7793
8690
  * Get the associated data id.
7794
8691
  *
@@ -7902,6 +8799,18 @@ export declare class ViewLayer {
7902
8799
  * @param {number} alpha The opacity ([0:1] range).
7903
8800
  */
7904
8801
  setOpacity(alpha: number): void;
8802
+ /**
8803
+ * Temporarily highlight a segment: its opacity progressively
8804
+ * dims and comes back to normal in one pulse. Only one
8805
+ * segment is highlighted at a time: a new call resets the
8806
+ * previous highlight.
8807
+ *
8808
+ * @param {number} segmentNumber The segment number.
8809
+ * @param {number} [duration] The highlight duration in milliseconds,
8810
+ * defaults to 750.
8811
+ * @returns {boolean} False if the layer is not a segmentation one.
8812
+ */
8813
+ highlightSegment(segmentNumber: number, duration?: number): boolean;
7905
8814
  /**
7906
8815
  * Get the fill opacity relative to the global opacity.
7907
8816
  *
@@ -8098,6 +9007,76 @@ export declare class ViewLayer {
8098
9007
  #private;
8099
9008
  }
8100
9009
 
9010
+ /**
9011
+ * Volume id: the id of a volume (fourth dimension index) and an
9012
+ * optional associated value, for example
9013
+ * `{id: {value: 2, source: 'TemporalPositionIdentifier',
9014
+ * tagKey: '00200100'}, value: {value: 10, unit: 'unit.s',
9015
+ * source: 'AcquisitionTime', tagKey: '00080032'}}`.
9016
+ * Only the id is reliable: it groups, orders and locates the volumes
9017
+ * (it is the fourth dimension world coordinate). The associated value
9018
+ * is informative, for example the acquisition time of the volumes of
9019
+ * a temporal position identifier. Ids that are values (for example
9020
+ * an echo time) usually do not have one. Without source, the id is
9021
+ * a frame index (for example `{id: {value: 2}}`).
9022
+ */
9023
+ export declare type VolumeId = {
9024
+ /**
9025
+ * The volume id.
9026
+ */
9027
+ id: SourcedNumberValue;
9028
+ /**
9029
+ * The associated value.
9030
+ */
9031
+ value?: SourcedNumberValue;
9032
+ };
9033
+
9034
+ /**
9035
+ * Volume id candidate getter.
9036
+ */
9037
+ export declare type VolumeIdCandidate = {
9038
+ /**
9039
+ * The candidate name.
9040
+ */
9041
+ name: string;
9042
+ /**
9043
+ * The volume id getter:
9044
+ * `(elements) => SourcedNumberValue|undefined`, the returned id
9045
+ * does not need a source (the candidate name is used), for
9046
+ * example `{value: 4.6, unit: 'unit.ms', tagKey: '00180081'}`.
9047
+ * An id without unit is an index: its associated value is guessed
9048
+ * once all data is loaded.
9049
+ */
9050
+ getter: Function;
9051
+ /**
9052
+ * Flag to also use the candidate
9053
+ * while loading.
9054
+ */
9055
+ preLoad?: boolean;
9056
+ /**
9057
+ * Flag to display the ids relative to
9058
+ * the smallest one, for example to get times since the first
9059
+ * acquisition instead of timestamps. Not applied to the ids.
9060
+ */
9061
+ relative?: boolean;
9062
+ };
9063
+
9064
+ /**
9065
+ * Pixel value of one volume.
9066
+ */
9067
+ export declare type VolumeValue = {
9068
+ /**
9069
+ * The volume id: with source and
9070
+ * possible associated value if the image has volume ids, else just
9071
+ * the volume index as id.
9072
+ */
9073
+ volumeId: VolumeId;
9074
+ /**
9075
+ * The rescaled pixel value and its unit.
9076
+ */
9077
+ pixValue: NumberValue;
9078
+ };
9079
+
8101
9080
  /**
8102
9081
  * @import {LayerGroup} from '../../gui/layerGroup.js';
8103
9082
  */
@@ -8187,21 +9166,31 @@ export declare class WindowPreset {
8187
9166
  */
8188
9167
  export declare class WriterRule {
8189
9168
  /**
8190
- * @param {string} action The rule action.
9169
+ * @param {string} action The rule action, one of the
9170
+ * `WriterRuleActions` values.
8191
9171
  */
8192
9172
  constructor(action: string);
8193
9173
  /**
8194
- * Rule action: `copy`, `remove`, `clear` or `replace`.
9174
+ * Rule action, one of the `WriterRuleActions` values.
8195
9175
  *
8196
9176
  * @type {string}
8197
9177
  */
8198
9178
  action: string;
8199
9179
  /**
8200
9180
  * Optional value to use for replace action.
9181
+ * A single value or an array of values for multi-valued
9182
+ * elements (for example `['A', 'B']` or a list of sequence items).
8201
9183
  *
8202
9184
  * @type {any|undefined}
8203
9185
  */
8204
9186
  value: any | undefined;
8205
9187
  }
8206
9188
 
9189
+ export declare namespace WriterRuleActions {
9190
+ let copy: string;
9191
+ let remove: string;
9192
+ let clear: string;
9193
+ let replace: string;
9194
+ }
9195
+
8207
9196
  export { }