Skip to content

Commit 87763d3

Browse files
authored
Merge pull request #252 from dstansby/hist-multiscale
Fix HistogramWidget for multiscale data
2 parents 559e1c1 + 31c8fac commit 87763d3

File tree

2 files changed

+14
-7
lines changed

2 files changed

+14
-7
lines changed

pyproject.toml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,15 @@ build-backend = "setuptools.build_meta"
66
write_to = "src/napari_matplotlib/_version.py"
77

88
[tool.pytest.ini_options]
9-
qt_api = "pyqt6"
10-
addopts = "--mpl --mpl-baseline-relative"
119
filterwarnings = [
1210
"error",
11+
"ignore:(?s).*Pyarrow will become a required dependency of pandas",
1312
# Coming from vispy
1413
"ignore:distutils Version classes are deprecated:DeprecationWarning",
1514
"ignore:`np.bool8` is a deprecated alias for `np.bool_`:DeprecationWarning",
1615
]
16+
qt_api = "pyqt6"
17+
addopts = "--mpl --mpl-baseline-relative"
1718

1819
[tool.black]
1920
line-length = 79

src/napari_matplotlib/histogram.py

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44
import numpy as np
55
import numpy.typing as npt
66
from matplotlib.container import BarContainer
7+
from napari.layers import Image
8+
from napari.layers._multiscale_data import MultiScaleData
79
from qtpy.QtWidgets import (
810
QComboBox,
911
QLabel,
@@ -68,14 +70,18 @@ def draw(self) -> None:
6870
"""
6971
Clear the axes and histogram the currently selected layer/slice.
7072
"""
71-
layer = self.layers[0]
73+
layer: Image = self.layers[0]
74+
data = layer.data
7275

73-
if layer.data.ndim - layer.rgb == 3:
76+
if isinstance(layer.data, MultiScaleData):
77+
data = data[layer.data_level]
78+
79+
if layer.ndim - layer.rgb == 3:
7480
# 3D data, can be single channel or RGB
75-
data = layer.data[self.current_z]
81+
# Slice in z dimension
82+
data = data[self.current_z]
7683
self.axes.set_title(f"z={self.current_z}")
77-
else:
78-
data = layer.data
84+
7985
# Read data into memory if it's a dask array
8086
data = np.asarray(data)
8187

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy