From 1979d98a1e2713ea371cabb3254a7c250d80468b Mon Sep 17 00:00:00 2001 From: Anne Haley Date: Fri, 26 May 2023 12:34:04 -0400 Subject: [PATCH 01/32] Send item Id through Frame Selector and maintain composite layers data --- .../views/imageViewerSelectWidget.js | 1 + .../vue/components/FrameSelector.vue | 27 +++++++++++++++---- 2 files changed, 23 insertions(+), 5 deletions(-) diff --git a/girder/girder_large_image/web_client/views/imageViewerSelectWidget.js b/girder/girder_large_image/web_client/views/imageViewerSelectWidget.js index b29389b39..544e31bff 100644 --- a/girder/girder_large_image/web_client/views/imageViewerSelectWidget.js +++ b/girder/girder_large_image/web_client/views/imageViewerSelectWidget.js @@ -71,6 +71,7 @@ var ImageViewerSelectWidget = View.extend({ const vm = new FrameSelector({ el, propsData: { + itemId: this.itemId, imageMetadata: imageMetadata, frameUpdate: frameUpdate } diff --git a/girder/girder_large_image/web_client/vue/components/FrameSelector.vue b/girder/girder_large_image/web_client/vue/components/FrameSelector.vue index 7eda00758..1507b3785 100644 --- a/girder/girder_large_image/web_client/vue/components/FrameSelector.vue +++ b/girder/girder_large_image/web_client/vue/components/FrameSelector.vue @@ -3,10 +3,11 @@ import Vue from 'vue'; import CompositeLayers from './CompositeLayers.vue'; import DualInput from './DualInput.vue' export default Vue.extend({ - props: ['imageMetadata', 'frameUpdate'], + props: ['itemId', 'imageMetadata', 'frameUpdate'], components: { CompositeLayers, DualInput }, data() { return { + loaded: false, currentFrame: 0, maxFrame: 0, sliderModes: [], @@ -131,12 +132,13 @@ export default Vue.extend({ this.maxFrame = this.imageMetadata.frames.length - 1 this.populateIndices() this.populateModes() + this.loaded = true } }); @@ -212,4 +254,13 @@ export default { .draggable { cursor: move; } +.percentage-input { + position: relative; +} +.percentage-input::after { + position: absolute; + content: '%'; + left: 35px; + top: 3px; +} From c18adbfddc58f5c31e75197929c44d4c333056df Mon Sep 17 00:00:00 2001 From: Anne Haley Date: Wed, 31 May 2023 12:14:04 -0400 Subject: [PATCH 06/32] Fix fetching histograms, refetch on currentFrame change --- .../vue/components/CompositeLayers.vue | 62 ++++++++++++------- 1 file changed, 38 insertions(+), 24 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 4763f0c8e..75ce423e1 100644 --- a/girder/girder_large_image/web_client/vue/components/CompositeLayers.vue +++ b/girder/girder_large_image/web_client/vue/components/CompositeLayers.vue @@ -58,35 +58,43 @@ export default { usedColors.push(chosenColor) } }) + this.fetchHistograms() + }, + fetchHistograms() { if (this.layerMap) { // layers are channels; each layer has a frame delta - Promise.all(this.layers.map((layer) => + this.layers.forEach((layer) => { restRequest({ type: 'GET', url: 'item/' + this.itemId + '/tiles/histogram', data: { frame: this.currentFrame + this.compositeLayerInfo[layer].framedelta, + width: 1024, + height: 1024, + bins: 512, } }).then((response) => { if (response.length < 3) { - return response[0] + this.histograms.push(response[0]) } else { - return response[1] + this.histograms.push(response[1]) } - }))).then((responses) => { - this.histograms = responses }) + }) } else { // layers are bands; they share the same frame restRequest({ - type: 'GET', - url: 'item/' + this.itemId + '/tiles/histogram', - data: { - frame: this.currentFrame, - } - }).then((response) => { - this.histograms = response - }); + type: 'GET', + url: 'item/' + this.itemId + '/tiles/histogram', + data: { + frame: this.currentFrame, + width: 1024, + height: 1024, + bins: 512, + } + }).then((response) => { + this.histograms = response + }); } }, toggleEnableAll() { @@ -164,18 +172,24 @@ export default { }, }, watch: { + currentFrame() { + this.histograms = [] + this.fetchHistograms() + }, histograms() { this.layers.forEach((layer, index) => { - const { min, max } = this.histograms[index] - this.compositeLayerInfo[layer] = Object.assign( - this.compositeLayerInfo[layer], { - min, - max, - defaultMin: min, - defaultMax: max, - } - ) - this.compositeLayerInfo = Object.assign({}, this.compositeLayerInfo) + if(this.histograms.length > index) { + const { min, max } = this.histograms[index] + this.compositeLayerInfo[layer] = Object.assign( + this.compositeLayerInfo[layer], { + min, + max, + defaultMin: min, + defaultMax: max, + } + ) + this.compositeLayerInfo = Object.assign({}, this.compositeLayerInfo) + } }) } }, @@ -251,7 +265,7 @@ export default { : expandedRows.includes(index) ? '▲' : '▼' }} -
+
Date: Wed, 31 May 2023 12:19:20 -0400 Subject: [PATCH 07/32] Make right tail value 100 - percentage --- .../web_client/vue/components/HistogramEditor.vue | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/girder/girder_large_image/web_client/vue/components/HistogramEditor.vue b/girder/girder_large_image/web_client/vue/components/HistogramEditor.vue index 63b996804..ac660b4bd 100644 --- a/girder/girder_large_image/web_client/vue/components/HistogramEditor.vue +++ b/girder/girder_large_image/web_client/vue/components/HistogramEditor.vue @@ -184,7 +184,7 @@ export default { >
From 8dff2257ba6f081054552cf690734e4d95a49106 Mon Sep 17 00:00:00 2001 From: Anne Haley Date: Wed, 31 May 2023 13:00:32 -0400 Subject: [PATCH 08/32] Only render composite layers for groups that exist --- .../web_client/vue/components/FrameSelector.vue | 2 ++ 1 file changed, 2 insertions(+) diff --git a/girder/girder_large_image/web_client/vue/components/FrameSelector.vue b/girder/girder_large_image/web_client/vue/components/FrameSelector.vue index 1507b3785..4150fa051 100644 --- a/girder/girder_large_image/web_client/vue/components/FrameSelector.vue +++ b/girder/girder_large_image/web_client/vue/components/FrameSelector.vue @@ -179,6 +179,7 @@ export default Vue.extend({
Date: Wed, 31 May 2023 13:01:04 -0400 Subject: [PATCH 09/32] Shorten max frequency height where appropriate --- .../web_client/vue/components/HistogramEditor.vue | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/girder/girder_large_image/web_client/vue/components/HistogramEditor.vue b/girder/girder_large_image/web_client/vue/components/HistogramEditor.vue index ac660b4bd..22fb1c1f0 100644 --- a/girder/girder_large_image/web_client/vue/components/HistogramEditor.vue +++ b/girder/girder_large_image/web_client/vue/components/HistogramEditor.vue @@ -31,6 +31,13 @@ export default { this.$refs.canvas.setAttribute('height', clientHeight) const maxFrequency = Math.max(...hist) + const minFrequency = Math.min(...hist) + const secondMaxFrequency = Math.max(...hist.filter((v) => v !== maxFrequency)) + const shortenMaxFrequency = ( + secondMaxFrequency > minFrequency + && (maxFrequency - secondMaxFrequency) > secondMaxFrequency / 3 + ) + const {width, height} = this.$refs.canvas const ctx = this.$refs.canvas.getContext("2d"); const widthBetweenPoints = width / hist.length @@ -41,7 +48,11 @@ export default { for (var i = 0; i < hist.length; i++) { const frequency = hist[i] const pointX = widthBetweenPoints * i - const pointY = height - (frequency / maxFrequency * height) + + let pointY = height - (frequency / maxFrequency * height) + if(shortenMaxFrequency) { + pointY = frequency === maxFrequency ? 0 : height - (frequency / secondMaxFrequency * height * 2 / 3) + } ctx.lineTo(pointX, pointY) } ctx.stroke(); From 91096edafc475d8691334d517c41c2ec068dbd0c Mon Sep 17 00:00:00 2001 From: Anne Haley Date: Wed, 31 May 2023 13:09:13 -0400 Subject: [PATCH 10/32] Reduce auto tails --- .../web_client/vue/components/HistogramEditor.vue | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/girder/girder_large_image/web_client/vue/components/HistogramEditor.vue b/girder/girder_large_image/web_client/vue/components/HistogramEditor.vue index 22fb1c1f0..3d44c2349 100644 --- a/girder/girder_large_image/web_client/vue/components/HistogramEditor.vue +++ b/girder/girder_large_image/web_client/vue/components/HistogramEditor.vue @@ -172,8 +172,8 @@ export default { }, tailsMode() { if (this.tailsMode) { - this.$emit('updateMin', this.fromDistributionPercentage(0.05)), - this.$emit('updateMax', this.fromDistributionPercentage(0.95)) + this.$emit('updateMin', this.fromDistributionPercentage(0.01)), + this.$emit('updateMax', this.fromDistributionPercentage(0.99)) } } } From bc037fdf9d24a701308d20f5d1c118e9dc6fe872 Mon Sep 17 00:00:00 2001 From: Anne Haley Date: Wed, 31 May 2023 13:12:17 -0400 Subject: [PATCH 11/32] Lint fix --- girder/girder_large_image/web_client/vue/utils/colors.js | 1 - 1 file changed, 1 deletion(-) diff --git a/girder/girder_large_image/web_client/vue/utils/colors.js b/girder/girder_large_image/web_client/vue/utils/colors.js index 229961337..9bc77c284 100644 --- a/girder/girder_large_image/web_client/vue/utils/colors.js +++ b/girder/girder_large_image/web_client/vue/utils/colors.js @@ -1,4 +1,3 @@ - export const CHANNEL_COLORS = { BRIGHTFIELD: '#FFFFFF', DAPI: '#0000FF', From 4f10794f9e22a0bf795e7c544b2af064834579fd Mon Sep 17 00:00:00 2001 From: Anne Haley Date: Thu, 1 Jun 2023 15:00:57 -0400 Subject: [PATCH 12/32] Remove inline width --- .../web_client/vue/components/FrameSelector.vue | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/girder/girder_large_image/web_client/vue/components/FrameSelector.vue b/girder/girder_large_image/web_client/vue/components/FrameSelector.vue index 4150fa051..4422bbd63 100644 --- a/girder/girder_large_image/web_client/vue/components/FrameSelector.vue +++ b/girder/girder_large_image/web_client/vue/components/FrameSelector.vue @@ -176,7 +176,7 @@ export default Vue.extend({ -
+
Date: Tue, 6 Jun 2023 12:02:41 -0400 Subject: [PATCH 13/32] Remove extra parameters in tile style queries --- .../web_client/vue/components/CompositeLayers.vue | 9 +++++++-- 1 file changed, 7 insertions(+), 2 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 75ce423e1..cd4696d2c 100644 --- a/girder/girder_large_image/web_client/vue/components/CompositeLayers.vue +++ b/girder/girder_large_image/web_client/vue/components/CompositeLayers.vue @@ -164,8 +164,13 @@ export default { ).filter((layer) => layer.enabled); const styleArray = [] activeLayers.forEach((layer) => { - const styleEntry = Object.assign({}, layer); - delete styleEntry.enabled + const styleEntry = { + min: layer.min, + max: layer.max, + palette: layer.palette, + framedelta: layer.framedelta, + band: layer.band, + } styleArray.push(styleEntry); }); this.$emit('updateStyle', {bands: styleArray}); From d1fb156c64ec7db6805183160895f5f2edce9a17 Mon Sep 17 00:00:00 2001 From: Anne Haley Date: Tue, 6 Jun 2023 12:03:35 -0400 Subject: [PATCH 14/32] Add resample: false in histogram query --- .../web_client/vue/components/CompositeLayers.vue | 2 ++ 1 file changed, 2 insertions(+) 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 cd4696d2c..54fa9626b 100644 --- a/girder/girder_large_image/web_client/vue/components/CompositeLayers.vue +++ b/girder/girder_large_image/web_client/vue/components/CompositeLayers.vue @@ -72,6 +72,7 @@ export default { width: 1024, height: 1024, bins: 512, + resample: false, } }).then((response) => { if (response.length < 3) { @@ -91,6 +92,7 @@ export default { width: 1024, height: 1024, bins: 512, + resample: false, } }).then((response) => { this.histograms = response From b44d581d3a457415036a8f2d46bbcb8d8e2dfbe0 Mon Sep 17 00:00:00 2001 From: Anne Haley Date: Tue, 6 Jun 2023 12:05:49 -0400 Subject: [PATCH 15/32] Consolidate histogram params definition --- .../vue/components/CompositeLayers.vue | 26 +++++++++---------- 1 file changed, 12 insertions(+), 14 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 54fa9626b..0839383ae 100644 --- a/girder/girder_large_image/web_client/vue/components/CompositeLayers.vue +++ b/girder/girder_large_image/web_client/vue/components/CompositeLayers.vue @@ -61,19 +61,23 @@ export default { this.fetchHistograms() }, fetchHistograms() { + const histogramParams = { + frame: this.currentFrame, + width: 1024, + height: 1024, + bins: 512, + resample: false, + } if (this.layerMap) { // layers are channels; each layer has a frame delta this.layers.forEach((layer) => { restRequest({ type: 'GET', url: 'item/' + this.itemId + '/tiles/histogram', - data: { - frame: this.currentFrame + this.compositeLayerInfo[layer].framedelta, - width: 1024, - height: 1024, - bins: 512, - resample: false, - } + data: Object.assign( + histogramParams, + {frame: this.currentFrame + this.compositeLayerInfo[layer].framedelta} + ) }).then((response) => { if (response.length < 3) { this.histograms.push(response[0]) @@ -87,13 +91,7 @@ export default { restRequest({ type: 'GET', url: 'item/' + this.itemId + '/tiles/histogram', - data: { - frame: this.currentFrame, - width: 1024, - height: 1024, - bins: 512, - resample: false, - } + data: histogramParams, }).then((response) => { this.histograms = response }); From 7eac9c8d7876ca7bb0df2f00f116c3b07802511c Mon Sep 17 00:00:00 2001 From: Anne Haley Date: Tue, 6 Jun 2023 12:08:37 -0400 Subject: [PATCH 16/32] Remove rounding to int when converting distribution percentages --- .../web_client/vue/components/HistogramEditor.vue | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/girder/girder_large_image/web_client/vue/components/HistogramEditor.vue b/girder/girder_large_image/web_client/vue/components/HistogramEditor.vue index 3d44c2349..467fe060a 100644 --- a/girder/girder_large_image/web_client/vue/components/HistogramEditor.vue +++ b/girder/girder_large_image/web_client/vue/components/HistogramEditor.vue @@ -105,7 +105,7 @@ export default { bucketIndex = index } }) - return Math.round(this.histogram.bin_edges[bucketIndex]); + return this.histogram.bin_edges[bucketIndex]; }, toDistributionPercentage(value) { @@ -115,7 +115,7 @@ export default { numSamples += count } }) - return Math.round(numSamples / this.histogram.samples * 100) + return numSamples / this.histogram.samples * 100 }, updateFromInput(funcName, value) { if (this.tailsMode) { From aef72526cb2663cf1e089f85f43569bc6bf2674f Mon Sep 17 00:00:00 2001 From: Anne Haley Date: Fri, 9 Jun 2023 11:29:51 -0400 Subject: [PATCH 17/32] Add a library for toggle switches --- girder/girder_large_image/web_client/package.json | 1 + 1 file changed, 1 insertion(+) diff --git a/girder/girder_large_image/web_client/package.json b/girder/girder_large_image/web_client/package.json index f22866988..02788119f 100644 --- a/girder/girder_large_image/web_client/package.json +++ b/girder/girder_large_image/web_client/package.json @@ -26,6 +26,7 @@ "vue": "~2.6.14", "vue-color": "^2.8.1", "vue-loader": "~15.9.8", + "vue-switches": "^2.0.1", "vue-template-compiler": "~2.6.14", "webpack": "^3", "yaml": "^2.1.1" From 7163b298712be5d23bcfeee3c1f0f793fc693b57 Mon Sep 17 00:00:00 2001 From: Anne Haley Date: Fri, 9 Jun 2023 11:30:17 -0400 Subject: [PATCH 18/32] Redesign for autoRange --- .../vue/components/CompositeLayers.vue | 208 +++++++++------ .../vue/components/HistogramEditor.vue | 237 +++++++++++------- 2 files changed, 280 insertions(+), 165 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 0839383ae..84133a4a2 100644 --- a/girder/girder_large_image/web_client/vue/components/CompositeLayers.vue +++ b/girder/girder_large_image/web_client/vue/components/CompositeLayers.vue @@ -1,6 +1,7 @@