Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit f94ccf0

Browse filesBrowse files
committed
Don't read full cube into mem for histogramming
1 parent 18f760d commit f94ccf0
Copy full SHA for f94ccf0

File tree

1 file changed

+4
-1
lines changed
Filter options

1 file changed

+4
-1
lines changed

‎src/napari_matplotlib/histogram.py

Copy file name to clipboardExpand all lines: src/napari_matplotlib/histogram.py
+4-1Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@ def draw(self) -> None:
3333
Clear the axes and histogram the currently selected layer/slice.
3434
"""
3535
layer = self.layers[0]
36-
bins = np.linspace(np.min(layer.data), np.max(layer.data), 100)
3736

3837
if layer.data.ndim - layer.rgb == 3:
3938
# 3D data, can be single channel or RGB
@@ -42,6 +41,10 @@ def draw(self) -> None:
4241
else:
4342
data = layer.data
4443

44+
# Important to calculate bins after slicing 3D data, to avoid reading
45+
# whole cube into memory.
46+
bins = np.linspace(np.min(layer.data), np.max(layer.data), 100)
47+
4548
if layer.rgb:
4649
# Histogram RGB channels independently
4750
for i, c in enumerate("rgb"):

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.