Skip to content

Tutorial: User Defined Variables

William Chapman edited this page Feb 14, 2019 · 1 revision

There are two methods for defining user-defined variables that will align to the session, including variable values at spike times.

root.myvar

Setting b_myvar will define a variable that aligns and epochs just like other fields (eg: root.cel_myvar will act like root.cel_ts). Only a single variable can be defined at a time, and no additional functionality is provided.

root.myvar2

This is a custom defined class that allows the storage of any number of named variables to be stored. Variables are epoched and spike times aligned, just like root.myvar. Additionally, tuning curve functions are provided. Currently we provide: PolarPlot (analogous to head direction tuning curve), SpatialPlot(shows mean of the variable in each spatial bin), and SpeedPlot (shows mean of the variable for a given running speed). More tuning curves may be added over time.

For example, here we find the tuning of a given neuron in response to the movement direction of the animal

dy = [NaN; diff(root.b_y)]; dx = [NaN; diff(root.b_x)];
heading = atan2(dy, dx);

root.myvar2 = [];
root.myvar2 = root.myvar2.add('heading',heading,root.b_ts,root.b_ts,1); 
%first is root timestamps, second is myvar timestamps, in case they are not sampled at the same rate

root.myvar2.get('heading')

root.myvar2.PolarMap('heading',root,'ifPlot',1)
root.myvar2.SpatialMap('heading',root,'ifPlot',1)
Clone this wiki locally