(yes this is ugly but I'll update it and make it pretty later on)
Running Klustakwik on Matlab
This is a walkthrough explaining how to automatically cluster cut ephys data using Klusta for MATLAB. This process is simplified by the “autoClusterCutting.m” script (the “main script”), and this walkthrough gives all the details needed to run this main script properly.
This guide assumes basic knowledge of MATLAB. If you don't have this yet, or computers are scary, then go to “BASICS OF MATLAB” [IN PROGRESS]
1. Setting the MATLAB path
(NOTE: once you do this step once, you can skip it for all cluster cutting you do on your computer)
You will need several folders and scripts from Dropbox to run the main script. These are as follows:
/media/data/Dropbox (NewmanLab)/scripts/openEphysImport
/media/data/Dropbox (NewmanLab)/scripts/KlustaMat
/media/data/Dropbox (NewmanLab)/scripts/utils/utils_io_and_filehandling
Add these folders to your synced files in Dropbox, and let the files download.
In order for the main MATLAB script to work, you must tell MATLAB where these scripts are. This is done by adding the folders to the “MATLAB path” (this “path” is simply where MATLAB searches for scripts, files, and folders – to use any script in MATLAB, it must be in the path).
So, to run the main script, you must add the three folders above to your MATLAB path by:
opening MATLAB
selecting “Set Path” in the upper Environment tab
selecting “Add Folder” and navigating to the folder you wish to add to your path
Repeat #3 for each of the three folders
IMPORTANT: once you have added the three folders, press “Save” to make these changes persist after you close MATLAB. Otherwise, you will have to go through #1-4 every time you open MATLAB.
Once you do this, you can skip these steps for future cluster cutting.
Once this is done, you will need the data you want to cluster cut.
2. Getting your data
Your data that you want to cluster cut is likely stored on Dropbox. In order to run the main script, you will first need to download your data from Dropbox onto the computer you're using, into one folder.
For example, for the rat Jolene, make a folder named something like “joleneCCdata” on your desktop. Then, download all the sessions that you want to cluster cut from Dropbox into this folder.
[Side/historical note: this step has to be done due to the naming of Dropbox; if “/Dropbox (NewmanLab)/” didn't have a space in the name, you wouldn't have to download the data files. Ask Bryce if you're curious why]
3. Starting the cluster cutting script
At this point, you're ready to run the main script, which starts all the cluster cutting of your data. The main script also gives instructions you can follow in addition to this guide
In MATLAB, type “autoClusterCutting” (without quotes) into the MATLAB terminal. This should bring up a prompt asking for the full name of the data folder you made in #2. Copy and paste the path name into MATLAB, and press enter.
From here, you can cluster cut multiple rounds of sessions (either individual sessions or groups of sessions) consecutively. To do this, follow the instructions below:
You will be prompted to say if you'd like to cluster cut a session. Since you're reading this guide, you probably want to cluster cut, so enter “yes”.
This lets you enter the session name(s) for one round cluster cutting. For example, if you're cluster cutting a combined session of three individual sessions, enter the name of each one at a time (pressing enter in between each), and then press enter.
This finalizes your first round of cluster cutting. If you would like to run more rounds of cluster cutting, enter "yes" to repeat the steps in 3. Otherwise, enter “no” and the automatic cluster cutting will start!
Brief outline of the scripts involved:
“autoClusterCutting.m” is a simple wrapper that walks the user through cluster cutting, while actually cluster cutting using either “exampleRun_OE_function.m” or “exampleRun_OE_CS_function.m” when appropriate.
For a single session, the former script is run, which simply cluster cuts the session using KlustaMat.RunEphys (this gets very technical and won't be outlined here).
For a set combined session, the latter script is run, where there are several additional steps in the process. The program first combines the data from the sessions sequentially into one large session, and then cluster cuts this one combined session (again, via KlustaMat.RunEphys).
It also generates .kwik files in each session's data directory, but does not cluster cut these.
This is all the script does for automatic cluster cutting. At this point, the generated files can be sorted manually.
Once a combined session is manually sorted, a final step must occur. The clusters resulting from the manual sorting of the full combined session are properly assigned to their corresponding individual session.