analyzing Intan KL data
These are the steps for analyzing the KL data from the Intan experiments:
Let's assume we are analyzing data from 2055-05-05
Make sure the files 2055-05-05/t*/vhlv_*.txt are removed if they are present. (They are for a different data acquisition system.)
The files reference.txt, vhintan_filtermap.txt, and vhintan_channelgrouping.txt should be appropriately created (fix this so it explains how and why).
For each directory, 2055-05-05/t*, run the Matlab command Intan_vhinterconnect_decode('PATH/2055-05-05/t0000X')
(this will extract the stimulus code information)
On the Matlab command window, type RunExperiment. When the interface opens, select the 2055-05-05 directory as your experiment.
Choose "Intan Sorting" from the "Useful tools" popup menu
Select the button "Preferences"; make "Should we perform a median filter" 1 (it says default 1 but the default is actually 0)
Select the button "Auto threshold"; this will set a 4 standard deviation threshold for all channels. You will get a dialog box when it is finished that can be dismissed
Select the button "Set/Edit thresholds/extract"
An interactive dialog box will open that shows (by default 10) seconds of data on all channels.
Zoom in on the channels to make sure the thresholds are set correctly. If there are channels that are garbage, make a note of them in your own notes. Use the "match axes" button to set the X and Y ranges of the axes to the same as the "current" axes.
If there are "large" events, you should be able to discard them in the clustering stage, so don't be too alarmed if there are some artifacts.
If you want to adjust a threshold, you can do so just by clicking in a window. The green bar will move. I would be a bit careful in doing this manually because there are so many channels, and the signals on the channels are not necessarily stationary. Another option is to close the window, go to "Preferences", and set the number of standard deviations to a number different than 4 (3.5, 4.5, etc), and choose "Auto Threshold" again
Select different starting time intervals to ensure that the data doesn't change substantially later on in the recording, and that the thresholds chosen remain good for the whole recording. If there is a channel with a lot of garbage, make a note of it in your own notes.
If there are multiple directories (t00001, t00002, etc), choose a different directory and move on to the other directories to repeat the process.
When the thresholds are set appropriately, click the button "Done"
Extract the spikes by selecting the "Choose directories to extract" button. Select all of the directories you wish to extract. There will be a progress bar (it takes a little while.)
Cluster the spikes (the most time-consuming step for the user):
For each name/reference pair (example: 'extra1 | 1' is the name 'extra1' and reference 1), select "Cluster"
Determine the best Features by which to view the clustered data. You can choose "pca3" to use 3-dimensional principle component analysis (PCA) or a direct measurement based version called "2points". You can edit which points are plotted on the "2points" version. I usually use "2points" because PCA can put the features into a weird space sometimes.
Cluster the data by choosing "Cluster all" with either Klustakwik or K-means (you can adjust the parameters)
You will obtain N clusters that you can edit with the "Cluster action" row of menus. You can merge clusters, discard spikes from the cluster, add spikes to the cluster. Be sure to exclude the artifacts. When you are finished, move the "good" cluster to be cluster 1 (from the popup menu).
Mark the good cluster as "Multi-unit"; mark every other cluster as "not usable".
When you are finished, click the button "Done".
Repeat this process until all channels are clustered
Choose "Import extracted cells" to import the clusters into the experiment.mat file
Calculate the KL structures:
Write ds = dirstruct([PATHNAME] filesep '2055-05-05']);
Write KLstruct=kl_packageforJF(ds,'t00001',1:16); % for each test directory
Save it: save 2055-05-05_t00001.mat KLstruct