├── README.md
├── data_RGCs
├── README.txt
├── SpTimes.mat
├── Stim.mat
└── stimtimes.mat
├── tutorial1_PoissonGLM.ipynb
├── tutorial2_spikehistcoupledGLM.ipynb
├── tutorial3_regularization_linGauss.ipynb
├── tutorial4_regularization_PoissonGLM.ipynb
└── tutorial5_MAPdecoding.ipynb
/README.md:
--------------------------------------------------------------------------------
1 | # GLMspiketraintutorial_python
2 |
3 | Simple tutorial on Gaussian and Poisson generalized linear models
4 | (GLMs) for spike train data, written in python.
5 |
6 | **Author**: [Jesse Kaminsky](https://scholar.google.com/citations?user=ZY1PtQ4AAAAJ&hl=en).
7 | (Translated from a [Matlab version](https://github.com/pillowlab/GLMspiketraintutorial) prepared by [Jonathan Pillow](http://pillowlab.princeton.edu)).
8 |
9 | **Slides**: This tutorial was prepared for use in a
10 | "Short Course" on [Data Science and Data Skills for Neuroscientists](https://neuronline.sfn.org/scientific-research/data-science-and-data-skills-for-neuroscientists#:~:text=Data%20science%20is%20fast%2Dgrowing,be%20used%20in%20different%20circumstances) organized at the SFN 2016 meeting. The slides used during the 1-hour
11 | presentation are available [here](https://github.com/pillowlab/GLMspiketraintutorial/blob/master/slides/slides_SFNshortcourse_Nov2016.pdf).
12 |
13 | **Dataset**: A small dataset required for the tutorial (provided by EJ Chichilnisky) is provided in the directory [data_RGCs](https://github.com/pillowlab/GLMspiketraintutorial_python/tree/main/data_RGCs).
14 |
15 | **Installation**: Clone the repo into the same directory as the provided dataset. Additionally, this tutorial requires that you have scipy, numpy, matplotlib, and [statsmodels](https://www.statsmodels.org/dev/install.html) installed. This tutorial runs on python 3.
16 |
17 | **Description**: The tutorial contains five jupyter notebooks that cover various methods for fitting and analyzing Gaussian and Poisson regression models for spike train data. Each notebook an interactive, self-contained script with 'blocks' of code that demonstrate each step in the fitting / analysis / model comparison pipeline:
18 |
19 | * **tutorial1_PoissonGLM.ipynb** - illustrates the fitting of a
20 | linear-Gaussian GLM (also known as the 'linear least-squares
21 | regression model') and a Poisson GLM (aka 'linear-nonlinear-Poisson'
22 | model) to single retinal ganglion cell responses to a temporal white
23 | noise stimulus.
24 |
25 | * **tutorial2_spikehistcoupledGLM.ipynb** - fitting of an autoregressive
26 | Poisson GLM (i.e., a GLM with spike-history) and a multivariate
27 | autoregressive Poisson GLM (a GLM with spike-history AND coupling
28 | between neurons).
29 |
30 | * **tutorial3_regularization_linGauss.ipynb** - regularizing
31 | linear-Gaussian model parameters using maximum a posteriori (MAP)
32 | estimation under two kinds of priors:
33 | - (1) ridge regression (aka "L2 penalty");
34 | - (2) L2 smoothing prior (aka "graph Laplacian").
35 |
36 |
37 | * **tutorial4_regularization_PoissonGLM.ipynb** - MAP estimation of
38 | Poisson-GLM parameters using same two priors considered in
39 | tutorial3.
40 |
41 | * **tutorial5_MAPdecoding.ipynb** - Bayesian (MAP) decoding of the stimulus from spikes under a fitted Poisson GLM (with or without spike-history). (_Note: this tutorial was added by J. Kaminsky, and does not exist in the Matlab version_)
42 |
43 |
44 |
45 | -------
46 |
47 | **Citation**: If you wish to cite this tutorial, feel free to acknowledge the paper from which it developed: [Pillow et al, *Nature* 2008](http://pillowlab.princeton.edu/pubs/abs_Pillow08_nature.html). Or, for the MAP decoding tutorial, cite: [Pillow et al, *Neural Comp* 2011](http://pillowlab.princeton.edu/pubs/abs_pillow11_NC.html).
48 |
49 |
50 |
51 |
52 |
53 |
54 | -------
55 |
56 | **Relevance / comparison to other GLM packages**:
57 |
58 | This tutorial is designed primarily for pedagogical purposes. The
59 | tutorial scripts are (almost entirely) self-contained, making it easy
60 | to understand the basic steps involved in simulating and fitting. It
61 | is easy to alter these scripts (e.g., to incorporate different kinds
62 | of regressors, or different kinds of priors for
63 | regularization). However, this implementation is not memory-efficient
64 | and does not support some of the advanced features available in other
65 | GLM packages (e.g., smooth basis functions for spike-history filters,
66 | memory-efficient temporal convolutions, different timescales for
67 | stimulus and spike-history components, low-rank parametrization of
68 | spatio-temporal filters, flexible handling of trial-based data). For
69 | more advanced features and applications, see the following two
70 | repositories:
71 |
72 | - [neuroGLM](http://pillowlab.princeton.edu/code_neuroGLM.html) -
73 | designed for single-neuron, trial-structured data. Supports flexible design matrices with multiple types of
74 | regressors. Relevant pub: [Park et al, *Nat Neurosci* 2014](http://pillowlab.princeton.edu/pubs/abs_ParkI_NN14.html).
75 |
76 | - [GLMspiketools](http://pillowlab.princeton.edu/code_GLM.html) -
77 | designed for single- and multi-neuron spike trains with flexible
78 | nonlinearities, multiple timescales, and low-rank parametrization of
79 | filters. Relevant pub: [Pillow et al, *Nature* 2008](http://pillowlab.princeton.edu/pubs/abs_Pillow08_nature.html).
80 |
--------------------------------------------------------------------------------
/data_RGCs/README.txt:
--------------------------------------------------------------------------------
1 | DATA:
2 | -----
3 |
4 | The dataset contains spike responses from 2 ON and 2 OFF parasol retinal
5 | ganglion cells (RGCs) in primate retina, stimulated with a non-repeating
6 | full-field binary white noise stimulus for 20 minutes.
7 |
8 | Files:
9 | -----
10 | Stim.mat % binary white noise stimulus (presented at ~120 Hz framerate).
11 | SpTimes.mat % Spike times from four neurons (in units of stim frames).
12 | % Neurons #1-2 are OFF, #3-4 are ON cells.
13 | stimtimes.mat % Stimulus frame times in seconds (if desired).
14 |
15 |
16 | ATTRIBUTION:
17 | ------------
18 |
19 | These data were collected by Valerie Uzzell in the lab of E.J. Chichilnisky (now
20 | at Stanford University). For full publication information, see Uzzell &
21 | Chichilnisky (J. Neurophysiol. 2004), or (Pillow et al, J. Neurosci. 2005).
22 |
23 | The dataset is provided for tutorial purposes only, and should not be
24 | distributed or used for publication without express permission from EJ
25 | Chichilnisky (ej@stanford.edu).
26 |
--------------------------------------------------------------------------------
/data_RGCs/SpTimes.mat:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pillowlab/GLMspiketraintutorial_python/100d95a3ad6dc98304fbbb52545669cc385a124b/data_RGCs/SpTimes.mat
--------------------------------------------------------------------------------
/data_RGCs/Stim.mat:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pillowlab/GLMspiketraintutorial_python/100d95a3ad6dc98304fbbb52545669cc385a124b/data_RGCs/Stim.mat
--------------------------------------------------------------------------------
/data_RGCs/stimtimes.mat:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pillowlab/GLMspiketraintutorial_python/100d95a3ad6dc98304fbbb52545669cc385a124b/data_RGCs/stimtimes.mat
--------------------------------------------------------------------------------