From 5274457e9f6a0c27fe4b7b8a239dae7b7946cb39 Mon Sep 17 00:00:00 2001 From: Anne Haley Date: Tue, 27 Jun 2023 10:45:25 -0400 Subject: [PATCH] Use regex to determine known channel matches --- .../vue/components/CompositeLayers.vue | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/girder/girder_large_image/web_client/vue/components/CompositeLayers.vue b/girder/girder_large_image/web_client/vue/components/CompositeLayers.vue index ac59516c5..1160b35a3 100644 --- a/girder/girder_large_image/web_client/vue/components/CompositeLayers.vue +++ b/girder/girder_large_image/web_client/vue/components/CompositeLayers.vue @@ -47,15 +47,20 @@ export default { autoRange: undefined } }) - Object.entries(CHANNEL_COLORS).forEach(([channelName, color]) => { - if(this.layers.includes(channelName)){ - this.compositeLayerInfo[channelName].palette = color - usedColors.push(color) - } - }) + // Assign colors this.layers.forEach((layerName) => { if (!this.compositeLayerInfo[layerName].palette) { let chosenColor; + + // Search for case-insensitive regex match among known channel-colors + Object.entries(CHANNEL_COLORS).forEach(([channelName, color]) => { + if (layerName.toUpperCase().match( + new RegExp("^" + channelName + ".*$") + )) { + chosenColor = color + } + }) + const unusedColors = OTHER_COLORS.filter( (color) => !usedColors.includes(color) )