Closed Yawende closed 1 year ago
Hi @Yawende
It's not possible in MEArec, but you can do it using SpikeInterface:
import spikeinterface as si
import spikeinterface.extractors as se
import numpy as np
# load recording and sorting
recording_mearec, sorting_mearec = se.read_mearec("path-to-mearec.h5")
# estimate maximum channel for each unit
waveforms = si.extract_waveforms(recording_mearec, sorting_mearec, folder="wf_folder")
extremum_channels = si.get_template_extremum_channel(waveforms, outputs="index")
# generate spike_times vector
spike_vector = sorting_mearec.to_spike_vector()
spike_times = spike_vector["sample_ind"] / sorting_mearec.sampling_frequency
# now we construct an array with the channel index associated to each spike
spike_channels = np.array([extremum_channels[unit_id] for unit_id in sorting_mearec.unit_ids[spike_vector["unit_ind"]]])
Now spike_channels
is an array with the channel index associated to each spike. Note that this will only contain the channel on which the unit waveform is largest (on average), and not all the channels where the unit was detected.
Cheers, Alessio
Dear Alessio,
Thank you very much, this is very helpful!
Hello,
In order to assess the performance of a spike detection algorithm called (WIRED-OR: https://ieeexplore-ieee-org.tudelft.idm.oclc.org/abstract/document/8801905), I would like to use MEArec. However, I noticed that it is unfortunately (if I'm correct) not possible to get the spike event times and the number of spikes for each electrode instead of each unit. Is this something that could be implemented? I would like to have this as a ground truth measurement.
Any assistance would be greatly appreciated.
Kind regards, Yawende Landbrug