Skip to content

gentnerlab/ephys-analysis

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ephys-analysis

scripts and utilities for processing electrophysiology data

Build Status Coverage Status

Quick introduction

These scripts are designed to operate on the data after manually sorting the phy output and mergining stimuli information. As a result, everything that follows assumes that:

  • you have sorted your data with phy
  • you have manually sorted your data with the phy gui
  • you have merged events into your kwik file with merge_stim_kwik

Data analysis functions are divided into logically separate components. We have strived to maintain well documented code, so you won't find detailed escriptions of the functions here. Go to the code and read the docstrings for the functions to get more specifics.

  • 'core' contains routines for loading the data and metadata, such as sampling rate.
  • 'events' contains routines for loading trial information
  • 'clust' constains routines for computing basic features of the clusters, such as waveform metrics and geometric location
  • 'spiketrains' contains functions for dealing with segments of your data. You can pass parameters to describe which slice of data you wish to extract and it will return to you the spiketrain. For example, you can use the trials dataframe to find trial times, and then pass those times into 'get_spiketrain' to get the spikes during that trial -'viz' contains routines to visualize clusters.

input file structure

these scripts assume that they are dealing with an experiment that has been sorted by phy. an example structure is as follows:

Pen01_Lft_AP2500_ML1350__Site10_Z2026__B997_cat_P01_S10_Epc10/ - directory containing the files. the naming convention comes from the way that ChronicScript.s2s and ExportMatlab.s2s name directories. This directory is from Penetration 1 (Left hemisphere, 2500um Anterior, 1350um Lateral), Site 10 (2026um depth), and consists of Epoch10. B997_cat_P01_S10_Epc10 is manually named in the prompt in MatlabExport.s2s so might vary and should not be considered reliable.

Inside this directory are the following files:

B997_cat_P01_S10_Epc10.kwik - hdf5 file containing spike times, cluster assignments, and event times B997_cat_P01_S10_Epc10.kwx - hdf5 file containing the PCA-reduced features that phy used to cluster spikes B997_cat_P01_S10_Epc10.raw.kwd - hdf5 file containing the raw waveforms used by phy B997_cat_P01_S10_Epc10.phy - a working directory used by phy to cache compture features and masks params.prm - python file containing the parameters that phy used to detect and cluster spikes A1x32-Poly3-6mm-50.prb - python-formatted probe file defining the channels and adjacency matrix used by phy

More details on these files can be found at http://phy.readthedocs.org/en/latest/kwik-format/

The directory also contains the following files generated by make_kwd:

B997_cat_P01_S10_Epc10_info.json - record of parameters used to generate raw.kwd file indx_port_site.txt - csv file of raw.kwd channel mapping. columns indicate the phy index, Spike2 channel name, and neuronexus site number

analysis architercture

what we need to be able to do

  • get spikes from a given trial
  • get spikes from a given stimulus or event
  • get spikes from a given neuron
  • get spikes from a population of neurons
  • make rasters
  • make PSTH
  • plot spike shapes
  • get spike widths
  • identify neuron location
  • cluster quality metrics
  • plot distribution of spike widths in a population

what Zeke also wants

  • save needed metadata into one of the HDF5 files (params.prm, indx_port_site.txt, probe file, _info.json, other)
  1. Core
  • load spikes
  • load clusters
  • load events
  • load spike shapes
  • load LFP
  • load metadata
  1. Neuron metrics
  • isolation quality measures
  • waveform, features
  • spike width
  • neuron location
  1. Event-responses
  • rasters
  • PSTHs
  • gaussian smoothed
  1. Behavior
  • trial data

Test Data

There is data to use for testing on the cube share under ephys-example-data. It is probably safest to copy this somewhere else for testing analysis code.

Pen01_Lft_AP2500_ML1350__Site10_Z2026__B997_cat_P01_S10_Epc10 - awake behaving block (Justin) Pen01_Lft_AP100_ML1300__Site03_Z2500__B1056_cat_P01_S03_1 - acute block (Krista & Brad)

approach

If you have code written already that works toward these ends, do the following...

  1. create a new branch of this repository
  2. add your files to ephys
  3. open a pull request for your branch

We'll hack on and merge branches as needed during the hackathon.

approach (step-by-step)

if you are not already familiar with this process you might enjoy these hopefully interpretable steps

If you have code written already that works toward these ends, do the following...

  1. Clone the repository on your local computer.
  2. From the terminal command line on your local computer
  3. change to the directory you want this repository to live,
  4. RUN git clone [https link for repository]
  5. Branch the repository before making any changes (add files, modify files, etc)
  6. from within the repository (so cd ../ephys-analysis)
  7. RUN git checkout -b [whatever you want to name your branch]
  8. Add (file system language) files to "ephys" directory
  9. copy your script that you want to contribute (using cp command in terminal OR dragging and dropping using Finder)
  10. (or if you do not already have the code written, create a new file from withing ephys and write whatever script you want)
  11. "Add" (git language) - means something more specific than "copy"
  12. RUN git add .
  13. Adds the files in the local repository and stages them for commit. To unstage a file, use git reset HEAD YOUR-FILE.
  14. commit these changes
  15. Commits the tracked changes and prepares them to be pushed to a remote repository. To remove this commit and modify the file, use git reset --soft HEAD~1 and commit and add the file again.
  16. RUN git commit -m "whatever message you want to provide about what you did"
  17. push the changes to the repository [on github?]
  18. RUN git push origin [whatever you named your branch in step #2]
  19. Pushes the changes in your local repository up to the remote repository you specified as the origin
  20. go online to http://github.com/gentnerlab/ephys-analysis/ to create a pull request for your branch
  21. after you "pushed your branch" from your computer, your branch should show up in the list under the branches tab in this repository
  22. CLICK on the "Pull Requests" tab
  23. CLICK "New Pull Request"
  24. CHOOSE "base: master" and "compare: [whatever you named your branch in step#2]"

naming conventions

  1. Functions that put together a filename are prefixed with 'find_'
  2. Functions that open files on disk and read their contents into memory are prefixed 'load_'
  3. Functions that return an attribute of some (data, object, etc) are prefixed 'get_'
  4. Functions that perform a computation are prefixed 'calc_'

About

Scripts and utilities for processing electrophysiology data

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published