dwv
Version:
DICOM Web Viewer.
1,785 lines (1,758 loc) • 176 kB
TypeScript
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 {
/**
* The ID.
*
* @type {string}
*/
id: string;
/**
* The reference image SOP UID.
*
* @type {string}
*/
referenceSopUID: string;
/**
* The mathematical shape.
*
* @type {object}
*/
mathShape: object;
/**
* Additional points used to define the annotation.
*
* @type {Point2D[]|undefined}
*/
referencePoints: Point2D[] | undefined;
/**
* The color: for example 'green', '#00ff00' or 'rgb(0,255,0)'.
*
* @type {string|undefined}
*/
colour: string | undefined;
/**
* Annotation quantification.
*
* @type {object|undefined}
*/
quantification: object | undefined;
/**
* Text expression. Can contain variables surrounded with '{}' that will
* be extracted from the quantification object.
*
* @type {string|undefined}
*/
textExpr: string | undefined;
/**
* Label position. If undefined, the default shape
* label position will be used.
*
* @type {Point2D|undefined}
*/
labelPosition: Point2D | undefined;
/**
* The plane origin, the 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 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 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} The factory.
*/
getFactory(): object;
#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.
*/
add(annotation: Annotation): void;
/**
* Update an existing annotation.
*
* @param {Annotation} annotation The annotation to update.
* @param {string[]} [propKeys] Optional properties that got updated.
*/
update(annotation: Annotation, propKeys?: string[]): void;
/**
* Remove an annotation.
*
* @param {string} id The id of the annotation to remove.
*/
remove(id: string): void;
/**
* Set the associated view controller.
*
* @param {ViewController} viewController The associated view controller.
*/
setViewController(viewController: ViewController): void;
/**
* Find an annotation.
*
* @param {string} id The id of the annotation to find.
* @returns {Annotation|undefined} The found annotation.
*/
find(id: 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} The meta data value.
*/
getMetaValue(key: string): string | object;
/**
* 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. Throws an error if not suitable.
*
* @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 Annotation} object from the read DICOM file.
*
* @param {Object<string, DataElement>} dataElements The DICOM tags.
* @returns {AnnotationGroup} A new annotation group.
*/
create(dataElements: {
[x: string]: DataElement;
}): AnnotationGroup;
/**
* Convert an annotation group into a DICOM SR object.
*
* @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;
};
#private;
}
/**
* List of ViewConfigs indexed by dataIds.
*
* @typedef {Object<string, ViewConfig[]>} DataViewConfigs
*/
/**
* Main application class.
*
* @example
* // create the dwv app
* const app = new dwv.App();
* // initialise
* const viewConfig0 = new dwv.ViewConfig('layerGroup0');
* const viewConfigs = {'*': [viewConfig0]};
* const options = new dwv.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;
/**
* Add a new DicomData.
*
* @param {DicomData} data The new data.
* @returns {string} The data id.
*/
addData(data: DicomData): string;
/**
* 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[];
/**
* 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} The layer group.
*/
getLayerGroupByDivId(divId: string): LayerGroup;
/**
* 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 {object} cmd The command to add.
* @fires UndoStack#undoadd
* @function
*/
addToUndoStack: (cmd: object) => 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
* // create the dwv app
* const app = new dwv.App();
* // initialise
* const viewConfig0 = new dwv.ViewConfig('layerGroup0');
* const viewConfigs = {'*': [viewConfig0]};
* const options = new dwv.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.
*/
resetLayout(): 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.
* @fires App#loadstart
* @fires App#loadprogress
* @fires App#loaditem
* @fires App#loadend
* @fires App#error
* @fires App#abort
* @function
*/
loadFiles: (files: File[]) => void;
/**
* 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.
* @fires App#loadstart
* @fires App#loadprogress
* @fires App#loaditem
* @fires App#loadend
* @fires App#error
* @fires App#abort
* @function
*/
loadURLs: (urls: string[], options?: object) => void;
/**
* Load from an input uri.
*
* @param {string} uri The input uri, for example: 'window.location.href'.
* @param {object} [options] Optional url request options.
* @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}].
* @fires App#loadstart
* @fires App#loadprogress
* @fires App#loaditem
* @fires App#loadend
* @fires App#error
* @fires App#abort
* @function
*/
loadImageObject: (data: any[]) => void;
/**
* 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.
*/
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 {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;
/**
* 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 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;
/**
* 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 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.
*
* 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;
/**
* 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;
}
/**
* 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 {string[]} flags A list of stat values to calculate.
* @returns {object} A quantification object.
*/
quantify(viewController: ViewController, flags: string[]): object;
#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[];
}
/**
* 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 customUI {
/**
* Open a dialogue to edit roi data. Defaults to window.prompt.
*
* @param {Annotation} annotation The roi data.
* @param {Function} callback The callback to launch on dialogue exit.
*/
export function openRoiDialog(annotation: Annotation, callback: Function): void;
}
/**
* 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[];
}
/**
* Decoder scripts to be passed to web workers for image decoding.
*/
export declare const decoderScripts: {
jpeg2000: string;
'jpeg-lossless': string;
'jpeg-baseline': string;
rle: string;
};
/**
* List of default window level presets.
*
* @type {Object.<string, Object.<string, WindowLevel>>}
*/
export declare const defaultPresets: {
[x: string]: {
[x: string]: WindowLevel;
};
};
export declare namespace defaults {
let labelText: {
[x: string]: {
[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.
*
* @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} meta The DICOM meta data.
*/
constructor(meta: object);
/**
* DICOM meta data.
*
* @type {object}
*/
meta: object;
/**
* Image extracted from meta data.
*
* @type {Image|undefined}
*/
image: Image_2 | undefined;
/**
* Annotattion group extracted from meta data.
*
* @type {AnnotationGroup|undefined}
*/
annotationGroup: AnnotationGroup | undefined;
}
/**
* DicomParser class.
*
* @example
* // XMLHttpRequest onload callback
* const onload = function (event) {
* // setup the dicom parser
* const dicomParser = new dwv.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;
};
/**
* Parse the complete DICOM file (given as input to the class).
* Fills in the member object 'dataElements'.
*
* @param {ArrayBuffer} buffer The input array buffer.
*/
parse(buffer: ArrayBuffer): 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 (0040,A730).
*
* @type {DicomSRContent[]|undefined}
*/
contentSequence: DicomSRContent[] | undefined;
/**
* 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;
}
/**
* DICOM writer.
*
* @example
* // 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 dwv.DicomParser();
* parser.parse(event.target.response);
* // create writer
* const writer = new dwv.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/ivmartel/dwv/master/tests/data/bbmri-53323851.dcm';
* request.open('GET', url);
* request.responseType = 'arraybuffer';
* request.onload = onload;
* request.send();
*/
export declare class DicomWriter {
/**
* Set the use UN VR for private sequence flag.
*
* @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`,
* tagKey, tagName or groupName.
* Each DICOM element will be checked to see if a rule is applicable.
* First checked by tagKey, tagName and then by groupName,
* if nothing is found the default rule is applied.
*
* @param {Object<string, WriterRule>} 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;
}, addMissingTags?: boolean): void;
/**
* Use a TextEncoder instead of the default text decoder.
*/
useSpecialTextEncoder(): void;
/**
* Get the element to write according to the class rules.
* Priority order: tagName, groupName, default.
*
* @param {DataElement} element The element to check.
* @returns {DataElement|null} The element to write, can be null.
*/
getElementToWrite(element: DataElement): DataElement | null;
/**
* Get the ArrayBuffer corresponding to input DICOM elements.
*
* @param {Object<string, DataElement>} dataElements The elements to write.
* @returns {ArrayBuffer} The elements as a buffer.
*/
getBuffer(dataElements: {
[x: string]: DataElement;
}): ArrayBuffer;
#private;
}
/**
* Draw controller.
*/
export declare class DrawController {
/**
* @param {AnnotationGroup} [group] Optional annotation group.
*/
constructor(group?: AnnotationGroup);
/**
* Get an annotation.
*
* @param {string} id The annotation id.
* @returns {Annotation|undefined} The annotation.
*/
getAnnotation(id: string): Annotation | undefined;
/**
* Get the annotation group.
*
* @returns {AnnotationGroup} The list.
*/
getAnnotationGroup(): AnnotationGroup;
/**
* Check if the annotation group is editable.
*
* @returns {boolean} True if editable.
*/
isAnnotationGroupEditable(): boolean;
/**
* Set the annotation group editability.
*
* @param {boolean} flag True to make the annotation group editable.
*/
setAnnotationGroupEditable(flag: boolean): void;
/**
* Add an annotation.
*
* @param {Annotation} annotation The annotation to add.
*/
addAnnotation(annotation: Annotation): void;
/**
* Update an anotation from the list.
*
* @param {Annotation} annotation The annotation to update.
* @param {string[]} [propKeys] Optional properties that got updated.
*/
updateAnnotation(annotation: Annotation, propKeys?: string[]): void;
/**
* Remove an anotation for the list.
*
* @param {string} id The id of the annotation to remove.
*/
removeAnnotation(id: string): void;
/**
* Remove an annotation via a remove command (triggers draw actions).
*
* @param {string} id The annotation id.
* @param {Function} exeCallback The undo stack callback.
*/
removeAnnotationWithCommand(id: string, exeCallback: Function): void;
/**
* Update an annotation via an update command (triggers draw actions).
*
* @param {string} id The annotation id.
* @param {object} originalProps The original annotation properties
* that will be updated.
* @param {object} newProps The new annotation properties
* that will replace the original ones.
* @param {Function} exeCallback The undo stack callback.
*/
updateAnnotationWithCommand(id: string, originalProps: object, newProps: object, exeCallback: Function): void;
/**
* Remove all annotations via remove commands (triggers draw actions).
*
* @param {Function} exeCallback The undo stack callback.
*/
removeAllAnnotationsWithCommand(exeCallback: Function): void;
/**
* Check if the annotation group contains a meta data value.
*
* @param {string} key The key to check.
* @returns {boolean} True if the meta data is present.
*/
hasAnnotationMeta(key: string): boolean;
/**
* Set an annotation meta data.
*
* @param {string} key The meta data to set.
* @param {string} value The value of the meta data.
*/
setAnnotationMeta(key: string, value: string): void;
#private;
}
/**
* Debug function to output the layer hierarchy as text.
*
* @param {object} layer The Konva layer.
* @param {string} prefix A display prefix (used in recursion).
* @returns {string} A text representation of the hierarchy.
*/
/**
* Draw layer.
*/
export declare class DrawLayer {
/**
* @param {HTMLDivElement} containerDiv The layer div, its id will be used
* as this layer id.
*/
constructor(containerDiv: HTMLDivElement);
/**
* Set the draw shape handler.
*
* @param {DrawShapeHandler|undefined} handler The shape handler.
*/
setShapeHandler(handler: DrawShapeHandler | undefined): void;
/**
* Get the associated data id.
*
* @returns {string} The id.
*/
getDataId(): string;
/**
* Get the reference data id.
*
* @returns {string} The id.
*/
getReferenceLayerId(): string;
/**
* Get the Konva stage.
*
* @returns {Konva.Stage} The stage.
*/
getKonvaStage(): Konva.Stage;
/**
* Get the Konva layer.
*
* @returns {Konva.Layer} The layer.
*/
getKonvaLayer(): Konva.Layer;
/**
* Get the draw controller.
*
* @returns {DrawController} The controller.
*/
getDrawController(): DrawController;
/**
* Set the plane helper.
*
* @param {PlaneHelper} helper The helper.
*/
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 {Scalar2D} The size as {x,y}.
*/
getBaseSize(): Scalar2D;
/**
* Get the layer opacity.
*
* @returns {number} The opacity ([0:1] range).
*/
getOpacity(): number;
/**
* Set the layer opacity.
*
* @param {number} alpha The opacity ([0:1] range).
*/
setOpacity(alpha: number): void;
/**
* Add a flip offset along the layer X axis.
*/
addFlipOffsetX(): void;
/**
* 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 {Scalar3D} newScale The scale as {x,y,z}.
* @param {Point3D} [center] The scale c