Skip to main content

Bluelake data analysis tools

Project description

Lumicks pylake

Build Status Documentation Status

This Python package includes data analysis tools for Bluelake HDF5 data.

Install

For general use, all you need to do is enter the following on the command line:

pip install lumicks.pylake

To upgrade to the latest version:

pip install -U lumicks.pylake

Reading HDF5 files

from lumicks import pylake

h5file = pylake.File("example.h5")

FD curves

import matplotlib.pyplot as plt

# Plot all FD curves in a file
for name, fd in h5file.fdcurves.items():
    fd.plot_scatter()
    plt.savefig(name)

# Pick a single FD curve
fd = h5file.fdcurves["name"]
# By default, the FD channel pair is `downsampled_force2` and `distance1`
fd.with_channels(force='1x', distance='2').plot_scatter()

# Access the raw data: defaults
force = fd.f
distance = fd.d
# Access the raw data: specific
force = fd.downsampled_force1y
distance = fd.distance2

# Plot manually: FD curve
plt.scatter(distance.data, force.data)
# Plot manually: force timetrace
plt.plot(force.timestamps, force.data)

# By default `f` is `downsampled_force2` and `d` is `distance1`
altenative_fd = fd.with_channels(force='1x', distance='2')

# Baseline subtraction
fd_baseline = h5file.fdcurves["Baseline"]
fd_measured = h5file.fdcurves["Measurement"]
fd = fd_measured - fd_baseline
fd.plot_scatter()

Force vs. time

# Simple force plotting
h5file.force1x.plot()
plt.savefig("force1x")

# Accessing the raw data
f1x_data = h5file.force1x.data
f1x_timestamps = h5file.force1x.timestamps
plt.plot(f1x_timestamps, f1x_data)

Slicing data channels

# Take the entire channel
everything = h5file.force1x
everything.plot()

# Get the data between 1 and 1.5 seconds
part = h5file.force1x['1s':'1.5s']
part.plot()
# Or manually
f1x_data = part.data
f1x_timestamps = part.timestamps
plt.plot(f1x_timestamps, f1x_data)

# More slicing examples
a = h5file.force1x[:'-5s']  # everything except the last 5 seconds
b = h5file.force1x['-1m':]  # take the last minute
c = h5file.force1x['-1m':'-500ms']  # last minute except the last 0.5 seconds
d = h5file.force1x['1.2s':'-4s']  # between 1.2 seconds and 4 seconds from the end
e = h5file.force1x['5.7m':'1h 40m']  # 5.7 minutes to an hour and 40 minutes

Scans and kymographs

The following code uses kymographs as an example. Scans work the same way -- just substitute h5file.kymos with h5file.scans.

# Plot all kymographs in a file
for name, kymo in h5file.kymos.items():
    kymo.plot_rgb()
    plt.savefig(name)

# Pick a single kymograph
kymo = h5file.kymos["name"]
# Plot a single color channel
kymo.plot_red()

# Access the raw image data
rgb = kymo.rgb_image  # matrix
blue = kymo.blue_image
# Plot manually
plt.imshow(rgb)

# Low-level raw data
photons = kymo.red_photons
plt.plot(photons.timestamps, photons.data)

# Saving photon counts to TIFF
kymo.save_tiff("kymograph.tiff")
scan = h5file.scans["name"]

# A scan can have multiple frames
print(scan.num_frames)
print(scan.blue_image.shape)  # (self.num_frames, h, w) -> single color channel
print(scan.rgb_image.shape)  # (self.num_frames, h, w, 3) -> three color channels

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Filename, size & hash SHA256 hash help File type Python version Upload date
lumicks.pylake-0.3.0-py3-none-any.whl (27.7 kB) Copy SHA256 hash SHA256 Wheel py3
lumicks.pylake-0.3.0.tar.gz (22.3 kB) Copy SHA256 hash SHA256 Source None

Supported by

Elastic Elastic Search Pingdom Pingdom Monitoring Google Google BigQuery Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN SignalFx SignalFx Supporter DigiCert DigiCert EV certificate StatusPage StatusPage Status page