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].timestamps)
__init__(image_name, align=True)

Initialize self. See help(type(self)) for accurate signature.

Methods

__init__(image_name[, align]) Initialize self.
export_tiff(file_name[, roi]) Export a video of a particular scan plot
from_data(data[, name, start_idx, stop_idx]) Construct CorrelatedStack from image stack object
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.

Attributes

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 List of time stamps.
__getitem__(item)

All indexing is in frames

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]

classmethod from_data(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.

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')

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(), but numpy.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

Examples

from lumicks import pylake

file = pylake.File("example.h5")
stack = pylake.CorrelatedStack("example.tiff")
stack.plot_correlated(file.force1x, frame=5)
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

List of time stamps.