gentnerlab / ephys-analysis

Scripts and utilities for processing electrophysiology data
BSD 3-Clause "New" or "Revised" License
11 stars 8 forks source link

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:

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.

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

what Zeke also wants

  1. Core

    • load spikes
    • load clusters
    • load events
    • load spike shapes
    • load LFP
    • load metadata
  2. Neuron metrics

    • isolation quality measures
    • waveform, features
    • spike width
    • neuron location
  3. Event-responses

    • rasters
    • PSTHs
    • gaussian smoothed
  4. 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.
    1. From the terminal command line on your local computer
    2. change to the directory you want this repository to live,
    3. RUN git clone [https link for repository]
  2. Branch the repository before making any changes (add files, modify files, etc)
    1. from within the repository (so cd ../ephys-analysis)
    2. RUN git checkout -b [whatever you want to name your branch]
  3. Add (file system language) files to "ephys" directory
    1. copy your script that you want to contribute (using cp command in terminal OR dragging and dropping using Finder)
    2. (or if you do not already have the code written, create a new file from withing ephys and write whatever script you want)
  4. "Add" (git language) - means something more specific than "copy"
    1. RUN git add .
    2. Adds the files in the local repository and stages them for commit. To unstage a file, use git reset HEAD YOUR-FILE.
  5. commit these changes
    1. 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.
    2. RUN git commit -m "whatever message you want to provide about what you did"
  6. push the changes to the repository [on github?]
    1. RUN git push origin [whatever you named your branch in step #2]
    2. Pushes the changes in your local repository up to the remote repository you specified as the origin
  7. go online to http://github.com/gentnerlab/ephys-analysis/ to create a pull request for your branch
    1. after you "pushed your branch" from your computer, your branch should show up in the list under the branches tab in this repository
    2. CLICK on the "Pull Requests" tab
    3. CLICK "New Pull Request"
    4. 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_'