Skip to content

About

No description, website, or topics provided.

Resources

Stars

1 star

Watchers

0 watching

Forks

Latest commit

 

History

3 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Neuronal Spike Waveform Clustering

MATLAB and Python workflows for exploring neuronal spike waveforms, calculating waveform attributes, comparing k-means with Ward hierarchical clustering, and visualizing clusters in PCA space.

Example results

Example spike waveforms

K-means clusters in PCA space

Waveforms grouped by k-means cluster

The repository also includes a plot of all waveforms and a results slide deck.

Methods

  • Inspect waveform traces and check for missing values
  • Calculate maximum amplitude, minimum amplitude, and area under the curve
  • Classify waveforms by the relative size of their positive and negative peaks
  • Group waveforms using k-means and Ward hierarchical clustering
  • Project waveforms onto the first two principal components to visualize cluster assignments
  • Plot individual waveforms and mean traces for each cluster

PCA is used for visualization in these scripts; clustering is performed on waveform samples. Area under the curve is calculated as a waveform attribute, not used as a clustering input.

Repository contents

  • analyze_spike_waveforms.m — MATLAB waveform attributes, clustering, PCA plots, cluster traces, and attribute plots
  • spike_clustering.py — Python command-line workflow that saves waveform, PCA, and cluster-trace figures
  • neuroPixels_crossCorr_night.m — separate MATLAB cross-correlation analysis
  • DS.txt — optional direction-selectivity values; the Python clustering script checks this file but does not use it to form clusters
  • *.png — selected example outputs
  • spike_clustering_results_verified.pptx — additional results

Input data

The clustering scripts require a text file containing one waveform per row and one sample per column. spike_waveforms.txt is not currently included in this repository. Supply an appropriately shareable waveform file before running the scripts.

The MATLAB script expects spike_waveforms.txt beside analyze_spike_waveforms.m. It reads DS.txt from the same location when available. It stops if the waveform matrix contains NaN values, so clean missing values before running it.

Run the MATLAB analysis

Place spike_waveforms.txt in the repository directory and run analyze_spike_waveforms.m in MATLAB. The script uses eight clusters by default; change numClusters near the top to use another value.

Run the Python analysis

Install NumPy, Matplotlib, SciPy, and scikit-learn, then run:

python spike_clustering.py spike_waveforms.txt --output-dir figures

To include the optional direction-selectivity file:

python spike_clustering.py spike_waveforms.txt --ds DS.txt --output-dir figures

The Python script uses the first 2,000 waveforms for its clustering demonstration by default. Adjust this with --n-demo; adjust the cluster count with --clusters. Ward clustering can be skipped with --no-ward.

Related work

Data_Science_Tasks contains Jupyter notebooks for PCA, clustering-method comparison, and cluster characterization. neuropixels_analysis contains a separate waveform import and cleaning notebook.

About

No description, website, or topics provided.

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages