from kwik files to spike sorting

663 views
Skip to first unread message

Edgar Bermudez

unread,
Apr 14, 2016, 1:52:03 PM4/14/16
to Open Ephys
Hi all,

I am starting to look at my first datasets in kwik format and I am wondering what is the best software option to start spike sorting (aligning data, etc). I know this is almost a personal taste. I am quite familiar with klustakwik and Mclust but I am wondering if I should try something else. Preferably matlab based and well documented :)

I read a bit about simple clust but not sure where to start. Any suggestions are more than welcome.

Many thanks!

Edgar

Chris Rodgers

unread,
Apr 14, 2016, 4:58:34 PM4/14/16
to Open Ephys
I think the best option right now is Phy. It is from Ken Harris and collaborators and is the modern incarnation of klustakwik.
http://phy.readthedocs.org/en/latest/

It accepts flat binary files as input so you may need to write a quick script to dump data from Kwik to binary.

Edgar Bermudez

unread,
Apr 15, 2016, 11:58:59 AM4/15/16
to Open Ephys
Hi Chris,

Thank you for the suggestion. I will have a look at phy.

Do you know of a tutorial about how to spike sort the kwik files? in any spike sorting program? I want to become familiar with the format with an example first before starting to write my own functions.

Cheers,

E

Chris Rodgers

unread,
Apr 15, 2016, 1:36:34 PM4/15/16
to Open Ephys
There is sample data and a tutorial included with phy but I think it is in binary, not kwik. I am away from my computer for the weekend but can post my quick Python script to convert from kwik to binary when I get back. It's pretty straightforward if you know how to write binary files.

Here's their recent publication
http://www.nature.com/neuro/journal/v19/n4/abs/nn.4268.html

I was remiss in not mentioning Cyrille Rossant is the lead (I think) developer and first author, with many collaborators (see author list).

maxym myroshnychenko

unread,
Apr 21, 2016, 3:15:45 PM4/21/16
to Open Ephys
Hi Edgar,

Take a look at this thread in phy board. The last post has a matlab script attachment. I second Chris' suggestion of phy, it's excellent.

Max

Edgar Bermudez

unread,
May 4, 2016, 7:36:54 PM5/4/16
to Open Ephys
Thank you very much maxym.

Maybe this would be a good addition to the wiki, a tutorial about how to start spike sorting once you have collected the data.

Edgar Bermudez

unread,
Jun 1, 2016, 3:28:21 PM6/1/16
to Open Ephys
Hi all,

Can anyone suggest where to start to do spike sorting in MATLAB from the .kwx files? (I don't mean documentation about how to do spike sorting, I mean about how to convert/extract data to use Klustakwik and MClust (for example) with data collected with open-ephys)

I am having trouble trying to find any documentation about this.

Many thanks again,

Edgar

Chris Rodgers

unread,
Jun 2, 2016, 4:37:40 PM6/2/16
to Open Ephys
KlustaKwik is not intended to be used from Matlab. To use Klustakwik, try out the thread on the Phy message board that Maxym recommended.

My understanding is that MClust is a Matlab thing but I've never used it. You can load the KWX files using Matlab's ability to read HDF5 files. Try googling "matlab HDF5 files". That's all I can suggest with the experience I have.

Josh Siegle

unread,
Jun 4, 2016, 3:52:56 AM6/4/16
to Edgar Bermudez, Open Ephys
Hi Egdar,

We already have some code for loading Open Ephys .spikes files into MClust: https://github.com/open-ephys/analysis-tools/blob/master/LoadTT_openephys.m

This can be easily modified to work with the .kwx files. If you end up making the changes, please share them on GitHub!

Josh

-- 
You received this message because you are subscribed to the Google Groups "Open Ephys" group.
To unsubscribe from this group and stop receiving emails from it, send an email to open-ephys+...@googlegroups.com.
To post to this group, send email to open-...@googlegroups.com.
Visit this group at https://groups.google.com/group/open-ephys.
To view this discussion on the web visit https://groups.google.com/d/msgid/open-ephys/e0e88220-8de9-4d08-9677-4d665f0ec83c%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Message has been deleted

Edgar Bermudez

unread,
Jun 22, 2016, 4:15:51 PM6/22/16
to Open Ephys, edgar.b...@gmail.com
Hi Josh,

Thanks for your email. I am writing the LoadingEngine function in MClust for the kwx format. However, I am having trouble deciding how to re-organize the data so that the loading function follows the MClust convention.

Since one sorts one tetrode at a time, MClust loads the spikes for each tetrode separately. Previously, for the .spikes format (and also the Neuralynx format), the wave forms are already divided into files according to the tetrode where they came from (i.e. TT1.spikes or TT01.ntt).

In the new OE format kwx, all of them are in one single file so the loading function has to know which tetrode needs to be accessed at a time (i.e. /channel_grousp/TT/time_
samples, where TT is the tetrode number) which would imply modifying MClust or alternatevely, the HDF5 file needs to be divided into files corresponding to tetrodes. I am tempted to write a another function to separate all spikes into tetrode files, so that the loading engine function is called each time for every file.

Alternatively, I could convert the kwx file into .dat files and run MClust directly on those?

Any ideas what option would be preferable for most people? I plan to update the resulting LoadingEngine functions for MClust.

Cheers,

Edgar

Josh Siegle

unread,
Jun 23, 2016, 1:13:04 PM6/23/16
to Edgar Bermudez, Open Ephys
Hi Edgar,

Is there an easy way to specify the electrode number as an optional argument to the loading engine? You’d probably have to modify the MClust source code, but it would allow you to load the spikes directly from the KWX file. That seems like the most straightforward way to get what you need.

That said, a KWX to DAT converter would be useful for a lot of things, not just MClust. If you end up writing one, we’d be happy to share it in the analysis-tools repository!

Josh

Edgar Bermudez

unread,
Jun 24, 2016, 5:58:18 PM6/24/16
to Open Ephys, edgar.b...@gmail.com
Yes, I am modifying MClust to have a selection of the electrode and pass it to the loading engine. It is not pretty, but should do the job.

Soon I will look into convert kwx into dat files.

Thanks for the suggestion!

Edgar

Antonin Blot

unread,
Jul 4, 2016, 10:53:34 AM7/4/16
to Open Ephys, edgar.b...@gmail.com
In case someone looks for a python reader for openephys kwik files, I use that:
https://bitbucket.org/blota/openephysreader
It is not bug free and might be a bit messy

There is a function to convert kwd to dat (but nothing for kwx).
Reply all
Reply to author
Forward
0 new messages