lumicks.pylake.scan.Scan¶
- class Scan(name, file, start, stop, metadata)¶
A confocal scan exported from Bluelake
- Parameters
name (str) – Scan name
file (lumicks.pylake.File) – Parent file. Contains the channel data.
start (int) – Start point in the relevant info wave.
stop (int) – End point in the relevant info wave.
metadata (ScanMetaData) – Metadata.
- __getitem__(item)¶
Returns specific scan frame(s) and/or cropped scans.
The first item refers to the scan frames; both indexing (by integer) and slicing are allowed, but using steps or slicing by list is not. The last two items refer to the spatial dimensions in pixel rows and columns. Only full slices (without steps) are allowed. All values should be given in pixels.
Examples
import lumicks.pylake as lk file = lk.File("example.h5") scan = file.scans["my_scan"] scan[5] # Gets the 6th frame of the scan (0 is the first). scan[1:5] # Get scan frames 1, 2, 3 and 4. scan[:, 10:50, 20:50] # Gets all frames cropped from row 11 to 50 and column 21 to 50. scan[:, 10:50] # Gets all frames and all columns but crops from row 11 to 50. scan[5, 10:20, 10:20] # Obtains the 6th frame and crops it. scan[[1, 3, 4]] # Produces an error, lists are not allowed. scan[1:5:2] # Produces an error, steps are not allowed. scan[1, 3, 5] # Error, integer indices are not allowed for the spatial dimensions. scan[1, 3:5:2] # Produces an error, steps are not allowed when slicing. stack["1s":"5s"] # Gets the scan frames from first to the fifth second stack[:"-5s"] # Gets the scan frames up to the last 5 seconds stack[file.force1x.start:file.force1x.stop] # Gets frames overlapping with force1x
- crop_by_pixels(x_min, x_max, y_min, y_max) lumicks.pylake.scan.Scan ¶
Crop the image stack by pixel values.
- export_tiff(filename, *, dtype=<class 'numpy.float32'>, clip=False)¶
Save the RGB photon counts to a TIFF image
- Parameters
filename (str) – The name of the TIFF file where the image will be saved.
dtype (np.dtype) – The data type of a single color channel in the resulting image.
clip (bool) – If enabled, the photon count data will be clipped to fit into the desired
dtype
. This option is disabled by default: an error will be raise if the data does not fit.
- export_video(channel, file_name, *, start_frame=None, stop_frame=None, fps=15, adjustment=<lumicks.pylake.adjustments.ColorAdjustment object>, **kwargs)¶
Export a video
- Parameters
channel (str) – Color channel(s) to use “red”, “green”, “blue” or “rgb”.
file_name (str) – File name to export to.
start_frame (int) – First frame in exported video.
stop_frame (int) – Last frame in exported video.
fps (int) – Frame rate.
adjustment (lk.ColorAdjustment) – Color adjustments to apply to the output image.
**kwargs – Forwarded to
matplotlib.pyplot.imshow()
.
- export_video_blue(file_name, start_frame=None, end_frame=None, fps=15, adjustment=<lumicks.pylake.adjustments.ColorAdjustment object>, **kwargs)¶
Export multi-frame scan as video.
- Parameters
file_name (str) – File name to export to.
start_frame (int) – Initial frame.
end_frame (int) – Last frame.
fps (int) – Frames per second.
adjustment (lk.ColorAdjustment) – Color adjustments to apply to the output image.
**kwargs – Forwarded to
matplotlib.pyplot.imshow()
.
- export_video_green(file_name, start_frame=None, end_frame=None, fps=15, adjustment=<lumicks.pylake.adjustments.ColorAdjustment object>, **kwargs)¶
Export multi-frame scan as video.
- Parameters
file_name (str) – File name to export to.
start_frame (int) – Initial frame.
end_frame (int) – Last frame.
fps (int) – Frames per second.
adjustment (lk.ColorAdjustment) – Color adjustments to apply to the output image.
**kwargs – Forwarded to
matplotlib.pyplot.imshow()
.
- export_video_red(file_name, start_frame=None, end_frame=None, fps=15, adjustment=<lumicks.pylake.adjustments.ColorAdjustment object>, **kwargs)¶
Export multi-frame scan as video.
- Parameters
file_name (str) – File name to export to.
start_frame (int) – Initial frame.
end_frame (int) – Last frame.
fps (int) – Frames per second.
adjustment (lk.ColorAdjustment) – Color adjustments to apply to the output image.
**kwargs – Forwarded to
matplotlib.pyplot.imshow()
.
- export_video_rgb(file_name, start_frame=None, end_frame=None, fps=15, adjustment=<lumicks.pylake.adjustments.ColorAdjustment object>, **kwargs)¶
Export multi-frame scan as video.
- Parameters
file_name (str) – File name to export to.
start_frame (int) – Initial frame.
end_frame (int) – Last frame.
fps (int) – Frames per second.
adjustment (lk.ColorAdjustment) – Color adjustments to apply to the output image.
**kwargs – Forwarded to
matplotlib.pyplot.imshow()
.
- frame_timestamp_ranges(exclude=None, *, include_dead_time=None)¶
Get start and stop timestamp of each frame in the scan.
Note: The stop timestamp for each frame is defined as the first sample past the end of the relevant data such that the timestamps can be used for slicing directly.
- Parameters
Examples
from lumicks import pylake file = pylake.File("example.h5") scan = file.scans["my scan"] # Grab start and stop timestamp of the first scan. start, stop = scan.frame_timestamp_ranges()[0] # Plot the force data corresponding to the first scan. file.force1x[start:stop].plot()
- classmethod from_dataset(h5py_dset, file)¶
Construct a confocal class from dataset.
- Parameters
h5py_dset (h5py.Dataset) – The original HDF5 dataset containing confocal scan information
file (lumicks.pylake.File) – The parent file. Used to loop up channel data
- get_image(channel='rgb') numpy.ndarray ¶
Get image data for the full stack as an
np.ndarray
.- Parameters
channel ({'red', 'green', 'blue', 'rgb'}) – The color channel of the requested data.
- plot(channel, axes=None, **kwargs)¶
Show a formatted plot for the requested color channel.
- Parameters
channel ({'red', 'green', 'blue', 'rgb'}) – Color channel to plot.
axes (mpl.axes.Axes or None) – If supplied, the axes instance in which to plot.
**kwargs – Forwarded to
matplotlib.pyplot.plot()
ormatplotlib.pyplot.imshow()
- plot_blue(**kwargs)¶
Plot an image of the blue photon channel
Deprecated since version 0.11.1:
plot_blue()
is deprecated. Useplot(channel='blue')
instead.
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.
adjustment (lk.ColorAdjustment) – Color adjustments to apply to the output image.
Examples
from lumicks import pylake file = pylake.File("example.h5") scan = file.scans["my scan"] scan.plot_correlated(file.force1x, channel="red")
- plot_green(**kwargs)¶
Plot an image of the green photon channel
Deprecated since version 0.11.1:
plot_green()
is deprecated. Useplot(channel='green')
instead.
- plot_red(**kwargs)¶
Plot an image of the red photon channel
Deprecated since version 0.11.1:
plot_red()
is deprecated. Useplot(channel='red')
instead.
- plot_rgb(**kwargs)¶
Plot an image of all color channels.
Deprecated since version 0.11.1:
plot_rgb()
is deprecated. Useplot(channel='rgb')
instead.
- save_tiff(filename, dtype=<class 'numpy.float32'>, clip=False)¶
Deprecated since version 0.13.0: This method has been renamed to
export_tiff
to more accurately reflect that it is exporting to a different format.
- property blue_image¶
Returns an image representing the blue channel
Deprecated since version 0.12.0: This property will be removed in a future release. Use
get_image('blue')
instead.
- property center_point_um¶
Returns a dictionary of the x/y/z center coordinates of the scan (w.r.t. brightfield field of view)
- property green_image¶
Returns an image representing the green channel
Deprecated since version 0.12.0: This property will be removed in a future release. Use
get_image('green')
instead.
- property pixel_time_seconds¶
Pixel dwell time in seconds
- property pixelsize_um¶
Returns a
List
of axes dimensions in um. The length of the list corresponds to the number of scan axes.
- property red_image¶
Returns an image representing the red channel
Deprecated since version 0.12.0: This property will be removed in a future release. Use
get_image('red')
instead.
- property rgb_image¶
Returns an rgb image
Deprecated since version 0.12.0: This property will be removed in a future release. Use
get_image('rgb')
instead.
- property shape¶
Shape of the reconstructed
Scan
image
- property size_um¶
Returns a
List
of scan sizes in um along axes. The length of the list corresponds to the number of scan axes.
- property timestamps: numpy.ndarray¶
Timestamps for each image pixel.
The returned array has the same shape as the
color_image
arrays. Timestamps are defined at the mean of the timestamps.