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

Colorbar feature #605

Open
wants to merge 42 commits into
base: master
Choose a base branch
from
Open

Colorbar feature #605

wants to merge 42 commits into from

Conversation

Tom-TBT
Copy link
Contributor

@Tom-TBT Tom-TBT commented Dec 9, 2024

This PR implements the optional display of a colorbar next to a panel. The colorbar shows the mapping between pixel values and LUT ("normal" color included). This is work from @MinaEnayat and me.
There are still adjustments to be made, but this is functional and mature enough that we thought it was ready to receive comments/ideas.

image

Implemented features:

  • colorbar display showing the LUT of the first active channel (opinion on what other behavior when more than 1 channel?)
  • The colorbar can be placed on one of the four sides of the panel
  • Parameters for:
    • thickness of the colorbar
    • spacing between colorbar and panel
    • number of ticks+labels
    • ticks+labels+spine color
    • tick length
    • label margin (distance between label and dash)
    • label font size
  • Crop page around panels handles horizontal labels (measure the CSS property of generated labels). Could be adapted for the handling of right/left normal labels
  • Export to pdf / tiff

A spine with the ticks and labels gives a visual clue when the LUT is the same color as the page background, but only on one side to avoid confusion with the LUT when the LUT is the same color as the spine:
image

Suggestions for tests:

  • Intensity range:
    • 0-255 (full range)
    • 40-190 (different start-end value)
    • 16-bit range
  • reversed channel flips the colorbar (not the labels)
  • uneven panel resizing (width/height without keeping the ratio).
  • Parameter testing thickness, spacing, label font, label margin, and tick length:
    • python export handles them all
    • "crop page around panel" handles them all
  • all tests above for the python export to tiff & pdf

Known issues / work left:

  • CSS display of ticks's dashes is uneven -> cannot be solved afaik (not the case with the exported figure)
  • Labels in python left justified. Make them the same way in JS
  • Labels in python do not always match the labels in JS (rounding difference)
  • Handle left/right normal labels for "crop page around panels"
  • labels are rounded according to the ticks spread: -log10(end-start / num_ticks)
  • Rearrange Colorbar form (adding/removing options ?)

MinaEnayat and others added 30 commits November 18, 2024 16:56
this.render();
});
this.loadLuts();
this.render();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This change now calls this.render() before the luts have loaded. Haven't tested to see if this actually causes a bug, but I think this will be fixed with:

this.loadLuts().then(() => this.render());

@will-moore
Copy link
Member

I wonder if you want to allow users to choose the channel for the colorbar (if you have more than one active)?
In this case, I'm most interested in the Green channel (but I still want the Red channel to be active):

Screenshot 2025-01-10 at 14 31 28

It's even possible to imagine someone wanting 2 or more colorbars at once, for different channels, but I guess that's a bit edge case (you would just do a split-view figure).
Actually, you can fake it by duplicating the panel and overlaying both panels, with the underneath panel having just one channel active! :)

Screenshot 2025-01-10 at 14 36 31

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants