-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
34 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
from pijm.plot import plot_zstack |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
""" Plotting methods | ||
""" | ||
|
||
|
||
import matplotlib.pyplot as plt | ||
import numpy as np | ||
|
||
from pijm.events import StackScroller | ||
|
||
|
||
# TODO: return type? | ||
# TODO: type hint for array shape? | ||
def plot_zstack(image_array: np.ndarray): | ||
"""Interactively plot stack, capturing scrolling events to scroll through slices | ||
Args: | ||
image_array - (n_x, n_y, n_z) | ||
""" | ||
assert image_array.ndim == 3 | ||
|
||
axes_image = plt.imshow( | ||
image_array[:, :, image_array.shape[2] // 2], | ||
vmin=image_array.min(), | ||
vmax=image_array.max(), | ||
) | ||
|
||
handlers = [] | ||
|
||
handlers.append(StackScroller(image_array, axes_image)) | ||
|
||
# NOTE: handlers will be garbage collected if not returned | ||
# TODO: find more elegant solution | ||
return axes_image, handlers |