petersenpeter / CellExplorer

CellExplorer is a graphical user interface, a standardized processing module and data structure for exploring and classifying single cells acquired using extracellular electrodes.
https://cellexplorer.org/
BSD 3-Clause "New" or "Revised" License
96 stars 59 forks source link

Hi Peter,Error loading waveforms #60

Closed jesusmartin-cortecero closed 2 years ago

jesusmartin-cortecero commented 2 years ago

Hi Peter First of all, Many thanks for such an amazing tool.

I am trying to use Cellexplorer with some example data, but i am not able to identify this error i usually get with some files. i am all the time doing the same. converting from Spike2 smrx format to .bin. then sorting with kilosort2 and manual curation in phy2, however while with some files Cellexplorer works perfectly fine, with some others i get the following error:

Error using plot Vectors must be the same length.

Error in getWaveformsFromDat (line 240) plot(time,wfF2), hold on, plot(time,wfF2(:,maxWaveformCh1),'k','linewidth',2), xlabel('Time (ms)'),title('All channels'),ylabel('Average filtered waveforms across channels (\muV)','Interpreter','tex'),hold off

Error in loadSpikes (line 871) spikes = getWaveformsFromDat(spikes,session,'showWaveforms',parameters.showWaveforms);

Error in ProcessCellMetrics (line 271) spikes{1} = loadSpikes('session',session,'labelsToRead',preferences.loadSpikes.labelsToRead,'getWaveformsFromDat',parameters.getWaveformsFromDat,'showWaveforms',parameters.showWaveforms);

Thank you very much in advance

Best

Jesús

petersenpeter commented 2 years ago

Hi Jesús

Could you share a data session with me that gives this error? It will make it easier for me to troubleshoot. Thanks.

/ Peter

jesusmartin-cortecero commented 2 years ago

Hi Peter

here is an old file i am using to test cell explorer and that generates the above mentioned error

https://drive.google.com/drive/folders/1wk5Vk9gmgr_xuDY6J-LdwWxVNCZrfsLn?usp=sharing

Jesús

petersenpeter commented 2 years ago

Hi, I don't see a binary/raw data file in the folder?

jesusmartin-cortecero commented 2 years ago

the name is a bit long, sorry if it is confusing

https://drive.google.com/drive/folders/1wk5Vk9gmgr_xuDY6J-LdwWxVNCZrfsLn?usp=sharing

"010719_Jesus_Emilio_Jittering_1600_1500_3800_h5_diff_laser_duration.bin" image

petersenpeter commented 2 years ago

It seems it was caused by your sampling rate of 30030Hz. Setting it to 30000Hz solved it.

jesusmartin-cortecero commented 2 years ago

Thanks a lot

Jesus

petersenpeter commented 2 years ago

I would recommend you to work with the rounded sampling rate of 30,000Hz, and then rescale if needed, but I will look into what caused the crash. Every digitizer has its own sampling rate, which is never really 20KHz or 30KHz (say 29987.44Hz for a Neuropixels probe), so this becomes tricky to handle when working with data from multiple recordings.

jesusmartin-cortecero commented 2 years ago

Thank you very much. Jesus

petersenpeter commented 2 years ago

I fixed the issue, which was a simple plotting error, and committed the changes to GitHub.

CellExplorer generates the PSTHs using:

PSTH = calc_PSTH(event,spikes)

The event input follows the event structs convention: https://cellexplorer.org/datastructure/data-structure-and-format/#events

If you want CellExplorer to generate it for you, you simply have to save the trigger events as event files in the basepath before running ProcessCellMetrics, and it will automatically generate PSTHs. Check the above link and the example dataset here: https://cellexplorer.org/datastructure/data-structure-and-format/#example-dataset

If you want to show PSTH rasters, the approach is slightly different. You want to generate a custom spike plot as described here: https://cellexplorer.org/tutorials/plotting-spike-data/

jesusmartin-cortecero commented 2 years ago

Thank you very much, now is working perfect