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

Channel sites not accurate in Phy #225

Closed
AamnaLawrence opened this issue Aug 20, 2020 · 2 comments · Fixed by #595
Closed

Channel sites not accurate in Phy #225

AamnaLawrence opened this issue Aug 20, 2020 · 2 comments · Fixed by #595

Comments

@AamnaLawrence
Copy link

Hi,

After using KS2 for sorting my data, I obtain the unit activities for each of the clusters and then compute the firing rate. I want to know which cluster belongs to what channel and I was relying on Phy for it. However, the firing rate computed by Phy for my cluster of interest is different from what I calculated. Is there a way I can find the exact channel sites for the clusters?

@JoseGuzman
Copy link
Contributor

JoseGuzman commented Sep 10, 2020

In the Phy documentation you can read that spike_times.npy contains the times (in sampling points) of all units. In spike_clusters.npy you will have an unique cluster ID (an integer) that corresponds to every spike in spike_times.npy. The first element of spike_clusters.npy the ID of the first unit in your cluster. To collect all spikes of that unit, you need to see in which position the integer appears in spike_clusters.npy, and read them from spike_times.npy.

In Python, you would use something like this to get all the spikes form that first cluster:

# read *npy binaries, let path be the location of your sorting (e.g. $HOME/binaries/Nobelprize/TC001/kilosorting/)
spike_times = np.load(path + 'spike_times.npy').flatten()
spike_clusters = np.load(path + 'spike_clusters.npy')

myid = spike_clusters[0] # first unit (an integer)
spike_times[np.where(spike_clusters==myid)]

If you divide the length of by the size of the recording by the size of your recording (in sec.) you can get the average firing rate of your Unit. You will see that Phy returns a similar value (with 2 decimal points accuracy, though)

@AamnaLawrence
Copy link
Author

Thank you!

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.

2 participants