lumicks.pylake.correlated_stack.CorrelatedStack¶
-
class
CorrelatedStack
(image_name, align=True)¶ CorrelatedStack acquired with Bluelake. Bluelake can export stacks of images to various formats. These can be opened and correlated to timeline data using CorrelatedStack.
Parameters: - image_name : str
Filename for the image stack. Typically a TIFF file recorded from a camera in Bluelake.
- align : bool
If enabled, multi-channel images will be reconstructed from the image alignment metadata from Bluelake. The default value is
True
.
Examples
from lumicks import pylake # Loading a stack. stack = pylake.CorrelatedStack("example.tiff") # Making a plot where force is correlated to images in the stack. file = pylake.File("example.h5") stack.plot_correlated(file.force1x) # Determine the force trace averaged over frame 2...9. file.force1x.downsampled_over(stack[2:10].frame_timestamp_ranges)
-
__init__
(image_name, align=True)¶ Initialize self. See help(type(self)) for accurate signature.
Methods
__init__
(image_name[, align])Initialize self. crop_and_rotate
([frame, channel, show_title])Open a widget to interactively edit the image stack. crop_by_pixels
(x_min, x_max, y_min, y_max)Crop the image stack by pixel values. define_tether
(point1, point2)Returns a copy of the stack rotated such that the tether defined by point_1
andpoint_2
is horizontal.export_tiff
(file_name[, roi])Export a video of a particular scan plot from_data
(data[, name, start_idx, stop_idx])Deprecated since version 0.10.1.
from_dataset
(data[, name, start_idx, stop_idx])Construct CorrelatedStack from image stack object get_image
([channel])Get image data for the full stack as an np.ndarray
.plot
([frame, channel, show_title])Plot image from image stack plot_correlated
(channel_slice[, frame, …])Downsample channel on a frame by frame basis and plot the results. plot_tether
(**kwargs)Plot a line at the tether position. Attributes
frame_timestamp_ranges
List of time stamps. num_frames
Number of frames in the stack. raw
Raw frame data. start
Starting time stamp of the stack. stop
Final time stamp of the stack. timestamps
Deprecated since version 0.11.1.
-
__getitem__
(item)¶ All indexing is in frames
-
crop_and_rotate
(frame=0, channel='rgb', show_title=True, **kwargs)¶ Open a widget to interactively edit the image stack.
- Actions include:
- scrolling through frames using the mouse wheel
- left-click to define the location of the tether
Parameters: - frame : int, optional
Index of the frame to plot.
- channel : ‘rgb’, ‘red’, ‘green’, ‘blue’, None; optional
Channel to plot for RGB images (None defaults to ‘rgb’) Not used for grayscale images
- show_title : bool, optional
Controls display of auto-generated plot title
- **kwargs
Forwarded to
matplotlib.pyplot.imshow()
.
Examples
from lumicks import pylake import matplotlib.pyplot as plt
# Loading a stack. stack = pylake.CorrelatedStack(“example.tiff”) widget = stack.crop_and_rotate() plt.show()
# Select cropping ROI by right-click drag # Select tether ends by left-click
# Grab the updated image stack new_stack = widget.image
-
crop_by_pixels
(x_min, x_max, y_min, y_max)¶ Crop the image stack by pixel values.
Parameters: - x_min : int
minimum x pixel (inclusive)
- x_max : int
maximum x pixel (exclusive)
- y_min : int
minimum y pixel (inclusive)
- y_max : int
maximum y pixel (exclusive)
-
define_tether
(point1, point2)¶ Returns a copy of the stack rotated such that the tether defined by
point_1
andpoint_2
is horizontal.Parameters: - point_1 : (float, float)
(x, y) coordinates of the tether start point
- point_2 : (float, float)
(x, y) coordinates of the tether end point
-
export_tiff
(file_name, roi=None)¶ Export a video of a particular scan plot
Parameters: - file_name : str
File name to export to.
- roi : list_like
region of interest in pixel values [xmin, xmax, ymin, ymax] Deprecated since v0.10.1 Instead, use
CorrelatedStack.crop_by_pixels()
to select the ROI before exporting.”
-
classmethod
from_data
(data, name=None, start_idx=0, stop_idx=None)¶ Deprecated since version 0.10.1: Renamed to
from_dataset()
for consistency withKymo
andScan
.
-
classmethod
from_dataset
(data, name=None, start_idx=0, stop_idx=None)¶ Construct CorrelatedStack from image stack object
Parameters: - data : TiffStack
TiffStack object.
- name : str
Plot label of the correlated stack
- start_idx : int
Index at the first frame.
- stop_idx: int
Index beyond the last frame.
-
get_image
(channel='rgb')¶ Get image data for the full stack as an
np.ndarray
.Parameters: - channel : {‘red’, ‘green’, ‘blue’, ‘rgb’}
The color channel of the requested data. For single-color data, this argument is ignored.
-
plot
(frame=0, channel='rgb', show_title=True, **kwargs)¶ Plot image from image stack
Parameters: - frame : int, optional
Index of the frame to plot.
- channel : ‘rgb’, ‘red’, ‘green’, ‘blue’, None; optional
Channel to plot for RGB images (None defaults to ‘rgb’) Not used for grayscale images
- show_title : bool, optional
Controls display of auto-generated plot title
- **kwargs
Forwarded to
matplotlib.pyplot.imshow()
.
-
plot_correlated
(channel_slice, frame=0, reduce=<function mean>, channel='rgb', figure_scale=0.75)¶ Downsample channel on a frame by frame basis and plot the results. The downsampling function (e.g. np.mean) is evaluated for the time between a start and end time of a frame. Note: In environments which support interactive figures (e.g. jupyter notebook with ipywidgets or interactive python) this plot will be interactive.
Parameters: - channel_slice : pylake.channel.Slice
Data slice that we with to downsample.
- frame : int
Frame to show.
- reduce : callable
The function which is going to reduce multiple samples into one. The default is
numpy.mean()
, butnumpy.sum()
could also be appropriate for some cases e.g. photon counts.- channel : ‘rgb’, ‘red’, ‘green’, ‘blue’, None; optional
Channel to plot for RGB images (None defaults to ‘rgb’) Not used for grayscale images
- figure_scale : float
Scaling of the figure width and height. Values greater than one increase the size of the figure.
Examples
from lumicks import pylake file = pylake.File("example.h5") stack = pylake.CorrelatedStack("example.tiff") stack.plot_correlated(file.force1x, frame=5)
-
plot_tether
(**kwargs)¶ Plot a line at the tether position.
Parameters: - **kwargs
Forwarded to :fun:`matplotlib.pyplot.plot`.
-
frame_timestamp_ranges
¶ List of time stamps.
-
num_frames
¶ Number of frames in the stack.
-
raw
¶ Raw frame data.
Deprecated since version 0.10.1: Access to raw frame instances will be removed in a future release. All operations on these objects should be handled through the
CorrelatedStack
public API. For example, to retrieve the image data as annp.ndarray
please useCorrelatedStack.get_image()
.
-
start
¶ Starting time stamp of the stack.
-
stop
¶ Final time stamp of the stack.
-
timestamps
¶ Deprecated since version 0.11.1: For camera based images only the integration start/stop timestamps are defined. Use
CorrelatedStack.frame_timestamp_ranges
instead.