Skip to content

Commit 34c9e2c

Browse files
committed
Fix HistogramWidget for multiscale
data
1 parent d7cca90 commit 34c9e2c

File tree

1 file changed

+11
-5
lines changed

1 file changed

+11
-5
lines changed

Diff for: src/napari_matplotlib/histogram.py

+11-5
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,
@@ -67,14 +69,18 @@ def draw(self) -> None:
6769
"""
6870
Clear the axes and histogram the currently selected layer/slice.
6971
"""
70-
layer = self.layers[0]
72+
layer: Image = self.layers[0]
73+
data = layer.data
7174

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

0 commit comments

Comments
 (0)