@@ -52,7 +52,7 @@ import DICOMwebClient from 'dicomweb-client/build/dicomweb-client.js'
5252
5353/** Extracts value of Pixel Spacing attribute from metadata.
5454 *
55- * @param {Object } metadata - Metadata of a DICOM VL Whole Slide Microscopy Image instance
55+ * @param {object } metadata - Metadata of a DICOM VL Whole Slide Microscopy Image instance
5656 * @returns {number[] } Spacing between pixel columns and rows in millimeter
5757 * @private
5858 */
@@ -87,7 +87,7 @@ function _getPixelSpacing(metadata) {
8787 * slide coordinate system (x, y, z), i.e. it express in which direction one
8888 * is moving in the slide coordinate system when the ROW index changes.
8989 *
90- * @param {Object } metadata - Metadata of a DICOM VL Whole Slide Microscopy Image instance
90+ * @param {object } metadata - Metadata of a DICOM VL Whole Slide Microscopy Image instance
9191 * @returns {number } Rotation in radians
9292 * @private
9393*/
@@ -166,7 +166,7 @@ function _getRotation(metadata) {
166166/** Converts a vector graphic from an Openlayers Geometry into a DICOM SCOORD3D
167167 * representation.
168168 *
169- * @param {Object } geometry - Openlayers Geometry
169+ * @param {object } geometry - Openlayers Geometry
170170 * @param {Object[] } pyramid - Metadata for resolution levels of image pyramid
171171 * @returns {Scoord3D } DICOM Microscopy Viewer Scoord3D
172172 * @private
@@ -234,7 +234,7 @@ function _geometry2Scoord3d(geometry, pyramid) {
234234 *
235235 * @param {Scoord3D } scoord3d - DICOM Microscopy Viewer Scoord3D
236236 * @param {Object[] } pyramid - Metadata for resolution levels of image pyramid
237- * @returns {Object } Openlayers Geometry
237+ * @returns {object } Openlayers Geometry
238238 * @private
239239 */
240240function _scoord3d2Geometry ( scoord3d , pyramid ) {
@@ -376,7 +376,7 @@ function _coordinateFormatScoord3d2Geometry(coordinates, pyramid) {
376376/** Extracts and transforms the region of interest (ROI) from an Openlayers
377377 * Feature.
378378 *
379- * @param {Object } feature - Openlayers Feature
379+ * @param {object } feature - Openlayers Feature
380380 * @param {Object[] } pyramid - Metadata for resolution levels of image pyramid
381381 * @returns {ROI } Region of interest
382382 * @private
@@ -423,11 +423,12 @@ class VolumeImageViewer {
423423 /**
424424 * Create a viewer instance for displaying VOLUME images.
425425 *
426- * @param {Object } options
427- * @param {Object } options.client - A DICOMwebClient instance for interacting with an origin server over HTTP.
426+ * @param {object } options
427+ * @param {object } options.client - A DICOMwebClient instance for interacting with an origin server over HTTP.
428428 * @param {Object[] } options.metadata - An array of DICOM JSON metadata objects, one for each VL Whole Slide Microscopy Image instance.
429429 * @param {string[] } [options.controls=[]] - Names of viewer control elements that should be included in the viewport.
430430 * @param {boolean } [options.retrieveRendered=true] - Whether image frames should be retrieved via DICOMweb prerendered by the server.
431+ * @param {boolean } [options.includeIccProfile=false] - Whether ICC Profile should be included for correction of image colors.
431432 * @param {boolean } [options.useWebGL=true] - Whether WebGL renderer should be used.
432433 */
433434 constructor ( options ) {
@@ -648,29 +649,36 @@ class VolumeImageViewer {
648649 sopInstanceUID,
649650 frameNumbers,
650651 mediaTypes : [ { mediaType } ] ,
651- queryParams : {
652+ } ;
653+ if ( options . includeIccProfile ) {
654+ retrieveOptions [ 'queryParams' ] = {
652655 iccprofile : 'yes'
653656 }
654- } ;
655- options . client . retrieveInstanceFramesRendered ( retrieveOptions ) . then ( ( renderedFrame ) => {
656- const blob = new Blob ( [ renderedFrame ] , { type : mediaType } ) ;
657- img . src = window . URL . createObjectURL ( blob ) ;
658- } ) ;
657+ }
658+ options . client . retrieveInstanceFramesRendered ( retrieveOptions ) . then (
659+ ( renderedFrame ) => {
660+ const blob = new Blob ( [ renderedFrame ] , { type : mediaType } ) ;
661+ img . src = window . URL . createObjectURL ( blob ) ;
662+ }
663+ ) ;
659664 } else {
660665 // TODO: support "image/jp2" and "image/jls"
661666 const mediaType = 'image/jpeg' ;
662-
663667 const retrieveOptions = {
664668 studyInstanceUID,
665669 seriesInstanceUID,
666670 sopInstanceUID,
667671 frameNumbers,
668- mediaTypes : [ { mediaType, transferSyntaxUID : '1.2.840.10008.1.2.4.50' } ]
672+ mediaTypes : [
673+ { mediaType, transferSyntaxUID : '1.2.840.10008.1.2.4.50' }
674+ ]
669675 } ;
670- options . client . retrieveInstanceFrames ( retrieveOptions ) . then ( ( rawFrames ) => {
671- const blob = new Blob ( rawFrames , { type : mediaType } ) ;
672- img . src = window . URL . createObjectURL ( blob ) ;
673- } ) ;
676+ options . client . retrieveInstanceFrames ( retrieveOptions ) . then (
677+ ( rawFrames ) => {
678+ const blob = new Blob ( rawFrames , { type : mediaType } ) ;
679+ img . src = window . URL . createObjectURL ( blob ) ;
680+ }
681+ ) ;
674682 }
675683 } else {
676684 console . warn ( 'could not load tile' ) ;
@@ -839,7 +847,7 @@ class VolumeImageViewer {
839847 }
840848
841849 /** Renders the images in the specified viewport container.
842- * @param {Object } options - Rendering options.
850+ * @param {object } options - Rendering options.
843851 * @param {(string|HTMLElement) } options.container - HTML Element in which the viewer should be injected.
844852 */
845853 render ( options ) {
@@ -912,7 +920,7 @@ class VolumeImageViewer {
912920 }
913921
914922 /** Activates the draw interaction for graphic annotation of regions of interest.
915- * @param {Object } options - Drawing options.
923+ * @param {object } options - Drawing options.
916924 * @param {string } options.geometryType - Name of the geometry type (point, circle, box, polygon, freehandPolygon, line, freehandLine)
917925 */
918926 activateDrawInteraction ( options ) {
@@ -1000,7 +1008,7 @@ class VolumeImageViewer {
10001008
10011009 /* Activates select interaction.
10021010 *
1003- * @param {Object } options - Selection options.
1011+ * @param {object } options - Selection options.
10041012 */
10051013 activateSelectInteraction ( options = { } ) {
10061014 this . deactivateSelectInteraction ( ) ;
@@ -1037,7 +1045,7 @@ class VolumeImageViewer {
10371045
10381046 /** Activates modify interaction.
10391047 *
1040- * @param {Object } options - Modification options.
1048+ * @param {object } options - Modification options.
10411049 */
10421050 activateModifyInteraction ( options = { } ) {
10431051 this . deactivateModifyInteraction ( ) ;
@@ -1181,11 +1189,12 @@ class _NonVolumeImageViewer {
11811189
11821190 /** Creates a viewer instance for displaying non-VOLUME images.
11831191 *
1184- * @param {Object } options
1185- * @param {Object } options.client - A DICOMwebClient instance for interacting with an origin server over HTTP.
1186- * @param {Object } options.metadata - DICOM JSON metadata object for a VL Whole Slide Microscopy Image instance.
1187- * @param {Object } [options.orientation] - Orientation of the slide (vertical: label on top, or horizontal: label on right side).
1188- * @param {Object } [options.resizeFactor] - To which extent image should be reduced in size (fraction).
1192+ * @param {object } options
1193+ * @param {object } options.client - A DICOMwebClient instance for interacting with an origin server over HTTP.
1194+ * @param {object } options.metadata - DICOM JSON metadata object for a VL Whole Slide Microscopy Image instance.
1195+ * @param {string } options.orientation - Orientation of the slide (vertical: label on top, or horizontal: label on right side).
1196+ * @param {number } [options.resizeFactor=1] - To which extent image should be reduced in size (fraction).
1197+ * @param {boolean } [options.includeIccProfile=false] - Whether ICC Profile should be included for correction of image colors.
11891198 */
11901199 constructor ( options ) {
11911200 this [ _client ] = options . client ;
@@ -1213,18 +1222,24 @@ class _NonVolumeImageViewer {
12131222 const seriesInstanceUID = DICOMwebClient . utils . getSeriesInstanceUIDFromUri ( src ) ;
12141223 const sopInstanceUID = DICOMwebClient . utils . getSOPInstanceUIDFromUri ( src ) ;
12151224 const mediaType = 'image/png' ;
1225+ const queryParams = {
1226+ viewport : [
1227+ this [ _metadata ] . TotalPixelMatrixRows ,
1228+ this [ _metadata ] . TotalPixelMatrixColumns
1229+ ] . join ( ',' )
1230+ } ;
1231+ // We make this optional because a) not all archives currently support
1232+ // this query parameter and b) because ICC Profiles can be large and
1233+ // their inclusion can result in significant overhead.
1234+ if ( options . includeIccProfile ) {
1235+ queryParams [ 'iccprofile' ] = 'yes' ;
1236+ }
12161237 const retrieveOptions = {
12171238 studyInstanceUID : this [ _metadata ] . StudyInstanceUID ,
12181239 seriesInstanceUID : this [ _metadata ] . SeriesInstanceUID ,
12191240 sopInstanceUID : this [ _metadata ] . SOPInstanceUID ,
12201241 mediaTypes : [ { mediaType } ] ,
1221- queryParams : {
1222- viewport : [
1223- this [ _metadata ] . TotalPixelMatrixRows ,
1224- this [ _metadata ] . TotalPixelMatrixColumns
1225- ] . join ( ',' ) ,
1226- iccprofile : 'yes'
1227- }
1242+ queryParams : queryParams
12281243 } ;
12291244 options . client . retrieveInstanceRendered ( retrieveOptions ) . then ( ( thumbnail ) => {
12301245 const blob = new Blob ( [ thumbnail ] , { type : mediaType } ) ;
@@ -1258,10 +1273,11 @@ class _NonVolumeImageViewer {
12581273 source : rasterSource ,
12591274 } ) ;
12601275
1261- var rotation = 0 ;
1262- if ( options . orientation === 'horizontal' ) {
1263- const degrees = 90 ;
1264- rotation = degrees * ( Math . PI / 180 ) ;
1276+ // The default rotation is 'horizontal' with the slide label on the right
1277+ var rotation = _getRotation ( this [ _metadata ] ) ;
1278+ if ( options . orientation === 'vertical' ) {
1279+ // Rotate counterclockwise by 90 degrees to have slide label at the top
1280+ rotation -= 90 * ( Math . PI / 180 ) ;
12651281 }
12661282
12671283 const view = new View ( {
@@ -1281,7 +1297,7 @@ class _NonVolumeImageViewer {
12811297 }
12821298
12831299 /** Renders the image in the specified viewport container.
1284- * @param {Object } options - Rendering options.
1300+ * @param {object } options - Rendering options.
12851301 * @param {(string|HTMLElement) } options.container - HTML Element in which the viewer should be injected.
12861302 */
12871303 render ( options ) {
@@ -1328,12 +1344,15 @@ class OverviewImageViewer extends _NonVolumeImageViewer {
13281344
13291345 /** Creates a viewer instance for displaying OVERVIEW images.
13301346 *
1331- * @param {Object } options
1332- * @param {Object } options.client - A DICOMwebClient instance for interacting with an origin server over HTTP.
1333- * @param {Object } options.metadata - DICOM JSON metadata object for a VL Whole Slide Microscopy Image instance.
1347+ * @param {object } options
1348+ * @param {object } options.client - A DICOMwebClient instance for interacting with an origin server over HTTP.
1349+ * @param {object } options.metadata - DICOM JSON metadata object for a VL Whole Slide Microscopy Image instance.
1350+ * @param {string } [options.orientation='horizontal'] - Orientation of the slide (vertical: label on top, or horizontal: label on right side).
1351+ * @param {number } [options.resizeFactor=1] - To which extent image should be reduced in size (fraction).
1352+ * @param {boolean } [options.includeIccProfile=false] - Whether ICC Profile should be included for correction of image colors.
13341353 */
13351354 constructor ( options ) {
1336- if ( ! ( ' orientation' in options ) ) {
1355+ if ( options . orientation === undefined ) {
13371356 options . orientation = 'horizontal' ;
13381357 }
13391358 super ( options )
@@ -1350,12 +1369,15 @@ class LabelImageViewer extends _NonVolumeImageViewer {
13501369
13511370 /** Creates a viewer instance for displaying LABEL images.
13521371 *
1353- * @param {Object } options
1354- * @param {Object } options.client - A DICOMwebClient instance for interacting with an origin server over HTTP.
1355- * @param {Object } options.metadata - DICOM JSON metadata object for a VL Whole Slide Microscopy Image instance.
1372+ * @param {object } options
1373+ * @param {object } options.client - A DICOMwebClient instance for interacting with an origin server over HTTP.
1374+ * @param {object } options.metadata - DICOM JSON metadata object for a VL Whole Slide Microscopy Image instance.
1375+ * @param {string } [options.orientation='vertical'] - Orientation of the slide (vertical: label on top, or horizontal: label on right side).
1376+ * @param {number } [options.resizeFactor=1] - To which extent image should be reduced in size (fraction).
1377+ * @param {boolean } [options.includeIccProfile=false] - Whether ICC Profile should be included for correction of image colors.
13561378 */
13571379 constructor ( options ) {
1358- if ( ! ( ' orientation' in options ) ) {
1380+ if ( options . orientation === undefined ) {
13591381 options . orientation = 'vertical' ;
13601382 }
13611383 super ( options )
0 commit comments