@@ -81,7 +81,7 @@ const OVERLAY_ADJUSTMENTS = {
8181 */
8282async function fetchColoredRegionData ( boneId , isBonesetSelection = false ) {
8383 if ( ! boneId ) {
84- console . debug ( "[ColoredRegions] No boneId provided for colored regions" ) ;
84+ console . error ( "[ColoredRegions] No boneId provided for colored regions" ) ;
8585 return null ;
8686 }
8787
@@ -90,7 +90,7 @@ async function fetchColoredRegionData(boneId, isBonesetSelection = false) {
9090 // Map ilium to bony_pelvis for boneset selections
9191 let mappedBoneId = boneId ;
9292 if ( boneId === "ilium" && isBonesetSelection ) {
93- console . log ( "[ColoredRegions] Mapping \"ilium\" to \"bony_pelvis\" for boneset selection" ) ;
93+ console . debug ( "[ColoredRegions] Mapping \"ilium\" to \"bony_pelvis\" for boneset selection" ) ;
9494 mappedBoneId = "bony_pelvis" ;
9595 }
9696
@@ -146,9 +146,9 @@ function convertCommandToPixels(command, dimensions, debugInfo = {}) {
146146 if ( command . x !== undefined ) {
147147 converted . x = emuToPixels ( command . x , slideWidth , imageWidth ) ;
148148 if ( debugInfo . isFirstCommand ) {
149- console . log ( `[ColoredRegions] First coord conversion: EMU(${ command . x } , ${ command . y } ) -> Pixel(${ converted . x . toFixed ( 2 ) } , ${ emuToPixels ( command . y , slideHeight , imageHeight ) . toFixed ( 2 ) } )` ) ;
150- console . log ( `[ColoredRegions] EMU dimensions: ${ slideWidth } x ${ slideHeight } ` ) ;
151- console . log ( `[ColoredRegions] Pixel dimensions: ${ imageWidth } x ${ imageHeight } ` ) ;
149+ console . debug ( `[ColoredRegions] First coord conversion: EMU(${ command . x } , ${ command . y } ) -> Pixel(${ converted . x . toFixed ( 2 ) } , ${ emuToPixels ( command . y , slideHeight , imageHeight ) . toFixed ( 2 ) } )` ) ;
150+ console . debug ( `[ColoredRegions] EMU dimensions: ${ slideWidth } x ${ slideHeight } ` ) ;
151+ console . debug ( `[ColoredRegions] Pixel dimensions: ${ imageWidth } x ${ imageHeight } ` ) ;
152152 }
153153 }
154154 if ( command . y !== undefined ) {
@@ -235,14 +235,14 @@ function createColoredRegionsSVG(coloredRegions, imageWidth, imageHeight, imageD
235235 svg . style . width = "100%" ;
236236 svg . style . height = "100%" ;
237237 svg . style . pointerEvents = "none" ; // Allow clicks to pass through to image
238-
239- console . log ( `[ColoredRegions DEBUG] Creating SVG for bone: ${ boneId } , imageIndex: ${ imageIndex } ` ) ;
240- console . log ( "[ColoredRegions DEBUG] OVERLAY_ADJUSTMENTS lookup:" , OVERLAY_ADJUSTMENTS [ boneId ] ) ;
238+
239+ console . debug ( `[ColoredRegions DEBUG] Creating SVG for bone: ${ boneId } , imageIndex: ${ imageIndex } ` ) ;
240+ console . debug ( "[ColoredRegions DEBUG] OVERLAY_ADJUSTMENTS lookup:" , OVERLAY_ADJUSTMENTS [ boneId ] ) ;
241241
242242 // Apply positioning adjustments if defined for this bone and image
243243 if ( OVERLAY_ADJUSTMENTS [ boneId ] && OVERLAY_ADJUSTMENTS [ boneId ] [ imageIndex ] ) {
244244 const adjustments = OVERLAY_ADJUSTMENTS [ boneId ] [ imageIndex ] ;
245- console . log ( "[ColoredRegions DEBUG] Found adjustments:" , adjustments ) ;
245+ console . debug ( "[ColoredRegions DEBUG] Found adjustments:" , adjustments ) ;
246246 const transforms = [ ] ;
247247
248248 if ( adjustments . x !== 0 || adjustments . y !== 0 ) {
@@ -260,7 +260,7 @@ function createColoredRegionsSVG(coloredRegions, imageWidth, imageHeight, imageD
260260 if ( transforms . length > 0 ) {
261261 svg . style . transform = transforms . join ( " " ) ;
262262 svg . style . transformOrigin = "center" ;
263- console . log ( `[ColoredRegions] Applied positioning adjustments for ${ boneId } image ${ imageIndex } : ${ svg . style . transform } ` ) ;
263+ console . debug ( `[ColoredRegions] Applied positioning adjustments for ${ boneId } image ${ imageIndex } : ${ svg . style . transform } ` ) ;
264264 }
265265 }
266266
@@ -273,8 +273,8 @@ function createColoredRegionsSVG(coloredRegions, imageWidth, imageHeight, imageD
273273 imageWidth : imageWidth ,
274274 imageHeight : imageHeight
275275 } ;
276-
277- console . log ( "[ColoredRegions] Coordinate conversion:" , {
276+
277+ console . debug ( "[ColoredRegions] Coordinate conversion:" , {
278278 sourceWidth : dimensions . slideWidth ,
279279 sourceHeight : dimensions . slideHeight ,
280280 targetWidth : dimensions . imageWidth ,
@@ -357,7 +357,6 @@ function createColoredRegionsSVG(coloredRegions, imageWidth, imageHeight, imageD
357357 path . setAttribute ( "data-region-type" , "fill" ) ;
358358 }
359359
360- // Add to SVG
361360 svg . appendChild ( path ) ;
362361
363362 console . debug ( `Created colored region path ${ pathIndex + 1 } /${ pathDataArray . length } : ${ region . anatomical_name } (${ region . color_name } )` ) ;
@@ -382,9 +381,8 @@ function createColoredRegionsSVG(coloredRegions, imageWidth, imageHeight, imageD
382381 * @returns {Promise<void> }
383382 */
384383export async function displayColoredRegions ( imageElement , boneId , imageIndex = 0 , isBonesetSelection = false ) {
385- console . log ( "[ColoredRegions] ============ START displayColoredRegions ============" ) ;
386- console . log ( `[ColoredRegions] boneId: ${ boneId } , imageIndex: ${ imageIndex } , isBonesetSelection: ${ isBonesetSelection } ` ) ;
387- console . log ( "[ColoredRegions] imageElement:" , imageElement ) ;
384+ console . debug ( `[ColoredRegions] boneId: ${ boneId } , imageIndex: ${ imageIndex } , isBonesetSelection: ${ isBonesetSelection } ` ) ;
385+ console . debug ( "[ColoredRegions] imageElement:" , imageElement ) ;
388386
389387 if ( ! imageElement || ! boneId ) {
390388 console . debug ( "[ColoredRegions] Missing image element or boneId for colored regions" ) ;
@@ -395,7 +393,7 @@ export async function displayColoredRegions(imageElement, boneId, imageIndex = 0
395393 let mappedBoneId = boneId ;
396394 if ( boneId === "ilium" && isBonesetSelection ) {
397395 mappedBoneId = "bony_pelvis" ;
398- console . log ( "[ColoredRegions] Using mapped bone ID \"bony_pelvis\" for positioning adjustments" ) ;
396+ console . debug ( "[ColoredRegions] Using mapped bone ID \"bony_pelvis\" for positioning adjustments" ) ;
399397 }
400398
401399 // Fetch colored region data
@@ -404,7 +402,7 @@ export async function displayColoredRegions(imageElement, boneId, imageIndex = 0
404402
405403 // Return early if no colored region data exists
406404 if ( ! regionData ) {
407- console . debug ( `[ColoredRegions] No colored regions to display for ${ boneId } ` ) ;
405+ console . log ( `[ColoredRegions] No colored regions to display for ${ boneId } ` ) ;
408406 return ;
409407 }
410408
@@ -413,8 +411,8 @@ export async function displayColoredRegions(imageElement, boneId, imageIndex = 0
413411 let regionsToDisplay = [ ] ;
414412
415413 if ( regionData . images && Array . isArray ( regionData . images ) ) {
416- // New structure: data organized by image
417- console . log ( `[ColoredRegions] Using new multi -image structure with ${ regionData . images . length } images` ) ;
414+ // One possible structure: data organized by image
415+ console . debug ( `[ColoredRegions] Using organized-by -image structure with ${ regionData . images . length } images` ) ;
418416
419417 if ( imageIndex >= 0 && imageIndex < regionData . images . length ) {
420418 imageData = regionData . images [ imageIndex ] ;
@@ -424,8 +422,8 @@ export async function displayColoredRegions(imageElement, boneId, imageIndex = 0
424422 return ;
425423 }
426424 } else if ( regionData . colored_regions ) {
427- // Old structure: single set of regions for all images
428- console . log ( "[ColoredRegions] Using old single-image structure" ) ;
425+ // Alternate structure: single set of regions for all images
426+ console . debug ( "[ColoredRegions] Using alternate structure" ) ;
429427 regionsToDisplay = regionData . colored_regions ;
430428 imageData = {
431429 width : regionData . image_dimensions ?. width ,
@@ -442,7 +440,7 @@ export async function displayColoredRegions(imageElement, boneId, imageIndex = 0
442440
443441 // Wait for image to load to get correct dimensions
444442 if ( ! imageElement . complete ) {
445- console . log ( "[ColoredRegions] Waiting for image to complete loading..." ) ;
443+ console . debug ( "[ColoredRegions] Waiting for image to complete loading..." ) ;
446444 await new Promise ( resolve => {
447445 imageElement . addEventListener ( "load" , resolve , { once : true } ) ;
448446 } ) ;
@@ -454,8 +452,8 @@ export async function displayColoredRegions(imageElement, boneId, imageIndex = 0
454452 const imageWidth = imageElement . naturalWidth ;
455453 const imageHeight = imageElement . naturalHeight ;
456454
457- console . log ( `[ColoredRegions] Image natural dimensions: ${ imageWidth } x${ imageHeight } ` ) ;
458- console . log ( `[ColoredRegions] Image displayed dimensions: ${ imageElement . offsetWidth } x${ imageElement . offsetHeight } ` ) ;
455+ console . debug ( `[ColoredRegions] Image natural dimensions: ${ imageWidth } x${ imageHeight } ` ) ;
456+ console . debug ( `[ColoredRegions] Image displayed dimensions: ${ imageElement . offsetWidth } x${ imageElement . offsetHeight } ` ) ;
459457
460458 if ( imageWidth === 0 || imageHeight === 0 ) {
461459 console . warn ( "[ColoredRegions] Image has zero dimensions, cannot display colored regions" ) ;
@@ -492,13 +490,13 @@ export async function displayColoredRegions(imageElement, boneId, imageIndex = 0
492490
493491 // Add the SVG overlay
494492 parent . appendChild ( svg ) ;
495-
496- console . log ( "[ColoredRegions] SVG appended to parent container" ) ;
497- console . log ( "[ColoredRegions] Parent element:" , parent ) ;
498- console . log ( "[ColoredRegions] Parent classes:" , parent . className ) ;
499- console . log ( "[ColoredRegions] SVG data-bone attribute:" , svg . getAttribute ( "data-bone" ) ) ;
500- console . log ( "[ColoredRegions] SVG element:" , svg ) ;
501- console . log ( `[ColoredRegions] SVG has ${ svg . children . length } path elements` ) ;
493+
494+ console . debug ( "[ColoredRegions] SVG appended to parent container" ) ;
495+ console . debug ( "[ColoredRegions] Parent element:" , parent ) ;
496+ console . debug ( "[ColoredRegions] Parent classes:" , parent . className ) ;
497+ console . debug ( "[ColoredRegions] SVG data-bone attribute:" , svg . getAttribute ( "data-bone" ) ) ;
498+ console . debug ( "[ColoredRegions] SVG element:" , svg ) ;
499+ console . debug ( `[ColoredRegions] SVG has ${ svg . children . length } path elements` ) ;
502500
503501 console . log ( `[ColoredRegions] Successfully displayed ${ regionsToDisplay . length } colored regions for image ${ imageIndex } ` ) ;
504502}
0 commit comments