@@ -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