diff --git a/demo/trunk/node_modules/.yarn-integrity b/demo/trunk/node_modules/.yarn-integrity index c335bf8..be87ae0 100644 --- a/demo/trunk/node_modules/.yarn-integrity +++ b/demo/trunk/node_modules/.yarn-integrity @@ -8,7 +8,7 @@ ], "linkedModules": [], "topLevelPatterns": [ - "dwv@0.32.6", + "dwv@0.33.0", "eslint@^8.53.0", "grunt-cli@^1.4.2", "grunt-contrib-connect@^4.0.0", @@ -82,7 +82,7 @@ "detect-file@^1.0.0": "https://registry.yarnpkg.com/detect-file/-/detect-file-1.0.0.tgz#f0d66d03672a825cb1b73bdb3fe62310c8e552b7", "doctrine@^3.0.0": "https://registry.yarnpkg.com/doctrine/-/doctrine-3.0.0.tgz#addebead72a6574db783639dc87a121773973961", "duplexify@^3.5.1": "https://registry.yarnpkg.com/duplexify/-/duplexify-3.7.1.tgz#2a4df5317f6ccfd91f86d6fd25d8d8a103b88309", - "dwv@0.32.6": "https://registry.yarnpkg.com/dwv/-/dwv-0.32.6.tgz#0d9bba6ce143adb6173771ed6d0b6750b9a0f4ab", + "dwv@0.33.0": "https://registry.yarnpkg.com/dwv/-/dwv-0.33.0.tgz#727ba406593c52b10d8efbc4a54012f08de62f2d", "ee-first@1.1.1": "https://registry.yarnpkg.com/ee-first/-/ee-first-1.1.1.tgz#590c61156b0ae2f4f0255732a158b266bc56b21d", "encodeurl@~1.0.2": "https://registry.yarnpkg.com/encodeurl/-/encodeurl-1.0.2.tgz#ad3ff4c86ec2d029322f5a02c3a9a606c95b3f59", "end-of-stream@^1.0.0": "https://registry.yarnpkg.com/end-of-stream/-/end-of-stream-1.4.4.tgz#5ae64a5f45057baf3626ec14da0ca5e4b2431eb0", @@ -203,7 +203,7 @@ "js-yaml@~3.14.0": "https://registry.yarnpkg.com/js-yaml/-/js-yaml-3.14.1.tgz#dae812fdb3825fa306609a8717383c50c36a0537", "json-schema-traverse@^0.4.1": "https://registry.yarnpkg.com/json-schema-traverse/-/json-schema-traverse-0.4.1.tgz#69f6a87d9513ab8bb8fe63bdb0979c448e684660", "json-stable-stringify-without-jsonify@^1.0.1": "https://registry.yarnpkg.com/json-stable-stringify-without-jsonify/-/json-stable-stringify-without-jsonify-1.0.1.tgz#9db7b59496ad3f3cfef30a75142d2d930ad72651", - "jszip@~3.10.1": "https://registry.yarnpkg.com/jszip/-/jszip-3.10.1.tgz#34aee70eb18ea1faec2f589208a157d1feb091c2", + "jszip@^3.10.1": "https://registry.yarnpkg.com/jszip/-/jszip-3.10.1.tgz#34aee70eb18ea1faec2f589208a157d1feb091c2", "kind-of@^6.0.2": "https://registry.yarnpkg.com/kind-of/-/kind-of-6.0.3.tgz#07c05034a6c349fa06e24fa35aa76db4580ce4dd", "konva@~8.4.2": "https://registry.yarnpkg.com/konva/-/konva-8.4.3.tgz#d6754fdb53e69295c24dbdfe967a27f92da51e47", "levn@^0.4.1": "https://registry.yarnpkg.com/levn/-/levn-0.4.1.tgz#ae4562c007473b932a6200d403268dd2fffc6ade", diff --git a/demo/trunk/node_modules/dwv/decoders/pdfjs/readme.md b/demo/trunk/node_modules/dwv/decoders/pdfjs/readme.md index c16f68d..2ca911b 100644 --- a/demo/trunk/node_modules/dwv/decoders/pdfjs/readme.md +++ b/demo/trunk/node_modules/dwv/decoders/pdfjs/readme.md @@ -1,15 +1,14 @@ -Third Party: pdf.js -===================== +# Third Party: pdf.js -* Web: https://github.com/mozilla/pdf.js -* Version: v1.1.1 (pdf.js) and commit fcaf281 of jpambrun -* Date: copied on 05/05/2015 -* Download: - * [jpg.js](https://github.com/mozilla/pdf.js/blob/master/src/core/jpg.js) modified as in - https://github.com/notmasteryet/jpgjs/pull/33 - * [jpx.js](https://github.com/jpambrun/jpx-medical/blob/master/jpx.js) - * [arithmetic_decoder.js](https://github.com/mozilla/pdf.js/blob/v1.1.1/src/core/arithmetic_decoder.js) - * [util.js](https://github.com/mozilla/pdf.js/blob/v1.1.1/src/shared/util.js) -* License: Apache 2.0 (see [license.txt](https://github.com/mozilla/pdf.js/blob/master/LICENSE)) -* Description: Mozilla's JPEG and JPEG2000 decoder from PDF.js with added support for 16 bit signed grayscale images. -* Purpose for dwv: read DICOM files containing JPEG or JPEG2000 data. +- Web: https://github.com/mozilla/pdf.js +- Version: v1.1.1 (pdf.js) and commit fcaf281 of jpambrun +- Date: copied on 05/05/2015 +- Download: +- [jpg.js](https://github.com/mozilla/pdf.js/blob/master/src/core/jpg.js) modified as in + https://github.com/notmasteryet/jpgjs/pull/33 +- [jpx.js](https://github.com/jpambrun/jpx-medical/blob/master/jpx.js) +- [arithmetic_decoder.js](https://github.com/mozilla/pdf.js/blob/v1.1.1/src/core/arithmetic_decoder.js) +- [util.js](https://github.com/mozilla/pdf.js/blob/v1.1.1/src/shared/util.js) +- License: Apache 2.0 (see [license.txt](https://github.com/mozilla/pdf.js/blob/master/LICENSE)) +- Description: Mozilla's JPEG and JPEG2000 decoder from PDF.js with added support for 16 bit signed grayscale images. +- Purpose for dwv: read DICOM files containing JPEG or JPEG2000 data. diff --git a/demo/trunk/node_modules/dwv/decoders/rii-mango/readme.md b/demo/trunk/node_modules/dwv/decoders/rii-mango/readme.md index 5fd2d0f..b114a31 100644 --- a/demo/trunk/node_modules/dwv/decoders/rii-mango/readme.md +++ b/demo/trunk/node_modules/dwv/decoders/rii-mango/readme.md @@ -1,12 +1,11 @@ -Third Party: rii-mango -====================== +# Third Party: rii-mango -JPEGLosslessDecoderJS ---------------------- -* Web: https://github.com/rii-mango/JPEGLosslessDecoderJS -* Version: [2.0.2](https://github.com/rii-mango/JPEGLosslessDecoderJS/releases/tag/v2.0.2) -* Date: 19/03/2017 -* Download: see release -* License: MIT (see https://github.com/rii-mango/JPEGLosslessDecoderJS/blob/v2.0.2/LICENSE) -* Description: JPEG Lossless decoder. -* Purpose for dwv: Decode JPEG embeded in DICOM. +## JPEGLosslessDecoderJS + +- Web: https://github.com/rii-mango/JPEGLosslessDecoderJS +- Version: [2.0.2](https://github.com/rii-mango/JPEGLosslessDecoderJS/releases/tag/v2.0.2) +- Date: 19/03/2017 +- Download: see release +- License: MIT (see https://github.com/rii-mango/JPEGLosslessDecoderJS/blob/v2.0.2/LICENSE) +- Description: JPEG Lossless decoder. +- Purpose for dwv: Decode JPEG embeded in DICOM. diff --git a/demo/trunk/node_modules/dwv/dist/dwv.d.ts b/demo/trunk/node_modules/dwv/dist/dwv.d.ts index 4d90ba0..08eb138 100644 --- a/demo/trunk/node_modules/dwv/dist/dwv.d.ts +++ b/demo/trunk/node_modules/dwv/dist/dwv.d.ts @@ -1,10 +1,16 @@ +import Konva from 'konva'; + /** * Add tags to the dictionary. * * @param {string} group The group key. - * @param {object} tags The tags to add. + * @param {Object} tags The tags to add as an + * object indexed by element key with values as: + * [VR, multiplicity, TagName] (all strings). */ -export declare function addTagsToDictionary(group: string, tags: object): void; +export declare function addTagsToDictionary(group: string, tags: { + [x: string]: string[]; +}): void; /** * List of ViewConfigs indexed by dataIds. @@ -31,80 +37,82 @@ export declare class App { /** * Get the image. * - * @param {number} index The data index. - * @returns {Image} The associated image. - */ - getImage(index: number): Image_2; - /** - * Get the last loaded image. - * - * @returns {Image} The image. - */ - getLastImage(): Image_2; - /** - * Set the image at the given index. - * - * @param {number} index The data index. - * @param {Image} img The associated image. + * @param {string} dataId The data id. + * @returns {Image|undefined} The associated image. */ - setImage(index: number, img: Image_2): void; + getImage(dataId: string): Image_2 | undefined; /** - * Set the last image. + * Set the image at the given id. * + * @param {string} dataId The data id. * @param {Image} img The associated image. */ - setLastImage(img: Image_2): void; + setImage(dataId: string, img: Image_2): void; /** * Add a new image. * * @param {Image} image The new image. * @param {object} meta The image meta. - * @returns {number} The new image id. + * @param {string} source The source of the new image, + * will be passed with load events. + * @returns {string} The new image data id. */ - addNewImage(image: Image_2, meta: object): number; + addNewImage(image: Image_2, meta: object, source: string): string; /** * Get the meta data. * - * @param {number} index The data index. - * @returns {object} The list of meta data. + * @param {string} dataId The data id. + * @returns {Object|undefined} The list of meta data. */ - getMetaData(index: number): object; + getMetaData(dataId: string): { + [x: string]: DataElement; + } | undefined; /** - * Get the number of loaded data. + * Get the list of ids in the data storage. * - * @returns {number} The number. + * @returns {string[]} The list of data ids. */ - getNumberOfLoadedData(): number; + getDataIds(): string[]; /** - * Can the data be scrolled? + * Get the list of dataIds that contain the input UIDs. + * + * @param {string[]} uids A list of UIDs. + * @returns {string[]} The list of dataIds that contain the UIDs. + */ + getDataIdsFromSopUids(uids: string[]): string[]; + /** + * Can the data (of the active view of the active layer) be scrolled? * * @returns {boolean} True if the data has a third dimension greater than one. + * @deprecated Please use the ViewController equivalent directly instead. */ canScroll(): boolean; /** - * Can window and level be applied to the data? + * Can window and level be applied to the data + * (of the active view of the active layer)? * * @returns {boolean} True if the data is monochrome. + * @deprecated Please use the ViewController equivalent directly instead. */ canWindowLevel(): boolean; /** - * Get the layer scale on top of the base scale. + * Get the active layer group scale on top of the base scale. * - * @returns {object} The scale as {x,y}. + * @returns {Scalar3D} The scale as {x,y,z}. */ - getAddedScale(): object; + getAddedScale(): Scalar3D; /** - * Get the base scale. + * Get the base scale of the active layer group. * - * @returns {object} The scale as {x,y}. + * @returns {Scalar3D} The scale as {x,y,z}. */ - getBaseScale(): object; + getBaseScale(): Scalar3D; /** - * Get the layer offset. + * Get the layer offset of the active layer group. * - * @returns {object} The offset. + * @returns {Scalar3D} The offset as {x,y,z}. */ - getOffset(): object; + getOffset(): Scalar3D; /** * Get the toolbox controller. * @@ -115,25 +123,31 @@ export declare class App { * Get the active layer group. * The layer is available after the first loaded item. * - * @returns {LayerGroup} The layer group. + * @returns {LayerGroup|undefined} The layer group. + */ + getActiveLayerGroup(): LayerGroup | undefined; + /** + * Set the active layer group. + * + * @param {number} index The layer group index. */ - getActiveLayerGroup(): LayerGroup; + setActiveLayerGroup(index: number): void; /** - * Get the view layers associated to a data index. + * Get the view layers associated to a data id. * The layer are available after the first loaded item. * - * @param {number} index The data index. + * @param {string} dataId The data id. * @returns {ViewLayer[]} The layers. */ - getViewLayersByDataIndex(index: number): ViewLayer[]; + getViewLayersByDataId(dataId: string): ViewLayer[]; /** - * Get the draw layers associated to a data index. + * Get the draw layers associated to a data id. * The layer are available after the first loaded item. * - * @param {number} index The data index. + * @param {string} dataId The data id. * @returns {DrawLayer[]} The layers. */ - getDrawLayersByDataIndex(index: number): DrawLayer[]; + getDrawLayersByDataId(dataId: string): DrawLayer[]; /** * Get a layer group by div id. * The layer is available after the first loaded item. @@ -165,7 +179,7 @@ export declare class App { /** * Initialise the application. * - * @param {AppOptions} opt The application options + * @param {AppOptions} opt The application options. * @example * // create the dwv app * const app = new dwv.App(); @@ -227,8 +241,8 @@ export declare class App { * @fires App#loadprogress * @fires App#loaditem * @fires App#loadend - * @fires App#loaderror - * @fires App#loadabort + * @fires App#error + * @fires App#abort * @function */ loadFiles: (files: File[]) => void; @@ -237,15 +251,15 @@ export declare class App { * * @param {string[]} urls The list of urls to load. * @param {object} [options] The options object, can contain: - * - requestHeaders: an array of {name, value} to use as request headers - * - withCredentials: boolean xhr.withCredentials flag to pass to the request - * - batchSize: the size of the request url batch + * - requestHeaders: an array of {name, value} to use as request headers, + * - withCredentials: boolean xhr.withCredentials flag to pass to the request, + * - batchSize: the size of the request url batch. * @fires App#loadstart * @fires App#loadprogress * @fires App#loaditem * @fires App#loadend - * @fires App#loaderror - * @fires App#loadabort + * @fires App#error + * @fires App#abort * @function */ loadURLs: (urls: string[], options?: object) => void; @@ -266,15 +280,21 @@ export declare class App { * @fires App#loadprogress * @fires App#loaditem * @fires App#loadend - * @fires App#loaderror - * @fires App#loadabort + * @fires App#error + * @fires App#abort * @function */ loadImageObject: (data: any[]) => void; /** - * Abort the current load. + * Abort all the current loads. + */ + abortAllLoads(): void; + /** + * Abort an individual data load. + * + * @param {string} dataId The data to stop loading. */ - abortLoad(): void; + abortLoad(dataId: string): void; /** * Fit the display to the data of each layer group. * To be called once the image is loaded. @@ -282,8 +302,37 @@ export declare class App { fitToContainer(): void; /** * Init the Window/Level display + * (of the active layer of the active layer group). + * + * @deprecated Please set the opacity of the desired view layer directly. */ initWLDisplay(): void; + /** + * Set the imageSmoothing flag value. Default is false. + * + * @param {boolean} flag True to enable smoothing. + */ + setImageSmoothing(flag: boolean): void; + /** + * Get the layer group configuration from a data id. + * + * @param {string} dataId The data id. + * @param {boolean} [excludeStarConfig] Exclude the star config + * (default to false). + * @returns {ViewConfig[]} The list of associated configs. + */ + getViewConfigs(dataId: string, excludeStarConfig?: boolean): ViewConfig[]; + /** + * Get the layer group configuration for a data id and group + * div id. + * + * @param {string} dataId The data id. + * @param {string} groupDivId The layer group div id. + * @param {boolean} [excludeStarConfig] Exclude the star config + * (default to false). + * @returns {ViewConfig|undefined} The associated config. + */ + getViewConfig(dataId: string, groupDivId: string, excludeStarConfig?: boolean): ViewConfig | undefined; /** * Get the data view config. * Carefull, returns a reference, do not modify without resetting. @@ -302,20 +351,44 @@ export declare class App { setDataViewConfigs(configs: { [x: string]: ViewConfig[]; }): void; + /** + * Add a data view config. + * + * @param {string} dataId The data id. + * @param {ViewConfig} config The view configuration. + */ + addDataViewConfig(dataId: string, config: ViewConfig): void; + /** + * Remove a data view config. + * + * @param {string} dataId The data id. + * @param {string} divId The div id. + */ + removeDataViewConfig(dataId: string, divId: string): void; + /** + * Update an existing data view config. + * Removes and re-creates the layer if found. + * + * @param {string} dataId The data id. + * @param {string} divId The div id. + * @param {ViewConfig} config The view configuration. + */ + updateDataViewConfig(dataId: string, divId: string, config: ViewConfig): void; /** * Set the layer groups binders. * - * @param {Array} list The list of binder names. + * @param {string[]} list The list of binder names. */ - setLayerGroupsBinders(list: any[]): void; + setLayerGroupsBinders(list: string[]): void; /** * Render the current data. * - * @param {number} dataIndex The data index to render. + * @param {string} dataId The data id to render. + * @param {ViewConfig[]} [viewConfigs] The list of configs to render. */ - render(dataIndex: number): void; + render(dataId: string, viewConfigs?: ViewConfig[]): void; /** - * Zoom to the layers. + * Zoom the layers of the active layer group. * * @param {number} step The step to add to the current zoom. * @param {number} cx The zoom center X coordinate. @@ -323,20 +396,21 @@ export declare class App { */ zoom(step: number, cx: number, cy: number): void; /** - * Apply a translation to the layers. + * Apply a translation to the layers of the active layer group. * * @param {number} tx The translation along X. * @param {number} ty The translation along Y. */ translate(tx: number, ty: number): void; /** - * Set the image layer opacity. + * Set the active view layer (of the active layer group) opacity. * * @param {number} alpha The opacity ([0:1] range). + * @deprecated Please set the opacity of the desired view layer directly. */ setOpacity(alpha: number): void; /** - * Set the drawings on the current stage. + * Set the drawings of the active layer group. * * @param {Array} drawings An array of drawings. * @param {Array} drawingsDetails An array of drawings details. @@ -372,12 +446,14 @@ export declare class App { onKeydown: (event: KeyboardEvent) => void; /** * Key down event handler example. - * - CRTL-Z: undo - * - CRTL-Y: redo - * - CRTL-ARROW_LEFT: next element on fourth dim - * - CRTL-ARROW_UP: next element on third dim - * - CRTL-ARROW_RIGHT: previous element on fourth dim - * - CRTL-ARROW_DOWN: previous element on third dim + * - CRTL-Z: undo, + * - CRTL-Y: redo, + * - CRTL-ARROW_LEFT: next element on fourth dim, + * - CRTL-ARROW_UP: next element on third dim, + * - CRTL-ARROW_RIGHT: previous element on fourth dim, + * - CRTL-ARROW_DOWN: previous element on third dim. + * + * Applies to the active view of the active layer group. * * @param {KeyboardEvent} event The key down event. * @fires UndoStack#undo @@ -386,27 +462,29 @@ export declare class App { */ defaultOnKeydown: (event: KeyboardEvent) => void; /** - * Reset the display + * Reset the display. */ resetDisplay(): void; /** - * Reset the app zoom.s + * Reset the app zoom. */ resetZoom(): void; /** - * Set the colour map. + * Set the colour map of the active view of the active layer group. * * @param {string} name The colour map name. + * @deprecated Please use the ViewController equivalent directly instead. */ setColourMap(name: string): void; /** - * Set the window/level preset. + * Set the window/level preset of the active view of the active layer group. * - * @param {object} preset The window/level preset. + * @param {string} preset The window/level preset. + * @deprecated Please use the ViewController equivalent directly instead. */ - setWindowLevelPreset(preset: object): void; + setWindowLevelPreset(preset: string): void; /** - * Set the tool + * Set the tool. * * @param {string} tool The tool. */ @@ -418,13 +496,13 @@ export declare class App { */ setToolFeatures(list: object): void; /** - * Undo the last action + * Undo the last action. * * @fires UndoStack#undo */ undo(): void; /** - * Redo the last action + * Redo the last action. * * @fires UndoStack#redo */ @@ -441,6 +519,19 @@ export declare class App { * @returns {number} The stack index. */ getCurrentStackIndex(): number; + /** + * Get the overlay data for a data id. + * + * @param {string} dataId The data id. + * @returns {OverlayData|undefined} The overlay data. + */ + getOverlayData(dataId: string): OverlayData | undefined; + /** + * Toggle overlay listeners. + * + * @param {string} dataId The data id. + */ + toggleOverlayListeners(dataId: string): void; #private; } @@ -449,20 +540,20 @@ export declare class App { */ export declare class AppOptions { /** - * @param {Object} dataViewConfigs DataId + * @param {Object} [dataViewConfigs] Optional dataId * indexed object containing the data view configurations. */ - constructor(dataViewConfigs: { + constructor(dataViewConfigs?: { [x: string]: ViewConfig[]; }); /** * DataId indexed object containing the data view configurations. * - * @type {Object} + * @type {Object|undefined} */ dataViewConfigs: { [x: string]: ViewConfig[]; - }; + } | undefined; /** * Tool name indexed object containing individual tool configurations. * @@ -479,25 +570,46 @@ export declare class AppOptions { binders: string[] | undefined; /** * Optional boolean flag to trigger the first data render - * after the first loaded data or not. Defaults to true; + * after the first loaded data or not. Defaults to true. * * @type {boolean|undefined} */ viewOnFirstLoadItem: boolean | undefined; /** - * Optional default chraracter set string used for DICOM parsing if - * not passed in DICOM file. - * Valid values: https://developer.mozilla.org/en-US/docs/Web/API/Encoding_API/Encodings + * Optional default chraracterset string used for DICOM parsing if + * not passed in DICOM file. + * + * Valid values: {@link https://developer.mozilla.org/en-US/docs/Web/API/Encoding_API/Encodings}. * * @type {string|undefined} */ defaultCharacterSet: string | undefined; + /** + * Optional overlay config. + * + * @type {object|undefined} + */ + overlayConfig: object | undefined; + /** + * DOM root document. + * + * @type {DocumentFragment} + */ + rootDocument: DocumentFragment; +} + +export declare namespace BLACK { + let r: number; + let g: number; + let b: number; } /** * Build a multipart message. - * See: https://en.wikipedia.org/wiki/MIME#Multipart_messages - * See: https://hg.orthanc-server.com/orthanc-dicomweb/file/tip/Resources/Samples/JavaScript/stow-rs.js + * + * Ref: + * - {@link https://en.wikipedia.org/wiki/MIME#Multipart_messages}, + * - {@link https://hg.orthanc-server.com/orthanc-dicomweb/file/tip/Resources/Samples/JavaScript/stow-rs.js}. * * @param {Array} parts The message parts as an array of object containing * content headers and messages as the data property (as returned by parse). @@ -506,9 +618,59 @@ export declare class AppOptions { */ export declare function buildMultipart(parts: any[], boundary: string): Uint8Array; +/** + * Change segment colour command. + */ +export declare class ChangeSegmentColourCommand { + /** + * @param {Image} mask The mask image. + * @param {MaskSegment} segment The segment to modify. + * @param {RGB|number} newColour The new segment colour. + * @param {boolean} [silent] Whether to send a creation event or not. + */ + constructor(mask: Image_2, segment: MaskSegment, newColour: RGB | number, silent?: boolean); + /** + * Get the command name. + * + * @returns {string} The command name. + */ + getName(): string; + /** + * Check if a command is valid and can be executed. + * + * @returns {boolean} True if the command is valid. + */ + isValid(): boolean; + /** + * Execute the command. + * + * @fires ChangeSegmentColourCommand#changemasksegmentcolour + */ + execute(): void; + /** + * Undo the command. + * + * @fires ChangeSegmentColourCommand#changemasksegmentcolour + */ + undo(): void; + /** + * Handle an execute event. + * + * @param {object} _event The execute event with type and id. + */ + onExecute(_event: object): void; + /** + * Handle an undo event. + * + * @param {object} _event The undo event with type and id. + */ + onUndo(_event: object): void; + #private; +} + /** * Colour map: red, green and blue components - * to associate with intensity values. + * to associate with intensity values. */ export declare class ColourMap { /** @@ -540,27 +702,33 @@ export declare class ColourMap { /** * Create an Image from DICOM elements. * - * @param {object} elements The DICOM elements. + * @param {Object} elements The DICOM elements. * @returns {Image} The Image object. */ -export declare function createImage(elements: object): Image_2; +export declare function createImage(elements: { + [x: string]: DataElement; +}): Image_2; /** * Create a mask Image from DICOM elements. * - * @param {object} elements The DICOM elements. + * @param {Object} elements The DICOM elements. * @returns {Image} The mask Image object. */ -export declare function createMaskImage(elements: object): Image_2; +export declare function createMaskImage(elements: { + [x: string]: DataElement; +}): Image_2; /** * Create a View from DICOM elements and image. * - * @param {object} elements The DICOM elements. + * @param {Object} elements The DICOM elements. * @param {Image} image The associated image. * @returns {View} The View object. */ -export declare function createView(elements: object, image: Image_2): View; +export declare function createView(elements: { + [x: string]: DataElement; +}, image: Image_2): View; export declare namespace customUI { /** @@ -643,16 +811,112 @@ export declare const decoderScripts: { /** * List of default window level presets. * - * @type {Object.>} + * @type {Object.>} */ export declare const defaultPresets: { [x: string]: { + [x: string]: WindowLevel; + }; +}; + +export declare namespace defaults { + let labelText: { [x: string]: { - center: number; - width: number; + [x: string]: string; }; }; -}; +} + +/** + * Delete segment command. + */ +export declare class DeleteSegmentCommand { + /** + * @param {Image} mask The mask image. + * @param {MaskSegment} segment The segment to remove. + * @param {boolean} [silent] Whether to send a creation event or not. + */ + constructor(mask: Image_2, segment: MaskSegment, silent?: boolean); + /** + * Get the command name. + * + * @returns {string} The command name. + */ + getName(): string; + /** + * Check if a command is valid and can be executed. + * + * @returns {boolean} True if the command is valid. + */ + isValid(): boolean; + /** + * Execute the command. + * + * @fires DeleteSegmentCommand#masksegmentdelete + */ + execute(): void; + /** + * Undo the command. + * + * @fires DeleteSegmentCommand#masksegmentredraw + */ + undo(): void; + /** + * Handle an execute event. + * + * @param {object} _event The execute event with type and id. + */ + onExecute(_event: object): void; + /** + * Handle an undo event. + * + * @param {object} _event The undo event with type and id. + */ + onUndo(_event: object): void; + #private; +} + +/** + * DICOM code: item of a basic code sequence. + * + * Ref: {@link https://dicom.nema.org/medical/dicom/2022a/output/chtml/part03/sect_8.8.html}. + */ +export declare class DicomCode { + /** + * @param {string} meaning The code meaning. + */ + constructor(meaning: string); + /** + * Code meaning (0008,0104). + * + * @type {string} + */ + meaning: string; + /** + * Code value (0008,0100). + * + * @type {string|undefined} + */ + value: string | undefined; + /** + * Long code value (0008,0119). + * + * @type {string|undefined} + */ + longValue: string | undefined; + /** + * URN code value (0008,0120). + * + * @type {string|undefined} + */ + urnValue: string | undefined; + /** + * Coding scheme designator (0008,0102). + * + * @type {string|undefined} + */ + schemeDesignator: string | undefined; +} /** * DicomParser class. @@ -755,31 +1019,37 @@ export declare class DicomWriter { * @param {boolean} flag True to use UN VR. */ setUseUnVrForPrivateSq(flag: boolean): void; + /** + * Set the vr=UN check and fix flag. + * + * @param {boolean} flag True to activate the check and fix. + */ + setFixUnknownVR(flag: boolean): void; /** * Set the writing rules. - * List of writer rules indexed by either `default`, tagName or groupName. + * List of writer rules indexed by either `default`, + * tagKey, tagName or groupName. * Each DICOM element will be checked to see if a rule is applicable. - * First checked by tagName and then by groupName, + * First checked by tagKey, tagName and then by groupName, * if nothing is found the default rule is applied. * * @param {Object} rules The input rules. + * @param {boolean} [addMissingTags] If true, explicit tags that + * have replace rule and a value will be + * added if missing. Defaults to false. */ setRules(rules: { [x: string]: WriterRule; - }): void; + }, addMissingTags?: boolean): void; /** * Use a TextEncoder instead of the default text decoder. */ useSpecialTextEncoder(): void; - /** - * Use default anonymisation rules. - */ - useDefaultAnonymisationRules(): void; /** * Get the element to write according to the class rules. * Priority order: tagName, groupName, default. * - * @param {DataElement} element The element to check + * @param {DataElement} element The element to check. * @returns {DataElement|null} The element to write, can be null. */ getElementToWrite(element: DataElement): DataElement | null; @@ -795,6 +1065,140 @@ export declare class DicomWriter { #private; } +/** + * Draw controller. + */ +export declare class DrawController { + /** + * @param {DrawLayer} drawLayer The draw layer. + */ + constructor(drawLayer: DrawLayer); + /** + * Get the current position group. + * + * @returns {Konva.Group|undefined} The Konva.Group. + */ + getCurrentPosGroup(): Konva.Group | undefined; + /** + * Reset: clear the layers array. + */ + reset(): void; + /** + * Get a Konva group using its id. + * + * @param {string} id The group id. + * @returns {object|undefined} The Konva group. + */ + getGroup(id: string): object | undefined; + /** + * Activate the current draw layer. + * + * @param {Index} index The current position. + * @param {number} scrollIndex The scroll index. + */ + activateDrawLayer(index: Index, scrollIndex: number): void; + /** + * Get a list of drawing display details. + * + * @returns {DrawDetails[]} A list of draw details. + */ + getDrawDisplayDetails(): DrawDetails[]; + /** + * Get a list of drawing store details. Used in state. + * + * @returns {object} A list of draw details including id, text, quant... + * TODO Unify with getDrawDisplayDetails? + */ + getDrawStoreDetails(): object; + /** + * Set the drawings on the current stage. + * + * @param {Array} drawings An array of drawings. + * @param {DrawDetails[]} drawingsDetails An array of drawings details. + * @param {object} cmdCallback The DrawCommand callback. + * @param {object} exeCallback The callback to call once the + * DrawCommand has been executed. + */ + setDrawings(drawings: any[], drawingsDetails: DrawDetails[], cmdCallback: object, exeCallback: object): void; + /** + * Update a drawing from its details. + * + * @param {DrawDetails} drawDetails Details of the drawing to update. + */ + updateDraw(drawDetails: DrawDetails): void; + /** + * Delete a Draw from the stage. + * + * @param {Konva.Group} group The group to delete. + * @param {object} cmdCallback The DeleteCommand callback. + * @param {object} exeCallback The callback to call once the + * DeleteCommand has been executed. + */ + deleteDrawGroup(group: Konva.Group, cmdCallback: object, exeCallback: object): void; + /** + * Delete a Draw from the stage. + * + * @param {string} id The id of the group to delete. + * @param {Function} cmdCallback The DeleteCommand callback. + * @param {Function} exeCallback The callback to call once the + * DeleteCommand has been executed. + * @returns {boolean} False if the group cannot be found. + */ + deleteDraw(id: string, cmdCallback: Function, exeCallback: Function): boolean; + /** + * Delete all Draws from the stage. + * + * @param {Function} cmdCallback The DeleteCommand callback. + * @param {Function} exeCallback The callback to call once the + * DeleteCommand has been executed. + */ + deleteDraws(cmdCallback: Function, exeCallback: Function): void; + /** + * Get the total number of draws + * (at all positions). + * + * @returns {number} The total number of draws. + */ + getNumberOfDraws(): number; + #private; +} + +/** + * Draw details. + */ +export declare class DrawDetails { + /** + * The draw ID. + * + * @type {number} + */ + id: number; + /** + * The draw position: an Index converted to string. + * + * @type {string} + */ + position: string; + /** + * The draw type. + * + * @type {string} + */ + type: string; + /** + * The draw color: for example 'green', '#00ff00' or 'rgb(0,255,0)'. + * + * @type {string} + */ + color: string; + /** + * The draw meta. + * + * @type {DrawMeta} + */ + meta: DrawMeta; +} + /** * Draw layer. */ @@ -805,23 +1209,23 @@ export declare class DrawLayer { */ constructor(containerDiv: HTMLDivElement); /** - * Get the associated data index. + * Get the associated data id. * - * @returns {number} The index. + * @returns {string} The id. */ - getDataIndex(): number; + getDataId(): string; /** * Get the Konva stage. * - * @returns {object} The stage. + * @returns {Konva.Stage} The stage. */ - getKonvaStage(): object; + getKonvaStage(): Konva.Stage; /** * Get the Konva layer. * - * @returns {object} The layer. + * @returns {Konva.Layer} The layer. */ - getKonvaLayer(): object; + getKonvaLayer(): Konva.Layer; /** * Get the draw controller. * @@ -831,21 +1235,25 @@ export declare class DrawLayer { /** * Set the plane helper. * - * @param {object} helper The helper. + * @param {PlaneHelper} helper The helper. */ - setPlaneHelper(helper: object): void; + setPlaneHelper(helper: PlaneHelper): void; /** * Get the id of the layer. * * @returns {string} The string id. */ getId(): string; + /** + * Remove the HTML element from the DOM. + */ + removeFromDOM(): void; /** * Get the layer base size (without scale). * - * @returns {object} The size as {x,y}. + * @returns {Scalar2D} The size as {x,y}. */ - getBaseSize(): object; + getBaseSize(): Scalar2D; /** * Get the layer opacity. * @@ -866,19 +1274,31 @@ export declare class DrawLayer { * Add a flip offset along the layer Y axis. */ addFlipOffsetY(): void; + /** + * Flip the scale along the layer X axis. + */ + flipScaleX(): void; + /** + * Flip the scale along the layer Y axis. + */ + flipScaleY(): void; + /** + * Flip the scale along the layer Z axis. + */ + flipScaleZ(): void; /** * Set the layer scale. * - * @param {object} newScale The scale as {x,y}. + * @param {Scalar3D} newScale The scale as {x,y,z}. * @param {Point3D} [center] The scale center. */ - setScale(newScale: object, center?: Point3D): void; + setScale(newScale: Scalar3D, center?: Point3D): void; /** * Set the layer offset. * - * @param {object} newOffset The offset as {x,y}. + * @param {Scalar3D} newOffset The offset as {x,y,z}. */ - setOffset(newOffset: object): void; + setOffset(newOffset: Scalar3D): void; /** * Set the base layer offset. Updates the layer offset. * @@ -901,25 +1321,25 @@ export declare class DrawLayer { isVisible(): boolean; /** * Draw the content (imageData) of the layer. - * The imageData variable needs to be set + * The imageData variable needs to be set. */ draw(): void; /** - * Initialise the layer: set the canvas and context + * Initialise the layer: set the canvas and context. * - * @param {object} size The image size as {x,y}. - * @param {object} spacing The image spacing as {x,y}. - * @param {number} index The associated data index. + * @param {Scalar2D} size The image size as {x,y}. + * @param {Scalar2D} spacing The image spacing as {x,y}. + * @param {string} dataId The associated data id. */ - initialise(size: object, spacing: object, index: number): void; + initialise(size: Scalar2D, spacing: Scalar2D, dataId: string): void; /** * Fit the layer to its parent container. * - * @param {number} fitScale1D The 1D fit scale. - * @param {object} fitSize The fit size as {x,y}. - * @param {object} fitOffset The fit offset as {x,y}. + * @param {Scalar2D} containerSize The container size as {x,y}. + * @param {number} divToWorldSizeRatio The div to world size ratio. + * @param {Scalar2D} fitOffset The fit offset as {x,y}. */ - fitToContainer(fitScale1D: number, fitSize: object, fitOffset: object): void; + fitToContainer(containerSize: Scalar2D, divToWorldSizeRatio: number, fitOffset: Scalar2D): void; /** * Check the visibility of a given group. * @@ -949,6 +1369,13 @@ export declare class DrawLayer { * DeleteCommand has been executed. */ deleteDraws(exeCallback: object): void; + /** + * Get the total number of draws of this layer + * (at all positions). + * + * @returns {number|undefined} The total number of draws. + */ + getNumberOfDraws(): number | undefined; /** * Enable and listen to container interaction events. */ @@ -985,12 +1412,31 @@ export declare class DrawLayer { } /** - * 2D/3D Geometry class. + * Draw meta data. */ -export declare class Geometry { +export declare class DrawMeta { /** - * @param {Point3D} origin The object origin (a 3D point). - * @param {Size} size The object size. + * Draw quantification. + * + * @type {object} + */ + quantification: object; + /** + * Draw text expression. Can contain variables surrounded with '{}' that will + * be extracted from the quantification object. + * + * @type {string} + */ + textExpr: string; +} + +/** + * 2D/3D Geometry class. + */ +export declare class Geometry { + /** + * @param {Point3D} origin The object origin (a 3D point). + * @param {Size} size The object size. * @param {Spacing} spacing The object spacing. * @param {Matrix33} [orientation] The object orientation (3*3 matrix, * default to 3*3 identity). @@ -1036,9 +1482,9 @@ export declare class Geometry { /** * Get the object origins. * - * @returns {Array} The object origins. + * @returns {Point3D[]} The object origins. */ - getOrigins(): any[]; + getOrigins(): Point3D[]; /** * Check if a point is in the origin list. * @@ -1053,7 +1499,7 @@ export declare class Geometry { * Warning: the size comes as stored in DICOM, meaning that it could * be oriented. * - * @param {Matrix33} [viewOrientation] The view orientation (optional) + * @param {Matrix33} [viewOrientation] The view orientation (optional). * @returns {Size} The object size. */ getSize(viewOrientation?: Matrix33): Size; @@ -1062,7 +1508,7 @@ export declare class Geometry { * Warning: the spacing comes as stored in DICOM, meaning that it could * be oriented. * - * @param {Matrix33} [viewOrientation] The view orientation (optional) + * @param {Matrix33} [viewOrientation] The view orientation (optional). * @returns {Spacing} The object spacing. */ getSpacing(viewOrientation?: Matrix33): Spacing; @@ -1131,10 +1577,10 @@ export declare class Geometry { * Check that a index is within bounds. * * @param {Index} index The index to check. - * @param {Array} [dirs] Optional list of directions to check. + * @param {number[]} [dirs] Optional list of directions to check. * @returns {boolean} True if the given coordinates are within bounds. */ - isIndexInBounds(index: Index, dirs?: any[]): boolean; + isIndexInBounds(index: Index, dirs?: number[]): boolean; /** * Convert an index into world coordinates. * @@ -1166,6 +1612,13 @@ export declare class Geometry { #private; } +/** + * Get the default DICOM seg tags as an object. + * + * @returns {object} The default tags. + */ +export declare function getDefaultDicomSegJson(): object; + /** * List of DICOM data elements indexed via a 8 character string formed from * the group and element numbers. @@ -1180,28 +1633,57 @@ export declare class Geometry { export declare function getDwvVersion(): string; /** - * Get the DICOM elements from a 'simple' DICOM json tags object. - * The json is a simplified version of the oficial DICOM json with + * Get the DICOM elements from a 'simple' DICOM tags object. + * The input object is a simplified version of the oficial DICOM json with * tag names instead of keys and direct values (no value property) for * simple tags. See synthetic test data (in tests/dicom) for examples. * - * @param {Object} jsonTags The DICOM - * json tags object. + * @param {Object} simpleTags The 'simple' DICOM + * tags object. * @returns {Object} The DICOM elements. */ -export declare function getElementsFromJSONTags(jsonTags: { +export declare function getElementsFromJSONTags(simpleTags: { [x: string]: any; }): { [x: string]: DataElement; }; +/** + * Get the indices that form a ellpise. + * + * @param {Index} center The ellipse center. + * @param {number[]} radius The 2 ellipse radiuses. + * @param {number[]} dir The 2 ellipse directions. + * @returns {Index[]} The indices of the ellipse. + */ +export declare function getEllipseIndices(center: Index, radius: number[], dir: number[]): Index[]; + +/** + * Get the layer details from a mouse event. + * + * @param {object} event The event to get the layer div id from. Expecting + * an event origininating from a canvas inside a layer HTML div + * with the 'layer' class and id generated with `getLayerDivId`. + * @returns {object} The layer details as {groupDivId, layerId}. + */ +export declare function getLayerDetailsFromEvent(event: object): object; + +/** + * Get the offset of an input mouse event. + * + * @param {object} event The event to get the offset from. + * @returns {Point2D} The 2D point. + */ +export declare function getMousePoint(event: object): Point2D; + /** * Get the name of an image orientation patient. * - * @param {Array} orientation The image orientation patient. - * @returns {string} The orientation name: axial, coronal or sagittal. + * @param {number[]} orientation The image orientation patient. + * @returns {string|undefined} The orientation + * name: axial, coronal or sagittal. */ -export declare function getOrientationName(orientation: any[]): string; +export declare function getOrientationName(orientation: number[]): string | undefined; /** * Get the PixelData Tag. @@ -1226,6 +1708,14 @@ export declare function getReverseOrientation(ori: string): string; */ export declare function getTagFromKey(key: string): Tag; +/** + * Get the offsets of an input touch event. + * + * @param {object} event The event to get the offset from. + * @returns {Point2D[]} The array of points. + */ +export declare function getTouchPoints(event: object): Point2D[]; + /** * Get the appropriate TypedArray in function of arguments. * @@ -1241,11 +1731,14 @@ export declare function getTypedArray(bitsAllocated: number, pixelRepresentation /** * Get a UID for a DICOM tag. - * Note: Use https://github.com/uuidjs/uuid? * - * @see http://dicom.nema.org/dicom/2013/output/chtml/part05/chapter_9.html - * @see http://dicomiseasy.blogspot.com/2011/12/chapter-4-dicom-objects-in-chapter-3.html - * @see https://stackoverflow.com/questions/46304306/how-to-generate-unique-dicom-uid + * Note: Use {@link https://github.com/uuidjs/uuid}? + * + * Ref: + * - {@link http://dicom.nema.org/medical/dicom/2022a/output/chtml/part05/chapter_9.html}, + * - {@link http://dicomiseasy.blogspot.com/2011/12/chapter-4-dicom-objects-in-chapter-3.html}, + * - {@link https://stackoverflow.com/questions/46304306/how-to-generate-unique-dicom-uid}. + * * @param {string} tagName The input tag. * @returns {string} The corresponding UID. */ @@ -1253,8 +1746,9 @@ export declare function getUID(tagName: string): string; /** * Check that an input buffer includes the DICOM prefix 'DICM' - * after the 128 bytes preamble. - * Ref: [DICOM File Meta]{@link https://dicom.nema.org/dicom/2013/output/chtml/part10/chapter_7.html#sect_7.1} + * after the 128 bytes preamble. + * + * Ref: [DICOM File Meta]{@link https://dicom.nema.org/medical/dicom/2022a/output/chtml/part10/chapter_7.html#sect_7.1}. * * @param {ArrayBuffer} buffer The buffer to check. * @returns {boolean} True if the buffer includes the prefix. @@ -1313,9 +1807,9 @@ declare class Image_2 { /** * @param {Geometry} geometry The geometry of the image. * @param {TypedArray} buffer The image data as a one dimensional buffer. - * @param {Array} [imageUids] An array of Uids indexed to slice number. + * @param {string[]} [imageUids] An array of Uids indexed to slice number. */ - constructor(geometry: Geometry, buffer: Int8Array | Uint8Array | Int16Array | Uint16Array | Int32Array | Uint32Array, imageUids?: any[]); + constructor(geometry: Geometry, buffer: Int8Array | Uint8Array | Int16Array | Uint16Array | Int32Array | Uint32Array, imageUids?: string[]); /** * Get the image UID at a given index. * @@ -1323,6 +1817,13 @@ declare class Image_2 { * @returns {string} The UID. */ getImageUid(index?: Index): string; + /** + * Check if this image includes the input uids. + * + * @param {string[]} uids UIDs to test for presence. + * @returns {boolean} True if all uids are in this image uids. + */ + containsImageUids(uids: string[]): boolean; /** * Get the geometry of the image. * @@ -1332,7 +1833,7 @@ declare class Image_2 { /** * Get the data buffer of the image. * - * @todo dangerous... + * @todo Dangerous... * @returns {TypedArray} The data buffer of the image. */ getBuffer(): Int8Array | Uint8Array | Int16Array | Uint16Array | Int32Array | Uint32Array; @@ -1346,8 +1847,15 @@ declare class Image_2 { * Can window and level be applied to the data? * * @returns {boolean} True if the data is monochrome. + * @deprecated Please use isMonochrome instead. */ canWindowLevel(): boolean; + /** + * Is the data monochrome. + * + * @returns {boolean} True if the data is monochrome. + */ + isMonochrome(): boolean; /** * Can the data be scrolled? * @@ -1368,16 +1876,17 @@ declare class Image_2 { * Get the rescale slope and intercept. * * @param {Index} [index] The index (only needed for non constant rsi). - * @returns {object} The rescale slope and intercept. + * @returns {RescaleSlopeAndIntercept} The rescale slope and intercept. */ - getRescaleSlopeAndIntercept(index?: Index): object; + getRescaleSlopeAndIntercept(index?: Index): RescaleSlopeAndIntercept; /** * Set the rescale slope and intercept. * - * @param {object} inRsi The input rescale slope and intercept. + * @param {RescaleSlopeAndIntercept} inRsi The input rescale + * slope and intercept. * @param {number} [offset] The rsi offset (only needed for non constant rsi). */ - setRescaleSlopeAndIntercept(inRsi: object, offset?: number): void; + setRescaleSlopeAndIntercept(inRsi: RescaleSlopeAndIntercept, offset?: number): void; /** * Are all the RSIs identity (1,0). * @@ -1423,15 +1932,19 @@ declare class Image_2 { /** * Get the meta information of the image. * - * @returns {object} The meta information of the image. + * @returns {Object} The meta information of the image. */ - getMeta(): object; + getMeta(): { + [x: string]: any; + }; /** * Set the meta information of the image. * - * @param {object} rhs The meta information of the image. + * @param {Object} rhs The meta information of the image. */ - setMeta(rhs: object): void; + setMeta(rhs: { + [x: string]: any; + }): void; /** * Get value at offset. Warning: No size check... * @@ -1443,19 +1956,19 @@ declare class Image_2 { * Get the offsets where the buffer equals the input value. * Loops through the whole volume, can get long for big data... * - * @param {number|object} value The value to check. - * @returns {Array} The list of offsets. + * @param {number|RGB} value The value to check. + * @returns {number[]} The list of offsets. */ - getOffsets(value: number | object): any[]; + getOffsets(value: number | RGB): number[]; /** * Check if the input values are in the buffer. * Could loop through the whole volume, can get long for big data... * * @param {Array} values The values to check. - * @returns {Array} A list of booleans for each input value, + * @returns {boolean[]} A list of booleans for each input value, * set to true if the value is present in the buffer. */ - hasValues(values: any[]): any[]; + hasValues(values: any[]): boolean[]; /** * Clone the image. * @@ -1466,6 +1979,7 @@ declare class Image_2 { * Append a slice to the image. * * @param {Image} rhs The slice to append. + * @fires Image#imagegeometrychange */ appendSlice(rhs: Image_2): void; /** @@ -1485,15 +1999,15 @@ declare class Image_2 { /** * Get the data range. * - * @returns {object} The data range. + * @returns {NumberRange} The data range. */ - getDataRange(): object; + getDataRange(): NumberRange; /** * Get the rescaled data range. * - * @returns {object} The rescaled data range. + * @returns {NumberRange} The rescaled data range. */ - getRescaledDataRange(): object; + getRescaledDataRange(): NumberRange; /** * Get the histogram. * @@ -1519,29 +2033,31 @@ declare class Image_2 { /** * Set the inner buffer values at given offsets. * - * @param {Array} offsets List of offsets where to set the data. - * @param {object} value The value to set at the given offsets. - * @fires Image#imagechange + * @param {number[]} offsets List of offsets where to set the data. + * @param {number|RGB} value The value to set at the given offsets. + * @fires Image#imagecontentchange */ - setAtOffsets(offsets: any[], value: object): void; + setAtOffsets(offsets: number[], value: number | RGB): void; /** * Set the inner buffer values at given offsets. * - * @param {Array} offsetsLists List of offset lists where to set the data. - * @param {object} value The value to set at the given offsets. + * @param {number[][]} offsetsLists List of offset lists where + * to set the data. + * @param {RGB} value The value to set at the given offsets. * @returns {Array} A list of objects representing the original values before * replacing them. - * @fires Image#imagechange + * @fires Image#imagecontentchange */ - setAtOffsetsAndGetOriginals(offsetsLists: any[], value: object): any[]; + setAtOffsetsAndGetOriginals(offsetsLists: number[][], value: RGB): any[]; /** * Set the inner buffer values at given offsets. * - * @param {Array} offsetsLists List of offset lists where to set the data. - * @param {object|Array} value The value to set at the given offsets. - * @fires Image#imagechange + * @param {number[][]} offsetsLists List of offset lists + * where to set the data. + * @param {RGB|Array} value The value to set at the given offsets. + * @fires Image#imagecontentchange */ - setAtOffsetsWithIterator(offsetsLists: any[], value: object | any[]): void; + setAtOffsetsWithIterator(offsetsLists: number[][], value: RGB | any[]): void; /** * Get the value of the image at a specific coordinate. * @@ -1613,20 +2129,20 @@ declare class Image_2 { * * Note: Uses raw buffer values. * - * @param {Array} weights The weights of the 2D kernel as a 3x3 matrix. + * @param {number[]} weights The weights of the 2D kernel as a 3x3 matrix. * @returns {Image} The convoluted image. */ - convolute2D(weights: any[]): Image_2; + convolute2D(weights: number[]): Image_2; /** * Convolute an image buffer with a given 2D kernel. * * Note: Uses raw buffer values. * - * @param {Array} weights The weights of the 2D kernel as a 3x3 matrix. + * @param {number[]} weights The weights of the 2D kernel as a 3x3 matrix. * @param {TypedArray} buffer The buffer to convolute. * @param {number} startOffset The index to start at. */ - convoluteBuffer(weights: any[], buffer: Int8Array | Uint8Array | Int16Array | Uint16Array | Int32Array | Uint32Array, startOffset: number): void; + convoluteBuffer(weights: number[], buffer: Int8Array | Uint8Array | Int16Array | Uint16Array | Int32Array | Uint32Array, startOffset: number): void; /** * Transform an image using a specific operator. * WARNING: no size check! @@ -1731,39 +2247,45 @@ export declare class Index { #private; } +/** + * Check if two rgb objects are equal. + * + * @param {RGB} c1 The first colour. + * @param {RGB} c2 The second colour. + * @returns {boolean} True if both colour are equal. + */ +export declare function isEqualRgb(c1: RGB, c2: RGB): boolean; + +/** + * CIE LAB value (L: [0, 100], a: [-128, 127], b: [-128, 127]) to + * unsigned int CIE LAB ([0, 65535]). + * + * @param {object} triplet CIE XYZ triplet as {l,a,b} with CIE LAB range. + * @returns {object} CIE LAB triplet as {l,a,b} with unsigned range. + */ +export declare function labToUintLab(triplet: object): object; + /** * Layer group. * - * Display position: {x,y} - * Plane position: Index (access: get(i)) - * (world) Position: Point3D (access: getX, getY, getZ) + * - Display position: {x,y}, + * - Plane position: Index (access: get(i)), + * - (world) Position: Point3D (access: getX, getY, getZ). * * Display -> World: - * planePos = viewLayer.displayToPlanePos(displayPos) - * -> compensate for layer scale and offset - * pos = viewController.getPositionFromPlanePoint(planePos) + * - planePos = viewLayer.displayToPlanePos(displayPos) + * -> compensate for layer scale and offset, + * - pos = viewController.getPositionFromPlanePoint(planePos). * - * World -> display - * planePos = viewController.getOffset3DFromPlaneOffset(pos) - * no need yet for a planePos to displayPos... + * World -> Display: + * - planePos = viewController.getOffset3DFromPlaneOffset(pos) + * no need yet for a planePos to displayPos... */ export declare class LayerGroup { /** * @param {HTMLElement} containerDiv The associated HTML div. */ constructor(containerDiv: HTMLElement); - /** - * Get the target orientation. - * - * @returns {Matrix33} The orientation matrix. - */ - getTargetOrientation(): Matrix33; - /** - * Set the target orientation. - * - * @param {Matrix33} orientation The orientation matrix. - */ - setTargetOrientation(orientation: Matrix33): void; /** * Get the showCrosshair flag. * @@ -1776,6 +2298,12 @@ export declare class LayerGroup { * @param {boolean} flag True to display the crosshair. */ setShowCrosshair(flag: boolean): void; + /** + * Set the imageSmoothing flag value. + * + * @param {boolean} flag True to enable smoothing. + */ + setImageSmoothing(flag: boolean): void; /** * Get the Id of the container div. * @@ -1785,46 +2313,66 @@ export declare class LayerGroup { /** * Get the layer scale. * - * @returns {object} The scale as {x,y,z}. + * @returns {Scalar3D} The scale as {x,y,z}. */ - getScale(): object; + getScale(): Scalar3D; /** * Get the base scale. * - * @returns {object} The scale as {x,y,z}. + * @returns {Scalar3D} The scale as {x,y,z}. */ - getBaseScale(): object; + getBaseScale(): Scalar3D; /** - * Get the added scale: the scale added to the base scale + * Get the added scale: the scale added to the base scale. * - * @returns {object} The scale as {x,y,z}. + * @returns {Scalar3D} The scale as {x,y,z}. */ - getAddedScale(): object; + getAddedScale(): Scalar3D; /** * Get the layer offset. * - * @returns {object} The offset as {x,y,z}. + * @returns {Scalar3D} The offset as {x,y,z}. */ - getOffset(): object; + getOffset(): Scalar3D; /** * Get the number of layers handled by this class. * * @returns {number} The number of layers. */ getNumberOfLayers(): number; + /** + * Check if this layerGroup contains a layer with the input id. + * + * @param {string} id The layer id to look for. + * @returns {boolean} True if this group contains + * a layer with the input id. + */ + includes(id: string): boolean; + /** + * Get the number of view layers handled by this class. + * + * @returns {number} The number of layers. + */ + getNumberOfViewLayers(): number; /** * Get the active image layer. * - * @returns {ViewLayer} The layer. + * @returns {ViewLayer|undefined} The layer. + */ + getActiveViewLayer(): ViewLayer | undefined; + /** + * Get the base view layer. + * + * @returns {ViewLayer|undefined} The layer. */ - getActiveViewLayer(): ViewLayer; + getBaseViewLayer(): ViewLayer | undefined; /** - * Get the view layers associated to a data index. + * Get the view layers associated to a data id. * - * @param {number} index The data index. + * @param {string} dataId The data id. * @returns {ViewLayer[]} The layers. */ - getViewLayersByDataIndex(index: number): ViewLayer[]; + getViewLayersByDataId(dataId: string): ViewLayer[]; /** * Search view layers for equal imae meta data. * @@ -1835,22 +2383,22 @@ export declare class LayerGroup { /** * Get the view layers data indices. * - * @returns {Array} The list of indices. + * @returns {string[]} The list of indices. */ - getViewDataIndices(): any[]; + getViewDataIndices(): string[]; /** * Get the active draw layer. * - * @returns {DrawLayer} The layer. + * @returns {DrawLayer|undefined} The layer. */ - getActiveDrawLayer(): DrawLayer; + getActiveDrawLayer(): DrawLayer | undefined; /** - * Get the draw layers associated to a data index. + * Get the draw layers associated to a data id. * - * @param {number} index The data index. + * @param {string} dataId The data id. * @returns {DrawLayer[]} The layers. */ - getDrawLayersByDataIndex(index: number): DrawLayer[]; + getDrawLayersByDataId(dataId: string): DrawLayer[]; /** * Set the active view layer. * @@ -1858,11 +2406,11 @@ export declare class LayerGroup { */ setActiveViewLayer(index: number): void; /** - * Set the active view layer with a data index. + * Set the active view layer with a data id. * - * @param {number} index The data index. + * @param {string} dataId The data id. */ - setActiveViewLayerByDataIndex(index: number): void; + setActiveViewLayerByDataId(dataId: string): void; /** * Set the active draw layer. * @@ -1870,20 +2418,24 @@ export declare class LayerGroup { */ setActiveDrawLayer(index: number): void; /** - * Set the active draw layer with a data index. + * Set the active draw layer with a data id. * - * @param {number} index The data index. + * @param {string} dataId The data id. */ - setActiveDrawLayerByDataIndex(index: number): void; + setActiveDrawLayerByDataId(dataId: string): void; /** * Add a view layer. * + * The new layer will be marked as the active view layer. + * * @returns {ViewLayer} The created layer. */ addViewLayer(): ViewLayer; /** * Add a draw layer. * + * The new layer will be marked as the active draw layer. + * * @returns {DrawLayer} The created layer. */ addDrawLayer(): DrawLayer; @@ -1891,6 +2443,61 @@ export declare class LayerGroup { * Empty the layer list. */ empty(): void; + /** + * Remove all layers for a specific data. + * + * @param {string} dataId The data to remove its layers. + */ + removeLayersByDataId(dataId: string): void; + /** + * Remove a layer from this layer group. + * Warning: if current active layer, the index will + * be set to `undefined`. Call one of the setActive + * methods to define the active index. + * + * @param {ViewLayer | DrawLayer} layer The layer to remove. + */ + removeLayer(layer: ViewLayer | DrawLayer): void; + /** + * Displays a tooltip in a temporary `span`. + * Works with css to hide/show the span only on mouse hover. + * + * @param {Point2D} point The update point. + */ + showTooltip(point: Point2D): void; + /** + * Remove the tooltip html div. + */ + removeTooltipDiv(): void; + /** + * Test if one of the view layers satisfies an input callbackFn. + * + * @param {Function} callbackFn A function that takes a ViewLayer as input + * and returns a boolean. + * @returns {boolean} True if one of the ViewLayers satisfies the callbackFn. + */ + someViewLayer(callbackFn: Function): boolean; + /** + * Can the input position be set on one of the view layers. + * + * @param {Point} position The input position. + * @returns {boolean} True if one view layer accepts the input position. + */ + isPositionInBounds(position: Point): boolean; + /** + * Can one of the view layers be scrolled. + * + * @returns {boolean} True if one view layer can be scrolled. + */ + canScroll(): boolean; + /** + * Does one of the view layer have more than one slice in the + * given dimension. + * + * @param {number} dim The input dimension. + * @returns {boolean} True if one view layer has more than one slice. + */ + moreThanOne(dim: number): boolean; /** * Update layers (but not the active view layer) to a position change. * @@ -1899,23 +2506,24 @@ export declare class LayerGroup { */ updateLayersToPositionChange: (event: object) => void; /** - * Calculate the fit scale: the scale that fits the largest data. + * Calculate the div to world size ratio needed to fit + * the largest data. * - * @returns {number|undefined} The fit scale. + * @returns {number|undefined} The ratio. */ - calculateFitScale(): number | undefined; + getDivToWorldSizeRatio(): number | undefined; /** - * Set the layer group fit scale. + * Fit to container: set the layers div to world size ratio. * - * @param {number} scaleIn The fit scale. + * @param {number} divToWorldSizeRatio The ratio. */ - setFitScale(scaleIn: number): void; + fitToContainer(divToWorldSizeRatio: number): void; /** - * Get the largest data size. + * Get the largest data world (mm) size. * - * @returns {object|undefined} The largest size as {x,y}. + * @returns {Scalar2D|undefined} The largest size as {x,y}. */ - getMaxSize(): object | undefined; + getMaxWorldSize(): Scalar2D | undefined; /** * Flip all layers along the Z axis without offset compensation. */ @@ -1930,24 +2538,24 @@ export declare class LayerGroup { /** * Set the layers' scale. * - * @param {object} newScale The scale to apply as {x,y,z}. + * @param {Scalar3D} newScale The scale to apply as {x,y,z}. * @param {Point3D} [center] The scale center Point3D. * @fires LayerGroup#zoomchange */ - setScale(newScale: object, center?: Point3D): void; + setScale(newScale: Scalar3D, center?: Point3D): void; /** * Add translation to the layers. * - * @param {object} translation The translation as {x,y,z}. + * @param {Scalar3D} translation The translation as {x,y,z}. */ - addTranslation(translation: object): void; + addTranslation(translation: Scalar3D): void; /** * Set the layers' offset. * - * @param {object} newOffset The offset as {x,y,z}. + * @param {Scalar3D} newOffset The offset as {x,y,z}. * @fires LayerGroup#offsetchange */ - setOffset(newOffset: object): void; + setOffset(newOffset: Scalar3D): void; /** * Reset the stage to its initial scale and no offset. */ @@ -1983,13 +2591,13 @@ export declare class LayerGroup { export declare namespace logger { export namespace levels { - const TRACE: number; - const DEBUG: number; - const INFO: number; - const WARN: number; - const ERROR: number; + let TRACE: number; + let DEBUG: number; + let INFO: number; + let WARN: number; + let ERROR: number; } - const level: number; + let level: number; export function trace(msg: string): void; export function debug(msg: string): void; export function info(msg: string): void; @@ -2006,22 +2614,238 @@ export declare const luts: { [x: string]: ColourMap; }; +/** + * Mask {@link Image} factory. + */ +export declare class MaskFactory { + /** + * Get a warning string if elements are not as expected. + * Created by checkElements. + * + * @returns {string|undefined} The warning. + */ + getWarning(): string | undefined; + /** + * Check dicom elements. Throws an error if not suitable. + * + * @param {Object} _dicomElements The DICOM tags. + * @returns {string|undefined} A possible warning. + */ + checkElements(_dicomElements: { + [x: string]: DataElement; + }): string | undefined; + /** + * Get an {@link Image} object from the read DICOM file. + * + * @param {Object} dataElements The DICOM tags. + * @param {Uint8Array | Int8Array | + * Uint16Array | Int16Array | + * Uint32Array | Int32Array} pixelBuffer The pixel buffer. + * @returns {Image} A new Image. + */ + create(dataElements: { + [x: string]: DataElement; + }, pixelBuffer: Uint8Array | Int8Array | Uint16Array | Int16Array | Uint32Array | Int32Array): Image_2; + /** + * Convert a mask image into a DICOM segmentation object. + * + * @param {Image} image The mask image. + * @param {MaskSegment[]} segments The mask segments. + * @param {Image} sourceImage The source image. + * @param {Object} [extraTags] Optional list of extra tags. + * @returns {Object} A list of dicom elements. + */ + toDicom(image: Image_2, segments: MaskSegment[], sourceImage: Image_2, extraTags?: { + [x: string]: any; + }): { + [x: string]: DataElement; + }; + #private; +} + +/** + * DICOM (mask) segment: item of a SegmentSequence (0062,0002). + * + * Ref: {@link https://dicom.nema.org/medical/dicom/2022a/output/chtml/part03/sect_C.8.20.4.html}. + */ +export declare class MaskSegment { + /** + * @param {number} number The segment number. + * @param {string} label The segment label. + * @param {string} algorithmType The segment number. + */ + constructor(number: number, label: string, algorithmType: string); + /** + * Segment number (0062,0004). + * + * @type {number} + */ + number: number; + /** + * Segment label (0062,0005). + * + * @type {string} + */ + label: string; + /** + * Segment algorithm type (0062,0008). + * + * @type {string} + */ + algorithmType: string; + /** + * Segment algorithm name (0062,0009). + * + * @type {string|undefined} + */ + algorithmName: string | undefined; + /** + * Segment display value as simple value. + * + * @type {number|undefined} + */ + displayValue: number | undefined; + /** + * Segment display value as RGB colour ({r,g,b}). + * + * @type {RGB|undefined} + */ + displayRGBValue: RGB | undefined; + /** + * Segment property code: specific property + * the segment represents (0062,000F). + * + * @type {DicomCode|undefined} + */ + propertyTypeCode: DicomCode | undefined; + /** + * Segment property category code: general category + * of the property the segment represents (0062,0003). + * + * @type {DicomCode|undefined} + */ + propertyCategoryCode: DicomCode | undefined; + /** + * Segment tracking UID (0062,0021). + * + * @type {string|undefined} + */ + trackingUid: string | undefined; + /** + * Segment tracking id: text label for the UID (0062,0020). + * + * @type {string|undefined} + */ + trackingId: string | undefined; +} + +/** + * Mask segment helper: helps handling the segments list, + * but does *NOT* update the associated mask (use special commands + * for that such as DeleteSegmentCommand, ChangeSegmentColourCommand...). + */ +export declare class MaskSegmentHelper { + /** + * @param {Image} mask The associated mask image. + */ + constructor(mask: Image_2); + /** + * Check if a segment is part of the segments list. + * + * @param {number} segmentNumber The segment number. + * @returns {boolean} True if the segment is included. + */ + hasSegment(segmentNumber: number): boolean; + /** + * Check if a segment is present in a mask image. + * + * @param {number[]} numbers Array of segment numbers. + * @returns {boolean[]} Array of boolean set to true + * if the segment is present in the mask. + */ + maskHasSegments(numbers: number[]): boolean[]; + /** + * Get a segment from the inner segment list. + * + * @param {number} segmentNumber The segment number. + * @returns {MaskSegment|undefined} The segment or undefined if not found. + */ + getSegment(segmentNumber: number): MaskSegment | undefined; + /** + * Add a segment to the segments list. + * + * @param {MaskSegment} segment The segment to add. + */ + addSegment(segment: MaskSegment): void; + /** + * Remove a segment from the segments list. + * + * @param {number} segmentNumber The segment number. + */ + removeSegment(segmentNumber: number): void; + /** + * Update a segment of the segments list. + * + * @param {MaskSegment} segment The segment to update. + */ + updateSegment(segment: MaskSegment): void; + #private; +} + +/** + * Mask segment view helper: handles hidden segments. + */ +export declare class MaskSegmentViewHelper { + /** + * Check if a segment is in the hidden list. + * + * @param {number} segmentNumber The segment number. + * @returns {boolean} True if the segment is in the list. + */ + isHidden(segmentNumber: number): boolean; + /** + * Add a segment to the hidden list. + * + * @param {MaskSegment} segment The segment to add. + */ + addToHidden(segment: MaskSegment): void; + /** + * Remove a segment from the hidden list. + * + * @param {number} segmentNumber The segment number. + */ + removeFromHidden(segmentNumber: number): void; + /** + * @callback alphaFn@callback alphaFn + * @param {number[]|number} value The pixel value. + * @param {number} index The values' index. + * @returns {number} The opacity of the input value. + */ + /** + * Get the alpha function to apply hidden colors. + * + * @returns {alphaFn} The corresponding alpha function. + */ + getAlphaFunc(): (value: number[] | number, index: number) => number; + #private; +} + /** * Immutable 3x3 Matrix. */ export declare class Matrix33 { /** - * @param {Array} values row-major ordered 9 values. + * @param {number[]} values Row-major ordered 9 values. */ - constructor(values: any[]); + constructor(values: number[]); /** * Get a value of the matrix. * * @param {number} row The row at wich to get the value. * @param {number} col The column at wich to get the value. - * @returns {number} The value at the position. + * @returns {number|undefined} The value at the position. */ - get(row: number, col: number): number; + get(row: number, col: number): number | undefined; /** * Get the inverse of this matrix. * @@ -2060,10 +2884,10 @@ export declare class Matrix33 { /** * Multiply this matrix by a 3D array. * - * @param {Array} array3D The input 3D array. - * @returns {Array} The result 3D array. + * @param {number[]} array3D The input 3D array. + * @returns {number[]} The result 3D array. */ - multiplyArray3D(array3D: any[]): any[]; + multiplyArray3D(array3D: number[]): number[]; /** * Multiply this matrix by a 3D vector. * @@ -2100,7 +2924,7 @@ export declare class Matrix33 { */ getColAbsMax(col: number): object; /** - * Get this matrix with only zero and +/- ones instead of the maximum, + * Get this matrix with only zero and +/- ones instead of the maximum. * * @returns {Matrix33} The simplified matrix. */ @@ -2114,6 +2938,179 @@ export declare class Matrix33 { #private; } +/** + * Number range. + */ +export declare class NumberRange { + /** + * @param {number} min The minimum. + * @param {number} max The maximum. + */ + constructor(min: number, max: number); + /** + * @type {number} + */ + min: number; + /** + * @type {number} + */ + max: number; +} + +export declare namespace Orientation { + let Axial: string; + let Coronal: string; + let Sagittal: string; +} + +/** + * DICOM Header overlay info. + */ +export declare class OverlayData { + /** + * @param {App} app The associated application. + * @param {string} dataId The associated data id. + * @param {object} configs The overlay config. + */ + constructor(app: App, dataId: string, configs: object); + /** + * Reset the data. + */ + reset(): void; + /** + * Handle a new loaded item event. + * + * @param {object} data The item meta data. + */ + addItemMeta(data: object): void; + /** + * Is this class listening to app events. + * + * @returns {boolean} True is listening to app events. + */ + isListening(): boolean; + /** + * Toggle info listeners. + */ + addAppListeners(): void; + /** + * Toggle info listeners. + */ + removeAppListeners(): void; + /** + * Add an event listener to this class. + * + * @param {string} type The event type. + * @param {object} callback The method associated with the provided + * event type, will be called with the fired event. + */ + addEventListener(type: string, callback: object): void; + /** + * Remove an event listener from this class. + * + * @param {string} type The event type. + * @param {object} callback The method associated with the provided + * event type. + */ + removeEventListener(type: string, callback: object): void; + #private; +} + +/** + * Plane geometry helper. + */ +export declare class PlaneHelper { + /** + * @param {Spacing} spacing The spacing. + * @param {Matrix33} imageOrientation The image oientation. + * @param {Matrix33} viewOrientation The view orientation. + */ + constructor(spacing: Spacing, imageOrientation: Matrix33, viewOrientation: Matrix33); + /** + * Get a 3D offset from a plane one. + * + * @param {Scalar2D} offset2D The plane offset as {x,y}. + * @returns {Vector3D} The 3D world offset. + */ + getOffset3DFromPlaneOffset(offset2D: Scalar2D): Vector3D; + /** + * Get a plane offset from a 3D one. + * + * @param {Scalar3D} offset3D The 3D offset as {x,y,z}. + * @returns {Scalar2D} The plane offset as {x,y}. + */ + getPlaneOffsetFromOffset3D(offset3D: Scalar3D): Scalar2D; + /** + * Orient an input vector from real to target space. + * + * @param {Vector3D} vector The input vector. + * @returns {Vector3D} The oriented vector. + */ + getTargetOrientedVector3D(vector: Vector3D): Vector3D; + /** + * De-orient an input vector from target to real space. + * + * @param {Vector3D} planeVector The input vector. + * @returns {Vector3D} The de-orienteded vector. + */ + getTargetDeOrientedVector3D(planeVector: Vector3D): Vector3D; + /** + * De-orient an input point from target to real space. + * + * @param {Point3D} planePoint The input point. + * @returns {Point3D} The de-orienteded point. + */ + getTargetDeOrientedPoint3D(planePoint: Point3D): Point3D; + /** + * Orient an input vector from target to image space. + * + * @param {Vector3D} planeVector The input vector. + * @returns {Vector3D} The orienteded vector. + */ + getImageOrientedVector3D(planeVector: Vector3D): Vector3D; + /** + * Orient an input point from target to image space. + * + * @param {Point3D} planePoint The input vector. + * @returns {Point3D} The orienteded vector. + */ + getImageOrientedPoint3D(planePoint: Point3D): Point3D; + /** + * De-orient an input vector from image to target space. + * + * @param {Vector3D} vector The input vector. + * @returns {Vector3D} The de-orienteded vector. + */ + getImageDeOrientedVector3D(vector: Vector3D): Vector3D; + /** + * De-orient an input point from image to target space. + * + * @param {Point3D} point The input point. + * @returns {Point3D} The de-orienteded point. + */ + getImageDeOrientedPoint3D(point: Point3D): Point3D; + /** + * Reorder values to follow target orientation. + * + * @param {Scalar3D} values Values as {x,y,z}. + * @returns {Scalar3D} Reoriented values as {x,y,z}. + */ + getTargetOrientedPositiveXYZ(values: Scalar3D): Scalar3D; + /** + * Get the (view) scroll dimension index. + * + * @returns {number} The index. + */ + getScrollIndex(): number; + /** + * Get the native (image) scroll dimension index. + * + * @returns {number} The index. + */ + getNativeScrollIndex(): number; + #private; +} + /** * Immutable point. * Warning: the input array is NOT cloned, modifying it will @@ -2227,19 +3224,6 @@ export declare class Point2D { * @returns {string} The point as a string. */ toString(): string; - /** - * Get the distance to another Point2D. - * - * @param {Point2D} point2D The input point. - * @returns {number} The distance to the input point. - */ - getDistance(point2D: Point2D): number; - /** - * Round a Point2D. - * - * @returns {Point2D} The rounded point. - */ - getRound(): Point2D; #private; } @@ -2300,6 +3284,13 @@ export declare class Point3D { * @returns {number} Ths distance to the input point. */ getDistance(point3D: Point3D): number; + /** + * Get the closest point to this in a Point3D list. + * + * @param {Point3D[]} pointList The list to check. + * @returns {number} The index of the closest point in the input list. + */ + getClosest(pointList: Point3D[]): number; /** * Get the difference to another Point3D. * @@ -2312,9 +3303,11 @@ export declare class Point3D { /** * Round a float number to a given precision. - * Inspired from https://stackoverflow.com/a/49729715/3639892. + * + * Inspired from {@link https://stackoverflow.com/a/49729715/3639892}. + * * Can be a solution to not have trailing zero as when - * using toFixed or toPrecision. + * using toFixed or toPrecision. * '+number.toFixed(precision)' does not pass all the tests... * * @param {number} number The number to round. @@ -2324,95 +3317,136 @@ export declare class Point3D { export declare function precisionRound(number: number, precision: number): number; /** - * Rescale LUT class. - * Typically converts from integer to float. + * Rescale Slope and Intercept. */ -export declare class RescaleLut { +export declare class RescaleSlopeAndIntercept { /** - * @param {RescaleSlopeAndIntercept} rsi The rescale slope and intercept. - * @param {number} bitsStored The number of bits used to store the data. + * @param {number} slope The slope of the RSI. + * @param {number} intercept The intercept of the RSI. */ - constructor(rsi: RescaleSlopeAndIntercept, bitsStored: number); + constructor(slope: number, intercept: number); + /** + * Get the slope of the RSI. + * + * @returns {number} The slope of the RSI. + */ + getSlope(): number; + /** + * Get the intercept of the RSI. + * + * @returns {number} The intercept of the RSI. + */ + getIntercept(): number; + /** + * Apply the RSI on an input value. + * + * @param {number} value The input value. + * @returns {number} The value to rescale. + */ + apply(value: number): number; + /** + * Check for RSI equality. + * + * @param {RescaleSlopeAndIntercept} rhs The other RSI to compare to. + * @returns {boolean} True if both RSI are equal. + */ + equals(rhs: RescaleSlopeAndIntercept): boolean; + /** + * Is this RSI an ID RSI. + * + * @returns {boolean} True if the RSI has a slope of 1 and no intercept. + */ + isID(): boolean; + #private; +} + +/** + * RGB colour class. + */ +export declare class RGB { /** - * Get the Rescale Slope and Intercept (RSI). - * - * @returns {RescaleSlopeAndIntercept} The rescale slope and intercept object. + * @param {number} r Red component. + * @param {number} g Green component. + * @param {number} b Blue component. */ - getRSI(): RescaleSlopeAndIntercept; + constructor(r: number, g: number, b: number); /** - * Is the lut ready to use or not? If not, the user must - * call 'initialise'. + * Red component. * - * @returns {boolean} True if the lut is ready to use. - */ - isReady(): boolean; - /** - * Initialise the LUT. + * @type {number} */ - initialise(): void; + r: number; /** - * Get the length of the LUT array. + * Green component. * - * @returns {number} The length of the LUT array. + * @type {number} */ - getLength(): number; + g: number; /** - * Get the value of the LUT at the given offset. + * Blue component. * - * @param {number} offset The input offset in [0,2^bitsStored] range. - * @returns {number} The float32 value of the LUT at the given offset. + * @type {number} */ - getValue(offset: number): number; - #private; + b: number; } /** - * Rescale Slope and Intercept + * Mutable 2D scalar ({x,y}). */ -export declare class RescaleSlopeAndIntercept { +export declare class Scalar2D { /** - * @param {number} slope The slope of the RSI. - * @param {number} intercept The intercept of the RSI. + * X value. + * + * @type {number} */ - constructor(slope: number, intercept: number); + x: number; /** - * Get the slope of the RSI. + * Y value. * - * @returns {number} The slope of the RSI. + * @type {number} */ - getSlope(): number; + y: number; +} + +/** + * Mutable 3D scalar ({x,y,z}). + */ +export declare class Scalar3D { /** - * Get the intercept of the RSI. + * X value. * - * @returns {number} The intercept of the RSI. + * @type {number} */ - getIntercept(): number; + x: number; /** - * Apply the RSI on an input value. + * Y value. * - * @param {number} value The input value. - * @returns {number} The value to rescale. + * @type {number} */ - apply(value: number): number; + y: number; /** - * Check for RSI equality. + * Z value. * - * @param {RescaleSlopeAndIntercept} rhs The other RSI to compare to. - * @returns {boolean} True if both RSI are equal. + * @type {number} */ - equals(rhs: RescaleSlopeAndIntercept): boolean; + z: number; +} + +/** + * Scroll wheel class: provides a wheel event handler + * that scroll the corresponding data. + */ +export declare class ScrollWheel { /** - * Get a string representation of the RSI. - * - * @returns {string} The RSI as a string. + * @param {App} app The associated application. */ - toString(): string; + constructor(app: App); /** - * Is this RSI an ID RSI. + * Handle mouse wheel event. * - * @returns {boolean} True if the RSI has a slope of 1 and no intercept. + * @param {WheelEvent} event The mouse wheel event. */ - isID(): boolean; + wheel(event: WheelEvent): void; #private; } @@ -2423,9 +3457,9 @@ export declare class RescaleSlopeAndIntercept { */ export declare class Size { /** - * @param {Array} values The size values. + * @param {number[]} values The size values. */ - constructor(values: any[]); + constructor(values: number[]); /** * Get the size value at the given array index. * @@ -2448,9 +3482,9 @@ export declare class Size { /** * Get the values of this index. * - * @returns {Array} The array of values. + * @returns {number[]} The array of values. */ - getValues(): any[]; + getValues(): number[]; /** * Check if a dimension exists and has more than one element. * @@ -2499,10 +3533,10 @@ export declare class Size { * Check that an index is within bounds. * * @param {Index} index The index to check. - * @param {Array} dirs Optional list of directions to check. + * @param {number[]} dirs Optional list of directions to check. * @returns {boolean} True if the given coordinates are within bounds. */ - isInBounds(index: Index, dirs: any[]): boolean; + isInBounds(index: Index, dirs: number[]): boolean; /** * Convert an index to an offset in memory. * @@ -2521,9 +3555,9 @@ export declare class Size { /** * Get the 2D base of this size. * - * @returns {object} The 2D base [0,1] as {x,y}. + * @returns {Scalar2D} The 2D base [0,1] as {x,y}. */ - get2D(): object; + get2D(): Scalar2D; #private; } @@ -2534,9 +3568,9 @@ export declare class Size { */ export declare class Spacing { /** - * @param {Array} values The spacing values. + * @param {number[]} values The spacing values. */ - constructor(values: any[]); + constructor(values: number[]); /** * Get the spacing value at the given array index. * @@ -2559,9 +3593,9 @@ export declare class Spacing { /** * Get the values of this spacing. * - * @returns {Array} The array of values. + * @returns {number[]} The array of values. */ - getValues(): any[]; + getValues(): number[]; /** * Check for equality. * @@ -2572,12 +3606,20 @@ export declare class Spacing { /** * Get the 2D base of this size. * - * @returns {object} The 2D base [col,row] as {x,y}. + * @returns {Scalar2D} The 2D base [col,row] as {x,y}. */ - get2D(): object; + get2D(): Scalar2D; #private; } +/** + * Convert sRGB to CIE LAB (standard illuminant D65). + * + * @param {RGB} triplet 'sRGB' triplet as {r,g,b}. + * @returns {object} CIE LAB triplet as {l,a,b}. + */ +export declare function srgbToCielab(triplet: RGB): object; + /** * Immutable tag. */ @@ -2634,18 +3676,13 @@ export declare class Tag { isWithVR(): boolean; /** * Is the tag group a private tag group ? - * see: http://dicom.nema.org/medical/dicom/2015a/output/html/part05.html#sect_7.8 + * + * See: {@link http://dicom.nema.org/medical/dicom/2022a/output/html/part05.html#sect_7.8}. * * @returns {boolean} True if the tag group is private, * ie if its group is an odd number. */ isPrivate(): boolean; - /** - * Get the tag info from the dicom dictionary. - * - * @returns {Array|undefined} The info as [vr, multiplicity, name]. - */ - getInfoFromDictionary(): any[] | undefined; /** * Get the tag Value Representation (VR) from the dicom dictionary. * @@ -2690,6 +3727,13 @@ export declare class ToolboxController { * Initialise. */ init(): void; + /** + * Enable or disable shortcuts. The 'init' methods enables shortcuts + * by default. Call this method after init to disable shortcuts. + * + * @param {boolean} flag True to enable shortcuts. + */ + enableShortcuts(flag: boolean): void; /** * Get the tool list. * @@ -2732,10 +3776,10 @@ export declare class ToolboxController { /** * Listen to layer interaction events. * - * @param {object} layer The layer to listen to. - * @param {string} layerGroupDivId The associated layer group div id. + * @param {LayerGroup} layerGroup The associated layer group. + * @param {ViewLayer|DrawLayer} layer The layer to listen to. */ - bindLayer(layer: object, layerGroupDivId: string): void; + bindLayerGroup(layerGroup: LayerGroup, layer: ViewLayer | DrawLayer): void; #private; } @@ -2757,6 +3801,16 @@ export declare class ToolConfig { options: string[] | undefined; } +/** + * List of client provided tools to be added to + * the default ones. + * + * @type {Object} + */ +export declare const toolList: { + [x: string]: any; +}; + /** * Immutable 3D vector. */ @@ -2809,7 +3863,8 @@ export declare class Vector3D { * vector that is perpendicular to both a and b. * If both vectors are parallel, the cross product is a zero vector. * - * @see https://en.wikipedia.org/wiki/Cross_product + * Ref: {@link https://en.wikipedia.org/wiki/Cross_product}. + * * @param {Vector3D} vector3D The input vector. * @returns {Vector3D} The result vector. */ @@ -2817,11 +3872,19 @@ export declare class Vector3D { /** * Get the dot product with another Vector3D. * - * @see https://en.wikipedia.org/wiki/Dot_product + * Ref: {@link https://en.wikipedia.org/wiki/Dot_product}. + * * @param {Vector3D} vector3D The input vector. * @returns {number} The dot product. */ dotProduct(vector3D: Vector3D): number; + /** + * Is this vector codirectional to an input one. + * + * @param {Vector3D} vector3D The vector to test. + * @returns {boolean} True if codirectional, false is opposite. + */ + isCodirectional(vector3D: Vector3D): boolean; #private; } @@ -2896,7 +3959,7 @@ export declare class View { */ init(): void; /** - * Set the initial index to 0. + * Set the initial index to the middle position. */ setInitialIndex(): void; /** @@ -2908,39 +3971,23 @@ export declare class View { getPlaybackMilliseconds(recommendedDisplayFrameRate: number): number; /** * @callback alphaFn@callback alphaFn - * @param {object} value The pixel value. - * @param {object} index The values' index. - * @returns {number} The value to display. + * @param {number[]|number} value The pixel value. + * @param {number} index The values' index. + * @returns {number} The opacity of the input value. */ /** * Get the alpha function. * * @returns {alphaFn} The function. */ - getAlphaFunction(): (value: object, index: object) => number; + getAlphaFunction(): (value: number[] | number, index: number) => number; /** * Set alpha function. * * @param {alphaFn} func The function. * @fires View#alphafuncchange */ - setAlphaFunction(func: (value: object, index: object) => number): void; - /** - * Get the window LUT of the image. - * Warning: can be undefined in no window/level was set. - * - * @param {object} [rsi] Optional image rsi, will take the one of the - * current slice otherwise. - * @returns {WindowLut} The window LUT of the image. - * @fires View#wlchange - */ - getCurrentWindowLut(rsi?: object): WindowLut; - /** - * Add the window LUT to the list. - * - * @param {WindowLut} wlut The window LUT of the image. - */ - addWindowLut(wlut: WindowLut): void; + setAlphaFunction(func: (value: number[] | number, index: number) => number): void; /** * Get the window presets. * @@ -2950,40 +3997,40 @@ export declare class View { /** * Get the window presets names. * - * @returns {object} The list of window presets names. + * @returns {string[]} The list of window presets names. */ - getWindowPresetsNames(): object; + getWindowPresetsNames(): string[]; /** * Set the window presets. * * @param {object} presets The window presets. */ setWindowPresets(presets: object): void; - /** - * Set the default colour map. - * - * @param {ColourMap} map The colour map. - */ - setDefaultColourMap(map: ColourMap): void; /** * Add window presets to the existing ones. * * @param {object} presets The window presets. */ addWindowPresets(presets: object): void; + /** + * Get the current window level preset name. + * + * @returns {string} The preset name. + */ + getCurrentWindowPresetName(): string; /** * Get the colour map of the image. * - * @returns {ColourMap} The colour map of the image. + * @returns {string} The colour map name. */ - getColourMap(): ColourMap; + getColourMap(): string; /** * Set the colour map of the image. * - * @param {ColourMap} map The colour map of the image. - * @fires View#colourchange + * @param {string} name The colour map name. + * @fires View#colourmapchange */ - setColourMap(map: ColourMap): void; + setColourMap(name: string): void; /** * Get the current position. * @@ -2997,25 +4044,26 @@ export declare class View { */ getCurrentIndex(): Index; /** - * Check is the provided position can be set. + * Check if the current position (default) or + * the provided position is in bounds. * - * @param {Point} position The position. + * @param {Point} [position] Optional position. * @returns {boolean} True is the position is in bounds. */ - canSetPosition(position: Point): boolean; + isPositionInBounds(position?: Point): boolean; /** - * Get the origin at a given position. + * Get the first origin or at a given position. * - * @param {Point} position The position. - * @returns {Point} The origin. + * @param {Point} [position] Optional position. + * @returns {Point3D} The origin. */ - getOrigin(position: Point): Point; + getOrigin(position?: Point): Point3D; /** * Set the current position. * * @param {Point} position The new position. * @param {boolean} silent Flag to fire event or not. - * @returns {boolean} False if not in bounds + * @returns {boolean} False if not in bounds. * @fires View#positionchange */ setCurrentPosition(position: Point, silent: boolean): boolean; @@ -3031,14 +4079,19 @@ export declare class View { /** * Set the view window/level. * - * @param {number} center The window center. - * @param {number} width The window width. + * @param {WindowLevel} wl The window and level. * @param {string} [name] Associated preset name, defaults to 'manual'. * Warning: uses the latest set rescale LUT or the default linear one. * @param {boolean} [silent] Flag to launch events with skipGenerate. * @fires View#wlchange */ - setWindowLevel(center: number, width: number, name?: string, silent?: boolean): void; + setWindowLevel(wl: WindowLevel, name?: string, silent?: boolean): void; + /** + * Get the window/level. + * + * @returns {WindowLevel} The window and level. + */ + getWindowLevel(): WindowLevel; /** * Set the window level to the preset with the input name. * @@ -3073,9 +4126,9 @@ export declare class View { * Get the image window/level that covers the full data range. * Warning: uses the latest set rescale LUT or the default linear one. * - * @returns {WindowCenterAndWidth} A min/max window level. + * @returns {WindowLevel} A min/max window level. */ - getWindowLevelMinMax(): WindowCenterAndWidth; + getWindowLevelMinMax(): WindowLevel; /** * Set the image window/level to cover the full data range. * Warning: uses the latest set rescale LUT or the default linear one. @@ -3089,42 +4142,12 @@ export declare class View { * otherwise generates at current index. */ generateImageData(data: ImageData, index: Index): void; - /** - * Increment the provided dimension. - * - * @param {number} dim The dimension to increment. - * @param {boolean} silent Do not send event. - * @returns {boolean} False if not in bounds. - */ - incrementIndex(dim: number, silent: boolean): boolean; - /** - * Decrement the provided dimension. - * - * @param {number} dim The dimension to increment. - * @param {boolean} silent Do not send event. - * @returns {boolean} False if not in bounds. - */ - decrementIndex(dim: number, silent: boolean): boolean; /** * Get the scroll dimension index. * * @returns {number} The index. */ getScrollIndex(): number; - /** - * Decrement the scroll dimension index. - * - * @param {boolean} silent Do not send event. - * @returns {boolean} False if not in bounds. - */ - decrementScrollIndex(silent: boolean): boolean; - /** - * Increment the scroll dimension index. - * - * @param {boolean} silent Do not send event. - * @returns {boolean} False if not in bounds. - */ - incrementScrollIndex(silent: boolean): boolean; #private; } @@ -3151,17 +4174,37 @@ export declare class ViewConfig { */ orientation: string | undefined; /** - * Optional view colour map. + * Optional view colour map name. * - * @type {ColourMap|undefined} + * @type {string|undefined} */ - colourMap: ColourMap | undefined; + colourMap: string | undefined; /** * Optional layer opacity; in [0, 1] range. * * @type {number|undefined} */ opacity: number | undefined; + /** + * Optional layer window level preset name. + * If present, the preset name will be used and + * the window centre and width ignored. + * + * @type {string|undefined} + */ + wlPresetName: string | undefined; + /** + * Optional layer window center. + * + * @type {number|undefined} + */ + windowCenter: number | undefined; + /** + * Optional layer window width. + * + * @type {number|undefined} + */ + windowWidth: number | undefined; } /** @@ -3170,15 +4213,15 @@ export declare class ViewConfig { export declare class ViewController { /** * @param {View} view The associated view. - * @param {number} index The associated data index. + * @param {string} dataId The associated data id. */ - constructor(view: View, index: number); + constructor(view: View, dataId: string); /** * Get the plane helper. * - * @returns {object} The helper. + * @returns {PlaneHelper} The helper. */ - getPlaneHelper(): object; + getPlaneHelper(): PlaneHelper; /** * Check is the associated image is a mask. * @@ -3186,33 +4229,21 @@ export declare class ViewController { */ isMask(): boolean; /** - * Get the mask segment helper. - * - * @returns {object} The helper. - */ - getMaskSegmentHelper(): object; - /** - * Apply the hidden segments list by setting - * the corresponding alpha function. + * Initialise the controller. */ - applyHiddenSegments(): void; + initialise(): void; /** - * Delete a segment. + * Get the image modality. * - * @param {number} segmentNumber The segment number. - * @param {Function} exeCallback The post execution callback. + * @returns {string} The modality. */ - deleteSegment(segmentNumber: number, exeCallback: Function): void; - /** - * Initialise the controller. - */ - initialise(): void; + getModality(): string; /** * Get the window/level presets names. * - * @returns {Array} The presets names. + * @returns {string[]} The presets names. */ - getWindowLevelPresetsNames(): any[]; + getWindowLevelPresetsNames(): string[]; /** * Add window/level presets to the view. * @@ -3269,12 +4300,12 @@ export declare class ViewController { */ getCurrentScrollIndexValue(): object; /** - * Get the origin at a given posittion. + * Get the first origin or at a given position. * - * @param {Point} position The input position. - * @returns {Point} The origin. + * @param {Point} [position] Opitonal position. + * @returns {Point3D} The origin. */ - getOrigin(position: Point): Point; + getOrigin(position?: Point): Point3D; /** * Get the current scroll position value. * @@ -3285,27 +4316,27 @@ export declare class ViewController { * Generate display image data to be given to a canvas. * * @param {ImageData} array The array to fill in. - * @param {Index} index Optional index at which to generate, + * @param {Index} [index] Optional index at which to generate, * otherwise generates at current index. */ - generateImageData(array: ImageData, index: Index): void; + generateImageData(array: ImageData, index?: Index): void; /** * Set the associated image. * * @param {Image} img The associated image. - * @param {number} index The data index of the image. + * @param {string} dataId The data id of the image. */ - setImage(img: Image_2, index: number): void; + setImage(img: Image_2, dataId: string): void; /** - * Get the current spacing. + * Get the current view (2D) spacing. * - * @returns {Array} The 2D spacing. + * @returns {Scalar2D} The spacing as a 2D array. */ - get2DSpacing(): any[]; + get2DSpacing(): Scalar2D; /** * Get the image rescaled value at the input position. * - * @param {Point} position the input position. + * @param {Point} position The input position. * @returns {number|undefined} The image value or undefined if out of bounds * or no quantifiable (for ex RGB). */ @@ -3313,7 +4344,7 @@ export declare class ViewController { /** * Get the image pixel unit. * - * @returns {string} The unit + * @returns {string} The unit. */ getPixelUnit(): string; /** @@ -3327,10 +4358,10 @@ export declare class ViewController { /** * Get some values from the associated image in variable regions. * - * @param {Array} regions A list of regions. + * @param {number[][][]} regions A list of [x, y] pairs (min, max). * @returns {Array} A list of values. */ - getImageVariableRegionValues(regions: any[]): any[]; + getImageVariableRegionValues(regions: number[][][]): any[]; /** * Can the image values be quantified? * @@ -3341,8 +4372,15 @@ export declare class ViewController { * Can window and level be applied to the data? * * @returns {boolean} True if possible. + * @deprecated Please use isMonochrome instead. */ canWindowLevel(): boolean; + /** + * Is the data monochrome. + * + * @returns {boolean} True if the data is monochrome. + */ + isMonochrome(): boolean; /** * Can the data be scrolled? * @@ -3351,17 +4389,25 @@ export declare class ViewController { */ canScroll(): boolean; /** - * Get the image size. + * Get the oriented image size. * * @returns {Size} The size. */ getImageSize(): Size; + /** + * Is the data size larger than one in the given dimension? + * + * @param {number} dim The dimension. + * @returns {boolean} True if the image size is larger than one + * in the given dimension. + */ + moreThanOne(dim: number): boolean; /** * Get the image world (mm) 2D size. * - * @returns {object} The 2D size as {x,y}. + * @returns {Scalar2D} The 2D size as {x,y}. */ - getImageWorldSize(): object; + getImageWorldSize(): Scalar2D; /** * Get the image rescaled data range. * @@ -3376,12 +4422,13 @@ export declare class ViewController { */ equalImageMeta(meta: object): boolean; /** - * Check is the provided position can be set. + * Check if the current position (default) or + * the provided position is in bounds. * - * @param {Point} position The position. + * @param {Point} [position] Optional position. * @returns {boolean} True is the position is in bounds. */ - canSetPosition(position: Point): boolean; + isPositionInBounds(position?: Point): boolean; /** * Set the current position. * @@ -3392,20 +4439,19 @@ export declare class ViewController { */ setCurrentPosition(pos: Point, silent?: boolean): boolean; /** - * Get a position from a 2D (x,y) position. + * Get a world position from a 2D plane position. * - * @param {number} x The column position. - * @param {number} y The row position. + * @param {Point2D} point2D The input point. * @returns {Point} The associated position. */ - getPositionFromPlanePoint(x: number, y: number): Point; + getPositionFromPlanePoint(point2D: Point2D): Point; /** - * Get a 2D (x,y) position from a position. + * Get a 2D plane position from a world position. * * @param {Point} point The 3D position. - * @returns {object} The 2D position. + * @returns {Point2D} The 2D position. */ - getPlanePositionFromPosition(point: Point): object; + getPlanePositionFromPosition(point: Point): Point2D; /** * Set the current index. * @@ -3418,17 +4464,43 @@ export declare class ViewController { * Get a plane 3D position from a plane 2D position: does not compensate * for the image origin. Needed for setting the scale center... * - * @param {object} point2D The 2D position as {x,y}. + * @param {Point2D} point2D The 2D position. * @returns {Point3D} The 3D point. */ - getPlanePositionFromPlanePoint(point2D: object): Point3D; + getPlanePositionFromPlanePoint(point2D: Point2D): Point3D; /** * Get a 3D offset from a plane one. * - * @param {object} offset2D The plane offset as {x,y}. + * @param {Scalar2D} offset2D The plane offset as {x,y}. * @returns {Vector3D} The 3D world offset. */ - getOffset3DFromPlaneOffset(offset2D: object): Vector3D; + getOffset3DFromPlaneOffset(offset2D: Scalar2D): Vector3D; + /** + * Get the current position incremented in the input direction. + * + * @param {number} dim The direction in which to increment. + * @returns {Point} The resulting point. + */ + getIncrementPosition(dim: number): Point; + /** + * Get the current position decremented in the input direction. + * + * @param {number} dim The direction in which to decrement. + * @returns {Point} The resulting point. + */ + getDecrementPosition(dim: number): Point; + /** + * Get the current position decremented in the scroll direction. + * + * @returns {Point} The resulting point. + */ + getIncrementScrollPosition(): Point; + /** + * Get the current position decremented in the scroll direction. + * + * @returns {Point} The resulting point. + */ + getDecrementScrollPosition(): Point; /** * Increment the provided dimension. * @@ -3470,46 +4542,57 @@ export declare class ViewController { /** * Get the window/level. * - * @returns {object} The window center and width. + * @returns {WindowLevel} The window and level. + */ + getWindowLevel(): WindowLevel; + /** + * Get the current window level preset name. + * + * @returns {string} The preset name. */ - getWindowLevel(): object; + getCurrentWindowPresetName(): string; /** - * Set the window/level. + * Set the window and level. * - * @param {number} wc The window center. - * @param {number} ww The window width. + * @param {WindowLevel} wl The window and level. */ - setWindowLevel(wc: number, ww: number): void; + setWindowLevel(wl: WindowLevel): void; /** * Get the colour map. * - * @returns {ColourMap} The colour map. + * @returns {string} The colour map name. */ - getColourMap(): ColourMap; + getColourMap(): string; /** * Set the colour map. * - * @param {ColourMap} colourMap The colour map. + * @param {string} name The colour map name. */ - setColourMap(colourMap: ColourMap): void; + setColourMap(name: string): void; /** * @callback alphaFn@callback alphaFn - * @param {object} value The pixel value. - * @param {object} index The values' index. - * @returns {number} The value to display. + * @param {number[]|number} value The pixel value. + * @param {number} index The values' index. + * @returns {number} The opacity of the input value. */ /** * Set the view per value alpha function. * * @param {alphaFn} func The function. */ - setViewAlphaFunction(func: (value: object, index: object) => number): void; + setViewAlphaFunction(func: (value: number[] | number, index: number) => number): void; /** - * Set the colour map from a name. + * Bind the view image to the provided layer. * - * @param {string} name The name of the colour map to set. + * @param {ViewLayer} viewLayer The layer to bind. */ - setColourMapFromName(name: string): void; + bindImageAndLayer(viewLayer: ViewLayer): void; + /** + * Unbind the view image to the provided layer. + * + * @param {ViewLayer} viewLayer The layer to bind. + */ + unbindImageAndLayer(viewLayer: ViewLayer): void; /** * Add an event listener to this class. * @@ -3539,24 +4622,36 @@ export declare class ViewLayer { */ constructor(containerDiv: HTMLElement); /** - * Get the associated data index. + * Get the associated data id. * - * @returns {number} The index. + * @returns {string} The data id. + */ + getDataId(): string; + /** + * Get the layer scale. + * + * @returns {Scalar2D} The scale as {x,y}. */ - getDataIndex(): number; + getScale(): Scalar2D; /** - * Set the imageSmoothingEnabled flag value. + * Get the layer zoom offset without the fit scale. + * + * @returns {Scalar2D} The offset as {x,y}. + */ + getAbsoluteZoomOffset(): Scalar2D; + /** + * Set the imageSmoothing flag value. * * @param {boolean} flag True to enable smoothing. */ - enableImageSmoothing(flag: boolean): void; + setImageSmoothing(flag: boolean): void; /** * Set the associated view. * * @param {object} view The view. - * @param {number} index The associated data index. + * @param {string} dataId The associated data id. */ - setView(view: object, index: number): void; + setView(view: object, dataId: string): void; /** * Get the view controller. * @@ -3576,31 +4671,50 @@ export declare class ViewLayer { * @function */ onimageset: (event: object) => void; + /** + * Bind this layer to the view image. + */ + bindImage(): void; + /** + * Unbind this layer to the view image. + */ + unbindImage(): void; + /** + * Handle an image content change event. + * + * @param {object} event The event. + * @function + */ + onimagecontentchange: (event: object) => void; /** * Handle an image change event. * * @param {object} event The event. * @function */ - onimagechange: (event: object) => void; + onimagegeometrychange: (event: object) => void; /** * Get the id of the layer. * * @returns {string} The string id. */ getId(): string; + /** + * Remove the HTML element from the DOM. + */ + removeFromDOM(): void; /** * Get the layer base size (without scale). * - * @returns {object} The size as {x,y}. + * @returns {Scalar2D} The size as {x,y}. */ - getBaseSize(): object; + getBaseSize(): Scalar2D; /** * Get the image world (mm) 2D size. * - * @returns {object} The 2D size as {x,y}. + * @returns {Scalar2D} The 2D size as {x,y}. */ - getImageWorldSize(): object; + getImageWorldSize(): Scalar2D; /** * Get the layer opacity. * @@ -3621,67 +4735,85 @@ export declare class ViewLayer { * Add a flip offset along the layer Y axis. */ addFlipOffsetY(): void; + /** + * Flip the scale along the layer X axis. + */ + flipScaleX(): void; + /** + * Flip the scale along the layer Y axis. + */ + flipScaleY(): void; + /** + * Flip the scale along the layer Z axis. + */ + flipScaleZ(): void; /** * Set the layer scale. * - * @param {object} newScale The scale as {x,y}. + * @param {Scalar3D} newScale The scale as {x,y,z}. * @param {Point3D} [center] The scale center. */ - setScale(newScale: object, center?: Point3D): void; + setScale(newScale: Scalar3D, center?: Point3D): void; + /** + * Initialise the layer scale. + * + * @param {Scalar3D} newScale The scale as {x,y,z}. + * @param {Scalar2D} absoluteZoomOffset The zoom offset as {x,y} + * without the fit scale (as provided by getAbsoluteZoomOffset). + */ + initScale(newScale: Scalar3D, absoluteZoomOffset: Scalar2D): void; /** * Set the base layer offset. Updates the layer offset. * * @param {Vector3D} scrollOffset The scroll offset vector. * @param {Vector3D} planeOffset The plane offset vector. + * @param {Point3D} [layerGroupOrigin] The layer group origin. + * @param {Point3D} [layerGroupOrigin0] The layer group first origin. * @returns {boolean} True if the offset was updated. */ - setBaseOffset(scrollOffset: Vector3D, planeOffset: Vector3D): boolean; + setBaseOffset(scrollOffset: Vector3D, planeOffset: Vector3D, layerGroupOrigin?: Point3D, layerGroupOrigin0?: Point3D): boolean; /** * Set the layer offset. * - * @param {object} newOffset The offset as {x,y}. + * @param {Scalar3D} newOffset The offset as {x,y,z}. */ - setOffset(newOffset: object): void; + setOffset(newOffset: Scalar3D): void; /** - * Transform a display position to an index. + * Transform a display position to a 2D index. * - * @param {number} x The X position. - * @param {number} y The Y position. - * @returns {Index} The equivalent index. + * @param {Point2D} point2D The input point. + * @returns {Index} The equivalent 2D index. */ - displayToPlaneIndex(x: number, y: number): Index; + displayToPlaneIndex(point2D: Point2D): Index; /** * Remove scale from a display position. * - * @param {number} x The X position. - * @param {number} y The Y position. - * @returns {object} The de-scaled position as {x,y}. + * @param {Point2D} point2D The input point. + * @returns {Point2D} The de-scaled point. */ - displayToPlaneScale(x: number, y: number): object; + displayToPlaneScale(point2D: Point2D): Point2D; /** * Get a plane position from a display position. * - * @param {number} x The X position. - * @param {number} y The Y position. - * @returns {object} The plane position as {x,y}. + * @param {Point2D} point2D The input point. + * @returns {Point2D} The plane position. */ - displayToPlanePos(x: number, y: number): object; + displayToPlanePos(point2D: Point2D): Point2D; /** * Get a display position from a plane position. * - * @param {number} x The X position. - * @param {number} y The Y position. - * @returns {object} The display position as {x,y}. + * @param {Point2D} point2D The input point. + * @returns {Point2D} The display position, can be individually + * undefined if out of bounds. */ - planePosToDisplay(x: number, y: number): object; + planePosToDisplay(point2D: Point2D): Point2D; /** * Get a main plane position from a display position. * - * @param {number} x The X position. - * @param {number} y The Y position. - * @returns {object} The main plane position as {x,y}. + * @param {Point2D} point2D The input point. + * @returns {Point2D} The main plane position. */ - displayToMainPlanePos(x: number, y: number): object; + displayToMainPlanePos(point2D: Point2D): Point2D; /** * Display the layer. * @@ -3696,28 +4828,28 @@ export declare class ViewLayer { isVisible(): boolean; /** * Draw the content (imageData) of the layer. - * The imageData variable needs to be set + * The imageData variable needs to be set. * * @fires App#renderstart * @fires App#renderend */ draw(): void; /** - * Initialise the layer: set the canvas and context + * Initialise the layer: set the canvas and context. * - * @param {object} size The image size as {x,y}. - * @param {object} spacing The image spacing as {x,y}. + * @param {Scalar2D} size The image size as {x,y}. + * @param {Scalar2D} spacing The image spacing as {x,y}. * @param {number} alpha The initial data opacity. */ - initialise(size: object, spacing: object, alpha: number): void; + initialise(size: Scalar2D, spacing: Scalar2D, alpha: number): void; /** * Fit the layer to its parent container. * - * @param {number} fitScale1D The 1D fit scale. - * @param {object} fitSize The fit size as {x,y}. - * @param {object} fitOffset The fit offset as {x,y}. + * @param {Scalar2D} containerSize The fit size as {x,y}. + * @param {number} divToWorldSizeRatio The div to world size ratio. + * @param {Scalar2D} fitOffset The fit offset as {x,y}. */ - fitToContainer(fitScale1D: number, fitSize: object, fitOffset: object): void; + fitToContainer(containerSize: Scalar2D, divToWorldSizeRatio: number, fitOffset: Scalar2D): void; /** * Enable and listen to container interaction events. */ @@ -3758,132 +4890,33 @@ export declare class ViewLayer { } /** - * WindowCenterAndWidth class. - *
Pseudo-code: - *
- *  if (x <= c - 0.5 - (w-1)/2), then y = ymin
- *  else if (x > c - 0.5 + (w-1)/2), then y = ymax,
- *  else y = ((x - (c - 0.5)) / (w-1) + 0.5) * (ymax - ymin) + ymin
- * 
- * - * @see DICOM doc for [Window Center and Window Width]{@link http://dicom.nema.org/dicom/2013/output/chtml/part03/sect_C.11.html#sect_C.11.2.1.2} + * Window and Level also known as window width and center. */ -export declare class WindowCenterAndWidth { +export declare class WindowLevel { /** * @param {number} center The window center. * @param {number} width The window width. */ constructor(center: number, width: number); /** - * Get the window center. - * - * @returns {number} The window center. - */ - getCenter(): number; - /** - * Get the window width. - * - * @returns {number} The window width. - */ - getWidth(): number; - /** - * Set the output value range. - * - * @param {string} min The output value minimum. - * @param {string} max The output value maximum. - */ - setRange(min: string, max: string): void; - /** - * Set the signed offset. - * - * @param {number} offset The signed data offset, - * typically: slope * ( size / 2). - */ - setSignedOffset(offset: number): void; - /** - * Apply the window level on an input value. - * - * @param {number} value The value to rescale as an integer. - * @returns {number} The leveled value, in the - * [ymin, ymax] range (default [0,255]). - */ - apply(value: number): number; - /** - * Check for window level equality. - * - * @param {WindowCenterAndWidth} rhs The other window level to compare to. - * @returns {boolean} True if both window level are equal. - */ - equals(rhs: WindowCenterAndWidth): boolean; - /** - * Get a string representation of the window level. - * - * @returns {string} The window level as a string. - */ - toString(): string; - #private; -} - -/** - * Window LUT class. - * Typically converts from float to integer. - */ -export declare class WindowLut { - /** - * @param {RescaleLut} rescaleLut The associated rescale LUT. - * @param {boolean} isSigned Flag to know if the data is signed or not. - */ - constructor(rescaleLut: RescaleLut, isSigned: boolean); - /** - * Get the window / level. - * - * @returns {WindowCenterAndWidth} The window / level. - */ - getWindowLevel(): WindowCenterAndWidth; - /** - * Get the signed flag. + * The window center. * - * @returns {boolean} The signed flag. - */ - isSigned(): boolean; - /** - * Get the rescale lut. - * - * @returns {RescaleLut} The rescale lut. - */ - getRescaleLut(): RescaleLut; - /** - * Is the lut ready to use or not? If not, the user must - * call 'update'. - * - * @returns {boolean} True if the lut is ready to use. - */ - isReady(): boolean; - /** - * Set the window center and width. - * - * @param {WindowCenterAndWidth} wl The window level. - */ - setWindowLevel(wl: WindowCenterAndWidth): void; - /** - * Update the lut if needed.. + * @type {number} */ - update(): void; + center: number; /** - * Get the length of the LUT array. + * The window width. * - * @returns {number} The length of the LUT array. + * @type {number} */ - getLength(): number; + width: number; /** - * Get the value of the LUT at the given offset. + * Check for equality. * - * @param {number} offset The input offset in [0,2^bitsStored] range. - * @returns {number} The integer value (default [0,255]) of the LUT - * at the given offset. + * @param {WindowLevel} rhs The other object to compare to. + * @returns {boolean} True if both objects are equal. */ - getValue(offset: number): number; - #private; + equals(rhs: WindowLevel): boolean; } /** diff --git a/demo/trunk/node_modules/dwv/dist/dwv.min.js b/demo/trunk/node_modules/dwv/dist/dwv.min.js index 1d8ff38..aa1f7fd 100644 --- a/demo/trunk/node_modules/dwv/dist/dwv.min.js +++ b/demo/trunk/node_modules/dwv/dist/dwv.min.js @@ -1,2 +1,2 @@ -!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t(require("konva"),require("jszip"),require("magic-wand-tool")):"function"==typeof define&&define.amd?define(["konva","jszip","konmagic-wand-tool"],t):"object"==typeof exports?exports.dwv=t(require("konva"),require("jszip"),require("magic-wand-tool")):e.dwv=t(e.Konva,e.JSZip,e.MagicWand)}(this,(function(e,t,n){return function(){"use strict";var i={626:function(e){e.exports=t},436:function(t){t.exports=e},812:function(e){e.exports=n}},r={};function o(e){var t=r[e];if(void 0!==t)return t.exports;var n=r[e]={exports:{}};return i[e](n,n.exports,o),n.exports}o.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return o.d(t,{a:t}),t},o.d=function(e,t){for(var n in t)o.o(t,n)&&!o.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:t[n]})},o.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},o.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var a={};return function(){o.r(a),o.d(a,{App:function(){return Vn},AppOptions:function(){return Nn},ColourMap:function(){return S},DataElement:function(){return oe},DicomParser:function(){return Ce},DicomWriter:function(){return _n},DrawLayer:function(){return Tt},Geometry:function(){return xe},Image:function(){return Ye},Index:function(){return e},LayerGroup:function(){return Pt},Matrix33:function(){return v},Point:function(){return w},Point2D:function(){return P},Point3D:function(){return O},RescaleLut:function(){return n},RescaleSlopeAndIntercept:function(){return Oe},Size:function(){return we},Spacing:function(){return Ae},Tag:function(){return Q},TagValueExtractor:function(){return qe},ToolConfig:function(){return Bn},ToolboxController:function(){return Qt},Vector3D:function(){return D},View:function(){return Ze},ViewConfig:function(){return Mn},ViewController:function(){return et},ViewLayer:function(){return at},WindowCenterAndWidth:function(){return r},WindowLut:function(){return s},WriterRule:function(){return Hn},addTagsToDictionary:function(){return x},buildMultipart:function(){return re},createImage:function(){return We},createMaskImage:function(){return ze},createView:function(){return _e},customUI:function(){return nt},decoderScripts:function(){return zt},defaultPresets:function(){return i},getDwvVersion:function(){return ae},getElementsFromJSONTags:function(){return Jn},getOrientationName:function(){return de},getPixelDataTag:function(){return G},getReverseOrientation:function(){return ue},getTagFromKey:function(){return M},getTypedArray:function(){return De},getUID:function(){return Wn},hasDicomPrefix:function(){return se},i18n:function(){return ln},logger:function(){return g},luts:function(){return h},precisionRound:function(){return J}});class e{#e;constructor(e){if(!e||void 0===e)throw new Error("Cannot create index with no values.");if(0===e.length)throw new Error("Cannot create index with empty values.");if(!e.every((function(e){return!isNaN(e)})))throw new Error("Cannot create index with non number values.");this.#e=e}get(e){return this.#e[e]}length(){return this.#e.length}toString(){return"("+this.#e.toString()+")"}getValues(){return this.#e.slice()}canCompare(e){return!!e&&this.length()===e.length()}equals(e){if(!this.canCompare(e))return!1;for(let t=0,n=this.length();t=this.length())throw new Error("Non valid dimension for toStringId.");let t="";for(let n=0;nr&&(r=i);if(0===r)throw new Error("No dimension found in point stringId");const o=new Array(r);o.fill(0);for(let e=0;ethis.#S?this.#u:e*this.#h+this.#g}equals(e){return null!==e&&this.getCenter()===e.getCenter()&&this.getWidth()===e.getWidth()}toString(){return this.getCenter()+", "+this.getWidth()}}class s{#m;#p;#n=null;#f=null;#i=!1;#D=0;constructor(e,t){this.#m=e,this.#p=t}getWindowLevel(){return this.#f}isSigned(){return this.#p}getRescaleLut(){return this.#m}isReady(){return this.#i}setWindowLevel(e){if(this.#f=e,this.#D=0,this.#f.setSignedOffset(0),this.#p){const e=this.#m.getLength();this.#D=e/2,this.#f.setSignedOffset(this.#m.getRSI().getSlope()*this.#D)}this.#i=!1}update(){if(this.#i)return;this.#m.isReady()||this.#m.initialise();const e=this.#m.getLength();this.#n||(this.#n=new Uint8ClampedArray(e));for(let t=0;t255?255:t})),green:c((function(e){const t=l/3;let n=0;return e>=t&&(n=3*(e-t),n>255)?255:n})),blue:c((function(e){const t=l/3;let n=0;return e>=2*t&&(n=3*(e-2*t),n>255)?255:n}))},hot_iron:{red:[0,2,4,6,8,10,12,14,16,18,20,22,24,26,28,30,32,34,36,38,40,42,44,46,48,50,52,54,56,58,60,62,64,66,68,70,72,74,76,78,80,82,84,86,88,90,92,94,96,98,100,102,104,106,108,110,112,114,116,118,120,122,124,126,128,130,132,134,136,138,140,142,144,146,148,150,152,154,156,158,160,162,164,166,168,170,172,174,176,178,180,182,184,186,188,190,192,194,196,198,200,202,204,206,208,210,212,214,216,218,220,222,224,226,228,230,232,234,236,238,240,242,244,246,248,250,252,254,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255],green:[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,4,6,8,10,12,14,16,18,20,22,24,26,28,30,32,34,36,38,40,42,44,46,48,50,52,54,56,58,60,62,64,66,68,70,72,74,76,78,80,82,84,86,88,90,92,94,96,98,100,102,104,106,108,110,112,114,116,118,120,122,124,126,128,130,132,134,136,138,140,142,144,146,148,150,152,154,156,158,160,162,164,166,168,170,172,174,176,178,180,182,184,186,188,190,192,194,196,198,200,202,204,206,208,210,212,214,216,218,220,222,224,226,228,230,232,234,236,238,240,242,244,246,248,250,252,255],blue:[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,4,8,12,16,20,24,28,32,36,40,44,48,52,56,60,64,68,72,76,80,84,88,92,96,100,104,108,112,116,120,124,128,132,136,140,144,148,152,156,160,164,168,172,176,180,184,188,192,196,200,204,208,212,216,220,224,228,232,236,240,244,248,252,255]},pet:{red:[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,3,5,7,9,11,13,15,17,19,21,23,25,27,29,31,33,35,37,39,41,43,45,47,49,51,53,55,57,59,61,63,65,67,69,71,73,75,77,79,81,83,85,86,88,90,92,94,96,98,100,102,104,106,108,110,112,114,116,118,120,122,124,126,128,130,132,134,136,138,140,142,144,146,148,150,152,154,156,158,160,162,164,166,168,170,171,173,175,177,179,181,183,185,187,189,191,193,195,197,199,201,203,205,207,209,211,213,215,217,219,221,223,225,227,229,231,233,235,237,239,241,243,245,247,249,251,253,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255],green:[0,2,4,6,8,10,12,14,16,18,20,22,24,26,28,30,32,34,36,38,40,42,44,46,48,50,52,54,56,58,60,62,65,67,69,71,73,75,77,79,81,83,85,87,89,91,93,95,97,99,101,103,105,107,109,111,113,115,117,119,121,123,125,128,126,124,122,120,118,116,114,112,110,108,106,104,102,100,98,96,94,92,90,88,86,84,82,80,78,76,74,72,70,68,66,64,63,61,59,57,55,53,51,49,47,45,43,41,39,37,35,33,31,29,27,25,23,21,19,17,15,13,11,9,7,5,3,1,0,2,4,6,8,10,12,14,16,18,20,22,24,26,28,30,32,34,36,38,40,42,44,46,48,50,52,54,56,58,60,62,64,66,68,70,72,74,76,78,80,82,84,86,88,90,92,94,96,98,100,102,104,106,108,110,112,114,116,118,120,122,124,126,128,130,132,134,136,138,140,142,144,146,148,150,152,154,156,158,160,162,164,166,168,170,172,174,176,178,180,182,184,186,188,190,192,194,196,198,200,202,204,206,208,210,212,214,216,218,220,222,224,226,228,230,232,234,236,238,240,242,244,246,248,250,252,255],blue:[0,1,3,5,7,9,11,13,15,17,19,21,23,25,27,29,31,33,35,37,39,41,43,45,47,49,51,53,55,57,59,61,63,65,67,69,71,73,75,77,79,81,83,85,87,89,91,93,95,97,99,101,103,105,107,109,111,113,115,117,119,121,123,125,127,129,131,133,135,137,139,141,143,145,147,149,151,153,155,157,159,161,163,165,167,169,171,173,175,177,179,181,183,185,187,189,191,193,195,197,199,201,203,205,207,209,211,213,215,217,219,221,223,225,227,229,231,233,235,237,239,241,243,245,247,249,251,253,255,252,248,244,240,236,232,228,224,220,216,212,208,204,200,196,192,188,184,180,176,172,168,164,160,156,152,148,144,140,136,132,128,124,120,116,112,108,104,100,96,92,88,84,80,76,72,68,64,60,56,52,48,44,40,36,32,28,24,20,16,12,8,4,0,4,8,12,16,20,24,28,32,36,40,44,48,52,56,60,64,68,72,76,80,85,89,93,97,101,105,109,113,117,121,125,129,133,137,141,145,149,153,157,161,165,170,174,178,182,186,190,194,198,202,206,210,214,218,222,226,230,234,238,242,246,250,255]},hot_metal_blue:{red:[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,3,6,9,12,15,18,21,24,26,29,32,35,38,41,44,47,50,52,55,57,59,62,64,66,69,71,74,76,78,81,83,85,88,90,93,96,99,102,105,108,111,114,116,119,122,125,128,131,134,137,140,143,146,149,152,155,158,161,164,166,169,172,175,178,181,184,187,190,194,198,201,205,209,213,217,221,224,228,232,236,240,244,247,251,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255],green:[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,4,6,8,9,11,13,15,17,19,21,23,24,26,28,30,32,34,36,38,40,41,43,45,47,49,51,53,55,56,58,60,62,64,66,68,70,72,73,75,77,79,81,83,85,87,88,90,92,94,96,98,100,102,104,105,107,109,111,113,115,117,119,120,122,124,126,128,130,132,134,136,137,139,141,143,145,147,149,151,152,154,156,158,160,162,164,166,168,169,171,173,175,177,179,181,183,184,186,188,190,192,194,196,198,200,201,203,205,207,209,211,213,215,216,218,220,222,224,226,228,229,231,233,235,237,239,240,242,244,246,248,250,251,253,255],blue:[0,2,4,6,8,10,12,14,16,17,19,21,23,25,27,29,31,33,35,37,39,41,43,45,47,49,51,53,55,57,59,61,63,65,67,69,71,73,75,77,79,81,83,84,86,88,90,92,94,96,98,100,102,104,106,108,110,112,114,116,117,119,121,123,125,127,129,131,133,135,137,139,141,143,145,147,149,151,153,155,157,159,161,163,165,167,169,171,173,175,177,179,181,183,184,186,188,190,192,194,196,198,200,197,194,191,188,185,182,179,176,174,171,168,165,162,159,156,153,150,144,138,132,126,121,115,109,103,97,91,85,79,74,68,62,56,50,47,44,41,38,35,32,29,26,24,21,18,15,12,9,6,3,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,3,6,9,12,15,18,21,24,26,29,32,35,38,41,44,47,50,53,56,59,62,65,68,71,74,76,79,82,85,88,91,94,97,100,103,106,109,112,115,118,121,124,126,129,132,135,138,141,144,147,150,153,156,159,162,165,168,171,174,176,179,182,185,188,191,194,197,200,203,206,210,213,216,219,223,226,229,232,236,239,242,245,249,252,255]},pet_20step:{red:[0,0,0,0,0,0,0,0,0,0,0,0,0,96,96,96,96,96,96,96,96,96,96,96,96,96,48,48,48,48,48,48,48,48,48,48,48,48,48,48,48,48,48,48,48,48,48,48,48,48,48,80,80,80,80,80,80,80,80,80,80,80,80,80,96,96,96,96,96,96,96,96,96,96,96,96,96,112,112,112,112,112,112,112,112,112,112,112,112,112,128,128,128,128,128,128,128,128,128,128,128,128,48,48,48,48,48,48,48,48,48,48,48,48,48,48,48,48,48,48,48,48,48,48,48,48,48,48,80,80,80,80,80,80,80,80,80,80,80,80,80,64,64,64,64,64,64,64,64,64,64,64,64,224,224,224,224,224,224,224,224,224,224,224,224,224,208,208,208,208,208,208,208,208,208,208,208,208,208,208,208,208,208,208,208,208,208,208,208,208,208,208,208,208,208,208,208,208,208,208,208,208,208,208,192,192,192,192,192,192,192,192,192,192,192,192,192,176,176,176,176,176,176,176,176,176,176,176,176,176,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255],green:[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,48,48,48,48,48,48,48,48,48,48,48,48,48,48,48,48,48,48,48,48,48,48,48,48,48,80,80,80,80,80,80,80,80,80,80,80,80,80,96,96,96,96,96,96,96,96,96,96,96,96,96,112,112,112,112,112,112,112,112,112,112,112,112,112,128,128,128,128,128,128,128,128,128,128,128,128,96,96,96,96,96,96,96,96,96,96,96,96,96,144,144,144,144,144,144,144,144,144,144,144,144,144,192,192,192,192,192,192,192,192,192,192,192,192,192,224,224,224,224,224,224,224,224,224,224,224,224,224,224,224,224,224,224,224,224,224,224,224,224,224,208,208,208,208,208,208,208,208,208,208,208,208,208,176,176,176,176,176,176,176,176,176,176,176,176,176,144,144,144,144,144,144,144,144,144,144,144,144,96,96,96,96,96,96,96,96,96,96,96,96,96,48,48,48,48,48,48,48,48,48,48,48,48,48,0,0,0,0,0,0,0,0,0,0,0,0,0,255,255,255,255,255,255,255,255,255,255,255,255,255],blue:[0,0,0,0,0,0,0,0,0,0,0,0,0,80,80,80,80,80,80,80,80,80,80,80,80,80,80,80,80,80,80,80,80,80,80,80,80,80,80,112,112,112,112,112,112,112,112,112,112,112,112,128,128,128,128,128,128,128,128,128,128,128,128,128,176,176,176,176,176,176,176,176,176,176,176,176,176,192,192,192,192,192,192,192,192,192,192,192,192,192,224,224,224,224,224,224,224,224,224,224,224,224,48,48,48,48,48,48,48,48,48,48,48,48,48,48,48,48,48,48,48,48,48,48,48,48,48,48,80,80,80,80,80,80,80,80,80,80,80,80,80,64,64,64,64,64,64,64,64,64,64,64,64,80,80,80,80,80,80,80,80,80,80,80,80,80,96,96,96,96,96,96,96,96,96,96,96,96,96,64,64,64,64,64,64,64,64,64,64,64,64,64,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,255,255,255,255,255,255,255,255,255,255,255,255,255]}},g={levels:{TRACE:0,DEBUG:1,INFO:2,WARN:3,ERROR:4},level:3,trace:function(e){this.level<=this.levels.TRACE&&console.trace(e)},debug:function(e){this.level<=this.levels.DEBUG&&console.debug(e)},info:function(e){this.level<=this.levels.INFO&&console.info(e)},warn:function(e){this.level<=this.levels.WARN&&console.warn(e)},error:function(e){this.level<=this.levels.ERROR&&console.error(e)}};function m(e){return function(e){return n=e,.001172549*(t={r:parseInt(n.substring(1,3),16),g:parseInt(n.substring(3,5),16),b:parseInt(n.substring(5,7),16)}).r+.002301961*t.g+447059e-9*t.b<.5;var t,n}(e)?"#fff":"#000"}const p={x:95.0489,y:100,z:108.884};function f(e){const t={Yellow:"#ffff00",Red:"#ff0000",White:"#ffffff",Green:"#008000",Blue:"#0000ff",Lime:"#00ff00",Fuchsia:"#ff00ff",Black:"#000000"};let n="#ffff00";return void 0!==t[e]&&(n=t[e]),n}class D{#y;#C;#v;constructor(e,t,n){this.#y=e,this.#C=t,this.#v=n}getX(){return this.#y}getY(){return this.#C}getZ(){return this.#v}equals(e){return null!==e&&this.getX()===e.getX()&&this.getY()===e.getY()&&this.getZ()===e.getZ()}toString(){return"("+this.getX()+", "+this.getY()+", "+this.getZ()+")"}norm(){return Math.sqrt(this.getX()*this.getX()+this.getY()*this.getY()+this.getZ()*this.getZ())}crossProduct(e){return new D(this.getY()*e.getZ()-e.getY()*this.getZ(),this.getZ()*e.getX()-e.getZ()*this.getX(),this.getX()*e.getY()-e.getX()*this.getY())}dotProduct(e){return this.getX()*e.getX()+this.getY()*e.getY()+this.getZ()*e.getZ()}}const y=1e4*Number.EPSILON;function C(e,t,n){return void 0===n&&(n=Number.EPSILON),Math.abs(e-t)0?1:-1;for(let t=0;t<3;++t)t===n.index?e.push(1*i):e.push(0)}return new v(e)}getThirdColMajorDirection(){return this.getColAbsMax(2).index}}function T(){return new v([1,0,0,0,1,0,0,0,1])}function I(){return new v([1,0,0,0,0,1,0,-1,0])}function L(e){let t=null;return"axial"===e?t=T():"coronal"===e?t=I():"sagittal"===e&&(t=new v([0,0,-1,1,0,0,0,-1,0])),t}class P{#y;#C;constructor(e,t){this.#y=e,this.#C=t}getX(){return this.#y}getY(){return this.#C}equals(e){return null!==e&&this.getX()===e.getX()&&this.getY()===e.getY()}toString(){return"("+this.getX()+", "+this.getY()+")"}getDistance(e){return Math.sqrt((this.getX()-e.getX())*(this.getX()-e.getX())+(this.getY()-e.getY())*(this.getY()-e.getY()))}getRound(){return new P(Math.round(this.getX()),Math.round(this.getY()))}}class O{#y;#C;#v;constructor(e,t,n){this.#y=e,this.#C=t,this.#v=n}getX(){return this.#y}getY(){return this.#C}getZ(){return this.#v}equals(e){return null!==e&&this.getX()===e.getX()&&this.getY()===e.getY()&&this.getZ()===e.getZ()}isSimilar(e,t){return null!==e&&C(this.getX(),e.getX(),t)&&C(this.getY(),e.getY(),t)&&C(this.getZ(),e.getZ(),t)}toString(){return"("+this.getX()+", "+this.getY()+", "+this.getZ()+")"}getDistance(e){return Math.sqrt((this.getX()-e.getX())*(this.getX()-e.getX())+(this.getY()-e.getY())*(this.getY()-e.getY())+(this.getZ()-e.getZ())*(this.getZ()-e.getZ()))}minus(e){return new D(this.getX()-e.getX(),this.getY()-e.getY(),this.getZ()-e.getZ())}}class w{#e;constructor(e){if(!e||void 0===e)throw new Error("Cannot create point with no values.");if(0===e.length)throw new Error("Cannot create point with empty values.");if(!e.every((function(e){return!isNaN(e)})))throw new Error("Cannot create point with non number values.");this.#e=e}get(e){return this.#e[e]}length(){return this.#e.length}toString(){return"("+this.#e.toString()+")"}getValues(){return this.#e.slice()}canCompare(e){return!!e&&this.length()===e.length()}equals(e){if(!this.canCompare(e))return!1;for(let t=0,n=this.length();to;t--,o++)r=n[o],n[o]=n[t],n[t]=r}class z{#P;#O=!0;#w=function(){return new Int8Array(new Int16Array([1]).buffer)[0]>0}();#A;#x;constructor(e,t){this.#P=e,void 0!==t&&(this.#O=t),this.#A=this.#O!==this.#w,this.#x=new DataView(e)}readUint16(e){return this.#x.getUint16(e,this.#O)}readInt16(e){return this.#x.getInt16(e,this.#O)}readUint32(e){return this.#x.getUint32(e,this.#O)}readBigUint64(e){return this.#x.getBigUint64(e,this.#O)}readInt32(e){return this.#x.getInt32(e,this.#O)}readBigInt64(e){return this.#x.getBigInt64(e,this.#O)}readFloat32(e){return this.#x.getFloat32(e,this.#O)}readFloat64(e){return this.#x.getFloat64(e,this.#O)}readBinaryArray(e,t){const n=new Uint8Array(this.#P,e,t),i=8*n.length,r=new Uint8Array(i);let o=0,a=0;for(let e=0;e0?0|n:0;return e.substring(i,i+t.length)===t}function X(e,t){return null!=e&&null!=t&&e.substring(e.length-t.length)===t}function j(e){const t=[];if(null==e)return t;const n=/{(\w+)}/g;let i=n.exec(e);for(;i;)t.push(i[1]),i=n.exec(e);return t}function _(e,t){let n="";if(null==e)return n;if(n=e,null==t)return n;const i=j(e);for(let e=0;e=e.length)&&(n=0),(void 0===i||i<=n||i>e.length)&&(i=e.length);for(let r=n;r2^"+e+").")}}return i}function ye(e,t){return t?8:R(e)?12:8}class Ce{#b={};#F;#R=new ce;#E=this.#R;#q(e){return this.#R.decode(e)}#U(e){return this.#E.decode(e)}getDefaultCharacterSet(){return this.#F}setDefaultCharacterSet(e){this.#F=e}setDecoderCharacterSet(e){this.#E=new TextDecoder(e)}getDicomElements(){return this.#b}#Q(e,t){const n=e.readHex(t);t+=Uint16Array.BYTES_PER_ELEMENT;const i=e.readHex(t);return t+=Uint16Array.BYTES_PER_ELEMENT,{tag:new Q(n,i),endOffset:t}}#M(e,t,n){const i={};let r=this.#B(e,t,n);if(t=r.endOffset,V(r.tag))return{data:i,endOffset:r.endOffset,isSeqDelim:!0};if(i[r.tag.getKey()]={tag:r.tag,vr:"NONE",vl:r.vl,undefinedLength:r.undefinedLength},r.undefinedLength){let o=!1;for(;!o;)r=this.#B(e,t,n),t=r.endOffset,o="FFFEE00D"===r.tag.getKey(),o||(i[r.tag.getKey()]=r)}else{const o=t;for(t-=r.vl;t8&&"OB"===a&&g.warn("Reading DICOM pixel data with bitsAllocated>8 and OB VR."),l=[],1===i)l.push(t.readBinaryArray(s,o));else if(8===i)0===n?l.push(t.readUint8Array(s,o)):l.push(t.readInt8Array(s,o));else{if(16!==i)throw new Error("Unsupported bits allocated: "+i);0===n?l.push(t.readUint16Array(s,o)):l.push(t.readInt16Array(s,o))}else if(void 0!==c)if("Uint8"===c)l=t.readUint8Array(s,o);else if("Uint16"===c)l=t.readUint16Array(s,o),"O"!==a[0]&&(l=Array.from(l));else if("Uint32"===c)l=t.readUint32Array(s,o),"O"!==a[0]&&(l=Array.from(l));else if("Uint64"===c)l=t.readUint64Array(s,o);else if("Int16"===c)l=Array.from(t.readInt16Array(s,o));else if("Int32"===c)l=Array.from(t.readInt32Array(s,o));else if("Int64"===c)l=t.readInt64Array(s,o);else if("Float32"===c)l=Array.from(t.readFloat32Array(s,o));else if("Float64"===c)l=Array.from(t.readFloat64Array(s,o));else{if("string"!==c)throw Error("Unknown VR type: "+c);{const e=t.readUint8Array(s,o);l=q(a)?this.#U(e):this.#q(e),l=function(e){let t=e;const n=e.length-1;return e[n]===le&&(t=e.substring(0,n)),t=t.trim(),t}(l).split("\\")}}else if("xx"===a)l=Array.from(t.readUint16Array(s,o));else if("ox"===a)l=8===i?Array.from(t.readUint8Array(s,o)):Array.from(t.readUint16Array(s,o));else if("xs"===a)l=0===n?Array.from(t.readUint16Array(s,o)):Array.from(t.readInt16Array(s,o));else if("AT"===a){const e=t.readUint16Array(s,o);l=[];for(let t=0,n=e.length;t=65&&r<=90&&o>=65&&o<=90);let s=null;if(n===t)s=a?"1.2.840.10008.1.2":"1.2.840.10008.1.2.1";else{if(a)throw new Error("Not a valid DICOM file (no magic DICM word foundand implicit VR big endian detected)");s="1.2.840.10008.1.2.2"}const l=new oe("UI");return l.tag=new Q("0002","0010"),l.value=[s+" "],l.vl=l.value[0].length,l.startOffset=e.startOffset,l.endOffset=l.startOffset+l.vl,l}(i);this.#b[e.tag.getKey()]=e,n=e.value[0],t=0}if(!function(e){return"1.2.840.10008.1.2"===e||"1.2.840.10008.1.2.1"===e||"1.2.840.10008.1.2.2"===e||ge(e)||me(e)||pe(e)||fe(e)}(n))throw new Error("Unsupported DICOM transfer syntax: '"+n+"' ("+function(e){let t="Unknown";return"1.2.840.10008.1.2"===e?t="Little Endian Implicit":"1.2.840.10008.1.2.1"===e?t="Little Endian Explicit":"1.2.840.10008.1.2.1.99"===e?t="Little Endian Deflated Explicit":"1.2.840.10008.1.2.2"===e?t="Big Endian Explicit":ge(e)?t="1.2.840.10008.1.2.4.50"===e?"JPEG Baseline":"JPEG Extended, Process 2+4":me(e)?t="1.2.840.10008.1.2.4.57"===e?"JPEG Lossless, Nonhierarchical (Processes 14)":"JPEG Lossless, Non-hierarchical, 1st Order Prediction":function(e){return null!==e.match(/1.2.840.10008.1.2.4.5/)&&!ge(e)&&!me(e)||null!==e.match(/1.2.840.10008.1.2.4.6/)}(e)?t="Retired JPEG":function(e){return null!==e.match(/1.2.840.10008.1.2.4.8/)}(e)?t="JPEG-LS":pe(e)?t="1.2.840.10008.1.2.4.91"===e?"JPEG 2000 (Lossless or Lossy)":"JPEG 2000 (Lossless only)":"1.2.840.10008.1.2.4.100"===e?t="MPEG2":fe(e)&&(t="RLE"),t}(n)+")");let s=!1;for(Se(n)&&(s=!0),he(n)&&(o=new z(e,!1));t1&&t.length>e){const n=t.length/e,r=[];let o=0;for(let i=0;i{if(void 0===this.#k[e.type])return;const t=this.#k[e.type].slice();for(let n=0;n2?e:0})));let c=o.indexToOffset(l);void 0===i&&(i=!1);let u=null;u=i?function(e){return t.getRescaledValueAtOffset(e)}:function(e){return t.getValueAtOffset(e)};const d=o.get(0),S=o.get(1),h=o.get(2);let g=o.getDimSize(2);const m=t.getNumberOfComponents(),p=1===t.getPlanarConfiguration(),f=function(e,t,n,i,r,o,a,s){return 1===m?Te(e,t,n,i,r,o,a,s):3===m?function(e,t,n,i,r,o,a,s,l){const c=[];return l?(c.push(Te(e,t,n,i,r,o,a,s)),c.push(Te(e,t+n*i,n,i,r,o,a,s)),c.push(Te(e,t+2*n*i,n,i,r,o,a,s))):(i*=3,o*=3,c.push(Te(e,t,n,i,r,o,a,s)),c.push(Te(e,t+1,n,i,r,o,a,s)),c.push(Te(e,t+2,n,i,r,o,a,s))),{next:function(){const e=c[0].next(),t=c[1].next(),n=c[2].next();return e.done?{done:!0,index:n.index}:{value:[e.value,t.value,n.value],done:!1,index:[e.index,t.index,n.index]}}}}(e,3*t,n,i,r,o,a,s,p):void 0};let D=null;if(r&&void 0!==r){const e=r.getColAbsMax(0),t=r.getColAbsMax(2),n=!1,i=!1;let o=null;if(2===t.index)o=d*S,D=0===e.index?f(u,c,o,1,d,d,n,i):f(u,c,o,d,S,1,n,i);else if(0===t.index)o=h*S,D=1===e.index?f(u,c,o,d,S,g,n,i):f(u,c,o,g,h,d,n,i);else{if(1!==t.index)throw new Error("Unknown direction: "+t.index);o=h*d,D=0===e.index?f(u,c,o,1,d,g,n,i):f(u,c,o,g,h,1,n,i)}}else if(1===t.getNumberOfComponents())D=function(e,t,n,i){void 0===i&&(i=1);let r=t;return{next:function(){if(r=e[i+1].index&&++i;const t={value:e[i].colour,done:!1,index:n};return++n,t}return{done:!0,index:t}}}}class Oe{#h;#H;constructor(e,t){this.#h=e,this.#H=t}getSlope(){return this.#h}getIntercept(){return this.#H}apply(e){return e*this.#h+this.#H}equals(e){return null!==e&&this.getSlope()===e.getSlope()&&this.getIntercept()===e.getIntercept()}toString(){return this.getSlope()+", "+this.getIntercept()}isID(){return 1===this.getSlope()&&0===this.getIntercept()}}class we{#e;constructor(e){if(!e||void 0===e)throw new Error("Cannot create size with no values.");if(0===e.length)throw new Error("Cannot create size with empty values.");if(!e.every((function(e){return!isNaN(e)&&0!==e})))throw new Error("Cannot create size with non number or zero values.");this.#e=e}get(e){return this.#e[e]}length(){return this.#e.length}toString(){return"("+this.#e.toString()+")"}getValues(){return this.#e.slice()}moreThanOne(e){return this.length()>=e+1&&1!==this.get(e)}canScroll3D(e){let t=2;return void 0!==e&&(t=e.getThirdColMajorDirection()),this.moreThanOne(t)}canScroll(e){let t=this.canScroll3D(e);for(let e=3;ethis.length())return null;if(void 0===t)t=0;else if(t<0||t>e)throw new Error("Invalid start value for getDimSize");let n=1;for(let i=t;in-1)throw new Error("Wrong input dir value: "+t[e]);for(let n=0;n=0&&ithis.length()-1)throw new Error("Invalid start value for indexToOffset");let n=0;for(let i=t;i0;--e)r=this.getDimSize(e),n[e]=Math.floor(i/r),i-=n[e]*r;return n[0]=i,new e(n)}get2D(){return{x:this.get(0),y:this.get(1)}}}class Ae{#e;constructor(e){if(!e||void 0===e)throw new Error("Cannot create spacing with no values.");if(0===e.length)throw new Error("Cannot create spacing with empty values.");if(!e.every((function(e){return!isNaN(e)&&0!==e})))throw new Error("Cannot create spacing with non number or zero values.");this.#e=e}get(e){return this.#e[e]}length(){return this.#e.length}toString(){return"("+this.#e.toString()+")"}getValues(){return this.#e.slice()}equals(e){if(!e)return!1;const t=this.length();if(t!==e.length())return!1;for(let n=0;n0?i+1:i}appendOrigin(e,t,n){if(void 0!==n&&this.#X[n].splice(t,0,e),void 0===n||n===this.#j){this.#Z=!0,this.#W.splice(t,0,e);const n=this.#z.getValues();n[2]+=1,this.#z=new we(n)}}appendFrame(e,t){this.#X[t]=[e];const n=this.#z.getValues(),i=this.#Y.getValues();4===n.length?n[3]+=1:(n.push(2),i.push(1)),this.#z=new we(n),this.#Y=new Ae(i)}toString(){return"Origin: "+this.getOrigin()+", Size: "+this.getSize()+", Spacing: "+this.getSpacing()+", Orientation: "+this.getOrientation()}equals(e){return null!==e&&this.getOrigin().equals(e.getOrigin())&&this.getSize().equals(e.getSize())&&this.getSpacing().equals(e.getSpacing())}isInBounds(e){return this.isIndexInBounds(this.worldToIndex(e))}isIndexInBounds(e,t){return this.getSize().isInBounds(e,t)}indexToWorld(e){const t=this.getSpacing(),n=new O(e.get(0)*t.get(0),e.get(1)*t.get(1),e.get(2)*t.get(2)),i=this.getOrientation().multiplyPoint3D(n),r=e.getValues(),o=this.getOrigin();return r[0]=o.getX()+i.getX(),r[1]=o.getY()+i.getY(),r[2]=o.getZ()+i.getZ(),new w(r)}pointToWorld(e){const t=this.getSpacing(),n=new O(e.getX()*t.get(0),e.getY()*t.get(1),e.getZ()*t.get(2)),i=this.getOrientation().multiplyPoint3D(n),r=this.getOrigin();return new O(r.getX()+i.getX(),r.getY()+i.getY(),r.getZ()+i.getZ())}worldToIndex(t){const n=this.getOrigin(),i=new O(t.get(0)-n.getX(),t.get(1)-n.getY(),t.get(2)-n.getZ()),r=this.getOrientation().getInverse().multiplyPoint3D(i),o=t.getValues(),a=this.getSpacing();return o[0]=Math.round(r.getX()/a.get(0)),o[1]=Math.round(r.getY()/a.get(1)),o[2]=Math.round(r.getZ()/a.get(2)),new e(o)}worldToPoint(e){const t=this.getOrigin(),n=new O(e.get(0)-t.getX(),e.get(1)-t.getY(),e.get(2)-t.getZ()),i=this.getOrientation().getInverse().multiplyPoint3D(n),r=e.getValues(),o=this.getSpacing();return r[0]=i.getX()/o.get(0),r[1]=i.getY()/o.get(1),r[2]=i.getZ()/o.get(2),new O(r[0],r[1],r[2])}}function be(e,t){return t.getInverse().multiplyArray3D(e)}function Fe(e,t){return t.multiplyArray3D(e)}function Re(e,t,n){if(void 0===n&&(n=!0),e.length<=1)return;const i=t.getInverse();let r=i.multiplyVector3D(e[0]),o=i.multiplyVector3D(e[1]),a=Math.abs(r.getZ()-o.getZ());const s=[];for(let t=0;t1e-4&&g.warn("Varying slice spacing, mean delta: "+t.toFixed(3)+" ("+s.length+" case(s))")}return a}function Ee(e){const t=e["00280010"];if(void 0===t)throw new Error("Missing DICOM image number of rows");if(0===t.value.length)throw new Error("Empty DICOM image number of rows");const n=e["00280011"];if(void 0===n)throw new Error("Missing DICOM image number of columns");if(0===n.value.length)throw new Error("Empty DICOM image number of columns");return[n.value[0],t.value[0]]}class qe{getTime(e){}}class Ue{checkElements(e){Ee(e)}create(e,t,n){const i=Ee(e),o=[i[0],i[1],1],a=e["00280008"];a&&o.push(a.value[0]);const s=new we(o),l=function(e){let t=1,n=1;const i=["00280030","00181164","00182010","00280034"];for(let r=0;r>8};r=t.value.map(e),o=n.value.map(e),a=i.value.map(e)}}else if(8===s.value[2]){g.info("Scaling 16bits color lut since the lut descriptor is 8.");let e=t.value.slice(0);r=new Uint8Array(e.buffer),e=n.value.slice(0),o=new Uint8Array(e.buffer),e=i.value.slice(0),a=new Uint8Array(e.buffer)}M.paletteLut={red:r,green:o,blue:a}}const Z=e["00082144"];return void 0!==Z&&(M.RecommendedDisplayFrameRate=parseInt(Z.value[0],10)),x.setMeta(M),x}}function Qe(e,t){return JSON.stringify(e)===JSON.stringify(t)}function Me(e,t){const n=e[t.tag];if(1===t.type||2===t.type){if(void 0===n)throw new Error("Missing or empty "+t.name)}else if(void 0===n)return;let i,r=!1;if(i=1===n.value.length?n.value[0]:n.value,Array.isArray(i))for(let e=0;e.206896552?Math.pow(e,3):.128418549*e-.017712903,t}const n=p,i=(e.l+16)/116;return{x:n.x*t(i+e.a/500),y:n.y*t(i),z:n.z*t(i-e.b/200)}}(e))}({l:.001525902*(n={l:i[0],a:i[1],b:i[2]}).l,a:.003891051*n.a-128,b:.003891051*n.b-128});t.displayValue=r}var n;if(void 0===e["00620003"])throw Error("Missing Segmented Property Category Code Sequence.");if(t.propertyCategoryCode=Ne(e["00620003"].value[0]),void 0===e["0062000F"])throw Error("Missing Segmented Property Type Code Sequence.");return t.propertyTypeCode=Ne(e["0062000F"].value[0]),void 0!==e["00620020"]&&(t.trackingId=e["00620020"].value[0],t.trackingUid=e["00620021"].value[0]),t}function Ge(e){if(void 0===e["00280030"])return null;const t=e["00280030"],n=[parseFloat(t.value[0]),parseFloat(t.value[1])];return void 0!==e["00180050"]?n.push(parseFloat(e["00180050"].value[0])):void 0!==e["00180088"]&&n.push(parseFloat(e["00180088"].value[0])),new Ae(n)}function ke(e){const t=[];if(void 0!==e["00089124"]){const n=e["00089124"].value;for(let e=0;e1e-4;return t&&(t=e>.001,t?(t=e>.01,t||g.warn("Using larger+ real world epsilon in SEG pos pat adding")):g.warn("Using larger real world epsilon in SEG pos pat adding")),t},U=[];U.push(T[0]);let Q=0;for(let t=1;ta)throw new Error("Test distance is increasing when adding intermediate pos pats");U.push(T[t])}const M=U.length,B=new xe(x[0],r,b,w),N=[0];for(let e=1;e=this.#ae.numberOfFiles?g.warn("Ignoring frame at index "+t+" (size: "+this.#ae.numberOfFiles+")"):(this.#P.set(e,i*t),this.appendFrame(t,new O(0,0,0)))}appendFrame(e,t){this.#J.appendFrame(t,e),this.#ge({type:"appendframe"})}getDataRange(){return this.#se||(this.#se=this.calculateDataRange()),this.#se}getRescaledDataRange(){return this.#le||(this.#le=this.calculateRescaledDataRange()),this.#le}getHistogram(){if(!this.#ce){const e=this.calculateHistogram();this.#se=e.dataRange,this.#le=e.rescaledDataRange,this.#ce=e.histogram}return this.#ce}addEventListener(e,t){this.#ue.add(e,t)}removeEventListener(e,t){this.#ue.remove(e,t)}#ge=e=>{this.#ue.fireEvent(e)};setAtOffsets(e,t){let n;for(let i=0,r=e.length;i=3&&(r=i.getDimSize(3));for(let i=0;it&&(t=n),nn?t:n}}{let e=this.getRescaledValueAtOffset(0),t=e,n=0;const i=this.getGeometry().getSize();let r=i.getTotalSize();3===i.length()&&(r=i.getDimSize(3));for(let i=0;it&&(t=n),ni&&(i=r),ra&&(a=s),s{const t=this.getCurrentIndex();if(3===t.length()){const n=t.getValues();n.push(0),this.setCurrentIndex(new e(n))}}))}getImage(){return this.#me}setImage(e){this.#me=e}getOrientation(){return this.#_}setOrientation(e){this.#_=e}init(){this.setInitialIndex()}setInitialIndex(){const t=this.#me.getGeometry().getSize(),n=new Array(t.length());n.fill(0),n[0]=Math.floor(t.get(0)/2),n[1]=Math.floor(t.get(1)/2),n[2]=Math.floor(t.get(2)/2),this.setCurrentIndex(new e(n),!0)}getPlaybackMilliseconds(e){return e||(e=10),Math.round(1e3/e)}#Te=function(e,t){return 255};getAlphaFunction(){return this.#Te}setAlphaFunction(e){this.#Te=e,this.#ge({type:"alphafuncchange"})}getCurrentWindowLut(e){this.getCurrentIndex()||this.setInitialIndex();const t=this.getCurrentIndex();void 0===e&&(e=this.#me.getRescaleSlopeAndIntercept(t));let i=null;if(this.#De&&void 0!==this.#fe[this.#De]&&void 0!==this.#fe[this.#De].perslice&&!0===this.#fe[this.#De].perslice){const e=this.#me.getSecondaryOffset(t);i=this.#fe[this.#De].wl[e]}i||(this.#ye||this.setWindowLevelPresetById(0,!0),i=this.#ye);let r=this.#pe[e.toString()];if(void 0===r){const e=new n(this.#me.getRescaleSlopeAndIntercept(),this.#me.getMeta().BitsStored),t=new s(e,this.#me.getMeta().IsSigned);this.addWindowLut(t),r=t}const o=r.getWindowLevel();return i.equals(o)||(r.setWindowLevel(i),r.update(),o&&o.getWidth()===i.getWidth()&&o.getCenter()===i.getCenter()||this.#ge({type:"wlchange",value:[i.getCenter(),i.getWidth()],wc:i.getCenter(),ww:i.getWidth(),skipGenerate:!0})),r}addWindowLut(e){const t=e.getRescaleLut().getRSI();this.#pe[t.toString()]=e}getWindowPresets(){return this.#fe}getWindowPresetsNames(){return Object.keys(this.#fe)}setWindowPresets(e){this.#fe=e}setDefaultColourMap(e){this.#Ce=e}addWindowPresets(e){const t=Object.keys(e);let n=null;for(let i=0;i{this.#ue.fireEvent(e)};getWindowLevelMinMax(){const e=this.getImage().getRescaledDataRange(),t=e.min;let n=e.max-t;return n<1&&(g.warn("Zero or negative window width, defaulting to one."),n=1),new r(t+n/2,n)}setWindowLevelMinMax(){const e=this.getWindowLevelMinMax();this.setWindowLevel(e.getCenter(),e.getWidth(),"minmax")}generateImageData(e,t){void 0===t&&(this.getCurrentIndex()||this.setInitialIndex(),t=this.getCurrentIndex());const n=this.getImage(),i=Le(n,t,!1,this.getOrientation()),r=n.getPhotometricInterpretation();switch(r){case"MONOCHROME1":case"MONOCHROME2":!function(e,t,n,i,r){let o=0,a=0,s=t.next();for(;!s.done;)a=i.getValue(s.value),e.data[o]=r.red[a],e.data[o+1]=r.green[a],e.data[o+2]=r.blue[a],e.data[o+3]=n(s.value,s.index),o+=4,s=t.next()}(e,i,this.getAlphaFunction(),this.getCurrentWindowLut(),this.getColourMap());break;case"PALETTE COLOR":!function(e,t,n,i,r){const o=function(e){return e>>8};r&&g.info("Scaling 16bits data to 8bits.");let a=0,s=0,l=t.next();for(;!l.done;)s=l.value,r?(e.data[a]=o(i.red[s]),e.data[a+1]=o(i.green[s]),e.data[a+2]=o(i.blue[s])):(e.data[a]=i.red[s],e.data[a+1]=i.green[s],e.data[a+2]=i.blue[s]),e.data[a+3]=n(s,l.index),a+=4,l=t.next()}(e,i,this.getAlphaFunction(),this.getColourMap(),16===n.getMeta().BitsStored);break;case"RGB":!function(e,t,n){let i=0,r=t.next();for(;!r.done;)e.data[i]=r.value[0],e.data[i+1]=r.value[1],e.data[i+2]=r.value[2],e.data[i+3]=n(r.value,r.index),i+=4,r=t.next()}(e,i,this.getAlphaFunction());break;case"YBR_FULL":!function(e,t,n){let i=0,r=null,o=t.next();for(;!o.done;)a=o.value[0],s=o.value[1],r={r:a+1.402*((l=o.value[2])-128),g:a-.34414*(s-128)-.71414*(l-128),b:a+1.772*(s-128)},e.data[i]=r.r,e.data[i+1]=r.g,e.data[i+2]=r.b,e.data[i+3]=n(o.value,o.index),i+=4,o=t.next();var a,s,l}(e,i,this.getAlphaFunction());break;default:throw new Error("Unsupported photometric interpretation: "+r)}}incrementIndex(t,n){const i=this.getCurrentIndex(),r=new Array(i.length());r.fill(0),t