UNPKG

dwv

Version:
1,790 lines (1,762 loc) 207 kB
import Konva from 'konva'; /** * Add tags to the dictionary. * * @param {string} group The group key. * @param {Object<string, string[]>} 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: { [x: string]: string[]; }): void; /** * Image annotation. */ export declare class Annotation { /** * Tracking id, unique within domain. * * @type {string} */ trackingId: string; /** * Tracking Unique id. * * @type {string} */ trackingUid: string; /** * Referenced image SOP isntance UID. * * @type {string} */ referencedSopInstanceUID: string; /** * Referenced image SOP class UID. * * @type {string} */ referencedSopClassUID: string; /** * Referenced frame number. * * @type {number|undefined} */ referencedFrameNumber: number | undefined; /** * Mathematical shape. * * @type {object} */ mathShape: object; /** * Additional points used to define the annotation. * * @type {Point2D[]|undefined} */ referencePoints: Point2D[] | undefined; /** * Colour: for example 'green', '#00ff00' or 'rgb(0,255,0)'. * * @type {string} */ colour: string; /** * Annotation quantification. * * @type {Object<string, Value>|undefined} */ quantification: { [x: string]: Value; } | undefined; /** * Text expression. Can contain variables surrounded with '{}' that will * be extracted from the quantification object. * * @type {string} */ textExpr: string; /** * Label position. If undefined, the default shape * label position will be used. * * @type {Point2D|undefined} */ labelPosition: Point2D | undefined; /** * Plane origin: 3D position of index [0, 0, k]. * * @type {Point3D|undefined} */ planeOrigin: Point3D | undefined; /** * A couple of points that help define the annotation plane. * * @type {Point3D[]|undefined} */ planePoints: Point3D[] | undefined; /** * Get the concepts ids of the annotation meta data. * * @returns {string[]} The ids. */ getMetaConceptIds(): string[]; /** * Get an annotation meta data. * * @param {string} conceptId The value of the concept dicom code. * @returns {object|undefined} The corresponding meta data item * as {concept, value} or undefined. */ getMetaItem(conceptId: string): object | undefined; /** * Add annotation meta data. * * @param {DicomCode} concept The concept code. * @param {DicomCode|string} value The value code. */ addMetaItem(concept: DicomCode, value: DicomCode | string): void; /** * Remove an annotation meta data. * * @param {string} conceptId The value of the concept dicom code. */ removeMetaItem(conceptId: string): void; /** * Get the orientation name for this annotation. * * @returns {string|undefined} The orientation name, * undefined if same as reference data. */ getOrientationName(): string | undefined; /** * Initialise the annotation. * * @param {ViewController} viewController The associated view controller. */ init(viewController: ViewController): void; /** * Check if the annotation can be displayed: true if it has * an associated view controller. * * @returns {boolean} True if the annotation can be displayed. */ canView(): boolean; /** * Check if an input view is compatible with the annotation. * * @param {PlaneHelper} planeHelper The input view to check. * @returns {boolean} True if compatible view. */ isCompatibleView(planeHelper: PlaneHelper): boolean; /** * Set the associated view controller if it is compatible. * * @param {ViewController} viewController The view controller. */ setViewController(viewController: ViewController): void; /** * Get the centroid of the math shape. * * @returns {Point|undefined} The 3D centroid point. */ getCentroid(): Point | undefined; /** * Set the annotation text expression. * * @param {Object.<string, string>} labelText The list of label * texts indexed by modality. */ setTextExpr(labelText: { [x: string]: string; }): void; /** * Get the annotation label text by applying the * text expression on the current quantification. * * @returns {string} The resulting text. */ getText(): string; /** * Update the annotation quantification. */ updateQuantification(): void; /** * Get the math shape associated draw factory. * * @returns {object|undefined} The factory. */ getFactory(): object | undefined; #private; } /** * Annotation group. */ export declare class AnnotationGroup { /** * @param {Annotation[]} [list] Optional list, will * create new if not provided. */ constructor(list?: Annotation[]); /** * Get the annotation group as an array. * * @returns {Annotation[]} The array. */ getList(): Annotation[]; /** * Get the number of annotations of this list. * * @returns {number} The number of annotations. */ getLength(): number; /** * Check if the annotation group is editable. * * @returns {boolean} True if editable. */ isEditable(): boolean; /** * Set the annotation group editability. * * @param {boolean} flag True to make the annotation group editable. */ setEditable(flag: boolean): void; /** * Get the group colour. * * @returns {string} The colour as hex string. */ getColour(): string; /** * Set the group colour. * * @param {string} colour The colour as hex string. */ setColour(colour: string): void; /** * Add a new annotation. * * @param {Annotation} annotation The annotation to add. * @param {boolean} [propagate] Whether the event propagates * outside of dwv or not, defaults to true. */ add(annotation: Annotation, propagate?: boolean): void; /** * Update an existing annotation. * * @param {Annotation} annotation The annotation to update. * @param {string[]} [propKeys] Optional properties that got updated. * @param {boolean} [propagate] Whether the event propagates * outside of dwv or not, defaults to true. */ update(annotation: Annotation, propKeys?: string[], propagate?: boolean): void; /** * Remove an annotation. * * @param {string} uid The UID of the annotation to remove. * @param {boolean} [propagate] Whether the event propagates * outside of dwv or not, defaults to true. */ remove(uid: string, propagate?: boolean): void; /** * Set the associated view controller. * * @param {ViewController} viewController The associated view controller. */ setViewController(viewController: ViewController): void; /** * Find an annotation. * * @param {string} uid The UID of the annotation to find. * @returns {Annotation|undefined} The found annotation. */ find(uid: string): Annotation | undefined; /** * Get the meta data. * * @returns {Object<string, any>} The meta data. */ getMeta(): { [x: string]: any; }; /** * Check if this list contains a meta data value. * * @param {string} key The key to check. * @returns {boolean} True if the meta data is present. */ hasMeta(key: string): boolean; /** * Get a meta data value. * * @param {string} key The meta data key. * @returns {string|object|undefined} The meta data value. */ getMetaValue(key: string): string | object | undefined; /** * Set a meta data. * * @param {string} key The meta data key. * @param {string|object} value The value of the meta data. */ setMetaValue(key: string, value: string | object): void; /** * Add an event listener to this class. * * @param {string} type The event type. * @param {Function} callback The function associated with the provided * event type, will be called with the fired event. */ addEventListener(type: string, callback: Function): void; /** * Remove an event listener from this class. * * @param {string} type The event type. * @param {Function} callback The function associated with the provided * event type. */ removeEventListener(type: string, callback: Function): void; #private; } /** * {@link AnnotationGroup} factory. */ export declare class AnnotationGroupFactory { /** * Get a warning string if elements are not as expected. * Created by checkElements. * * @returns {string|undefined} The warning. */ getWarning(): string | undefined; /** * Check dicom elements. * * @param {Object<string, DataElement>} dataElements The DICOM data elements. * @returns {string|undefined} A possible warning. */ checkElements(dataElements: { [x: string]: DataElement; }): string | undefined; /** * Get an {@link AnnotationGroup} object from the read DICOM file. * * @param {Object<string, DataElement>} dataElements The DICOM tags. * @returns {AnnotationGroup} A new annotation group. * @throws {Error} Error for missing or wrong data. */ create(dataElements: { [x: string]: DataElement; }): AnnotationGroup; /** * Get an {@link CADReport} object from the read DICOM file. * * @param {Object<string, DataElement>} dataElements The DICOM tags. * @returns {CADReport|undefined} A new CAD report. */ createCADReport(dataElements: { [x: string]: DataElement; }): CADReport | undefined; /** * Convert an annotation group into a DICOM SR object using the * TID 1500 template. * * @param {AnnotationGroup} annotationGroup The annotation group. * @param {Object<string, any>} [extraTags] Optional list of extra tags. * @returns {Object<string, DataElement>} A list of dicom elements. */ toDicom(annotationGroup: AnnotationGroup, extraTags?: { [x: string]: any; }): { [x: string]: DataElement; }; /** * Convert a CAD report into a DICOM CAD report SR object using * the TID 4100 template. * * @param {CADReport} report The CAD report. * @param {Object<string, any>} [extraTags] Optional list of extra tags. * @returns {Object<string, DataElement>} A list of dicom elements. */ toDicomCADReport(report: CADReport, extraTags?: { [x: string]: any; }): { [x: string]: DataElement; }; #private; } /** * List of ViewConfigs indexed by dataIds. * * @typedef {Object<string, ViewConfig[]>} DataViewConfigs */ /** * Main application class. * * @example * import {App, AppOptions, ViewConfig} from '//esm.sh/dwv'; * // create the dwv app * const app = new App(); * // initialise * const viewConfig0 = new ViewConfig('layerGroup0'); * const viewConfigs = {'*': [viewConfig0]}; * const options = new AppOptions(viewConfigs); * app.init(options); * // load dicom data * app.loadURLs([ * 'https://raw.githubusercontent.com/ivmartel/dwv/master/tests/data/bbmri-53323851.dcm' * ]); */ export declare class App { /** * Get a DicomData. * * @param {string} dataId The data id. * @returns {DicomData|undefined} The data. */ getData(dataId: string): DicomData | undefined; /** * Get the image. * * @param {string} dataId The data id. * @returns {Image|undefined} The associated image. * @deprecated Since v0.34, please use the getData method. */ getImage(dataId: string): Image_2 | undefined; /** * Set the image at the given id. * * @param {string} dataId The data id. * @param {Image} img The associated image. */ setImage(dataId: string, img: Image_2): void; /** * Get the next data id. * * @returns {string} The data id. */ getNextDataId(): string; /** * Add a new DicomData. * * @param {string} dataId The data id. * @param {DicomData} data The new data. * @returns {boolean} False if the data cannot be added. */ addData(dataId: string, data: DicomData): boolean; /** * Get the meta data. * * @param {string} dataId The data id. * @returns {Object<string, DataElement>|undefined} The list of meta data. */ getMetaData(dataId: string): { [x: string]: DataElement; } | undefined; /** * Get the list of ids in the data storage. * * @returns {string[]} The list of data ids. */ getDataIds(): string[]; /** * 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[]; /** * Get the first data id with the given SeriesInstanceUID. * * @param {string} uid The SeriesInstanceUID. * @returns {string} The data id. */ getDataIdFromSeriesUid(uid: 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 Since v0.33, please use the ViewController * equivalent directly instead. */ canScroll(): boolean; /** * 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 Since v0.33, please use the ViewController * equivalent directly instead. */ canWindowLevel(): boolean; /** * Get the active layer group scale on top of the base scale. * * @returns {Scalar3D} The scale as {x,y,z}. */ getAddedScale(): Scalar3D; /** * Get the base scale of the active layer group. * * @returns {Scalar3D} The scale as {x,y,z}. */ getBaseScale(): Scalar3D; /** * Get the layer offset of the active layer group. * * @returns {Scalar3D} The offset as {x,y,z}. */ getOffset(): Scalar3D; /** * Get the toolbox controller. * * @returns {ToolboxController} The controller. */ getToolboxController(): ToolboxController; /** * Get the active layer group. * The layer is available after the first loaded item. * * @returns {LayerGroup|undefined} The layer group. */ getActiveLayerGroup(): LayerGroup | undefined; /** * Set the active layer group. * * @param {number} index The layer group index. */ setActiveLayerGroup(index: number): void; /** * Get the view layers associated to a data id. * The layer are available after the first loaded item. * * @param {string} dataId The data id. * @returns {ViewLayer[]} The layers. */ getViewLayersByDataId(dataId: string): ViewLayer[]; /** * Get a list of view layers according to an input callback function. * * @param {Function} [callbackFn] A function that takes * a ViewLayer as input and returns a boolean. If undefined, * returns all view layers. * @returns {ViewLayer[]} The layers that * satisfy the callbackFn. */ getViewLayers(callbackFn?: Function): ViewLayer[]; /** * Get the draw layers associated to a data id. * The layer are available after the first loaded item. * * @param {string} dataId The data id. * @returns {DrawLayer[]} The layers. */ getDrawLayersByDataId(dataId: string): DrawLayer[]; /** * Get a list of draw layers according to an input callback function. * * @param {Function} [callbackFn] A function that takes * a DrawLayer as input and returns a boolean. If undefined, * returns all draw layers. * @returns {DrawLayer[]} The layers that * satisfy the callbackFn. */ getDrawLayers(callbackFn?: Function): DrawLayer[]; /** * Get a layer group by div id. * The layer is available after the first loaded item. * * @param {string} divId The div id. * @returns {LayerGroup|undefined} The layer group. */ getLayerGroupByDivId(divId: string): LayerGroup | undefined; /** * Get the number of layer groups. * * @returns {number} The number of groups. */ getNumberOfLayerGroups(): number; /** * Get the app style. * * @returns {object} The app style. */ getStyle(): object; /** * Add a command to the undo stack. * * @param {Command} cmd The command to add. * @fires UndoStack#undoadd * @function */ addToUndoStack: (cmd: Command) => void; /** * Remove a command from the undo stack. * * @param {string} name The name of the command to remove. * @returns {boolean} True if the command was found and removed. * @fires UndoStack#undoremove * @function */ removeFromUndoStack: (name: string) => boolean; /** * Initialise the application. * * @param {AppOptions} opt The application options. * @example * import {App, AppOptions, ViewConfig} from '//esm.sh/dwv'; * // create the dwv app * const app = new App(); * // initialise * const viewConfig0 = new ViewConfig('layerGroup0'); * const viewConfigs = {'*': [viewConfig0]}; * const options = new AppOptions(viewConfigs); * options.viewOnFirstLoadItem = false; * app.init(options); * // render button * const button = document.createElement('button'); * button.id = 'render'; * button.disabled = true; * button.appendChild(document.createTextNode('render')); * document.body.appendChild(button); * app.addEventListener('load', function () { * const button = document.getElementById('render'); * button.disabled = false; * button.onclick = function () { * // render data #0 * app.render(0); * }; * }); * // load dicom data * app.loadURLs([ * 'https://raw.githubusercontent.com/ivmartel/dwv/master/tests/data/bbmri-53323851.dcm' * ]); */ init(opt: AppOptions): void; /** * Reset the application. */ reset(): void; /** * Reset the layout of the application. * * @deprecated Since v0.35, prefer resetZoomPan. */ resetLayout(): void; /** * Reset the zoom and pan of the stage. */ resetZoomPan(): void; /** * Reset the position and window level of the stage. */ resetViews(): void; /** * Add an event listener to this class. * * @param {string} type The event type. * @param {Function} callback The function associated with the provided * event type, will be called with the fired event. */ addEventListener(type: string, callback: Function): void; /** * Remove an event listener from this class. * * @param {string} type The event type. * @param {Function} callback The function associated with the provided * event type. */ removeEventListener(type: string, callback: Function): void; /** * Load a list of files. Can be image files or a state file. * * @param {File[]} files The list of files to load. * @returns {string} The data ID, '-1' if problem. * @fires App#loadstart * @fires App#loadprogress * @fires App#loaditem * @fires App#loadend * @fires App#error * @fires App#abort * @function */ loadFiles: (files: File[]) => string; /** * Load a list of URLs. Can be image files or a state file. * * @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. * @returns {string} The data ID, '-1' if problem. * @fires App#loadstart * @fires App#loadprogress * @fires App#loaditem * @fires App#loadend * @fires App#error * @fires App#abort * @function */ loadURLs: (urls: string[], options?: object) => string; /** * Load from an input uri. * * @param {string} uri The input uri, for example: 'window.location.href'. * @param {object} [options] Optional url request options. * @deprecated Since v0.36, please extract the file list and * pass it to loadURLs. State from uri is no longer supported. * @function */ loadFromUri: (uri: string, options?: object) => void; /** * Load a list of ArrayBuffers. * * @param {Array} data The list of ArrayBuffers to load * in the form of [{name: "", filename: "", data: data}]. * @returns {string} The data ID. * @fires App#loadstart * @fires App#loadprogress * @fires App#loaditem * @fires App#loadend * @fires App#error * @fires App#abort * @function */ loadImageObject: (data: any[]) => string; /** * Abort all the current loads. */ abortAllLoads(): void; /** * Abort an individual data load. * * @param {string} dataId The data to stop loading. */ abortLoad(dataId: string): void; /** * Fit the display to the data of each layer group. * To be called once the image is loaded. */ fitToContainer(): void; /** * Init the Window/Level display * (of the active layer of the active layer group). * * @deprecated Since v0.33, 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. * * @returns {Object<string, ViewConfig[]>} The configuration list. */ getDataViewConfigs(): { [x: string]: ViewConfig[]; }; /** * Set the data view configuration. * Resets the stage and recreates all the views. * * @param {Object<string, ViewConfig[]>} configs The configuration list. */ setDataViewConfigs(configs: { [x: string]: ViewConfig[]; }): void; /** * Add a data view config. * * @param {string} dataId The data id. * @param {ViewConfig} config The view configuration. * @param {boolean} [doRender] Render data after configuration * add. Defaults to true. */ addDataViewConfig(dataId: string, config: ViewConfig, doRender?: boolean): void; /** * Remove a data view config. * Removes the associated layer if found, removes * the layer group if empty. * * @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 {string[]} list The list of binder names. */ setLayerGroupsBinders(list: string[]): void; /** * Render the current data. * * @param {string} dataId The data id to render. * @param {ViewConfig[]} [viewConfigs] The list of configs to render. */ render(dataId: string, viewConfigs?: ViewConfig[]): void; /** * 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. * @param {number} cy The zoom center Y coordinate. */ zoom(step: number, cx: number, cy: number): void; /** * 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; /** * Resample one image to match the orientation of another. * * @param {string} dataIdTarget The target image id to resample. * @param {string} dataIdSource The source image id to copy the * orientation from. */ resampleMatch(dataIdTarget: string, dataIdSource: string): void; /** * Resample an image to match an arbitrary orientation. * * @param {string} dataIdTarget The target image id to resample. * @param {Matrix33} orientation The orientation to resample to. */ resample(dataIdTarget: string, orientation: Matrix33): void; /** * Revert an image back to its original orientation. * * @param {string} dataIdTarget The target image id to revert. */ revertResample(dataIdTarget: string): void; /** * Set the active view layer (of the active layer group) opacity. * * @param {number} alpha The opacity ([0:1] range). * @deprecated Since v0.33, pplease set the opacity * of the desired view layer directly. */ setOpacity(alpha: number): void; /** * Set the drawings of the active layer group. * * @deprecated Since v0.34, please switch to DICOM SR annotations. * @param {Array} drawings An array of drawings. * @param {Array} drawingsDetails An array of drawings details. * @param {string} dataId The converted data id. */ setDrawings(drawings: any[], drawingsDetails: any[], dataId: string): void; /** * Apply a JSON state to this app. * * @deprecated Since v0.34, please switch to DICOM SR * for annotations. * @param {string} jsonState The state of the app as a JSON string. * @param {string} dataId The state data id. */ applyJsonState(jsonState: string, dataId: string): void; /** * Handle resize: fit the display to the window. * To be called once the image is loaded. * Can be connected to a window 'resize' event. * * @function */ onResize: () => void; /** * Key down callback. Meant to be used in tools. * * @param {KeyboardEvent} event The key down event. * @fires App#keydown * @function */ 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. * * Applies to the active view of the active layer group. * * @param {KeyboardEvent} event The key down event. * @fires UndoStack#undo * @fires UndoStack#redo * @function */ defaultOnKeydown: (event: KeyboardEvent) => void; /** * Reset the display. */ resetDisplay(): void; /** * Reset the app zoom. */ resetZoom(): void; /** * Set the colour map of the active view of the active layer group. * * @param {string} name The colour map name. * @deprecated Since v0.33, please use the ViewController * equivalent directly instead. */ setColourMap(name: string): void; /** * Set the window/level preset of the active view of the active layer group. * * @param {string} preset The window/level preset. * @deprecated Since v0.33, please use the ViewController * equivalent directly instead. */ setWindowLevelPreset(preset: string): void; /** * Set the tool. * * @param {string} tool The tool. */ setTool(tool: string): void; /** * Set the tool live features. * * @param {object} list The list of features. */ setToolFeatures(list: object): void; /** * Undo the last action. * * @fires UndoStack#undo */ undo(): void; /** * Redo the last action. * * @fires UndoStack#redo */ redo(): void; /** * Get the undo stack size. * * @returns {number} The size of the stack. */ getStackSize(): number; /** * Get the current undo stack index. * * @returns {number} The stack index. */ getCurrentStackIndex(): number; /** * Get the info data for a data id. * * @param {string} dataId The data id. * @returns {InfoData|undefined} The info data. */ getInfoData(dataId: string): InfoData | undefined; /** * Toggle info data listeners. * * @param {string} dataId The data id. */ toggleInfoDataListeners(dataId: string): void; /** * Create new annotation data based on the data of * the active view layer. * * @param {string} refDataId The reference data id. * @returns {DicomData} The new data. */ createAnnotationData(refDataId: string): DicomData; /** * Add new data and render it with a simple new data view config. * * @param {DicomData} data The data to add. * @param {string} divId The div where to draw. * @param {string} refDataId The reference data id. */ addAndRenderAnnotationData(data: DicomData, divId: string, refDataId: string): void; /** * Add a draw layer. * * @param {string} dataId The data id. * @param {ViewConfig} viewConfig The data view config. */ addDrawLayer(dataId: string, viewConfig: ViewConfig): void; #private; } /** * Application options. */ export declare class AppOptions { /** * @param {Object<string, ViewConfig[]>} [dataViewConfigs] Optional dataId * indexed object containing the data view configurations. */ constructor(dataViewConfigs?: { [x: string]: ViewConfig[]; }); /** * DataId indexed object containing the data view configurations. * * @type {Object<string, ViewConfig[]>|undefined} */ dataViewConfigs: { [x: string]: ViewConfig[]; } | undefined; /** * Tool name indexed object containing individual tool configurations. * * @type {Object<string, ToolConfig>|undefined} */ tools: { [x: string]: ToolConfig; } | undefined; /** * Optional array of layerGroup binder names. * * @type {string[]|undefined} */ binders: string[] | undefined; /** * Optional boolean flag to trigger the first data render * after the first loaded data or not. Defaults to true. * * @type {boolean|undefined} */ viewOnFirstLoadItem: boolean | undefined; /** * 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 layer config. * * @type {object|undefined} */ overlayConfig: object | undefined; /** * DOM root document. * * @type {DocumentFragment} */ rootDocument: DocumentFragment; } /** * Class to store a boolean result and a message. */ export declare class BooleanResult { /** * @param {boolean} success The success flag. */ constructor(success: boolean); /** * @type {boolean} */ success: boolean; /** * @type {string|undefined} */ message: string | undefined; } /** * Build a multipart message. * * 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). * @param {string} boundary The message boundary. * @returns {Uint8Array} The full multipart message. */ export declare function buildMultipart(parts: any[], boundary: string): Uint8Array; /** * CAD report class. */ export declare class CADReport { /** * @type {AnnotationGroup[]} */ annotationGroups: AnnotationGroup[]; /** * @type {ResponseEvaluation[]} */ responseEvaluations: ResponseEvaluation[]; /** * @type {string} */ comment: string; } /** * Change segment colour command. */ export declare class ChangeSegmentColourCommand extends Command { /** * @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); /** * Check if a command is valid and can be executed. * * @returns {boolean} True if the command is valid. */ isValid(): boolean; /** * 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; } /** * Circle shape. */ export declare class Circle { /** * @param {Point2D} centre A Point2D representing the centre * of the circle. * @param {number} radius The radius of the circle. */ constructor(centre: Point2D, radius: number); /** * Get the centre (point) of the circle. * * @returns {Point2D} The center (point) of the circle. */ getCenter(): Point2D; /** * Get the centroid of the circle. * * @returns {Point2D} The centroid point. */ getCentroid(): Point2D; /** * Get the radius of the circle. * * @returns {number} The radius of the circle. */ getRadius(): number; /** * Check for equality. * * @param {Circle} rhs The object to compare to. * @returns {boolean} True if both objects are equal. */ equals(rhs: Circle): boolean; /** * Get the surface of the circle. * * @returns {number} The surface of the circle. */ getSurface(): number; /** * Get the surface of the circle according to a spacing. * * @param {Scalar2D} spacing2D The 2D spacing. * @returns {number} The surface of the circle multiplied by the given * spacing or null for null spacings. */ getWorldSurface(spacing2D: Scalar2D): number; /** * Get the rounded limits of the circle. * * See: {@link https://en.wikipedia.org/wiki/Circle#Equations}. * * Circle formula: `x*x + y*y = r*r`. * * Implies: `y = (+-) sqrt(r*r - x*x)`. * * @returns {number[][][]} The rounded limits: * list of [x, y] pairs (min, max). */ getRound(): number[][][]; /** * Quantify an circle according to view information. * * @param {ViewController} viewController The associated view controller. * @param {Index} index The index at which to get the * image values. * @param {string[]} flags A list of stat values to calculate. * @returns {Object<string, Value>} A quantification object. */ quantify(viewController: ViewController, index: Index, flags: string[]): { [x: string]: Value; }; #private; } /** * Colour map: red, green and blue components * to associate with intensity values. */ export declare class ColourMap { /** * @param {number[]} red Red component. * @param {number[]} green Green component. * @param {number[]} blue Blue component. */ constructor(red: number[], green: number[], blue: number[]); /** * Red component: 256 values in the [0, 255] range. * * @type {number[]} */ red: number[]; /** * Green component: 256 values in the [0, 255] range. * * @type {number[]} */ green: number[]; /** * Blue component: 256 values in the [0, 255] range. * * @type {number[]} */ blue: number[]; } /** * Command interface. */ export declare class Command { /** * Get the command name. * * @returns {string} The command name. */ getName(): string; /** * Execute the command. */ execute(): void; /** * Undo the command. */ undo(): void; } /** * Create an Image from DICOM elements. * * @param {Object<string, DataElement>} elements The DICOM elements. * @returns {Image} The Image object. */ export declare function createImage(elements: { [x: string]: DataElement; }): Image_2; /** * Create a mask Image from DICOM elements. * * @param {Object<string, DataElement>} elements The DICOM elements. * @returns {Image} The mask Image object. */ export declare function createMaskImage(elements: { [x: string]: DataElement; }): Image_2; /** * Create a View from DICOM elements and image. * * @param {Object<string, DataElement>} elements The DICOM elements. * @param {Image} image The associated image. * @returns {View} The View object. */ export declare function createView(elements: { [x: string]: DataElement; }, image: Image_2): View; export declare namespace custom { let wlPresets: { [x: string]: { [x: string]: WindowLevel; }; }; let labelTexts: { [x: string]: { [x: string]: string; }; }; let privateBValueRules: object[]; let openRoiDialog: any; let getVolumeIdTagValue: any; let getPostLoadVolumeIdTagValue: any; let getTagPixelUnit: any; } /** * DICOM data element. */ export declare class DataElement { /** * @param {string} vr The element VR (Value Representation). */ constructor(vr: string); /** * The element Value Representation. * * @type {string} */ vr: string; /** * The element value. * * @type {Array} */ value: any[]; /** * The element dicom tag. * * @type {Tag} */ tag: Tag; /** * The element Value Length. * * @type {number} */ vl: number; /** * Flag to know if defined or undefined sequence length. * * @type {boolean} */ undefinedLength: boolean; /** * The element start offset. * * @type {number} */ startOffset: number; /** * The element end offset. * * @type {number} */ endOffset: number; /** * The sequence items. * * @type {Array} */ items: any[]; } /** * Default tool list. * * @type {Object<string, any>} */ export declare const defaultToolList: { [x: string]: any; }; /** * Default tool options. * * @type {Object<string, Object<string, any>>} */ export declare const defaultToolOptions: { [x: string]: { [x: string]: any; }; }; /** * Delete segment command. */ export declare class DeleteSegmentCommand extends Command { /** * @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); /** * Check if a command is valid and can be executed. * * @returns {boolean} True if the command is valid. */ isValid(): boolean; /** * 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; } /** * Diameter type. */ export declare class Diameter { /** * The scaled diameter value. * * @type {Value} */ diameter: Value; /** * The offset of the pixel at the start * of the line used to calculate this diameter. * * @type {number} */ offset1: number; /** * The offset of the pixel at the end * of the line used to calculate this diameter. * * @type {number} */ offset2: number; } /** * Diameters type. */ export declare class Diameters { /** * The major (longest) diameter of the segment. * * @type {Diameter} */ major: Diameter; /** * The minor (longest perpendicular to the major) diameter of the segment. * * @type {Diameter} */ minor: Diameter; } /** * 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. * * @type {string} */ meaning: string; /** * Code value. * * @type {string|undefined} */ value: string | undefined; /** * Long code value. * * @type {string|undefined} */ longValue: string | undefined; /** * URN code value. * * @type {string|undefined} */ urnValue: string | undefined; /** * Coding scheme designator. * * @type {string|undefined} */ schemeDesignator: string | undefined; /** * Get a string representation of this object. * * @returns {string} The code as string. */ toString(): string; } /** * DICOM data: meta and possible image. */ export declare class DicomData { /** * @param {Object<string, DataElement>} meta The DICOM meta data. */ constructor(meta: { [x: string]: DataElement; }); /** * DICOM meta data. * * @type {Object<string, DataElement>} */ meta: { [x: string]: DataElement; }; /** * Image extracted from meta data. * * @type {Image|undefined} */ image: Image_2 | undefined; /** * Annotattion group extracted from meta data. * * @type {AnnotationGroup|undefined} */ annotationGroup: AnnotationGroup | undefined; /** * Image buffer used to build image. * * @type {any|undefined} */ buffer: any | undefined; /** * Number of files/urls associated to the data. * * @type {number} */ numberOfFiles: number; /** * List of data creation warning. * * @type {string[]} */ warn: string[]; /** * Get the image complete flag (for image data). * * @returns {boolean|undefined} True if the image is complete. */ getComplete(): boolean | undefined; /** * Set the image complete flag (for image data). * * @param {boolean} flag True if the image is complete. */ setComplete(flag: boolean): void; /** * Get the duplicate origin flag. * * @returns {boolean} The flag. */ hasDuplicateOrigin(): boolean; /** * Append slice and update meta data. * * @param {DicomData} data The data to append. */ appendData(data: DicomData): void; #private; } /** * DicomParser class. * * @example * import {DicomParser} from '//esm.sh/dwv'; * // XMLHttpRequest onload callback * const onload = function (event) { * // setup the dicom parser * const dicomParser = new DicomParser(); * // parse the buffer * dicomParser.parse(event.target.response); * // get the dicom tags * const tags = dicomParser.getDicomElements(); * // display the modality * const div = document.getElementById('dwv'); * div.appendChild(document.createTextNode( * 'Modality: ' + tags['00080060'].value[0] * )); * }; * // DICOM file request * const request = new XMLHttpRequest(); * const url = 'https://raw.githubusercontent.com/ivmartel/dwv/master/tests/data/bbmri-53323851.dcm'; * request.open('GET', url); * request.responseType = 'arraybuffer'; * request.onload = onload; * request.send(); */ export declare class DicomParser { /** * Get the default character set. * * @returns {string} The default character set. */ getDefaultCharacterSet(): string; /** * Set the default character set. * * @param {string} characterSet The input character set. */ setDefaultCharacterSet(characterSet: string): void; /** * Set the text decoder character set. * * @param {string} characterSet The input character set. */ setDecoderCharacterSet(characterSet: string): void; /** * Get the DICOM data elements. * * @returns {Object<string, DataElement>} The data elements. */ getDicomElements(): { [x: string]: DataElement; }; /** * Safely get an elements' first value from the parsed elements. * * @param {string} key The tag key as for example '00100020'. * @returns {any|undefined} The elements' value or undefined. */ safeGet(key: string): any | undefined; /** * Parse a DICOM buffer. * Fills in the member object 'dataElements'. * * @param {ArrayBuffer} buffer The input array buffer. * @param {Tag} [untilTag] Optional tag to stop the parsing once reached. */ parse(buffer: ArrayBuffer, untilTag?: Tag): void; #private; } /** * DICOM SR content: item of a SR content sequence. * * Ref: {@link https://dicom.nema.org/medical/dicom/2022a/output/chtml/part03/sect_C.17.3.html}. */ export declare class DicomSRContent { /** * @param {string} valueType The content item value type. */ constructor(valueType: string); /** * Value type. * * @type {string} */ valueType: string; /** * Concept name code. * * @type {DicomCode|undefined} */ conceptNameCode: DicomCode | undefined; /** * Relationship Type. * * @type {string} */ relationshipType: string; /** * Content sequence. * * @type {DicomSRContent[]} */ contentSequence: DicomSRContent[]; /** * Value. * * @type {object} */ value: object; /** * Get a string representation of this object. * * @param {string} [prefix] An optional prefix for recursive content. * @returns {string} The object as string. */ toString(prefix?: string): string; /** * Check if this content has input header values. * * @param {string} valueType The value type. * @param {DicomCode} conceptNameCode The concept name code. * @param {string} relationshipType The relationship type. * @returns {boolean} True if equal. */ hasHeader(valueType: string, conceptNameCode: DicomCode, relationshipType: string): boolean; } /** * DICOM writer. * * @example * import {DicomParser, DicomWriter} from '//esm.sh/dwv'; * // add link to html * const link = document.createElement("a"); * link.appendChild(document.createTextNode("download")); * const div = document.getElementById("dwv"); * div.appendChild(link); * // XMLHttpRequest onload callback * const onload = function (event) { * const parser = new DicomParser(); * parser.parse(event.target.response); * // create writer * const writer = new DicomWriter(); * // get buffer using default rules * const dicomBuffer = writer.getBuffer(parser.getDicomElements()); * // create blob * const blob = new Blob([dicomBuffer], {type: 'application/dicom'}); * // add blob to download link * link.href = URL.createObjectURL(blob); * link.download = "anonym.dcm"; * }; * // DICOM file request * const request = new XMLHttpRequest(); * const url = 'https://raw.githubusercontent.com/