basesorting.py get_spike_trains method#3946
Conversation
convienient function to get spike trains of all units as dict
for more information, see https://pre-commit.ci
|
Hey @pas-calc , I think this is a great idea! I suspect there will be some debate about how to implement this. Just to note: there's another way to do this as follows: spike_trains_samples = si.spike_vector_to_spike_trains(sorting.to_spike_vector(concatenated=False), unit_ids=sort.unit_ids)
# go from sample index to seconds
spike_trains = {segment_id : {unit_id: spike_train/sorting.sampling_frequency for unit_id, spike_train in spike_trains_s\
egment.items()} for segment_id, spike_trains_segment in spike_trains_samples.items()}
I would also vote to call it |
|
The spikeinterface/src/spikeinterface/core/basesorting.py Lines 131 to 174 in 2914abd |
|
Hi. |
|
Thinking more about this I am against adding a method to the sorting extractor class that can be accomplished in one line: spike_trains_dict = {unit_id: sorting.get_unit_spike_train(unit_id=unit_id, segment_index=0) for unit_id in sorting.unit_ids}Let's not increase the API exposure area at the core level, this leaks complexity to all the other places in the library. |
|
Hi @pas-calc Thanks for the input but we discussed internally and we agree with @h-mayorquin. Since it's a one liner to get the dict of spiketrains let's not overload the core API! |
convienient function to get spike trains of all units as dict
an alternative method could be