Unformatted text preview:

9.02 Brain Lab J.J. DiCarloMATLAB project 1: Spike detection and plottingThe goal of this project is to make a simple routine (a set of MATLAB commands) that will allow you to take voltage data recorded near a neuron or axon and determine the times that an action potential occurred in that axon or neuron. Because action potentials are the units of communication between neurons in different parts of the brain, the times of action potentials is the fundamental neuronal measure of most of neurophysiology, especially in vivo. For now, some voltage data will be given to you, along with a list of action potential times, and this will allow you to develop and test your routine. However, later in the course, you will collect your own voltage data (where the times of the action potentials are not known) and run your routine on that data. The basics of MATLAB functionsYou should already know how to start MATLAB, make variables in the workspace, call functions(like “plot), and make respectable plots. (If you do not know this, go back and do MATLAB Project 0 .) To make your spike detection routine, you will need to learn how to put MATLAB commands together into a function (called an “m file” in MATLAB) so that you can later run thatfunction on any set of voltage data.From the MATLAB command window, let’s first run a function to detect spike times that we have already written for you. This function is not a very good spike detector (we want to leave that job to you!), but it will give you a basic structure for how your routine should look.First, load the first test data into the workspace:>> >> clear all;>> load('/mit/9.02/matlab/project1/data01');>> whos Name Size Bytes Class actualSpikeTimesMS 1x10 80 double array timesMS 1x20001 160008 double array voltagesUV 1x20001 160008 double arrayGrand total is 40012 elements using 320096 bytesCongratulations, you have just loaded some data into your workspace.Variable ContentsactualSpikeTimesMSlist of times that spikes occurred (units are msec)timesMSlist of all the times (in msec) that a voltage was measuredvoltagesUVall of the measured voltages (units = microvolts = V)Now, run the poor routine provided to you to try to detect and report the times of spike from this data. Note, the routine does not use the actual spike time (that would be cheating!). To run this function, you simply type its name and provide the input data and a variable to hold the output data. Here is an example of what to type at the command line:>>>> detectedSpikeTimesMS = poorRoutineToFindSpikeTimes(timesMS, voltagesUV);>> whos>>Type “help poorRoutineToFindSpikeTimes” in the Command window (without quotes) for more info on this particular function (just as you can get help on any other function).At this point, you should inspect the code in function “poorRoutineToFindSpikeTimes” to understand what a function looks like. To do this, open “/mit/9.02/matlab/project1/poorRoutineToFindSpikeTimes.m” in the editor of your choice. Using emacs under athena:athena% emacs /mit/9.02/matlab/project1/poorRoutineToFindSpikeTimes.m &(If you are not familiar with emacs, we recommend the brief emacs tutorial at http://www.math.utah.edu/lab/unix/emacs.html )Spend some time going through the function line by line to see what it does (also see the information in the project assignment below before you look too closely at the file). As the function name indicates, this is not a good spike detector (as you should see when you figure out how the function works). But it is a fine example of a typical MATLAB function that has the same inputs and outputs as the function that you should create for your project 1 assignment.9.02 Brain Lab J.J. DiCarloAssignment for MATLAB Project 1Goal 1 of Project 1 is to build a function that can do basic spike detection. Along the way, you will need to learn how to write your own MATLAB function. Believe me, this knowledge will be useful outside this course! Along with providing us an electronic copy of your routine, please provide a table showing the performance of your routine across the all of the test data sets (see below). This is not simply an exercise, as you will need to use your routine in the FLY labs near the end of the course.Goal 2 of Project 1 is to plot one of the provided data files showing the voltage vs time plot for the data (similar to Project 0) along with tick marks showing the times that spikes were detected. It is even better if you can also plot the waveforms of all of the detected spikes. An example of what this plot might look like (for a different data file) is shown at the end of this document.Writing your first MATLAB function For MATLAB project 1, the skeleton form of your function should be something like:function [spikeTimesMS]=myFindSpikeTimes(timesMS,voltagesUV) % line 1<<my command/call 1>> % line 2<<my command/call 2>> % line 3…spikeTimesMS = ??; % line 4return % line 5If you are already familiar with MATLAB (or related programming languages), the skeleton provided above should be clear. If not, do not worry, we will walk you through it. Remember, you can always go to the MATLAB help window to learn more about m files and functions in MATLAB. Let’s go through it line by line:There are 5 lines of code in this function skeleton, but that is just for illustration. Your function can have any number of lines. The only line that should be in the same place as this example is line 1.Line 1. This is the most important line in the function. The word “function” tells MATLAB thatthis is the start of a function. The variable name in brackets is the name of the variable in the function whos data values should be returned by whoever called the function. For example, when you called the function from the Command window, with the line:>> detectedSpikeTimesMS = poorRoutineToFindSpikeTimes(timesMS,voltagesUV);you asked MATLAB to place the output of the function called “poorRoutineToFindSpikeTimes” into a variable called “detectedSpikeTimesMS”. Note that you did not have to create this variable before you ran the function – MATLAB created it for you. If you had created a variable with the same namebefore you ran the function, MATLAB would have overwritten any data in your variable with thedata output from the function.The next part of line 1 after the “=” symbol is the name of the function. The name can be


View Full Document

MIT 9 02 - Spike detection and plotting

Download Spike detection and plotting
Our administrator received your request to download this document. We will send you the file to your email shortly.
Loading Unlocking...
Login

Join to view Spike detection and plotting and access 3M+ class-specific study document.

or
We will never post anything without your permission.
Don't have an account?
Sign Up

Join to view Spike detection and plotting 2 2 and access 3M+ class-specific study document.

or

By creating an account you agree to our Privacy Policy and Terms Of Use

Already a member?