a cauldron of Bayesian witchcraft for rat mind-reading
a sandbox for Bayesian neural decoding
This code is maintained by Luke Arend and the members of the Johnson laboratory at Bethel University.
The codebase contains utilities for building tuning curves from raw spike data, visualizing the encoding model, and performing Bayesian neural decoding. This can be done in a stimulus space of arbitrary dimensionality. The code is intended to run in MATLAB (written in version 2016a).
Image: "Thinking Rat" by Henriikka Pöllänen.
To get started, clone this repository to your local machine.
Acquire a data set, and run sandbox.m to start playing immediately!
Loading the neural data from a recording session assumes an Eichenbaum-style data file which contains at least the following fields:
- unitdata: 1 x 1 struct with two fields:
- units: 1 x K struct where each cell has two fields and K is the number of units:
- name: unit name.
- ts: s x 1 array containing spike timestamps for s spikes.
- rawLEDs: M x N array containing ground-truth stimulus data, where M is the number of samples and N is the number of stimuli recorded (dimensionality of the stimulus space).
- units: 1 x K struct where each cell has two fields and K is the number of units:
Use the function load_data_xy() to load x-y neural data.
Use build_tuning_curves() to construct tuning curves from neural data. This can build tuning curves either according to the Poisson encoding model (a simple estimate of the mean firing rate at each location) or the negative binomial encoding model (a sequential Bayesian estimate of a distribution over firing rate, using a gamma-distributed prior).
Use get_IC_curves() to compute an information content map for a tuning curve or set of tuning curves. As a measure of information content at each location, this finds the KL divergence between the posterior over firing rate at that location and the posterior if firing rate is averaged across location.
Note that this can only be used on Bayesian tuning curves (those generated under the negative binomial encoding model).
Use plot_curves() to visualize a set of tuning curves, information content curves, or decoded posterior distributions.
Use bayesian_decode() to perform Bayesian decoding on spiking data. This produces a posterior distribution over stimulus space for each decoding timestep. This function accepts either Poisson- or negative binomial-based tuning curves.