Skip to content

Commit 8ca5d86

Browse files
committed
Support adding roi measurements and evaluations
1 parent 1ead560 commit 8ca5d86

File tree

5 files changed

+412
-48
lines changed

5 files changed

+412
-48
lines changed

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "dicom-microscopy-viewer",
3-
"version": "0.20.1",
3+
"version": "0.21.0",
44
"description": "Interactive web-based viewer for DICOM Microscopy Images",
55
"main": "build/dicom-microscopy-viewer.js",
66
"scripts": {

src/roi.js

Lines changed: 55 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,10 @@ const _uid = Symbol('uid');
44
const _scoord3d = Symbol('scoord3d');
55
const _properties = Symbol('properties');
66

7+
const _name = Symbol('name');
8+
const _value = Symbol('value');
9+
10+
711
/** A region of interest (ROI)
812
*
913
* @class
@@ -16,7 +20,7 @@ class ROI {
1620
* @param {Object} options - Options for construction of ROI
1721
* @param {Scoord3D} options.scoord3d - Spatial 3D coordinates
1822
* @param {string} options.uid - Unique idenfifier
19-
* @param {Object} options.properties - Qualititative evaluations
23+
* @param {Object} options.properties - Properties (name-value pairs)
2024
*/
2125
constructor(options) {
2226
if (!('scoord3d' in options)) {
@@ -34,8 +38,23 @@ class ROI {
3438
this[_uid] = options.uid;
3539
}
3640
this[_scoord3d] = options.scoord3d;
37-
this[_properties] = options.properties;
38-
// TODO: store SOPInstanceUID, SOPClassUID and FrameNumbers as reference
41+
if ('properties' in options) {
42+
if (!(typeof(options.properties) === 'object')) {
43+
throw new Error('properties of ROI must be an object')
44+
}
45+
this[_properties] = options.properties;
46+
if (this[_properties].evaluations === undefined) {
47+
this[_properties]['evaluations'] = []
48+
}
49+
if (this[_properties].measurements === undefined) {
50+
this[_properties]['measurements'] = []
51+
}
52+
} else {
53+
this[_properties] = {};
54+
this[_properties]['evaluations'] = []
55+
this[_properties]['measurements'] = []
56+
}
57+
console.log(this[_properties])
3958
}
4059

4160
/** Gets unique identifier of region of interest.
@@ -62,6 +81,38 @@ class ROI {
6281
return this[_properties];
6382
}
6483

84+
/** Gets measurements of region of interest.
85+
*
86+
* @returns {Object[]} Measurements
87+
*/
88+
get measurements() {
89+
return this[_properties].measurements;
90+
}
91+
92+
/** Gets qualitative evaluations of region of interest.
93+
*
94+
* @returns {Object[]} QualitativeEvaluations
95+
*/
96+
get evaluations() {
97+
return this[_properties].evaluations;
98+
}
99+
100+
/** Adds a measurement.
101+
*
102+
* @params {Object} item - NUM content item representing a measurement
103+
*/
104+
addMeasurement(item) {
105+
this[_properties]['measurements'].push(item);
106+
}
107+
108+
/** Adds a qualitative evaluation.
109+
*
110+
* @params {Object} item - CODE content item representing a qualitative evaluation
111+
*/
112+
addEvaluation(item) {
113+
this[_properties]['evaluations'].push(item);
114+
}
115+
65116
}
66117

67-
export { ROI };
118+
export { Property, ROI };

src/viewer.js

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1106,6 +1106,42 @@ class VolumeImageViewer {
11061106
return _getROIFromFeature(feature, this[_pyramidMetadata]);
11071107
}
11081108

1109+
/** Adds a measurement to a region of interest.
1110+
*
1111+
* @param {string} uid - Unique identifier of the region of interest
1112+
* @param {Object} item - NUM content item representing a measurement
1113+
*/
1114+
addROIMeasurement(uid, item) {
1115+
const meaning = item.ConceptNameCodeSequence[0].CodeMeaning
1116+
console.info(`add measurement "${meaning}" to ROI ${uid}`)
1117+
this[_features].forEach(feature => {
1118+
const id = feature.getId();
1119+
if (id === uid) {
1120+
const properties = feature.getProperties();
1121+
properties['measurements'].push(item);
1122+
feature.setProperties(properties, true);
1123+
}
1124+
})
1125+
}
1126+
1127+
/** Adds a qualitative evaluation to a region of interest.
1128+
*
1129+
* @param {string} uid - Unique identifier of the region of interest
1130+
* @param {Object} item - CODE content item representing a qualitative evaluation
1131+
*/
1132+
addROIEvaluation(uid, item) {
1133+
const meaning = item.ConceptNameCodeSequence[0].CodeMeaning
1134+
console.info(`add qualitative evaluation "${meaning}" to ROI ${uid}`)
1135+
this[_features].forEach(feature => {
1136+
const id = feature.getId();
1137+
if (id === uid) {
1138+
const properties = feature.getProperties();
1139+
properties['evaluations'].push(item);
1140+
feature.setProperties(properties, true);
1141+
}
1142+
})
1143+
}
1144+
11091145
/** Pops the most recently annotated regions of interest.
11101146
*
11111147
* @returns {ROI} Regions of interest.

0 commit comments

Comments
 (0)