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

    1. Make sure the files 2055-05-05/t*/vhlv_*.txt are removed if they are present. (They are for a different data acquisition system.)

    2. The files reference.txt, vhintan_filtermap.txt, and vhintan_channelgrouping.txt should be appropriately created (fix this so it explains how and why).

    3. For each directory, 2055-05-05/t*, run the Matlab command Intan_vhinterconnect_decode('PATH/2055-05-05/t0000X')

    4. (this will extract the stimulus code information)

    5. On the Matlab command window, type RunExperiment. When the interface opens, select the 2055-05-05 directory as your experiment.

    6. Choose "Intan Sorting" from the "Useful tools" popup menu

      1. Select the button "Preferences"; make "Should we perform a median filter" 1 (it says default 1 but the default is actually 0)

      2. 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

      3. Select the button "Set/Edit thresholds/extract"

        1. An interactive dialog box will open that shows (by default 10) seconds of data on all channels.

        2. 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.

        3. 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.

        4. 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

        5. 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.

        6. If there are multiple directories (t00001, t00002, etc), choose a different directory and move on to the other directories to repeat the process.

        7. When the thresholds are set appropriately, click the button "Done"

      4. 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.)

      5. Cluster the spikes (the most time-consuming step for the user):

        1. For each name/reference pair (example: 'extra1 | 1' is the name 'extra1' and reference 1), select "Cluster"

        2. 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.

        3. Cluster the data by choosing "Cluster all" with either Klustakwik or K-means (you can adjust the parameters)

        4. 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).

        5. Mark the good cluster as "Multi-unit"; mark every other cluster as "not usable".

        6. When you are finished, click the button "Done".

        7. Repeat this process until all channels are clustered

      1. Choose "Import extracted cells" to import the clusters into the experiment.mat file

    1. Calculate the KL structures:

      1. Write ds = dirstruct([PATHNAME] filesep '2055-05-05']);

      2. Write KLstruct=kl_packageforJF(ds,'t00001',1:16); % for each test directory

    1. Save it: save 2055-05-05_t00001.mat KLstruct