- for data collection and preprocessing details: https://doi.org/10.1101/2025.08.25.672226
Analysis pipeline for:
- Training CEBRA* models (GPU/CUDA capabilities recommended)
- generates neural activity embeddings
- Running topological data analysis (TDA) using Ripser**
- constructs a Vietoris-Rips filtration on CEBRA embeddings
- Comparing topology of embeddings across brain areas, stimuli, & embedding dimensions
- via persistence diagrams, persistence landscapes, persistence barcode, and betti curves
All steps are in jupyter notebooks with intermediate data files that are saved and reused in subsequent notebooks
- note: you can "jump into" a notebook without having generated data from the previous. this will limit the results to the example data
Includes:
- cleaned neural spike data as primary input (
data/clean_spike_data.zip) - example intermediate files
data/CEBRA_embedding_examples- limited CERBA embeddings (3d & 8d for LGN & V1 color exchange)
data/persistence_diagram_examples- limited dgms examples (all dimensions, LGN & V1, color exchange, limited mice)
data/all_dgms.zip- all persistence diagrams
There are example intermediate data files provided in the data/ folder, but all downstream intermediates can be generated from using clean_spike_data.zip located in data/
If using a machine with CUDA capabilities: conda env create -f tda_environment.yml & conda activate topology
If using CPU: conda env create -f tda_environment_cpu.yml & conda activate base
To check GPU availability: import torch & torch.cuda.is_available()
RAM: recommended at least 8GB
All numerical steps in the notebooks should be executed in order.
If there are multiple processing options per step, choose the desired method and run the cell before moving on to the next.
-
01_CEBRA_embeddings.ipynb
- load cleaned spike data tensors from
\data\folder - train CEBRA models
- save embeddings to pickle files
- visualize embeddings
- load cleaned spike data tensors from
-
02_Ripser.ipynb
- load embedding pickle files
- compute persistence homology using Ripser
- generate dgms (persistence diagrams) for each homology group (H0, H1, & H2)
- plot dgms on a persistence diagram
- save dgms to pickle files
-
03_betti_curves.ipynb
- load dgms pickle files
- generate betti curves - plot betti numbers for each homology group during filtration
-
04_persistence_landscapes.ipynb
- load dgms pickle files
- compute average persistence landscapes across embeddings, regions, & stimuli
- persistence landscape is a vectorized representation of a persistence diagram. these plots are assumed to be more stable than betti curves and displays topological features as functions. often used as input to downstream pipelines like machine learning predictive models or statistical analyses.
Other notebook: persistence_barcodes.ipynb
- fuzzy UMAP algorithm from Gardner et al*** to generate persistence barcodes
- does not generate embeddings but rather constructs a UMAP neighborhood graph for input into Ripser
- rips_filtration_mp4.ipynb: create an visulization (mp4) of the Vietoris-Rips filtration
* https://cebra.ai/docs/
** https://ripser.scikit-tda.org/en/latest/index.html
***Gardner, R.J., Hermansen, E., Pachitariu, M. et al. Toroidal topology of population activity in grid cells. Nature 602, 123–128 (2022). https://doi.org/10.1038/s41586-021-04268-7
