Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Input data and Kilosort GUI #46

Closed
jesusdpa1 opened this issue Mar 28, 2019 · 8 comments · Fixed by #595
Closed

Input data and Kilosort GUI #46

jesusdpa1 opened this issue Mar 28, 2019 · 8 comments · Fixed by #595

Comments

@jesusdpa1
Copy link

Hi,

I have started to use Kilosort2 to sort the data gather using TDT, but have had many difficulties when setting everything up. The first difficulty I am having is when I transform the data from .mat to .bin using fwrite(fidOut, datae_f, 'int16'); the data gets downsample, most values are transformed to 0. Therefore the sorting of the data is done incorrectly giving me in most channels an error of bad channel, and when plotted using phy the signal looks like small pulses across time.

The values are presented in micro Volts ranges. I multiply the values by 10000, and got an improvement in the shape of the signal and the sorting but kept observing down sampling on the data. In the other hand when I multiplied by larger values the signal start looking over saturated. Any recommendations towards the input data?

The second issue I am having is when I tried to use the new Kilosort Gui. The first error that showed was that I needed to download the Adds On "GUI Layout Toolbox" after doing this the error change to "No constructor 'handle.listener' with matching signature found"

any suggestions?

Thanks

@chris-angeloni
Copy link

chris-angeloni commented Mar 29, 2019

You could try formatting the data as int16 in matlab int16(datae_f) and then plot one channel to see what changing to int16 does to your data. When I've tried doing this on some TDT data in the past it will often do some funny things, like turn everything to 0, and scaling seemed to help:

dat = int16(dat.*1e6); fwrite(fidOut,dat(:),'*int16'); fclose(fidOut);

I have some code that has successfully converted .sev files, which I believe are from TDT, if you're interested.

For the GUI, I had the same issue too, you need to make sure that you add the correct GUI Layout Toolbox, and make sure to add it from the Add On menu in Matlab. By default, searching "GUI Layout Toolbox" does not get the correct one, instead you need to search the author's name "David Sampson" in the Add On window, and that will find the right one. If the one you're downloading is not by David Sampson, it won't work. If you already installed a different one, make sure you completely uninstall it and remove it from the path before trying to install the correct one.

@jesusdpa1
Copy link
Author

Thank you very much! both of the solutions worked.

I neither understand why I was getting my values transformed to 0.

Also I would be interested in trying your code, I am curios to see if the extraction of the data is being done correctly by the .mat file provided by the company. Right now I am doing my filtering outside Kilosort (notch 60hz fiir 2 degree, highpass fiir 2 degree, sampling rate 48828.125), and I am not having good results detecting the spikes. Do you know by any chance the noise toleration of the algorithm? I am still leaving some artifacts that are in the signal (high magnitud spikes), but if needed I would include another filter.

@chris-angeloni
Copy link

The best way to debug this is to visualize the data you are giving to Kilosort. Errors in saving the .dat file, or providing the wrong number of channels can both cause Kilosort to fail, as it can't load the data correctly.

A simple way to load and visualize the .dat file, assuming a 32 channel recording (beware, if it's really big, this method can lock up matlab):

nChan = 32; fid = fopen('continuous.dat','r'); dat = fread(fid,[nChan inf],'*int16'); fclose(fid); plot(dat(:,1:50000)'+(1:size(dat,1))*1000);

Check to see if that plots your channels correctly

@nsteinme
Copy link
Collaborator

nsteinme commented Mar 30, 2019 via email

@chenchals
Copy link

Hi:
I used a different approach, basically created a DataAdapter matlab interface and created (EMouseDataAdapter and a TDTDataAdapter) and re-routed the "fread(...)" call such that depending on the type of data (TDT in my case) I could get Kilosort1 to work. Now I am adapting the code for Kilosort2 and have successfully used it for eMouse.
The advantage of this approach is to avoid creating a "huge" .bin file especially if you are using multiple vector probes. Would love to hear your comments. Once I set this up to work with KS2, would love to shre the code for those TDT users!

@jesusdpa1
Copy link
Author

Hi Chenchal,

This sounds great, let me know when you finish with this script to try it out. definitely the .bin files are "huge"

@chenchals
Copy link

@jesusdpa1 : I have had some success in coding interface for TDT data that can be used to to exercise Kilosort2. Basically, modified Kilosort2 files that read data from the binary file. Additionally, implemented a RawBinDataAdapter to work with the eMouse-generated-sample-binary file directly.
Attached is a zip file containing the modified Kilosort2 files and a tdtKs2 files in 2 folders. You will need to replace the files from Kilosort2Changed-files/xx folders to the right original Kilosort2/xx folders, of course, please back-up the original files :-)
Check the ⁨tdtKs2⁩/scratch⁩/⁨eMouseKS2⁩/ myEmouseConfig.m and myMasterEmouse.m files. All subdirs of the tdtKs2/toolbox need to be in matlabpath.
See if you can give it a spin.
Note: Cant view the raw data in phy-gui yet... :-( or load files via Kilosort2-GUI...
0-Ks2-share.zip

@marius10p
Copy link
Contributor

Issue has become inactive. Closing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants