Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR attempts to fix #1459.
I replicated the issue by:
LuCa-7color_[13860,52919]_1x1component_data.tif
(refered asA
) andLuCa-7color_[17572,60173]_3x3component_data.tif
(refered asB
), two different images but with the same channels.A
.A
is displayed.B
while keeping the brightness & contrast dialog open. The histogram ofA
is still displayed.The issue comes from the fact that in ImageDisplay, the function setImageData() is called when an image is open in QuPath. This function calls the
updateChannelOptions()
function and then theupdateHistogramMap()
function (see here):updateChannelOptions()
updates the channelOptions variable. It's an ObservableValue and, because of listeners, the BrightnessContrastHistogramPane.updateHistogram() function is called. This is the function responsible for displaying the histogram.updateHistogramMap()
updates thehistogramManager
variable. This variable is responsible for providing the histogram values.So the problem is that the function displaying the histogram can be called before the function updating the histogram values. It is not possible to simply switch the calls of the
updateChannelOptions()
andupdateHistogramMap()
functions.The solution I found was to make
histogramManager
an ObservableValue. In this case,BrightnessContrastHistogramPane.updateHistogram()
can be called each time thehistogramManager
value changes.I don't like this solution as it exposes the
histogramManager
variable (which is an implementation detail). But this was the solution requiring the less amount of refactoring I found.