<jupyter_start><jupyter_text>use of spike interface practice following getting started tutorial on:https://spikeinterface.readthedocs.io/en/latest/getting_started/plot_getting_started.html-ag 2/18/20<jupyter_code>import spikeinterface.extractors as se
import spikeinterface.toolkit as st
import spikeinterface.sorters as ss
import spikeinterface.comparison as sc
import spikeinterface.widgets as sw
import matplotlib
%matplotlib inline  
recording, sorting_true = se.example_datasets.toy_example(duration=10, num_channels=4, seed=0)
w_ts = sw.plot_timeseries(recording, trange = [0,5])
w_rs = sw.plot_rasters(sorting_true,trange=[0,5])
channel_ids = recording.get_channel_ids()
fs = recording.get_sampling_frequency()
num_chan = recording.get_num_channels()

print('Channel ids:', channel_ids)
print('Sampling frequency:', fs)
print('Number of channels:', num_chan)
unit_ids = sorting_true.get_unit_ids()
spike_train = sorting_true.get_unit_spike_train(unit_id=unit_ids[0])

print('Unit ids:', unit_ids)
print('Spike train of first unit:', spike_train)
recording_f = st.preprocessing.bandpass_filter(recording, freq_min=300, freq_max=5000)
recording_cmr = st.preprocessing.common_reference(recording_f, reference='median')
print('Available sorters', ss.available_sorters())
print('Installed sorters', ss.installed_sorter_list)
print(ss.get_default_params('mountainsort4'))
print()
print(ss.get_default_params('klusta'))
print()
print(ss.get_default_params('spykingcircus'))
print()
print(ss.get_default_params('herdingspikes'))
sort_ms4 = ss.run_mountainsort4(recording=recording_cmr, whiten=False, num_workers=4, detect_threshold=6)
sort_skc = ss.run_spykingcircus(recording=recording_cmr, filter=False, num_workers=4)
sort_Klusta = ss.run_klusta(recording=recording_cmr)
sort_HS = ss.run_herdingspikes(recording=recording_cmr)
sort_TC = ss.run_tridesclous(recording=recording_cmr)
print('Units found by Mountainsort4:', sort_ms4.get_unit_ids())
print('Units found by Spyking-Circus:', sort_skc.get_unit_ids())
print('Units found by Klusta:', sort_Klusta.get_unit_ids())
snrs = st.validation.compute_snrs(sort_ms4, recording_cmr)
isi_violations = st.validation.compute_isi_violations(sort_ms4)
isolations = st.validation.compute_isolation_distances(sort_ms4, recording)

print('SNR', snrs)
print('ISI violation ratios', isi_violations)
print('Isolation distances', isolations)
comp_gt_KL = sc.compare_sorter_to_ground_truth(gt_sorting=sorting_true, tested_sorting=sort_Klusta)
comp_KL_MS4 = sc.compare_two_sorters(sorting1=sort_Klusta, sorting2=sort_ms4)
comp_multi = sc.compare_multiple_sorters(sorting_list=[sort_ms4, sort_Klusta, sort_skc],
                                         name_list=['klusta', 'ms4','circus'])

comp_gt_KL.get_performance()
mapped_units = comp_KL_MS4.get_mapped_sorting1().get_mapped_unit_ids()

print('Klusta units:', sort_Klusta.get_unit_ids())
print('Mapped Mountainsort4 units:', mapped_units)
sorting_agreement = comp_multi.get_agreement_sorting(minimum_matching=2)

print('Units in agreement between Klusta and Mountainsort4:', sorting_agreement.get_unit_ids())

w_multi = sw.plot_multicomp_graph(comp_multi)<jupyter_output>Units in agreement between Klusta and Mountainsort4: [2, 3, 6, 7, 12]
{'fraction_non_alphanumeric': 0.1102508516568597, 'fraction_numerical': 0.01548467017652524, 'mean_word_length': 9.031055900621118, 'pattern_counts': {'":': 0, '<': 4, '<?xml version=': 0, '>': 4, 'https://': 1, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '1', 'dir': 'jupyter-structured-clean-dedup', 'id': '595893', 'license': 'MIT', 'n_tokens_mistral': 1184, 'n_tokens_neox': 1125, 'n_words': 186, 'path': 'Analyses/spike_interface_play.ipynb', 'repo_name': 'alexgonzl/TreeMazeAnalyses', 'size': '3229'}