@@ -3753,6 +3753,29 @@ class VolumeImageViewer {
37533753 color : this [ _options ] . primaryColor
37543754 }
37553755
3756+ // Helper function to extract color from annotation group metadata
3757+ const extractAnnotationGroupColor = ( annotationGroupItem ) => {
3758+ if ( annotationGroupItem . RecommendedDisplayCIELabValue &&
3759+ Array . isArray ( annotationGroupItem . RecommendedDisplayCIELabValue ) ) {
3760+ try {
3761+ // Convert CIELab to RGB using dcmjs
3762+ const labValues = annotationGroupItem . RecommendedDisplayCIELabValue
3763+ if ( labValues . length >= 3 ) {
3764+ const rgb = dcmjs . data . Colors . dicomlab2RGB ( labValues )
3765+ // Convert from 0-1 range to 0-255 range and round to integers
3766+ return [
3767+ Math . max ( 0 , Math . min ( 255 , Math . round ( rgb [ 0 ] * 255 ) ) ) ,
3768+ Math . max ( 0 , Math . min ( 255 , Math . round ( rgb [ 1 ] * 255 ) ) ) ,
3769+ Math . max ( 0 , Math . min ( 255 , Math . round ( rgb [ 2 ] * 255 ) ) )
3770+ ]
3771+ }
3772+ } catch ( error ) {
3773+ console . warn ( 'Failed to convert CIELab to RGB for annotation group:' , error )
3774+ }
3775+ }
3776+ return null
3777+ }
3778+
37563779 // We need to bind those variables to constants for the loader function
37573780 const client = _getClient (
37583781 this [ _clients ] ,
@@ -3783,6 +3806,14 @@ class VolumeImageViewer {
37833806 */
37843807 metadata . AnnotationGroupSequence . forEach ( ( item ) => {
37853808 const annotationGroupUID = item . AnnotationGroupUID
3809+
3810+ // Extract color from metadata if available
3811+ const extractedColor = extractAnnotationGroupColor ( item )
3812+ const annotationGroupStyle = {
3813+ opacity : defaultAnnotationGroupStyle . opacity ,
3814+ color : extractedColor || defaultAnnotationGroupStyle . color
3815+ }
3816+
37863817 const annotationGroup = {
37873818 annotationGroup : new AnnotationGroup ( {
37883819 uid : annotationGroupUID ,
@@ -3801,8 +3832,8 @@ class VolumeImageViewer {
38013832 referencedSeriesInstanceUID : metadata . ReferencedSeriesSequence [ 0 ] . SeriesInstanceUID ,
38023833 referencedSOPInstanceUID : metadata . ReferencedImageSequence [ 0 ] . ReferencedSOPInstanceUID
38033834 } ) ,
3804- style : { ...defaultAnnotationGroupStyle } ,
3805- defaultStyle : defaultAnnotationGroupStyle ,
3835+ style : { ...annotationGroupStyle } ,
3836+ defaultStyle : annotationGroupStyle ,
38063837 metadata
38073838 }
38083839
0 commit comments