Skip to content

rg314/pytraction

Repository files navigation

GitHub Python Workflow GitHub Test docker-compose codecov

PyTraction

Bayesian Traction Force Microscopy

Motivation: TFM data is annoying, disperse tool set (all in matlab / ImageJ / javascript)

PyTraction: Modern software and easy to use end-to-end

TO-DO

🕘 Tests for edge cases on input

🕘 Simulation validation

🕘 Add clean docker image

Colab examples

Please try running the following notebooks on google colab. You will need to generate a personal access token.

Example 1: Basic usage with an image stack and reference image in the correct format

Example 2: Basic usage with an ROI

Example 3: Basic usage unexpected image formats

TL;DR

Navigate to folder where you want to install and ensure you have miniconda and git installed and run the following commands.

git clone https://github.com/rg314/pytraction.git
conda create -n pytraction python=3.8
conda activate pytraction
pip install pytraction/
cd pytraction
python scripts/get_example_data.py
pip install notebook
python -m ipykernel install --user --name=pytraction
jupyter notebook scripts/usage.ipynb

Installation

Note: if running on Windows you may have problems with the shapely library and some ctypes extensions. Please install shapely via conda install shapely.

For HTTPS git clone https://github.com/rg314/pytraction.git

For SSH git clone git@github.com:rg314/pytraction.git

Create conda env

conda create -n pytraction python=3.8

Activate conda env

conda activate pytraction

Install pytraction (for dev install in editable mode - e .)

pip install pytraction/

Change directory to repository

cd pytraction

To get example data run

python scripts/get_example_data.py

Install jupyter notebook

pip install notebook

Install pytraction kernel to use with jupyter notebook

python -m ipykernel install --user --name=pytraction

For basic usage run

jupyter notebook scripts/usage.ipynb

Example

The following code show an basic example. Please make sure you download example data by running the following script python scripts/get_example_data.py. You need to make sure that the data folder is in your working directory when you run the following code. For a more in-depth examples please see scripts/usage.ipynb

For basic usage:

from pytraction import TractionForceConfig
from pytraction import plot, process_stack
import matplotlib.pyplot as plt

pix_per_mu = 1.3 # The number of pixels per micron 
E = 100 # Youngs modulus in Pa

img_path = 'data/example1/e01_pos1_axon1.tif'
ref_path = 'data/example1/e01_pos1_axon1_ref.tif'
config = 'config/config.yaml'

traction_config = TractionForceConfig(E=E, scaling_factor=pix_per_mu, config=config)
img, ref, _ = traction_config.load_data(img_path, ref_path)
log = process_stack(img[:1,:,:,:], ref, config=traction_config)

plot(log, frame=0)
plt.show()

image

Draft manuscript

Please follow OneDrive link to draft manuscript or OneDrive link to folder. I've chosen OneDrive as it nicely integrates with EndNote and multiple users editing at once.

The draft manuscript has only been sent to a few authors to date. Authors are listed alphabetically. Contributors will be invited to manuscript if a significant contribution is made which can consist of:

  • Significantly contributing to design or code of the core python package.
  • Demonstrating usage of core python package compared to other analysis techniques.
  • Demonstrating usage of core python package with computational techniques.
  • Fixing major bugs in core python package.
  • Contributed or provided experimental data for the manuscript.

If you believe that you have made a significant contribution (and have not been invited to the manuscript) or would like to make a significant contribution please contact me.

Contributing

Contributing: Think of Big O notation and Occam's_razor

For commiting big code blocks please relate them to issues and create a new branch. The branch name as the abbriviated issue (issue8 = iss8).

git checkout -b iss8

Commit to current branch and assign a reviewer when merging pull request into main branch from the webapp.

Amazing references

Here is a list of common resources that have been used

  1. Imagej piv
  2. Easy-to-use_TFM_package
  3. openpiv-python
  4. opencv-python
  5. A great paper from Sabass lab
  6. Template matching