Tracing Flow reconstructs particle trajectories from discrete time snapshots. It combines optimal transport between adjacent time points with neural networks that learn initial velocity and continuous-time acceleration.
The current entry point is Train.py.
Train.py: example training script forSimLineagetracingflow.py: OT matching, trajectory sampling, training, visualizationdataset.py: dataset wrappers for CSV files indatasets/models.py:InitialVelocityNetandAccelerationNetconfig.py: hyperparametersutils.py: keypoint export helpers
Create the Conda environment:
conda env create -f enviroment.yaml
conda activate tracingflowCreate the checkpoint directory before training because the code saves weights to ./checkpoints/ but does not create it automatically:
mkdir checkpointsIf your machine does not have CUDA, change device = "cuda" to device = "cpu" in config.py.
Run the default example:
python Train.pyTrain.py currently trains SimLineage with dim = 2.
Training flow:
- Load a dataset.
- Build
InitialVelocityNetandAccelerationNet. - Train with
TracingFlow.train_tracing_flow(...). - Generate trajectories with
generate_trajectory(...). - Plot results and save keypoints to
output_data/.
To use another dataset, edit Train.py and change the dataset class and dim.
Example:
from dataset import SimLineage3D
my_dataset = SimLineage3D()
dim = 3
my_ini_vel_net = InitialVelocityNet(dim=dim)
my_acc_net = AccelerationNet(dim=dim)dim must match the feature dimension of the selected dataset.
This repository does not include a standalone data generation script. To use your own data, place a CSV file in datasets/ and add or reuse a dataset class in dataset.py.
Most datasets use:
samples,x1,x2,...,xD,barcodes
0,...
1,...samples: discrete time indexx1 ... xD: coordinates or featuresbarcodes: optional label column
SimLineage3D uses this format instead:
time,x1,x2,x3,barcodes
0,...
1,...For a new dataset class, define:
self.csv_pathself.time_steps- feature column slicing
- whether the time column is
samplesortime
Main dataset wrappers in dataset.py:
SimLineageSimLineage3DCite5DCite100DRealLineageCite5D_wo_1,Cite5D_wo_2,Cite5D_wo_3EB5D,EB5D_wo_1,EB5D_wo_2,EB5D_wo_3,EB5D_wo_4Gulf_dataMolecular_data
High-dimensional data are projected to 2D with PCA for visualization.
Training saves model weights to checkpoints/:
ini_vel_<save_name>.pthacc_<save_name>.pth
save_keypoints(...) saves:
<prefix>_position_time_1.npy<prefix>_weight_time_1.npy<prefix>_barcode_time_1.npywhen labels are provided