%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Neural Decoding Matlab Demos
% Dan Morris
% Stanford University, 2005
%
% v1.00: 3/5/05
%
% http://techhouse.brown.edu/~dmorris/
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

This directory contains Matlab implementations of two "classic" neural
decoding algorithms, the linear filter presented by Warland et al and
the Kalman filter presented by Wu et al.  Some sample (synthetic) data
is also provided for you to play with.

The root directory contains the core filtering code... to get started,
just open up and run demo_linear_filter or demo_kalman_filter.  Looking
at those scripts - just tester files - is the best way to see what's
going on.

The 'data' directory contains some synthetic spike and hand position
data, generated under the assumption that each cell has a preferred
position in 2d space, outside of which his firing rate falls off 
according to a gaussian.  The .mat file is used by the demo scripts.

The 'background' directory contains the original papers describing
the linear and kalman filters, and a few notes on inverse kinematics.

The 'inv_kin' directory contains a demo script that takes the sample
data, computes inverse kinematics using an assumed arm configuration,
and builds a linear filter in _joint_ space.  Results of this 
experiment are online at:

http://techhouse.brown.edu/~dmorris/projects/decoding_results.html

That's about everything you need to know to play with this code...

A few more details about important files:

* make_linear_filter.m actually builds a linear filter given spike
  and kinematic input data

* make_kalman_filter.m actually builds a kalman filter given spike
  and kinematic input data

* make_predictions.m takes a computed linear filter and some test
  data and computes new hand position predictions.

* make_kalman_predictions.m takes a computed kalman filter and some test
  data and computes new hand position predictions.

* make_response_matrix.m formats spike data into the response 
  matrix presented by Warland et al.

* plx_to_matlab.m and tg2_to_matlab.m take raw input files (which
  you don't care about) and convert them to a Matlab structure that
  I call 'experiment' throughout this example.  It's one nice 
  structure that holds kinematic and spike data, independent of what
  format your data came in.  You'll never have to run these files,
  but the data format is used throughout this package.

Have fun...

-Dan