Constructor
new View(image)
Name | Type | Description |
---|---|---|
image | Image | The associated image. |
- Source
// XMLHttpRequest onload callback
const onload = function (event) {
// parse the dicom buffer
const dicomParser = new dwv.DicomParser();
dicomParser.parse(event.target.response);
// create the image object
const image = dwv.createImage(dicomParser.getDicomElements());
// create the view
const view = dwv.createView(dicomParser.getDicomElements(), image);
// setup canvas
const canvas = document.createElement('canvas');
canvas.width = 256;
canvas.height = 256;
const ctx = canvas.getContext("2d");
// update the image data
const imageData = ctx.createImageData(256, 256);
view.generateImageData(imageData);
ctx.putImageData(imageData, 0, 0);
// update html
const div = document.getElementById('dwv');
div.appendChild(canvas);;
};
// 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();
Classes
Methods
addEventListener(type, callback)
Add an event listener to this class.
Name | Type | Description |
---|---|---|
type | string | The event type. |
callback | function | The function associated with the provided event type, will be called with the fired event. |
- Source
addWindowPresets(presets)
Add window presets to the existing ones.
Name | Type | Description |
---|---|---|
presets | object | The window presets. |
- Source
generateImageData(data, index)
Generate display image data to be given to a canvas.
Name | Type | Description |
---|---|---|
data | ImageData | The iamge data to fill in. |
index | Index | Optional index at which to generate, otherwise generates at current index. |
- Source
getAlphaFunction() → {alphaFn}
Get the alpha function.
- Source
The function.
- Type:
- alphaFn
getColourMap() → {string}
Get the colour map of the image.
- Source
The colour map name.
- Type:
- string
getCurrentImageUid() → {string}
Get the SOP image UID of the current image.
- Source
The UID.
- Type:
- string
getCurrentIndex() → {Index}
Get the current index.
- Source
The current index.
- Type:
- Index
getCurrentPosition() → {Point}
Get the current position.
- Source
The current position.
- Type:
- Point
getCurrentWindowPresetName() → {string}
Get the current window level preset name.
- Source
The preset name.
- Type:
- string
getImage() → {Image}
Get the associated image.
- Source
The associated image.
- Type:
- Image
getOrientation() → {Matrix33}
Get the view orientation.
- Source
The orientation matrix.
- Type:
- Matrix33
getOrigin(positionopt) → {Point3D}
Get the first origin or at a given position.
Name | Type | Attributes | Description |
---|---|---|---|
position | Point | <optional> | Optional position. |
- Source
The origin.
- Type:
- Point3D
getOriginForImageUid(uid) → {Point3D|undefined}
Get the image origin for a image UID.
Name | Type | Description |
---|---|---|
uid | string | The UID. |
- Source
The origin.
- Type:
- Point3D |
undefined
getPlaybackMilliseconds(recommendedDisplayFrameRate) → {number}
Get the milliseconds per frame from frame rate.
Name | Type | Description |
---|---|---|
recommendedDisplayFrameRate | number | Recommended Display Frame Rate. |
- Source
The milliseconds per frame.
- Type:
- number
getScrollIndex() → {number}
Get the scroll dimension index.
- Source
The index.
- Type:
- number
getWindowLevel() → {WindowLevel}
Get the window/level.
- Source
The window and level.
- Type:
- WindowLevel
getWindowLevelMinMax() → {WindowLevel}
Get the image window/level that covers the full data range. Warning: uses the latest set rescale LUT or the default linear one.
- Source
A min/max window level.
- Type:
- WindowLevel
getWindowPresets() → {object}
Get the window presets.
- Source
The window presets.
- Type:
- object
getWindowPresetsNames() → {Array.<string>}
Get the window presets names.
- Source
The list of window presets names.
- Type:
- Array.<string>
includesImageUid(uid) → {boolean}
Check if the image includes an UID.
Name | Type | Description |
---|---|---|
uid | string | The UID. |
- Source
True if present.
- Type:
- boolean
init()
Initialise the view: set initial index.
- Source
isAquisitionOrientation() → {boolean}
Is this view in the same orientation as the image aquisition.
- Source
True if in aquisition plane.
- Type:
- boolean
isPositionInBounds(positionopt) → {boolean}
Check if the current position (default) or the provided position is in bounds.
Name | Type | Attributes | Description |
---|---|---|---|
position | Point | <optional> | Optional position. |
- Source
True is the position is in bounds.
- Type:
- boolean
removeEventListener(type, callback)
Remove an event listener from this class.
Name | Type | Description |
---|---|---|
type | string | The event type. |
callback | function | The function associated with the provided event type. |
- Source
setAlphaFunction(func)
Set alpha function.
Name | Type | Description |
---|---|---|
func | alphaFn | The function. |
- Source
setColourMap(name)
Set the colour map of the image.
Name | Type | Description |
---|---|---|
name | string | The colour map name. |
- Source
setCurrentIndex(index, silentopt) → {boolean}
Set the current index.
Name | Type | Attributes | Description |
---|---|---|---|
index | Index | The new index. | |
silent | boolean | <optional> | Flag to fire event or not. |
- Source
False if not in bounds.
- Type:
- boolean
setCurrentPosition(position, silentopt) → {boolean}
Set the current position.
Name | Type | Attributes | Description |
---|---|---|---|
position | Point | The new position. | |
silent | boolean | <optional> | Flag to fire event or not. |
- Source
False if not in bounds.
- Type:
- boolean
setImage(inImage)
Set the associated image.
Name | Type | Description |
---|---|---|
inImage | Image | The associated image. |
- Source
setInitialIndex()
Set the initial index to the middle position.
- Source
setOrientation(mat33)
Set the view orientation.
Name | Type | Description |
---|---|---|
mat33 | Matrix33 | The orientation matrix. |
- Source
setWindowLevel(wl, nameopt, silentopt)
Set the view window/level.
Name | Type | Attributes | Description |
---|---|---|---|
wl | WindowLevel | The window and level. | |
name | string | <optional> | Associated preset name, defaults to 'manual'. Warning: uses the latest set rescale LUT or the default linear one. |
silent | boolean | <optional> | Flag to launch events with skipGenerate. |
- Source
setWindowLevelMinMax()
Set the image window/level to cover the full data range. Warning: uses the latest set rescale LUT or the default linear one.
- Source
setWindowLevelPreset(name, silentopt)
Set the window level to the preset with the input name.
Name | Type | Attributes | Description |
---|---|---|---|
name | string | The name of the preset to activate. | |
silent | boolean | <optional> | Flag to launch events with skipGenerate. |
- Source
setWindowLevelPresetById(id, silentopt)
Set the window level to the preset with the input id.
Name | Type | Attributes | Description |
---|---|---|---|
id | number | The id of the preset to activate. | |
silent | boolean | <optional> | Flag to launch events with skipGenerate. |
- Source
setWindowPresets(presets)
Set the window presets.
Name | Type | Description |
---|---|---|
presets | object | The window presets. |
- Source
Events
alphafuncchange
Alpha func change event.
- object
Name | Type | Description |
---|---|---|
type | string | The event type. |
- Source
colourmapchange
Color change event.
- object
Name | Type | Description |
---|---|---|
type | string | The event type. |
value | Array | The changed value. |
- Source
positionchange
Position change event.
- object
Name | Type | Description |
---|---|---|
value | Array | The changed value as [index, pixelValue]. |
diffDims | Array.<number> | An array of modified indices. |
- Source
wlchange
Window/level change event.
- object
Name | Type | Description |
---|---|---|
type | string | The event type. |
value | Array | The changed value. |
wc | number | The new window center value. |
ww | number | The new window wdth value. |
skipGenerate | boolean | Flag to skip view generation. |
- Source
wlpresetadd
Window/level add preset event.
- object
Name | Type | Description |
---|---|---|
type | string | The event type. |
name | string | The name of the preset. |
- Source