dicom-microscopy-viewer 0.36.0 → 0.36.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +6 -1
- package/{build → dist}/08929516bda4c4fd2597.module.wasm +0 -0
- package/dist/4f2853de305c1b5afcac.module.wasm +0 -0
- package/{build → dist}/6ae9c6e051fd2bd70fad.module.wasm +0 -0
- package/dist/6b62efd6c7f30afd4c78.module.wasm +0 -0
- package/{build → dist}/7e1d2da75b59525e1933.module.wasm +0 -0
- package/{build → dist}/d051f2d564fae150ce94.module.wasm +0 -0
- package/dist/dicom-microscopy-viewer.js +2 -0
- package/{build → dist}/dicom-microscopy-viewer.js.LICENSE.txt +0 -0
- package/dist/dicom-microscopy-viewer.js.map +1 -0
- package/{build → dist}/e6305f756142e57c92cd.module.wasm +0 -0
- package/{build → dist}/f3e0c999ad06a34a7f75.module.wasm +0 -0
- package/docs/annotation.AnnotationGroup.html +2 -2
- package/docs/annotation.html +4 -3
- package/docs/annotation.js.html +8 -8
- package/docs/annotations__AnnotationManager.js.html +5 -5
- package/docs/annotations_markups__MarkupManager.js.html +52 -7
- package/docs/api.html +3 -3
- package/docs/color.PaletteColorLookupTable.html +688 -0
- package/docs/color.html +671 -0
- package/docs/color.js.html +30 -5
- package/docs/dicom-microscopy-viewer.js.html +30 -13
- package/docs/events.html +3 -3
- package/docs/events.js.html +2 -2
- package/docs/index.html +23 -24
- package/docs/mapping.ParameterMapping.html +10 -10
- package/docs/mapping.Transformation.html +180 -0
- package/docs/mapping.html +7 -4
- package/docs/mapping.js.html +7 -3
- package/docs/metadata.Comprehensive3DSR.html +2 -2
- package/docs/metadata.MicroscopyBulkSimpleAnnotations.html +2 -2
- package/docs/metadata.ParametricMap.html +2 -2
- package/docs/metadata.Segmentation.html +2 -2
- package/docs/metadata.VLWholeSlideMicroscopyImage.html +2 -2
- package/docs/metadata.html +3 -3
- package/docs/metadata.js.html +2 -2
- package/docs/opticalPath.OpticalPath.html +2 -2
- package/docs/opticalPath.html +3 -3
- package/docs/opticalPath.js.html +2 -2
- package/docs/pyramid.js.html +6 -4
- package/docs/roi.ROI.html +2 -2
- package/docs/roi.html +4 -4
- package/docs/roi.js.html +4 -4
- package/docs/scoord3d.Ellipse.html +2 -2
- package/docs/scoord3d.Ellipsoid.html +2 -2
- package/docs/scoord3d.Multipoint.html +2 -2
- package/docs/scoord3d.Point.html +2 -2
- package/docs/scoord3d.Polygon.html +2 -2
- package/docs/scoord3d.Polyline.html +2 -2
- package/docs/scoord3d.html +3 -3
- package/docs/scoord3d.js.html +4 -4
- package/docs/segment.Segment.html +2 -2
- package/docs/segment.html +4 -4
- package/docs/segment.js.html +2 -2
- package/docs/utils.html +2812 -5
- package/docs/utils.js.html +77 -14
- package/docs/viewer.LabelImageViewer.html +3 -3
- package/docs/viewer.OverviewImageViewer.html +3 -3
- package/docs/viewer.VolumeImageViewer.html +87 -87
- package/docs/viewer.html +3 -3
- package/docs/viewer.js.html +45 -14
- package/package.json +8 -7
- package/src/annotation.js +6 -6
- package/src/annotations/_AnnotationManager.js +3 -3
- package/src/annotations/markers/arrow.js +11 -2
- package/src/annotations/markups/_MarkupManager.js +49 -4
- package/src/annotations/markups/measurement.js +14 -6
- package/src/annotations/markups/textEvaluation.js +23 -8
- package/src/color.js +28 -3
- package/src/dicom-microscopy-viewer.js +28 -11
- package/src/mapping.js +5 -1
- package/src/pyramid.js +4 -2
- package/src/roi.js +2 -2
- package/src/scoord3d.js +2 -2
- package/src/utils.js +75 -12
- package/src/viewer.js +37 -10
- package/webpack.config.js +11 -1
- package/build/33ef438573e49fde75eb.module.wasm +0 -0
- package/build/510fe8aff40dafc5b19b.module.wasm +0 -0
- package/build/713dba1fa973be4d97f4.module.wasm +0 -0
- package/build/86e23957894a6f373e11.module.wasm +0 -0
- package/build/c337ef929a626d7e5353.module.wasm +0 -0
- package/build/ce3907ececff7b46856f.wasm +0 -0
- package/build/dicom-microscopy-viewer.js +0 -2
- package/build/dicom-microscopy-viewer.js.map +0 -1
- package/docs/PaletteColorLookupTable.html +0 -364
- package/docs/Transformation.html +0 -179
- package/docs/annotations_markers_arrow.js.html +0 -224
- package/docs/annotations_markups_measurement.js.html +0 -136
- package/docs/annotations_markups_textEvaluation.js.html +0 -184
- package/docs/annotations_markups_utils_getShortestLineBetweenOverlayAndFeature.js.html +0 -96
- package/docs/global.html +0 -6062
- package/examples/basic/index.html +0 -77
- package/examples/blend/index.html +0 -209
- package/examples/events/index.html +0 -436
- package/examples/index.html +0 -32
- package/examples/js/FileSaver.min.js +0 -3
- package/examples/js/jquery.min.js +0 -4
- package/examples/js/jquery.min.map +0 -1
- package/examples/simple_viewer/index.html +0 -520
- package/examples/simple_viewer/scripts/dicomdict.js +0 -34030
- package/examples/simple_viewer/scripts/metadata.js +0 -79
- package/examples/simple_viewer/styles/main.css +0 -238
- package/examples/structured_report/index.html +0 -278
- package/examples/styles.js +0 -46
- package/src/annotations/markups/utils/getShortestLineBetweenOverlayAndFeature.js +0 -45
- package/src/annotations/markups/utils/index.js +0 -1
package/src/color.js
CHANGED
|
@@ -1,9 +1,14 @@
|
|
|
1
1
|
import colormap from 'colormap'
|
|
2
2
|
|
|
3
|
-
import {
|
|
3
|
+
import { _generateUID, rescale } from './utils.js'
|
|
4
4
|
|
|
5
5
|
const _attrs = Symbol('attrs')
|
|
6
6
|
|
|
7
|
+
/**
|
|
8
|
+
* Enumerated values for color map names.
|
|
9
|
+
*
|
|
10
|
+
* @memberof color
|
|
11
|
+
*/
|
|
7
12
|
const ColormapNames = {
|
|
8
13
|
VIRIDIS: 'VIRIDIS',
|
|
9
14
|
INFERNO: 'INFERNO',
|
|
@@ -16,13 +21,16 @@ const ColormapNames = {
|
|
|
16
21
|
}
|
|
17
22
|
Object.freeze(ColormapNames)
|
|
18
23
|
|
|
19
|
-
/**
|
|
24
|
+
/**
|
|
25
|
+
* Create a color map.
|
|
20
26
|
*
|
|
21
27
|
* @param {object} options
|
|
22
28
|
* @param {string} options.name - Name of the color map
|
|
23
29
|
* @param {string} options.bins - Number of color bins
|
|
24
30
|
*
|
|
25
31
|
* @returns {number[][]} RGB triplet for each color
|
|
32
|
+
*
|
|
33
|
+
* @memberof color
|
|
26
34
|
*/
|
|
27
35
|
function createColormap ({ name, bins }) {
|
|
28
36
|
const lut = {
|
|
@@ -61,6 +69,8 @@ function createColormap ({ name, bins }) {
|
|
|
61
69
|
* @param {number} options.firstValueMapped - First value that should be mapped
|
|
62
70
|
*
|
|
63
71
|
* @returns {PaletteColorLookupTable} Mapping of grayscale pixel values to RGB color triplets
|
|
72
|
+
*
|
|
73
|
+
* @memberof color
|
|
64
74
|
*/
|
|
65
75
|
function buildPaletteColorLookupTable ({ data, firstValueMapped }) {
|
|
66
76
|
if (data == null) {
|
|
@@ -90,7 +100,7 @@ function buildPaletteColorLookupTable ({ data, firstValueMapped }) {
|
|
|
90
100
|
const descriptor = [numberOfEntries, firstValueMapped, 8]
|
|
91
101
|
|
|
92
102
|
return new PaletteColorLookupTable({
|
|
93
|
-
uid:
|
|
103
|
+
uid: _generateUID(),
|
|
94
104
|
redDescriptor: descriptor,
|
|
95
105
|
greenDescriptor: descriptor,
|
|
96
106
|
blueDescriptor: descriptor,
|
|
@@ -102,10 +112,25 @@ function buildPaletteColorLookupTable ({ data, firstValueMapped }) {
|
|
|
102
112
|
|
|
103
113
|
/**
|
|
104
114
|
* A Palette Color Lookup Table
|
|
115
|
+
*
|
|
116
|
+
* @class
|
|
117
|
+
* @memberof color
|
|
105
118
|
*/
|
|
106
119
|
class PaletteColorLookupTable {
|
|
107
120
|
/**
|
|
108
121
|
* Create a new PaletteColorLookupTable object.
|
|
122
|
+
*
|
|
123
|
+
* @param {object} options
|
|
124
|
+
* @param {string} options.uid - UID
|
|
125
|
+
* @param {number[]} options.redDescriptor - Red LUT descriptor
|
|
126
|
+
* @param {number[]} options.greenDescriptor - Green LUT descriptor
|
|
127
|
+
* @param {number[]} options.blueDescriptor - Blue LUT descriptor
|
|
128
|
+
* @param {Uint8Array|Uint16Array} options.redData - Red LUT data
|
|
129
|
+
* @param {Uint8Array|Uint16Array} options.greenData - Green LUT data
|
|
130
|
+
* @param {Uint8Array|Uint16Array} options.blueData - Blue LUT data
|
|
131
|
+
* @param {Uint8Array|Uint16Array} options.redSegmentedData - Red segmented LUT data
|
|
132
|
+
* @param {Uint8Array|Uint16Array} options.greenSegmentedData - Green segmented LUT data
|
|
133
|
+
* @param {Uint8Array|Uint16Array} options.blueSegmentedData - Blue segmented LUT data
|
|
109
134
|
*/
|
|
110
135
|
constructor ({
|
|
111
136
|
uid,
|
|
@@ -47,7 +47,9 @@ import {
|
|
|
47
47
|
Segment
|
|
48
48
|
} from './segment.js'
|
|
49
49
|
|
|
50
|
-
/**
|
|
50
|
+
/**
|
|
51
|
+
* Namespace for annotations of DICOM Micrsocopy Bulk Simple Annotations
|
|
52
|
+
* instances.
|
|
51
53
|
*
|
|
52
54
|
* @namespace annotation
|
|
53
55
|
*/
|
|
@@ -55,7 +57,8 @@ const annotation = {
|
|
|
55
57
|
AnnotationGroup
|
|
56
58
|
}
|
|
57
59
|
|
|
58
|
-
/**
|
|
60
|
+
/**
|
|
61
|
+
* Namespace for the viewer.
|
|
59
62
|
*
|
|
60
63
|
* @namespace api
|
|
61
64
|
* @deprecated use the viewer namespace instead
|
|
@@ -64,7 +67,8 @@ const api = {
|
|
|
64
67
|
VLWholeSlideMicroscopyImageViewer: VolumeImageViewer
|
|
65
68
|
}
|
|
66
69
|
|
|
67
|
-
/**
|
|
70
|
+
/**
|
|
71
|
+
* Namespace for the viewer.
|
|
68
72
|
*
|
|
69
73
|
* @namespace viewer
|
|
70
74
|
*/
|
|
@@ -74,7 +78,8 @@ const viewer = {
|
|
|
74
78
|
VolumeImageViewer
|
|
75
79
|
}
|
|
76
80
|
|
|
77
|
-
/**
|
|
81
|
+
/**
|
|
82
|
+
* Namespace for parameter mappings of DICOM Parametric Map instances.
|
|
78
83
|
*
|
|
79
84
|
* @namespace mapping
|
|
80
85
|
*/
|
|
@@ -82,7 +87,8 @@ const mapping = {
|
|
|
82
87
|
ParameterMapping
|
|
83
88
|
}
|
|
84
89
|
|
|
85
|
-
/**
|
|
90
|
+
/**
|
|
91
|
+
* Namespace for working with DICOM Metadata.
|
|
86
92
|
*
|
|
87
93
|
* @namespace metadata
|
|
88
94
|
*/
|
|
@@ -97,6 +103,11 @@ const metadata = {
|
|
|
97
103
|
Comprehensive3DSR
|
|
98
104
|
}
|
|
99
105
|
|
|
106
|
+
/**
|
|
107
|
+
* Namespace for color.
|
|
108
|
+
*
|
|
109
|
+
* @namespace color
|
|
110
|
+
*/
|
|
100
111
|
const color = {
|
|
101
112
|
ColormapNames,
|
|
102
113
|
createColormap,
|
|
@@ -104,7 +115,8 @@ const color = {
|
|
|
104
115
|
buildPaletteColorLookupTable
|
|
105
116
|
}
|
|
106
117
|
|
|
107
|
-
/**
|
|
118
|
+
/**
|
|
119
|
+
* Namespace for optical paths.
|
|
108
120
|
*
|
|
109
121
|
* @namespace opticalPath
|
|
110
122
|
*/
|
|
@@ -112,7 +124,8 @@ const opticalPath = {
|
|
|
112
124
|
OpticalPath
|
|
113
125
|
}
|
|
114
126
|
|
|
115
|
-
/**
|
|
127
|
+
/**
|
|
128
|
+
* Namespace for 3-dimensional spatial coordinates (SCOORD3D).
|
|
116
129
|
*
|
|
117
130
|
* @namespace scoord3d
|
|
118
131
|
*/
|
|
@@ -125,7 +138,8 @@ const scoord3d = {
|
|
|
125
138
|
Ellipse
|
|
126
139
|
}
|
|
127
140
|
|
|
128
|
-
/**
|
|
141
|
+
/**
|
|
142
|
+
* Namespace for regions of interest (ROIs).
|
|
129
143
|
*
|
|
130
144
|
* @namespace roi
|
|
131
145
|
*/
|
|
@@ -133,7 +147,8 @@ const roi = {
|
|
|
133
147
|
ROI
|
|
134
148
|
}
|
|
135
149
|
|
|
136
|
-
/**
|
|
150
|
+
/**
|
|
151
|
+
* Namespace for segments of DICOM Segmentation instances.
|
|
137
152
|
*
|
|
138
153
|
* @namespace segment
|
|
139
154
|
*/
|
|
@@ -141,7 +156,8 @@ const segment = {
|
|
|
141
156
|
Segment
|
|
142
157
|
}
|
|
143
158
|
|
|
144
|
-
/**
|
|
159
|
+
/**
|
|
160
|
+
* Namespace for viewer events.
|
|
145
161
|
*
|
|
146
162
|
* @namespace events
|
|
147
163
|
*/
|
|
@@ -149,7 +165,8 @@ const events = {
|
|
|
149
165
|
EVENTS
|
|
150
166
|
}
|
|
151
167
|
|
|
152
|
-
/**
|
|
168
|
+
/**
|
|
169
|
+
* Namespace for various utilities.
|
|
153
170
|
*
|
|
154
171
|
* @namespace utils
|
|
155
172
|
*/
|
package/src/mapping.js
CHANGED
|
@@ -7,6 +7,9 @@ const _attrs = Symbol('attrs')
|
|
|
7
7
|
* values in a defined unit. The transformation may either be described by a
|
|
8
8
|
* lookup table (LUT) or alternatively by the slope and intercept parameters if
|
|
9
9
|
* the transformation can be described by a linear function.
|
|
10
|
+
*
|
|
11
|
+
* @class
|
|
12
|
+
* @memberof mapping
|
|
10
13
|
*/
|
|
11
14
|
class Transformation {
|
|
12
15
|
/**
|
|
@@ -56,7 +59,8 @@ class Transformation {
|
|
|
56
59
|
}
|
|
57
60
|
}
|
|
58
61
|
|
|
59
|
-
/**
|
|
62
|
+
/**
|
|
63
|
+
* A parameter mapping.
|
|
60
64
|
*
|
|
61
65
|
* @class
|
|
62
66
|
* @memberof mapping
|
package/src/pyramid.js
CHANGED
|
@@ -5,11 +5,13 @@ import { getFrameMapping, VLWholeSlideMicroscopyImage } from './metadata.js'
|
|
|
5
5
|
import { getPixelSpacing } from './scoord3dUtils'
|
|
6
6
|
import { are1DArraysAlmostEqual, are2DArraysAlmostEqual } from './utils.js'
|
|
7
7
|
|
|
8
|
-
/**
|
|
8
|
+
/**
|
|
9
|
+
* Compute image pyramid.
|
|
9
10
|
*
|
|
10
11
|
* @param {object[]} metadata - Metadata of VL Whole Slide Microscopy Image instances
|
|
11
12
|
* @returns {object} Information about the image pyramid
|
|
12
|
-
*
|
|
13
|
+
*
|
|
14
|
+
* @private
|
|
13
15
|
*/
|
|
14
16
|
function _computeImagePyramid ({ metadata }) {
|
|
15
17
|
if (metadata.length === 0) {
|
package/src/roi.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { _generateUID } from './utils.js'
|
|
2
2
|
import Enums from './enums'
|
|
3
3
|
|
|
4
4
|
const _uid = Symbol('uid')
|
|
@@ -26,7 +26,7 @@ class ROI {
|
|
|
26
26
|
throw new Error('scoord3d of ROI must be a Scoord3D object')
|
|
27
27
|
}
|
|
28
28
|
if (!('uid' in options)) {
|
|
29
|
-
this[_uid] =
|
|
29
|
+
this[_uid] = _generateUID()
|
|
30
30
|
} else {
|
|
31
31
|
if (!(typeof options.uid === 'string' || options.uid instanceof String)) {
|
|
32
32
|
throw new Error('uid of ROI must be a string')
|
package/src/scoord3d.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { _generateUID } from './utils.js'
|
|
2
2
|
|
|
3
3
|
const _coordinates = Symbol('coordinates')
|
|
4
4
|
const _frameOfReferenceUID = Symbol('frameOfReferenceUID')
|
|
@@ -11,7 +11,7 @@ class Scoord3D {
|
|
|
11
11
|
throw new Error('frameOfReferenceUID of Scoord3D must be a string')
|
|
12
12
|
}
|
|
13
13
|
this[_frameOfReferenceUID] = options.frameOfReferenceUID
|
|
14
|
-
options.fiducialUID = options.fiducialUID ||
|
|
14
|
+
options.fiducialUID = options.fiducialUID || _generateUID()
|
|
15
15
|
if (!(typeof options.fiducialUID === 'string' ||
|
|
16
16
|
options.fiducialUID instanceof String)) {
|
|
17
17
|
throw new Error('fiducialUID of Scoord3D must be a string')
|
package/src/utils.js
CHANGED
|
@@ -5,9 +5,10 @@ import { getPointResolution } from 'ol/proj'
|
|
|
5
5
|
* Generates a UUID-derived DICOM UID with root `2.25`.
|
|
6
6
|
*
|
|
7
7
|
* @returns {string} Unique identifier
|
|
8
|
+
*
|
|
8
9
|
* @private
|
|
9
10
|
*/
|
|
10
|
-
function
|
|
11
|
+
function _generateUID () {
|
|
11
12
|
/**
|
|
12
13
|
* A UUID can be represented as a single integer value.
|
|
13
14
|
* http://dicom.nema.org/medical/dicom/current/output/chtml/part05/sect_B.2.html
|
|
@@ -19,8 +20,8 @@ function generateUID () {
|
|
|
19
20
|
* the least significant bit as the least significant bit (bit 0) of the last
|
|
20
21
|
* of the sixteen octets (octet 0).
|
|
21
22
|
*/
|
|
22
|
-
// FIXME: This is not a valid UUID!
|
|
23
23
|
let uid = '2.25.' + Math.floor(1 + Math.random() * 9)
|
|
24
|
+
// FIXME: This is not a valid UUID!
|
|
24
25
|
while (uid.length < 44) {
|
|
25
26
|
uid += Math.floor(1 + Math.random() * 10)
|
|
26
27
|
}
|
|
@@ -32,7 +33,10 @@ function generateUID () {
|
|
|
32
33
|
*
|
|
33
34
|
* @param {Object} options - Options
|
|
34
35
|
* @param {number[]} options.orientation - Direction cosines along the row and column direction of the Total Pixel Matrix for each of the three axis of the slide coordinate system
|
|
36
|
+
*
|
|
35
37
|
* @returns {number[][]} 2x2 rotation matrix
|
|
38
|
+
*
|
|
39
|
+
* @memberof utils
|
|
36
40
|
*/
|
|
37
41
|
function createRotationMatrix (options) {
|
|
38
42
|
if (!('orientation' in options)) {
|
|
@@ -56,7 +60,10 @@ function createRotationMatrix (options) {
|
|
|
56
60
|
* @param {number} maxInput - Upper bound of the full input value range
|
|
57
61
|
* @param {number} minOutput - Lower bound of the full output value range
|
|
58
62
|
* @param {number} maxOutput - Upper bound of the full output value range
|
|
63
|
+
*
|
|
59
64
|
* @returns {number} Rescaled value
|
|
65
|
+
*
|
|
66
|
+
* @memberof utils
|
|
60
67
|
*/
|
|
61
68
|
function rescale (
|
|
62
69
|
value,
|
|
@@ -77,7 +84,10 @@ function rescale (
|
|
|
77
84
|
*
|
|
78
85
|
* @param {number} lowerBound - Lower bound of the window
|
|
79
86
|
* @param {number} upperBound - Upper bound of the window
|
|
87
|
+
*
|
|
80
88
|
* @returns {number[]} Window center and width
|
|
89
|
+
*
|
|
90
|
+
* @memberof utils
|
|
81
91
|
*/
|
|
82
92
|
function createWindow (lowerBound, upperBound) {
|
|
83
93
|
const windowCenter = (lowerBound + upperBound) / 2
|
|
@@ -91,7 +101,10 @@ function createWindow (lowerBound, upperBound) {
|
|
|
91
101
|
* @param {Object} options - Options
|
|
92
102
|
* @param {number[]} options.orientation - Direction cosines along the row and column direction of the Total Pixel Matrix for each of the three axis of the slide coordinate system
|
|
93
103
|
* @param {boolean} options.inDegrees - Whether angle should be returned in degrees instead of radians
|
|
104
|
+
*
|
|
94
105
|
* @returns {number} Angle
|
|
106
|
+
*
|
|
107
|
+
* @memberof utils
|
|
95
108
|
*/
|
|
96
109
|
function computeRotation (options) {
|
|
97
110
|
const rot = createRotationMatrix({ orientation: options.orientation })
|
|
@@ -115,7 +128,10 @@ function computeRotation (options) {
|
|
|
115
128
|
* @param {number[]} options.offset - X and Y offset of the image in the slide coordinate system
|
|
116
129
|
* @param {number[]} options.orientation - Direction cosines along the row and column direction of the Total Pixel Matrix for each of the three axis of the slide coordinate system
|
|
117
130
|
* @param {number[]} options.spacing - Spacing between pixel rows and columns of the Total Pixel Matrix
|
|
131
|
+
*
|
|
118
132
|
* @returns {number[][]} 3x3 affine transformation matrix
|
|
133
|
+
*
|
|
134
|
+
* @memberof utils
|
|
119
135
|
*/
|
|
120
136
|
function buildTransform ({ offset, orientation, spacing }) {
|
|
121
137
|
// X and Y Offset in Slide Coordinate System
|
|
@@ -171,7 +187,10 @@ function buildTransform ({ offset, orientation, spacing }) {
|
|
|
171
187
|
* @param {Object} options - Options
|
|
172
188
|
* @params {number[]} options.coordinate - (column, row) image coordinate
|
|
173
189
|
* @params {number[][]} options.affine - 3x3 affine transformation matrix
|
|
190
|
+
*
|
|
174
191
|
* @returns {number[]} (x, y) reference coordinate
|
|
192
|
+
*
|
|
193
|
+
* @memberof utils
|
|
175
194
|
*/
|
|
176
195
|
function applyTransform ({ coordinate, affine }) {
|
|
177
196
|
if (coordinate == null) {
|
|
@@ -216,7 +235,10 @@ function applyTransform ({ coordinate, affine }) {
|
|
|
216
235
|
* @param {number[]} options.offset - X and Y offset of the image in the slide coordinate system
|
|
217
236
|
* @param {number[]} options.orientation - Direction cosines along the row and column direction of the Total Pixel Matrix for each of the three axis of the slide coordinate system
|
|
218
237
|
* @param {number[]} options.spacing - Spacing between pixel rows and columns of the Total Pixel Matrix
|
|
238
|
+
*
|
|
219
239
|
* @returns {number[][]} 3x3 affine transformation matrix
|
|
240
|
+
*
|
|
241
|
+
* @memberof utils
|
|
220
242
|
*/
|
|
221
243
|
function buildInverseTransform ({ offset, orientation, spacing }) {
|
|
222
244
|
// X and Y Offset in Slide Coordinate System
|
|
@@ -272,7 +294,10 @@ function buildInverseTransform ({ offset, orientation, spacing }) {
|
|
|
272
294
|
* @param {Object} options - Options
|
|
273
295
|
* @params {number[]} options.coordinate - (x, y) reference coordinate
|
|
274
296
|
* @params {number[][]} options.affine - 3x3 affine transformation matrix
|
|
297
|
+
*
|
|
275
298
|
* @returns {number[]} (column, row) image coordinate
|
|
299
|
+
*
|
|
300
|
+
* @memberof utils
|
|
276
301
|
*/
|
|
277
302
|
function applyInverseTransform ({ coordinate, affine }) {
|
|
278
303
|
if (coordinate == null) {
|
|
@@ -319,7 +344,9 @@ function applyInverseTransform ({ coordinate, affine }) {
|
|
|
319
344
|
* @param {number[]} options.orientation - Direction cosines along the row and column direction of the Total Pixel Matrix for each of the three axis of the slide coordinate system
|
|
320
345
|
* @param {number[]} options.spacing - Spacing between pixels along the Column and Row direction of the Total Pixel Matrix
|
|
321
346
|
* @param {number[]} options.point - (colum, row) image coordinates
|
|
347
|
+
*
|
|
322
348
|
* @returns {number[]} (x, y, z) slide coordinates
|
|
349
|
+
*
|
|
323
350
|
* @memberof utils
|
|
324
351
|
*/
|
|
325
352
|
function mapPixelCoordToSlideCoord ({ point, offset, orientation, spacing }) {
|
|
@@ -350,7 +377,9 @@ function mapPixelCoordToSlideCoord ({ point, offset, orientation, spacing }) {
|
|
|
350
377
|
* @param {number[]} options.orientation - Direction cosines along the row and column direction of the Total Pixel Matrix for each of the three axis of the slide coordinate system
|
|
351
378
|
* @param {number[]} options.spacing - Spacing between pixels along the Column and Row direction of the Total Pixel Matrix
|
|
352
379
|
* @param {number[]} options.point - (x, y, z) slide coordinates
|
|
380
|
+
*
|
|
353
381
|
* @returns {number[]} (row, column) image coordinates
|
|
382
|
+
*
|
|
354
383
|
* @memberof utils
|
|
355
384
|
*/
|
|
356
385
|
function mapSlideCoordToPixelCoord ({ point, offset, orientation, spacing }) {
|
|
@@ -378,7 +407,10 @@ function mapSlideCoordToPixelCoord ({ point, offset, orientation, spacing }) {
|
|
|
378
407
|
* @param {number[]} array a
|
|
379
408
|
* @param {number[]} array b
|
|
380
409
|
* @param {number} eps
|
|
381
|
-
*
|
|
410
|
+
*
|
|
411
|
+
* @returns {boolean} yes/no answer
|
|
412
|
+
*
|
|
413
|
+
* @memberof utils
|
|
382
414
|
*/
|
|
383
415
|
function are2DArraysAlmostEqual (a, b, eps = 1.e-6) {
|
|
384
416
|
if (a === b) return true
|
|
@@ -402,7 +434,10 @@ function are2DArraysAlmostEqual (a, b, eps = 1.e-6) {
|
|
|
402
434
|
* @param {number[]} array a
|
|
403
435
|
* @param {number[]} array b
|
|
404
436
|
* @param {number} eps
|
|
405
|
-
*
|
|
437
|
+
*
|
|
438
|
+
* @returns {boolean} yes/no answer
|
|
439
|
+
*
|
|
440
|
+
* @memberof utils
|
|
406
441
|
*/
|
|
407
442
|
function are1DArraysAlmostEqual (a, b, eps = 1.e-6) {
|
|
408
443
|
if (a == null || b == null) return false
|
|
@@ -422,7 +457,10 @@ function are1DArraysAlmostEqual (a, b, eps = 1.e-6) {
|
|
|
422
457
|
* @param {number} a
|
|
423
458
|
* @param {number} b
|
|
424
459
|
* @param {number} eps
|
|
425
|
-
*
|
|
460
|
+
*
|
|
461
|
+
* @returns {boolean} yes/no answer
|
|
462
|
+
*
|
|
463
|
+
* @memberof utils
|
|
426
464
|
*/
|
|
427
465
|
function areNumbersAlmostEqual (a, b, eps = 1.e-6) {
|
|
428
466
|
return Math.abs(a - b) < eps
|
|
@@ -432,9 +470,12 @@ function areNumbersAlmostEqual (a, b, eps = 1.e-6) {
|
|
|
432
470
|
* Get view unit suffix.
|
|
433
471
|
*
|
|
434
472
|
* @param {object} view Map view
|
|
473
|
+
*
|
|
435
474
|
* @returns {string} unit suffix
|
|
475
|
+
*
|
|
476
|
+
* @private
|
|
436
477
|
*/
|
|
437
|
-
function
|
|
478
|
+
function _getUnitSuffix (view) {
|
|
438
479
|
const UnitsEnum = { METERS: 'm' }
|
|
439
480
|
const DEFAULT_DPI = 25.4 / 0.28
|
|
440
481
|
|
|
@@ -477,16 +518,23 @@ function getUnitSuffix (view) {
|
|
|
477
518
|
* Get name coded concept from content item.
|
|
478
519
|
*
|
|
479
520
|
* @param {object} contentItem
|
|
521
|
+
*
|
|
480
522
|
* @returns {object} The concept name coded concept
|
|
523
|
+
*
|
|
524
|
+
* @memberof utils
|
|
481
525
|
*/
|
|
482
526
|
const getContentItemNameCodedConcept = (contentItem) =>
|
|
483
527
|
contentItem.ConceptNameCodeSequence[0]
|
|
484
528
|
|
|
485
529
|
/**
|
|
530
|
+
* Check whether coded concepts are equal.
|
|
486
531
|
*
|
|
487
532
|
* @param {object} codedConcept1
|
|
488
533
|
* @param {object} codedConcept2
|
|
489
|
-
*
|
|
534
|
+
*
|
|
535
|
+
* @returns {boolean} yes/no answer
|
|
536
|
+
*
|
|
537
|
+
* @memberof utils
|
|
490
538
|
*/
|
|
491
539
|
const areCodedConceptsEqual = (codedConcept1, codedConcept2) => {
|
|
492
540
|
if (
|
|
@@ -512,7 +560,10 @@ const areCodedConceptsEqual = (codedConcept1, codedConcept2) => {
|
|
|
512
560
|
*
|
|
513
561
|
* @param {object} contentItem1
|
|
514
562
|
* @param {object} contentItem2
|
|
515
|
-
*
|
|
563
|
+
*
|
|
564
|
+
* @returns {boolean} yes/no answer
|
|
565
|
+
*
|
|
566
|
+
* @memberof utils
|
|
516
567
|
*/
|
|
517
568
|
const doContentItemsMatch = (contentItem1, contentItem2) => {
|
|
518
569
|
const contentItem1NameCodedConcept = getContentItemNameCodedConcept(
|
|
@@ -529,7 +580,19 @@ const doContentItemsMatch = (contentItem1, contentItem2) => {
|
|
|
529
580
|
)
|
|
530
581
|
}
|
|
531
582
|
|
|
532
|
-
|
|
583
|
+
/**
|
|
584
|
+
* Fetch bulkdata.
|
|
585
|
+
*
|
|
586
|
+
* @param {object} options
|
|
587
|
+
* @param {object} options.client - DICOMweb client @param {object}
|
|
588
|
+
* options.reference - Data Element in DICOM JSON format containing "vr" and
|
|
589
|
+
* "BulkDataURI" fields
|
|
590
|
+
*
|
|
591
|
+
* @returns {Promise<TypedArray>} bulkdata
|
|
592
|
+
*
|
|
593
|
+
* @private
|
|
594
|
+
*/
|
|
595
|
+
async function _fetchBulkdata ({ client, reference }) {
|
|
533
596
|
const fixBulkDataURI = (uri) => {
|
|
534
597
|
// FIXME: Configure dcm4che-arc-light so that BulkDataURI value is
|
|
535
598
|
// set correctly by the archive:
|
|
@@ -588,14 +651,14 @@ async function fetchBulkdata ({ client, reference }) {
|
|
|
588
651
|
}
|
|
589
652
|
|
|
590
653
|
export {
|
|
591
|
-
|
|
654
|
+
_getUnitSuffix,
|
|
592
655
|
applyInverseTransform,
|
|
593
656
|
applyTransform,
|
|
594
657
|
buildInverseTransform,
|
|
595
658
|
buildTransform,
|
|
596
659
|
computeRotation,
|
|
597
|
-
|
|
598
|
-
|
|
660
|
+
_fetchBulkdata,
|
|
661
|
+
_generateUID,
|
|
599
662
|
mapPixelCoordToSlideCoord,
|
|
600
663
|
mapSlideCoordToPixelCoord,
|
|
601
664
|
areNumbersAlmostEqual,
|
package/src/viewer.js
CHANGED
|
@@ -65,11 +65,11 @@ import { ROI } from './roi.js'
|
|
|
65
65
|
import { Segment } from './segment.js'
|
|
66
66
|
import {
|
|
67
67
|
computeRotation,
|
|
68
|
-
|
|
69
|
-
|
|
68
|
+
_generateUID,
|
|
69
|
+
_getUnitSuffix,
|
|
70
70
|
doContentItemsMatch,
|
|
71
71
|
createWindow,
|
|
72
|
-
|
|
72
|
+
_fetchBulkdata
|
|
73
73
|
} from './utils.js'
|
|
74
74
|
import {
|
|
75
75
|
_scoord3dCoordinates2geometryCoordinates,
|
|
@@ -160,7 +160,7 @@ async function _initializeDecodersAndTransformers ({
|
|
|
160
160
|
console.warn('ICC Profile was not found')
|
|
161
161
|
continue
|
|
162
162
|
}
|
|
163
|
-
const iccProfile = await
|
|
163
|
+
const iccProfile = await _fetchBulkdata({
|
|
164
164
|
client,
|
|
165
165
|
reference: (
|
|
166
166
|
image
|
|
@@ -532,7 +532,7 @@ function _updateFeatureMeasurements (map, feature, pyramid) {
|
|
|
532
532
|
|
|
533
533
|
let measurement
|
|
534
534
|
const view = map.getView()
|
|
535
|
-
const unitSuffix =
|
|
535
|
+
const unitSuffix = _getUnitSuffix(view)
|
|
536
536
|
|
|
537
537
|
if (area != null) {
|
|
538
538
|
const unitCodedConceptValue = `${unitSuffix}2`
|
|
@@ -599,6 +599,8 @@ function _updateFeatureMeasurements (map, feature, pyramid) {
|
|
|
599
599
|
* @param {object} styleOptions.fill - Style options for body the geometry
|
|
600
600
|
* @param {number[]} styleOptions.fill.color - RGBA color of the body
|
|
601
601
|
* @param {object} styleOptions.image - Style options for image
|
|
602
|
+
*
|
|
603
|
+
* @private
|
|
602
604
|
*/
|
|
603
605
|
function _setFeatureStyle (feature, styleOptions) {
|
|
604
606
|
if (styleOptions !== undefined) {
|
|
@@ -614,6 +616,18 @@ function _setFeatureStyle (feature, styleOptions) {
|
|
|
614
616
|
}
|
|
615
617
|
}
|
|
616
618
|
|
|
619
|
+
/**
|
|
620
|
+
* Build OpenLayers style expression for coloring a WebGL TileLayer.
|
|
621
|
+
*
|
|
622
|
+
* @param {object} styleOptions - Style options
|
|
623
|
+
* @param {number} styleOptions.windowCenter - Center of the window used for contrast stretching
|
|
624
|
+
* @param {number} styleOptions.windowWidth - Width of the window used for contrast stretching
|
|
625
|
+
* @param {number[][]} styleOptions.colormap - RGB color triplets
|
|
626
|
+
*
|
|
627
|
+
* @returns {object} color style expression and corresponding variables
|
|
628
|
+
*
|
|
629
|
+
* @private
|
|
630
|
+
*/
|
|
617
631
|
function _getColorPaletteStyleForTileLayer ({
|
|
618
632
|
windowCenter,
|
|
619
633
|
windowWidth,
|
|
@@ -679,6 +693,19 @@ function _getColorPaletteStyleForTileLayer ({
|
|
|
679
693
|
return { color: expression, variables }
|
|
680
694
|
}
|
|
681
695
|
|
|
696
|
+
/**
|
|
697
|
+
* Build OpenLayers style expression for coloring a WebGL PointLayer.
|
|
698
|
+
*
|
|
699
|
+
* @param {object} styleOptions - Style options
|
|
700
|
+
* @param {string} styleOptions.name - Name of a property for which values should be colorized
|
|
701
|
+
* @param {number} styleOptions.minValue - Mininum value of the output range
|
|
702
|
+
* @param {number} styleOptions.maxValue - Maxinum value of the output range
|
|
703
|
+
* @param {number[][]} styleOptions.colormap - RGB color triplets
|
|
704
|
+
*
|
|
705
|
+
* @returns {object} color style expression
|
|
706
|
+
*
|
|
707
|
+
* @private
|
|
708
|
+
*/
|
|
682
709
|
function _getColorPaletteStyleForPointLayer ({
|
|
683
710
|
name,
|
|
684
711
|
minValue,
|
|
@@ -805,7 +832,7 @@ class VolumeImageViewer {
|
|
|
805
832
|
// The ID may have already been set when drawn. However, features could
|
|
806
833
|
// have also been added without a draw event.
|
|
807
834
|
if (e.element.getId() === undefined) {
|
|
808
|
-
e.element.setId(
|
|
835
|
+
e.element.setId(_generateUID())
|
|
809
836
|
}
|
|
810
837
|
|
|
811
838
|
this[_annotationManager].onAdd(e.element)
|
|
@@ -973,7 +1000,7 @@ class VolumeImageViewer {
|
|
|
973
1000
|
paletteColorLookupTableUID = (
|
|
974
1001
|
item.PaletteColorLookupTableUID
|
|
975
1002
|
? item.PaletteColorLookupTableUID
|
|
976
|
-
:
|
|
1003
|
+
: _generateUID()
|
|
977
1004
|
)
|
|
978
1005
|
/*
|
|
979
1006
|
* TODO: If the LUT Data are large, the elements may be bulkdata and
|
|
@@ -1955,7 +1982,7 @@ class VolumeImageViewer {
|
|
|
1955
1982
|
|
|
1956
1983
|
this[_interactions].draw.on(Enums.InteractionEvents.DRAW_START, (event) => {
|
|
1957
1984
|
event.feature.setProperties(builtInDrawOptions, true)
|
|
1958
|
-
event.feature.setId(
|
|
1985
|
+
event.feature.setId(_generateUID())
|
|
1959
1986
|
|
|
1960
1987
|
/** Set external styles before calling internal annotation hooks */
|
|
1961
1988
|
_setFeatureStyle(
|
|
@@ -3247,7 +3274,7 @@ class VolumeImageViewer {
|
|
|
3247
3274
|
refSegmentation.SegmentSequence.forEach((item, index) => {
|
|
3248
3275
|
const segmentNumber = Number(item.SegmentNumber)
|
|
3249
3276
|
console.info(`add segment # ${segmentNumber}`)
|
|
3250
|
-
let segmentUID =
|
|
3277
|
+
let segmentUID = _generateUID()
|
|
3251
3278
|
if (item.TrackingUID) {
|
|
3252
3279
|
segmentUID = item.TrackingUID
|
|
3253
3280
|
}
|
|
@@ -3622,7 +3649,7 @@ class VolumeImageViewer {
|
|
|
3622
3649
|
const mappingLabel = `${mappingNumber}`
|
|
3623
3650
|
const mappingDescriptions = mappingNumberToDescriptions[mappingNumber]
|
|
3624
3651
|
const refItem = mappingDescriptions[0]
|
|
3625
|
-
let mappingUID =
|
|
3652
|
+
let mappingUID = _generateUID()
|
|
3626
3653
|
if (refItem.TrackingUID != null) {
|
|
3627
3654
|
mappingUID = refItem.TrackingUID
|
|
3628
3655
|
}
|
package/webpack.config.js
CHANGED
|
@@ -3,7 +3,7 @@ const path = require('path')
|
|
|
3
3
|
const config = {
|
|
4
4
|
entry: path.resolve(__dirname, 'src/dicom-microscopy-viewer.js'),
|
|
5
5
|
output: {
|
|
6
|
-
path: path.resolve(__dirname, '
|
|
6
|
+
path: path.resolve(__dirname, 'dist'),
|
|
7
7
|
filename: 'dicom-microscopy-viewer.js',
|
|
8
8
|
library: {
|
|
9
9
|
name: 'DICOMMicroscopyViewer',
|
|
@@ -17,6 +17,16 @@ const config = {
|
|
|
17
17
|
{
|
|
18
18
|
test: /\.css$/,
|
|
19
19
|
use: 'css-loader'
|
|
20
|
+
},
|
|
21
|
+
{
|
|
22
|
+
test: /\.m?js$/,
|
|
23
|
+
exclude: /(node_modules)/,
|
|
24
|
+
use: {
|
|
25
|
+
loader: 'babel-loader',
|
|
26
|
+
options: {
|
|
27
|
+
presets: ['@babel/preset-env']
|
|
28
|
+
}
|
|
29
|
+
}
|
|
20
30
|
}
|
|
21
31
|
]
|
|
22
32
|
},
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|