Skip to content

Commit 888d62c

Browse files
authored
Merge pull request #20 from hkabbech/dev
Improve API documentation #11
2 parents b40fd4a + 343e28f commit 888d62c

24 files changed

+483
-115
lines changed

.gitignore

+3
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@ __pycache__
44
# pycharm:
55
.idea/
66

7+
# python env:
8+
tracksegnet-env/
9+
710
# Generated files:
811
results/
912

CONTRIBUTING.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ Before starting, you should read, agree to, and follow this guideline.
1010

1111
### Report bugs
1212

13-
Report bugs at: https://github.com/hkabbech/tracksegnet/issues/new.
13+
Report bugs at: [https://github.com/hkabbech/tracksegnet/issues/new](https://github.com/hkabbech/tracksegnet/issues/new).
1414

1515
When reporting a bug, please include the detailed steps to reproduce the bug.
1616
Where possible, please write a test case.

README.md

+35-28
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,15 @@
55

66
## Purposes
77

8+
Recent advances in the field of microscopy allow the capture, at nanometer resolution, of the motion of fluorescently-labeled particles in live cells such as proteins or chromatin loci. Therefore, the development of methods to characterize the dynamics of a group of particles has become more than necessary.
89

910
`TrackSegNet` is a tool designed for the classification and segmentation of experimental trajectories, specifically those obtained from single-particle tracking microscopy data, into different diffusive states.
1011

11-
To enable the training of the LSTM neural network, synthetic trajectories are initially generated, and the parameters of the generator can be fine-tuned.
12+
- To enable the training of the LSTM neural network, synthetic trajectories are initially generated, and the parameters of the generator can be fine-tuned.
1213

13-
Upon completion of the training process, the experimental trajectories are classified at each point using the trained model. Subsequently, the trajectories are segmented and grouped based on their respective diffusive states. In this context, "diffusive states" refer to the distinct modes or patterns observed in the movement of particles.
14+
- Upon completion of the training process, the experimental trajectories are classified at each point using the trained model. Subsequently, the trajectories are segmented and grouped based on their respective diffusive states. In this context, "diffusive states" refer to the distinct modes or patterns observed in the movement of particles.
1415

15-
For each segmented track, the diffusion constant ($D$) and anomalous exponent ($\alpha$) are further estimated. This is accomplished by computing the mean squared displacement (MSD), providing valuable insights into the dynamic behavior of the particles within each identified diffusive state.
16+
- For each segmented track, the diffusion constant (![equation](https://latex.codecogs.com/svg.image?\inline&space;D)) and anomalous exponent (![equation](https://latex.codecogs.com/svg.image?\inline&space;\alpha)) are further estimated. This is accomplished by computing the mean squared displacement (MSD), providing valuable insights into the dynamic behavior of the particles within each identified diffusive state.
1617

1718

1819
![pipeline](paper/pipeline.png)
@@ -27,32 +28,28 @@ cd TrackSegNet
2728

2829
### Either create and run a docker container
2930

30-
Build a docker image (Rebuild the image after changing the parameters):
3131
```bash
32+
# Build a docker image (Rebuild the image after changing the parameters):
3233
docker compose build
33-
```
34-
Run the container:
35-
36-
```bash
34+
# Run the container:
3735
docker compose run tracksegnet-env
3836
```
3937

40-
### Or create the environment and install the packages
41-
42-
```bash
43-
sudo apt install python3-virtualenv
44-
virtualenv -p /usr/bin/python3 tracksegnet-env
45-
source tracksegnet-env/bin/activate # for Windows: tracksegnet-env\bin\activate
46-
python -m pip install -r requirements.txt
47-
```
38+
### Or create a virtual environment and install the packages
4839

49-
Run the program:
40+
Requirement: python3.8 or equivalent and the virtualenv library
5041

5142
```bash
52-
./tracksegnet.py parms.csv
43+
# Create the environment:
44+
python -m venv tracksegnet-env
45+
# virtualenv -p /usr/bin/python3 tracksegnet-env
46+
# Activate the environment:
47+
source ./tracksegnet-env/bin/activate # for Windows PowerShell: .\tracksegnet-env\Scripts\Activate.ps1 (run as administrator)
48+
# Install the required python libraries:
49+
python -m pip install -r requirements.txt
5350
```
5451

55-
Note, to deactivate the virtual environment, type `deactivate`.
52+
Note for later, to deactivate the virtual environment, type `deactivate`.
5653

5754

5855
## Prepare your data
@@ -87,22 +84,32 @@ If `CSV` format is used, the headers should be: `x, y, frame, track_id`
8784

8885
### Change the main parameters
8986

90-
Update the main parameters in the `parms.csv` file according to your experiment:
87+
Tune the main parameters of the training in the `params.csv` file according to your experiment:
88+
89+
* `num_states` the number of diffusive states for the classification(from 2 to 6 states). This number can vary from 2 to 6 states, but it is recommended to choose 2 to 4 states.
90+
* `state_i_diff` and `state_i_alpha` the approximate motion parameters for each of the ![equation](https://latex.codecogs.com/svg.image?\inline&space;N) diffusive state. The diffusion constant ![equation](https://latex.codecogs.com/svg.image?\inline&space;D) is dimensionless, and the anomalous exponent value ![equation](https://latex.codecogs.com/svg.image?\inline&space;\alpha) is ranging from 0 to 2 (![equation](https://latex.codecogs.com/svg.image?\inline&space;]0-1[): subdiffusion, ![equation](https://latex.codecogs.com/svg.image?\inline&space;1): Brownian motion, ![equation](https://latex.codecogs.com/svg.image?\inline&space;]1-2[): superdiffusion).
91+
* `pt_i_j` the probability of transitionning from state i to state j. The total number of probabilities should be ![equation](https://latex.codecogs.com/svg.image?\inline&space;N^2).
92+
93+
The remaining parameters are related to the experimental dataset:
94+
95+
* `data_path`, the path of the dataset of trajectories to segment.
96+
* `track_format`, the format of the files containing the trajectory coordinates, either `MDF` (see `MTrackJ` data file format) or `CSV`
97+
* `time_frame`, the time interval between two trajectory points in seconds.
98+
* `pixel_size`, the dimension of a pixel in ![equation](https://latex.codecogs.com/svg.image?\inline&space;$\mu m).
9199

92-
- `data_path`: the path containing your data folder `SPT_experiment` to analyze
93-
- `track_format`: The format of the files containing the trajectory coordinates, should be `MDF` or `CSV`
94-
- `time_frame`: the time interval between two trajectory points (in second)
95-
- `pixel_size`: the dimension of a pixel (in µm)
96-
- `num_states`: the number of diffusive states for the classification(from 2 to 6 states)
97-
- `state_X_diff`: The expected diffusion value for state X (in µm^2/s).
98-
- `state_X_alpha`: The expected anomalous exponent α value for state X (from 0 to 2 -- ]0-1[: subdiffusion, 1: Brownian motion, ]1-2[: superdiffusion).
99-
- `pt_i_j`: the probability of transitionning from the state i to the state j. The total number of probabilities should be $N^2$.
100100

101101
Note that the program will run on the toy example if the parameters are unchanged.
102102

103103
For updating the parameters of the track simulation and neural network training, please make the changes in the main file `tracksegnet.py`.
104104

105105

106+
## Run the program
107+
108+
109+
```bash
110+
python tracksegnet.py parms.csv
111+
```
112+
106113
## Reference
107114

108115
Yavuz, S., Kabbech, H., van Staalduinen, J., Linder, S., van Cappellen, W.A., Nigg, A.L., Abraham, T.E., Slotman, J.A., Quevedo, M. Poot, R.A., Zwart, W., van Royen, M.E., Grosveld, F.G., Smal, I., Houtsmuller, A.B. (2023). Compartmentalization of androgen receptors at endogenous genes in living cells, *Nucleic Acids Research* 51(20), [https://doi.org/10.1093/nar/gkad803](https://doi.org/10.1093/nar/gkad803).

docs/source/analysis.rst

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
analysis module
2-
===============
1+
analysis
2+
========
33

44
.. automodule:: analysis
55
:members:

docs/source/compute_features.rst

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
compute\_features module
2-
========================
1+
compute\_features
2+
=================
33

44
.. automodule:: compute_features
55
:members:

docs/source/conf.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@
55

66
import os
77
import sys
8-
sys.path.insert(0, os.path.abspath('../../src/'))
8+
sys.path.insert(0, os.path.abspath('../..'))
9+
sys.path.insert(0, os.path.abspath('../../src'))
910

1011

1112
# -- Project information -----------------------------------------------------

docs/source/data-preparation.md

+52
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
# Prepare your data
2+
3+
4+
## Data organization
5+
6+
7+
Organize your data in a folder `SPT_experiment`, each sub-folder should contain a file storing the trajectory coordinates in a `MDF` or `CSV` file format.
8+
9+
If `CSV` format is used, the headers should be: `x, y, frame, track_id`
10+
11+
```bash
12+
.
13+
├── data/
14+
│ └── SPT_experiment/
15+
│ ├── Cell_1
16+
│ │ ├── *.tif
17+
│ │ └── *.mdf
18+
│ ├── Cell_2
19+
│ │ ├── *.tif
20+
│ │ └── *.mdf
21+
│ ├── Cell_3
22+
│ │ ├── *.tif
23+
│ │ └── *.mdf
24+
│ └── ...
25+
26+
├── src/
27+
├── tracksegnet-env/
28+
├── parms.csv
29+
├── tracksegnet.py
30+
└── ...
31+
```
32+
33+
## Change the main parameters
34+
35+
36+
Tune the main parameters of the training in the `params.csv` file according to your experiment:
37+
38+
* `num_states` the number of diffusive states for the classification(from 2 to 6 states). This number can vary from 2 to 6 states, but it is recommended to choose 2 to 4 states.
39+
* `state_i_diff` and `state_i_alpha` the approximate motion parameters for each of the ![equation](https://latex.codecogs.com/svg.image?\inline&space;N) diffusive state. The diffusion constant ![equation](https://latex.codecogs.com/svg.image?\inline&space;D) is dimensionless, and the anomalous exponent value ![equation](https://latex.codecogs.com/svg.image?\inline&space;\alpha) is ranging from 0 to 2 (![equation](https://latex.codecogs.com/svg.image?\inline&space;]0-1[): subdiffusion, ![equation](https://latex.codecogs.com/svg.image?\inline&space;1): Brownian motion, ![equation](https://latex.codecogs.com/svg.image?\inline&space;]1-2[): superdiffusion).
40+
* `pt_i_j` the probability of transitionning from state i to state j. The total number of probabilities should be ![equation](https://latex.codecogs.com/svg.image?\inline&space;N^2).
41+
42+
The remaining parameters are related to the experimental dataset:
43+
44+
* `data_path`, the path of the dataset of trajectories to segment.
45+
* `track_format`, the format of the files containing the trajectory coordinates, either `MDF` (see `MTrackJ` data file format) or `CSV`
46+
* `time_frame`, the time interval between two trajectory points in seconds.
47+
* `pixel_size`, the dimension of a pixel in ![equation](https://latex.codecogs.com/svg.image?\inline&space;$\mu m).
48+
49+
50+
Note that the program will run on the toy example if the parameters are unchanged.
51+
52+
For updating the parameters of the track simulation and neural network training, please make the changes in the main file `tracksegnet.py`.

docs/source/experimental_tracks.rst

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
experimental\_tracks module
2-
===========================
1+
experimental\_tracks
2+
====================
33

44
.. automodule:: experimental_tracks
55
:members:

docs/source/generate_lstm_model.rst

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
generate\_lstm\_model module
2-
============================
1+
generate\_lstm\_model
2+
=====================
33

44
.. automodule:: generate_lstm_model
55
:members:

docs/source/img/pipeline.png

198 KB
Loading

docs/source/index.rst

+8-5
Original file line numberDiff line numberDiff line change
@@ -8,19 +8,22 @@ TrackSegNet's documentation!
88

99
.. toctree::
1010
:maxdepth: 1
11-
:caption: Readme:
11+
:caption: TrackSegNet:
1212

13-
readme
13+
purposes
14+
installation
15+
data-preparation
16+
run-instruction
1417

1518
.. toctree::
1619
:maxdepth: 1
1720
:caption: Modules:
1821

19-
analysis
20-
compute_features
22+
simulate_tracks
2123
experimental_tracks
24+
compute_features
2225
generate_lstm_model
23-
simulate_tracks
26+
analysis
2427
utils
2528

2629
.. toctree::

docs/source/installation.md

+33
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
# Installation and requirements
2+
3+
## Clone the repository
4+
5+
```bash
6+
git clone https://github.com/hkabbech/TrackSegNet.git
7+
cd TrackSegNet
8+
```
9+
10+
## Either create and run a docker container
11+
12+
```bash
13+
# Build a docker image (Rebuild the image after changing the parameters):
14+
docker compose build
15+
# Run the container:
16+
docker compose run tracksegnet-env
17+
```
18+
19+
## Or create a virtual environment and install the packages
20+
21+
Requirement: python3.8 or equivalent and the virtualenv library
22+
23+
```bash
24+
# Create the environment:
25+
python -m venv tracksegnet-env
26+
# virtualenv -p /usr/bin/python3 tracksegnet-env
27+
# Activate the environment:
28+
source ./tracksegnet-env/bin/activate # for Windows PowerShell: .\tracksegnet-env\Scripts\Activate.ps1 (run as administrator)
29+
# Install the required python libraries:
30+
python -m pip install -r requirements.txt
31+
```
32+
33+
Note for later, to deactivate the virtual environment, type `deactivate`.

docs/source/purposes.md

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# Purposes
2+
3+
Recent advances in the field of microscopy allow the capture, at nanometer resolution, of the motion of fluorescently-labeled particles in live cells such as proteins or chromatin loci. Therefore, the development of methods to characterize the dynamics of a group of particles has become more than necessary.
4+
5+
`TrackSegNet` is a tool designed for the classification and segmentation of experimental trajectories, specifically those obtained from single-particle tracking microscopy data, into different diffusive states.
6+
7+
- To enable the training of the LSTM neural network, synthetic trajectories are initially generated, and the parameters of the generator can be fine-tuned.
8+
9+
- Upon completion of the training process, the experimental trajectories are classified at each point using the trained model. Subsequently, the trajectories are segmented and grouped based on their respective diffusive states. In this context, "diffusive states" refer to the distinct modes or patterns observed in the movement of particles.
10+
11+
- For each segmented track, the diffusion constant (![equation](https://latex.codecogs.com/svg.image?\inline&space;D)) and anomalous exponent (![equation](https://latex.codecogs.com/svg.image?\inline&space;\alpha)) are further estimated. This is accomplished by computing the mean squared displacement (MSD), providing valuable insights into the dynamic behavior of the particles within each identified diffusive state.
12+
13+
14+
![pipeline](img/pipeline.png)

docs/source/readme.md

-2
This file was deleted.

docs/source/run-instruction.md

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
# Run the program
2+
3+
4+
```bash
5+
python tracksegnet.py parms.csv
6+
```

docs/source/simulate_tracks.rst

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
simulate\_tracks module
2-
=======================
1+
simulate\_tracks
2+
================
33

44
.. automodule:: simulate_tracks
55
:members:

docs/source/utils.rst

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
utils module
2-
============
1+
utils
2+
=====
33

44
.. automodule:: utils
55
:members:

requirements.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ six==1.16.0
4343
tensorboard==2.11.2
4444
tensorboard-data-server==0.6.1
4545
tensorboard-plugin-wit==1.8.1
46-
tensorflow>=2.11.1
46+
tensorflow==2.11.1
4747
tensorflow-estimator==2.11.0
4848
tensorflow-io-gcs-filesystem==0.30.0
4949
termcolor==2.2.0

0 commit comments

Comments
 (0)