Skip to content

Commit 00c42dd

Browse files
committed
Add metadata class for structured report documents
1 parent 4f75f39 commit 00c42dd

File tree

2 files changed

+45
-8
lines changed

2 files changed

+45
-8
lines changed

src/dicom-microscopy-viewer.js

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
import EVENTS from './events.js';
2-
import { VLWholeSlideMicroscopyImage, formatMetadata } from './metadata.js';
2+
import {
3+
Comprehensive3DSR,
4+
VLWholeSlideMicroscopyImage,
5+
formatMetadata,
6+
} from './metadata.js';
37
import { ROI } from './roi.js';
48
import {
59
Point,
@@ -46,6 +50,7 @@ const viewer = {
4650
const metadata = {
4751
formatMetadata,
4852
VLWholeSlideMicroscopyImage,
53+
Comprehensive3DSR,
4954
};
5055

5156
/** Namespace for 3-dimensional spatial coordinates (SCOORD3D).
@@ -58,7 +63,7 @@ const scoord3d = {
5863
Polyline,
5964
Polygon,
6065
Ellipsoid,
61-
Ellipse
66+
Ellipse,
6267
};
6368

6469
/** Namespace for regions of interest (ROI).

src/metadata.js

Lines changed: 38 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -106,15 +106,19 @@ function formatMetadata(metadata) {
106106
// The top level (lowest resolution) image may be a single frame image in
107107
// which case the "NumberOfFrames" attribute is optional. We include it for
108108
// consistency.
109-
if (!('NumberOfFrames' in dataset)) {
109+
if (dataset === undefined) {
110+
throw new Error('Could not format metadata: ', metadata)
111+
}
112+
if (!('NumberOfFrames' in dataset) && (dataset.Modality === 'SM')) {
110113
dataset.NumberOfFrames = 1;
111114
}
112115

113116
return dataset;
114117
}
115118

116119

117-
/** DICOM VL Whole Slide Microscopy Image instance.
120+
/** DICOM VL Whole Slide Microscopy Image instance
121+
* (without Pixel Data or any other bulk data).
118122
*
119123
* @class
120124
* @memberof metadata
@@ -126,17 +130,45 @@ class VLWholeSlideMicroscopyImage {
126130
* @params {Object} options.metadata - Metadata in DICOM JSON format
127131
*/
128132
constructor(options) {
129-
const sopClassUID = options.metadata['00080016']['Value'][0];
130-
if (sopClassUID !== '1.2.840.10008.5.1.4.1.1.77.1.6') {
133+
const dataset = formatMetadata(options.metadata);
134+
if (dataset.SOPClassUID !== '1.2.840.10008.5.1.4.1.1.77.1.6') {
131135
throw new Error(
132136
'Cannot construct VL Whole Slide Microscopy Image instance ' +
133-
`given dataset with SOP Class UID "${sopClassUID}"`
137+
`given dataset with SOP Class UID "${dataset.SOPClassUID}"`
134138
);
135139
}
136140

141+
Object.assign(this, dataset);
142+
}
143+
}
144+
145+
/** DICOM Comprehensive 3D SR instance.
146+
*
147+
* @class
148+
* @memberof metadata
149+
*/
150+
class Comprehensive3DSR {
151+
152+
/**
153+
* @params {Object} options
154+
* @params {Object} options.metadata - Metadata in DICOM JSON format
155+
*/
156+
constructor(options) {
137157
const dataset = formatMetadata(options.metadata);
158+
if (dataset.SOPClassUID !== '1.2.840.10008.5.1.4.1.1.88.34') {
159+
throw new Error(
160+
'Cannot construct Comprehensive 3D SR instance ' +
161+
`given dataset with SOP Class UID "${dataset.SOPClassUID}"`
162+
);
163+
}
164+
138165
Object.assign(this, dataset);
139166
}
140167
}
141168

142-
export { VLWholeSlideMicroscopyImage, formatMetadata, getFrameMapping };
169+
export {
170+
Comprehensive3DSR,
171+
formatMetadata,
172+
getFrameMapping,
173+
VLWholeSlideMicroscopyImage,
174+
};

0 commit comments

Comments
 (0)