Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Histogram not updating fix #1462

Closed
wants to merge 1 commit into from
Closed

Conversation

Rylern
Copy link
Contributor

@Rylern Rylern commented Feb 9, 2024

This PR attempts to fix #1459.

I replicated the issue by:

  • Creating and opening a project containing LuCa-7color_[13860,52919]_1x1component_data.tif (refered as A) and LuCa-7color_[17572,60173]_3x3component_data.tif (refered as B), two different images but with the same channels.
  • Opening A.
  • Opening the brightness & contrast dialog. The histogram of A is displayed.
  • Opening B while keeping the brightness & contrast dialog open. The histogram of A 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 the updateHistogramMap() 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 the histogramManager 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() and updateHistogramMap() functions.

The solution I found was to make histogramManager an ObservableValue. In this case, BrightnessContrastHistogramPane.updateHistogram() can be called each time the histogramManager 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.

petebankhead added a commit to petebankhead/qupath that referenced this pull request Mar 1, 2024
Alternative simple approach (hack) to address qupath#1459 based on @Rylern's detailed investigations at qupath#1462
@petebankhead
Copy link
Member

Thanks, this is some excellent detective work!

Closing in favor of #1476 for v0.5.1 because it is simpler (and written based on the info you posted here), but we may revisit it as this is more listener-friendly.

@Rylern Rylern deleted the histogram-update-fix branch March 1, 2024 14:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Brightness/Contrast histogram doesn't always update when switching between similar images
2 participants