Skip to main content

Library for tracking motion in cardiac mps data

Project description

CI

MPS Motion Tracking

Library for tracking motion in cardiac mps data

Installation

You can install the software with pip. Clone the repo, change director to the root of the repo and do

python3 -m pip install install .

There is also a Makefile in this repo, and the same instructions can be executed using the command make install.

Alternatively you can install it directly from Github

python3 -m pip install git+https://github.com/ComputationalPhysiology/mps_motion

Development installations

Developers should install some extra dependencies

python3 -m pip install install -e ".[dev,docs,test]"

as well as the pre-commit hook

pre-commit install

Alternatively, you can use the Makefile and hit make dev.

Getting started

Command line interface

You can analyse a dataset used the command line interface as follows

python -m mps_motion PointH4A_ChannelBF_VC_Seq0018.nd2

Here PointH4A_ChannelBF_VC_Seq0018.nd2 is an example file containing cardiac cell data. Note that in order to read these data you need to also install the mps package. To see all available options for the cli you can do

python -m mps_motion --help

Computing displacement and strain

import matplotlib.pyplot as plt # For plotting
import mps # Package to load data
import mps_motion as mmt # Package for motion analysis

# Load raw data from Nikon images
data = mps.MPS("data.nd2")
print(data.info) # {'num_frames': 267, 'dt': 11.92, 'time_unit': 'ms',
# 'um_per_pixel': 0.325, 'size_x': 2044, 'size_y': 1174}
opt_flow = mmt.OpticalFlow(data, flow_algorithm="farneback", reference_frame=0)
u = opt_flow.get_displacements(scale=0.4)
print(u) # VectorFrameSequence((817, 469, 267, 2), dx=0.8125, scale=0.4)
u_norm = u.norm()
print(u_norm) # FrameSequence((817, 469, 267), dx=0.8125, scale=0.4)
# Compute mean of the norm of all pixels
u_norm_mean = u_norm.mean().compute()
plt.figure()
plt.plot(data.time_stamps, u_mean_norm)

mech = mmt.Mechancis(u=u, t=data.time_stamps)
# Green-Lagrange strain
print(mech.E) # TensorFrameSequence((817, 469, 267, 2, 2), dx=0.8125, scale=0.4)

# Plot the X-component of the Green-Lagrange strain
plt.figure()
plt.plot(data.time_stamps, mech.E.x.mean().compute())
plt.show()

Useful links:

Authors

Project details


Download files

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

Source Distribution

mps_motion-0.1.0.tar.gz (843.8 kB view hashes)

Uploaded Source

Built Distribution

mps_motion-0.1.0-py2.py3-none-any.whl (48.5 kB view hashes)

Uploaded Python 2 Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page