cortex-lab / phy

phy: interactive visualization and manual spike sorting of large-scale ephys data
BSD 3-Clause "New" or "Revised" License
320 stars 157 forks source link

Raw Amplitude Data #920

Closed Marrekko closed 4 years ago

Marrekko commented 4 years ago

Hey,

first, thanks for the great work with phy and phylib! I have an issue regarding data extraction. As I'm new to python and coding, I can't tell if it's related to Issue#908, but might be. I want to obtain raw amplitude data, preferred the mean raw amplitude of spikes in a given cluster. Using phylib, I'm able to construct figures of raw amplitude waveforms and even in phy the data looks fine. However, I couldnt find a function to extract the Information to an array or similar in phylib. Through the phy API documentation I found several ways to get a raw amplitude return. Trying those I got:

> WaveformMixin.get_mean_spike_raw_amplitudes(1)
> ---------------------------------------------------------------------------
> NameError                                 Traceback (most recent call last)
> <ipython-input-1-39e337a9ea85> in <module>
> ----> 1 WaveformMixin.get_mean_spike_raw_amplitudes(1)
> 
> NameError: name 'WaveformMixin' is not defined  

or

> In [2]: c.get_mean_spike_raw_amplitudes(1)
> Out[2]: 0.0

I got the same result, trying to extract them from the spike ids:

> In [3]: c.get_spike_ids(1)
> Out[3]: 
> array([  1,   2,  11,  12,  14,  15,  16,  17,  18,  19,  20,  21,  22,..............
> 
> In [4]: sid = c.get_spike_ids(1)
> 
> In [5]: c.get_spike_raw_amplitudes(sid)
> Out[5]: 
> array([0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
>        0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,.......................
> 

So basically I'm getting an array conatining zeros. Any Idea? I would appreciate any help or advise, maybe there is a phylib option I did not realise so far? My data was sorted using SpykingCircus, with multichannel binary as input.

rossant commented 4 years ago

This is not properly documented, but you should specify the channel on which to compute the waveform amplitude: c.get_spike_raw_amplitudes(sid, channel_id=c.get_best_channels(1)[0])