Initial dartsort wrapper implementation. - #2125
Conversation
|
@cwindolf any news ? |
….com:samuelgarcia/spikeinterface into dartsort_wrapper
for more information, see https://pre-commit.ci
….com:samuelgarcia/spikeinterface into dartsort_wrapper
….com:samuelgarcia/spikeinterface into dartsort_wrapper
| sorting = NumpySorting.from_samples_and_labels( | ||
| [times_samples[mask]], [labels[mask]], dartsort_sorting.sampling_frequency | ||
| ) | ||
|
|
There was a problem hiding this comment.
| # The main channel ids are kept in the Templates, which are saved in the sorter_output_folder | |
| matching_model_folders = list(Path(sorter_output_folder).glob("matching*_models")) | |
| if len(matching_model_folders) > 0: | |
| matching_model_folders.sort(key=lambda p: int(p.stem[8:-7])) | |
| last_matching_model_folder = matching_model_folders[-1] | |
| if (template_data_file := last_matching_model_folder / 'template_data.npz').is_file(): | |
| from dartsort.templates.templates import TemplateData | |
| template_data = TemplateData.from_npz(template_data_file) | |
| main_channel_indices = template_data.main_channels() | |
| main_channel_ids = recording.channel_ids[main_channel_indices] | |
| sorting.set_property('main_channel_id', main_channel_ids) |
We can add main_channel_ids by taking them from the templates file (as suggested by @cwindolf). Am testing on some real data now...
There was a problem hiding this comment.
Sorry, this doesn't work. A unit can be made from spikes from several templates, so there's no one to one map from the templates to unit main_channel_ids.
There was a problem hiding this comment.
but all templates associated to a unit should roughly have the same channels no? We could take the mode of the main channels from the templates associated to the same unit
There was a problem hiding this comment.
@cwindolf could this be implemented directly in dartsort? so that the to_numpy_sorting will already have this property
There was a problem hiding this comment.
spike_channels = dartsort_sorting.channels
main_channel_indices = [mode(spike_channels[labels == unit_id])[0] for unit_id in sorting.unit_ids]
main_channel_ids = recording.channel_ids[main_channel_indices]
sorting.set_property('main_channel_id', main_channel_ids)
Dartsort keeps the channel of each spike! So we can easily take the mode of the spike channels for each unit.
Co-authored-by: Chris Halcrow <57948917+chrishalcrow@users.noreply.github.com>
Co-authored-by: Chris Halcrow <57948917+chrishalcrow@users.noreply.github.com>
Co-authored-by: Alessio Buccino <alejoe9187@gmail.com>
for more information, see https://pre-commit.ci
|
Ok fixed a couple of stuff:
|
|
Ok to merge? |
cwindolf
left a comment
There was a problem hiding this comment.
Looks good to me! Thank you guys. Just adding some website links basically here.
Co-authored-by: Charlie Windolf <charliexwindolf@gmail.com>
@cwindolf @julienboussard @colehurwitz