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

working on general model refactor #33

Draft
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

tlambert03
Copy link
Member

this PR is not necessarily for merging, but rather for discussing high level model and control flow. I want to step back and reconsider the model carefully. ndv is "doing a thing" somewhat nicely, and it's a good time to step back and clarify exactly what that thing is, with an eye towards building a better foundation to fix some issues (i.e. channel-specific lut persistence) and prepare for some nice features (i.e. chunked loading #22)

cc @alisterburt
@hanjinliu, inasmuch as you're looking at this repo these days, would love your feedback!

Main players here are:

  • ArrayDisplayModel: the model representing instructions for visualizing some data source
  • LUT: instructions for displaying a specific channel
  • ArrayViewer: the view; stubbing out what should be done in response to various events
  • DataWrapper: a place to put all of the things we need from the data (we wrap provided data in a DataWrapper based on the type of data).

I'll keep tweaking and updating this flow here, and then actually implement it later

@tlambert03 tlambert03 changed the title working on general outline working on general model refactor Jun 16, 2024
Copy link

codecov bot commented Jun 16, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 74.27%. Comparing base (4e0c5fe) to head (d536b59).

Additional details and impacted files
@@            Coverage Diff             @@
##             main      #33      +/-   ##
==========================================
- Coverage   81.95%   74.27%   -7.69%     
==========================================
  Files          13       13              
  Lines        1236     1236              
==========================================
- Hits         1013      918      -95     
- Misses        223      318      +95     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

gamma: float = 1.0
"""Gamma correction for this channel."""

autoscale: bool | tuple[float, float] = (0, 1)
Copy link
Contributor

Choose a reason for hiding this comment

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

I think autoscale should be an instance of something like AutoscalePolicy class because There are many possible ways to autoscale an image (maybe even more complicated in the future).

class AutoscalePolicy(ABC):
    @abstractmethod
    def get_limits(self, image: np.ndarray) -> tuple[float | None, float | None]:
        pass

class NoAutoscale(AutoscalePolicy):
    def get_limits(self, image: np.ndarray) -> tuple[float | None, float | None]:
        return None, None

class MinMaxAutoscale(AutoscalePolicy):
    def get_limits(self, image: np.ndarray) -> tuple[float | None, float | None]:
        return image.min(), image.max()

class QuantileAutoscale(AutoscalePolicy):
    lower: float
    upper: float

    def get_limits(self, image: np.ndarray) -> tuple[float | None, float | None]:
        return np.quantile(image, [self.lower, self.upper])

# etc.

Copy link
Member Author

Choose a reason for hiding this comment

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

i like it 👍

@hanjinliu
Copy link
Contributor

Hi @tlambert03, thanks for tagging me. I think it's a nice idea to reconsider the class designs at this point. I'll look into this PR in detail little by little, and leave some comments if I found something might be relevant.

@alisterburt
Copy link

I love what I'm seeing at first pass, feels very nice but I need some time to integrate the whole model - need to think a little more on the index/bounds and how this might work/not work with oblique planes... interesting to think about!

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.

3 participants