Skip to main content

track2p

Cell tracking for longitudinal calcium imaging recordings.

Installation

Setting up the environment

First make sure that you have an updated version of conda installed (the procedure below is based on conda 23.11.0).

Next, set up conda environment with python 3.9:

conda create --name track2p python=3.9
conda activate track2p

Install dependencies:

conda install -c conda-forge matplotlib
conda install -c conda-forge numpy
conda install -c conda-forge scikit-image
pip install itk-elastix

Additionally if using the demo.ipynb notebook you should install jupyter, for example:

conda install conda-forge::jupyterlab

Setting up track2p

For now track2p can only be installed from source via GitHub (TODO: make pip-installable)

For this first clone the repo:

git clone https://github.com/juremaj/track2p

cd to the root directory:

cd track2p

And install the local package (all modules within the track2p/track2p subfolder):

pip install -e .

And thats it, track2p should be succesfully installed :)

Platform specific installation issues/requirements:

MacOS: You might need to have xcode enabled during installation. If you run into xcrun: error: invalid active developer path .../.../... , missing xcrun at .../.../... then enable xcode by running: xcode-select --install

Linux Ubuntu: Installation works, make sure to have Conda up to date, otherwise no issues for now.

Windows: (not tested yet)

Usage

Simple usage

The current version (v1.0.0) is not extremely user friendly, but this will be improved soon. It is recommended to run through run_track2p.py

Recommended: Run via script

This is fairly simple, everything is handled by the run_track2p.py script in the root of the directory. All that needs to be done is to set the paths to all the suite2p folders used for cell tracking by editing the script. The output directory to save the figures and results of tracking should also be defined there. Additional parameters can also be specified by overwriting the defaults (for basic documentation see track2p/ops/default.py, more documentation will be added soon).

After defining the paramters just open a terminal and run:

conda activate track2p
python -m run_track2p

This should start printing out the progress and will tell you once the algorithm is finished :)

Not recommended any more: Jupyter notebook

Another possible way (soon deprecated) is to do it thorugh a jupyter notebook:

conda activate track2p
cd track2p
jupyter lab

And then open demo_t2p.ipynb, where you can then set the paths to the suite2p output directories of the datasets to be matched, as well as the path where the outputs should be saved.

Changing algorithm parameters

TODO: add documentation of algorithm parameters (for now use the defaults saved at track2p/ops/default.py, they should work well)

Outputs

All the outputs of the script will be saved in a track2p folder created within the track_ops.save_path directory specified by the user when running the algorithm. For an introduction on how to use the outputs for further downstream analysis we provide a useful demo notebook demo_t2p_outlput.ipynb in the root of this repository.

Matches

There are two types of output from track2p:

  • A matrix (plane#_match_mat.npy) containing the indices of matched neurons across the session for a given plane (# is the index of the plane). Since matching is done from first day to last, some neurons will not be sucessfully tracked after one or a few days. In this case the matrix contains None values. To get neurons tracked across all days only take the rows of the matrices containing no None values.

  • A track_ops.npy object that contains the parameters used for the algorithm and some intermediate results that can be used for visualisations (e. g. registered images and ROIs etc.)

Visualisations

There are several visualisations that can be used to evaluate the registration and cell matching quality. These will all be saved in the path defined by track_ops.save_path under track2p/fig

The figures are the following (in the order of importance):

  • reg_img_output.png image visualising the quality of image registration across the two days. Each pair of recordings is visualised as red/green overlay of the mean images on the two days before (above) and after (below) registration. If the bottom images don't show good alignment the output of the algorithm would be completely useless (if this happen make sure everyhting is correct with the data)

ex_reg_img_output.png

ex_thr_met_hist.png

  • roi_match_plane#_idx###-###.png visualises a window of the mean gcamp image around an example match for all days. If there is more than 100 matches, they are split to separate figures. The dot in the middle shows the centroid of the ROI (whole ROI is not drawn to not bias the estimation of match).

ex_roi_match.png

  • all_roi_match.png visualises all matches across the FOV for all days. Here the full ROIs are drawn and the color is maintained across days.

ex_all_roi_match.png

Download files

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

Source Distribution

track2p-0.2.0.tar.gz (16.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

track2p-0.2.0-py3-none-any.whl (17.1 kB view details)

Uploaded Python 3

File details

Details for the file track2p-0.2.0.tar.gz.

File metadata

  • Download URL: track2p-0.2.0.tar.gz
  • Upload date:
  • Size: 16.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.0.0 CPython/3.9.18

File hashes

Hashes for track2p-0.2.0.tar.gz
Algorithm Hash digest
SHA256 daf4c441e77d73d368b43a8d9a0925b57acea02090a4b993773fabadfeb6a550
MD5 54af502408150e1d450dbbeaf64432b4
BLAKE2b-256 1e38e8c3d611d22fbe3ef01339204f10eaa795d060a189c36e416a6c2a30a8c9

See more details on using hashes here.

File details

Details for the file track2p-0.2.0-py3-none-any.whl.

File metadata

  • Download URL: track2p-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 17.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.0.0 CPython/3.9.18

File hashes

Hashes for track2p-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 77bae7defebda48bcf97200bbe7a938231a8a7c3a08f9557a8cff04fe1345432
MD5 897655a3ad8cbfaa4bdb34ebf56ad906
BLAKE2b-256 58bdf3cf3852c3bae460d2f8f54f330c726da856b8d9fc2af8826a5f0275b04f

See more details on using hashes here.

Release history Release notifications | RSS feed

0.6.2

2 files

0.6.1

2 files

0.6

2 files

0.5.8

2 files

0.5.7

2 files

0.5.6

2 files

0.5.5

2 files

0.5.4

1 file

0.5.3

2 files

0.5.2

2 files

0.5.1

2 files

0.5.0

2 files

0.4.4

2 files

0.4.2

2 files

0.4.1

2 files

0.3.3

2 files

0.3.2

2 files

0.3.1

2 files

0.3.0

2 files

0.2.1

2 files

This release

0.2.0 This release

2 files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page