-
Notifications
You must be signed in to change notification settings - Fork 17
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
fix: fix adjusting contrast limits for rgb data #276
Conversation
src/napari_spatialdata/_view.py
Outdated
has_adata = layer is not None and layer.metadata.get("adata") is not None | ||
|
||
# has_adata is added so we see the channels in the view widget under vars | ||
if layer is None or not is_image or not has_sdata or not has_adata: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe it should look like
if layer is None or not is_image or not has_sdata or not has_adata: | |
if layer is None or not is_image or not has_sdata or not has_adata or image.rgb: |
current_point = list(event.value) | ||
displayed = self._viewer.dims.displayed | ||
|
||
for i, (lo_size, hi_size, cord) in enumerate(zip(layer.data[-1].shape, layer.data[0].shape, displayed)): | ||
if i in displayed: | ||
current_point[i] = slice(None) | ||
else: | ||
current_point[i] = int(cord * lo_size / hi_size) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is logic for any dimensional data.
If you are 100% sure that data will always be 2D, then this logic may be obsolete.
If contrast limits needs to be calculated for the whole channel, not only the visible portion, then it is also overcomplicated. But then, for 3D data, should be no recalculation when change Z slice.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In the future we will not be sure about this. SpatialData already does have 3D models. Where bugs occur for 3D napari-spatialdata should be adjusted.
I will first add #153 . That PR required some upstream changes that I have now implemented. I will then check how your PR interacts with it. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Preapprove awaiting latest tests
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #276 +/- ##
==========================================
- Coverage 63.69% 63.08% -0.62%
==========================================
Files 19 19
Lines 2628 2636 +8
==========================================
- Hits 1674 1663 -11
- Misses 954 973 +19 ☔ View full report in Codecov by Sentry. |
While working on reproducing of performance problem for points and shapes, I found that adjusting contrast limits do not work for data with 3 channels, that are represented as RGB data.
This PR contains the following changes:
channel_changed
from local function to class method_channel_changed
to accept any dimensional data.AnnData
initialization for rgb data