-
Notifications
You must be signed in to change notification settings - Fork 240
Tools for Generation of Hybrid recordings #2436
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
147 commits
Select commit
Hold shift + click to select a range
26ac06f
WIP
yger 3f2bcfa
Merge branch 'SpikeInterface:main' into hybrid_raw_clustering
yger 4216503
WIP
yger 6275aa5
Merge branch 'hybrid_raw_clustering' of github.com:yger/spikeinterfac…
yger af485ea
Docstrings and cosmetics
yger ddb1d51
WIP
yger 08ffeef
WIP
yger 0db1597
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] a7b6de2
Merge branch 'estimate_sparsity' of github.com:samuelgarcia/spikeinte…
yger b89f6a3
WIP
yger 80e6b8d
WIP
yger 84b60ac
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] f5f3435
WIP
yger 1c8bb72
Polish
yger a5b12b0
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] 1c7cf33
Merge branch 'SpikeInterface:main' into hybrid_raw_clustering
yger fe6247c
Merge branch 'main' into hybrid_raw_clustering
yger ae285a4
WIP
yger 495b863
Merge branch 'SpikeInterface:main' into hybrid_raw_clustering
yger 05621bb
Merge branch 'SpikeInterface:main' into hybrid_raw_clustering
yger 7a96d85
WIP
yger 5f0235f
Merge branch 'main' of github.com:yger/spikeinterface into hybrid_raw…
yger e6595ee
Merge branch 'SpikeInterface:main' into hybrid_raw_clustering
yger e0251b0
Merge branch 'hybrid_raw_clustering' of github.com:yger/spikeinterfac…
yger 69f0674
Merge branch 'SpikeInterface:main' into hybrid_raw_clustering
yger e0037b3
WIP
yger 2b8656f
WIP
yger b2365d4
WIP
yger 6858a2f
Merge branch 'SpikeInterface:main' into hybrid_raw_clustering
yger 1d5b641
WIP
yger a139762
WIP
yger 6a1673d
WIP
yger 7742882
WIP
yger 36ec32d
WIP
yger 3c59afb
Merge branch 'main' into hybrid_raw_clustering
yger f6c4c4a
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] b2e87a0
Docs
yger 5046e53
Merge branch 'hybrid_raw_clustering' of github.com:yger/spikeinterfac…
yger 275f87a
Adding tests
yger 4e97eeb
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] 45653f6
One more test
yger e05f1d0
WIP
yger d1ee525
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] c12c746
Adding imports
yger c62f952
Merge branch 'main' into hybrid_raw_clustering
yger 03a41d2
Merge branch 'hybrid_raw_clustering' of github.com:yger/spikeinterfac…
yger a850950
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] 4bcbe5c
Moving functions in localization_tools
yger d974fe8
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] 3eedeb4
Imports
yger 37eb54d
Merge branch 'hybrid_raw_clustering' of github.com:yger/spikeinterfac…
yger 5f95fa0
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] 23be272
Hybrid recordings also with given templates
yger c40c9bd
Merge branch 'hybrid_raw_clustering' of github.com:yger/spikeinterfac…
yger 8d23525
Merge branch 'main' of github.com:spikeinterface/spikeinterface into …
yger 03fd84f
Extension of relocalization to real templates
yger c9b9215
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] 0d2d7f9
Unit_locations could be given
yger f1b37f4
Merge branch 'main' of github.com:spikeinterface/spikeinterface into …
yger 761cef5
Update src/spikeinterface/generation/tests/test_hybrid_tools.py
yger 04c66c6
Update src/spikeinterface/generation/tests/test_hybrid_tools.py
yger b39bea9
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] 394ecec
Update src/spikeinterface/generation/hybrid_tools.py
yger 396a0ca
Update src/spikeinterface/generation/tests/test_hybrid_tools.py
yger bf9cf53
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] d8e67de
Merge branch 'main' of https://github.com/SpikeInterface/spikeinterfa…
yger a33049a
WIP
yger 4c81d1e
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] ebee96a
Merge branch 'SpikeInterface:main' into hybrid_raw_clustering
yger 8127894
Merge branch 'main' into hybrid_raw_clustering
yger 057ad10
Merge branch 'main' into hybrid_raw_clustering
yger eaba48f
WIP
yger 01ec8ab
Imports
yger 15a9491
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] b081091
Imports
yger 88103d8
Merge branch 'main' into hybrid_raw_clustering
yger 095aa06
WIP
yger 82b5dde
WIP
yger 6ba6d96
WIP
yger 7bc2c6f
Merge branch 'main' of github.com:spikeinterface/spikeinterface into …
yger ef46881
Merge branch 'hybrid_raw_clustering' of github.com:yger/spikeinterfac…
yger 7cfc227
Merge branch 'SpikeInterface:main' into hybrid_raw_clustering
yger 33a426a
Merge branch 'main' of github.com:SpikeInterface/spikeinterface into …
alejoe91 40fd9ff
Add amplitude scaling std
alejoe91 c584a81
Merge branch 'main' of github.com:SpikeInterface/spikeinterface into …
alejoe91 76ab76d
Bunch of fixes and enable the use of external Templates objects
alejoe91 1043577
Fix scaling for drifting templates
alejoe91 836c2d4
fix tests
alejoe91 007acf7
Extend template database functionality
alejoe91 74bb13c
Final touches
alejoe91 a0179a1
pandas local import
alejoe91 e0b1ee6
Fix typing and SC2 matching
alejoe91 1213137
Merge branch 'main' of github.com:SpikeInterface/spikeinterface into …
alejoe91 38a887e
Fix tests
alejoe91 6224d2c
Add hybrid tools and extend plot_unit_templates to Templates
alejoe91 1795c9f
Merge branch 'main' into hybrid_raw_clustering
alejoe91 5dccdab
Remove unused import
alejoe91 289f337
Update src/spikeinterface/widgets/unit_waveforms.py
alejoe91 e25bac3
Fix get_unit_colors tests and rename filter_templates to select_templ…
alejoe91 ae32e26
Merge branch 'hybrid_raw_clustering' of github.com:yger/spikeinterfac…
alejoe91 b3816bd
Fix test zarr path in tests
alejoe91 f034b39
Fix scaling and add temlate manipulation tests
alejoe91 e6d5cb3
Add widen/narrow button and scale bar to plot_unitwaveforms/templates
alejoe91 2835350
cleanup ipywidgets utils
alejoe91 ff8b29a
Ramon's suggestions
alejoe91 91ebec8
Merge branch 'main' of github.com:SpikeInterface/spikeinterface into …
alejoe91 57af6ac
Revert changes to geT_unit_colors
alejoe91 8317ba4
fix tests
alejoe91 290701f
Merge branch 'main' into hybrid_raw_clustering
yger 4bc4f6a
Merge branch 'main' into hybrid_raw_clustering
yger 3e29d8d
Merge branch 'main' into hybrid_raw_clustering
yger bb1b489
Fixing tests
yger ec58a8e
Merge branch 'main' into hybrid_raw_clustering
yger f5e81a0
Fixing tests
yger 8fe4efb
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] 81d42b8
Fix conflicts
alejoe91 3047e30
Fixing colons
yger ffd93c7
Merge branch 'main' into hybrid_raw_clustering
h-mayorquin 070cb87
Fix conflicts
alejoe91 03fe4d9
from_static -> from_static_templates
alejoe91 d023420
Remove duplicate select_units/channels in Templates
alejoe91 93eb5e3
Changes form code review
alejoe91 c2df514
Fix imports and extend docstring
alejoe91 534202e
Move compute_* localization functions to localization_tools
alejoe91 c86cad4
Update save_motion_info and add tests
alejoe91 1ecda4a
Use save_motion_info in correct_motion
alejoe91 6f7d082
Merge branch 'main' of github.com:SpikeInterface/spikeinterface into …
alejoe91 28321d9
User-specified precomputed templates in DriftingTemplates
cwindolf 643ea6a
dataclasses are weird!
cwindolf 866da1e
Incorporate DriftingTemplates.from_precomputed_templates constructor …
alejoe91 5c3e73b
Start hibrid benchmark docs and add Neuropixel-384 toy probe
alejoe91 c45f283
wip example
alejoe91 bc83485
continue how to an lint
alejoe91 2dd5f8b
Merge branch 'main' of github.com:SpikeInterface/spikeinterface into …
alejoe91 3971512
Make Motion JSON serializable and add hybrit How to
alejoe91 f61a3c2
Merge branch 'main' into hybrid_raw_clustering
alejoe91 3e319dc
Merge branch 'main' into hybrid_raw_clustering
alejoe91 e6da491
Remove custom pickle
alejoe91 7f8f194
Remove duplicated line
alejoe91 d9c36a1
Use official prot_drift_map
alejoe91 8ffdd98
Add s3fs to test dependencies
alejoe91 406ebcf
Merge branch 'main' of github.com:SpikeInterface/spikeinterface into …
alejoe91 5186f74
Sam+Charlie's suggestions: estimate one motion vector per unit (plus …
alejoe91 8b16006
Update how to and fix displacement_vectors
alejoe91 b2d3d3b
Update jupytext readme
alejoe91 efd5ecf
Update how to benchmark with real data
alejoe91 0015f5f
Remove old displacement_unit_factor
alejoe91 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
Binary file added
BIN
+179 KB
...enchmark_with_hybrid_recordings_files/benchmark_with_hybrid_recordings_20_0.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+384 KB
...enchmark_with_hybrid_recordings_files/benchmark_with_hybrid_recordings_28_1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+79.7 KB
...enchmark_with_hybrid_recordings_files/benchmark_with_hybrid_recordings_37_1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+208 KB
...benchmark_with_hybrid_recordings_files/benchmark_with_hybrid_recordings_9_0.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,293 @@ | ||
| # --- | ||
| # jupyter: | ||
| # jupytext: | ||
| # cell_metadata_filter: -all | ||
| # formats: ipynb,py | ||
| # text_representation: | ||
| # extension: .py | ||
| # format_name: light | ||
| # format_version: '1.5' | ||
| # jupytext_version: 1.16.2 | ||
| # kernelspec: | ||
| # display_name: Python 3 (ipykernel) | ||
| # language: python | ||
| # name: python3 | ||
| # --- | ||
|
|
||
| # # Benchmark spike sorting with hybrid recordings | ||
| # | ||
| # This example shows how to use the SpikeInterface hybrid recordings framework to benchmark spike sorting results. | ||
| # | ||
| # Hybrid recordings are built from existing recordings by injecting units with known spiking activity. | ||
| # The template (aka average waveforms) of the injected units can be from previous spike sorted data. | ||
| # In this example, we will be using an open database of templates that we have constructed from the International Brain Laboratory - Brain Wide Map (available on [DANDI](https://dandiarchive.org/dandiset/000409?search=IBL&page=2&sortOption=0&sortDir=-1&showDrafts=true&showEmpty=false&pos=9)). | ||
| # | ||
| # Importantly, recordings from long-shank probes, such as Neuropixels, usually experience drifts. Such drifts have to be taken into account in order to smoothly inject spikes into the recording. | ||
|
|
||
| # + | ||
| import spikeinterface as si | ||
| import spikeinterface.extractors as se | ||
| import spikeinterface.preprocessing as spre | ||
| import spikeinterface.comparison as sc | ||
| import spikeinterface.generation as sgen | ||
| import spikeinterface.widgets as sw | ||
|
|
||
| from spikeinterface.sortingcomponents.motion_estimation import estimate_motion | ||
|
|
||
| import numpy as np | ||
| import matplotlib.pyplot as plt | ||
| from pathlib import Path | ||
| # - | ||
|
|
||
| # %matplotlib inline | ||
|
|
||
| si.set_global_job_kwargs(n_jobs=16) | ||
|
|
||
| # For this notebook, we will use a drifting recording similar to the one acquired by Nick Steinmetz and available [here](https://doi.org/10.6084/m9.figshare.14024495.v1), where an triangular motion was imposed to the recording by moving the probe up and down with a micro-manipulator. | ||
|
|
||
| workdir = Path("/ssd980/working/hybrid/steinmetz_imposed_motion") | ||
| workdir.mkdir(exist_ok=True) | ||
|
|
||
| recording_np1_imposed = se.read_spikeglx("/hdd1/data/spikeglx/nick-steinmetz/dataset1/p1_g0_t0/") | ||
| recording_preproc = spre.highpass_filter(recording_np1_imposed) | ||
| recording_preproc = spre.common_reference(recording_preproc) | ||
|
|
||
| # To visualize the drift, we can estimate the motion and plot it: | ||
|
|
||
| # to correct for drift, we need a float dtype | ||
| recording_preproc = spre.astype(recording_preproc, "float") | ||
| _, motion_info = spre.correct_motion( | ||
| recording_preproc, preset="nonrigid_fast_and_accurate", n_jobs=4, progress_bar=True, output_motion_info=True | ||
| ) | ||
|
|
||
| ax = sw.plot_drift_raster_map( | ||
| peaks=motion_info["peaks"], | ||
| peak_locations=motion_info["peak_locations"], | ||
| recording=recording_preproc, | ||
| cmap="Greys_r", | ||
| scatter_decimate=10, | ||
| depth_lim=(-10, 3000) | ||
| ) | ||
|
|
||
| # ## Retrieve templates from database | ||
|
|
||
| # + | ||
| templates_info = sgen.fetch_templates_database_info() | ||
|
|
||
| print(f"Number of templates in database: {len(templates_info)}") | ||
| print(f"Template database columns: {templates_info.columns}") | ||
| # - | ||
|
|
||
| available_brain_areas = np.unique(templates_info.brain_area) | ||
| print(f"Available brain areas: {available_brain_areas}") | ||
|
|
||
| # Let's perform a query: templates from visual brain regions and at the "top" of the probe | ||
|
|
||
| target_area = ["VISa5", "VISa6a", "VISp5", "VISp6a", "VISrl6b"] | ||
| minimum_depth = 1500 | ||
| templates_selected_info = templates_info.query(f"brain_area in {target_area} and depth_along_probe > {minimum_depth}") | ||
| len(templates_selected_info) | ||
|
|
||
| # We can now retrieve the selected templates as a `Templates` object: | ||
|
|
||
| templates_selected = sgen.query_templates_from_database(templates_selected_info, verbose=True) | ||
| print(templates_selected) | ||
|
|
||
| # While we selected templates from a target aread and at certain depths, we can see that the template amplitudes are quite large. This will make spike sorting easy... we can further manipulate the `Templates` by rescaling, relocating, or further selections with the `sgen.scale_template_to_range`, `sgen.relocate_templates`, and `sgen.select_templates` functions. | ||
| # | ||
| # In our case, let's rescale the amplitudes between 50 and 150 $\mu$V and relocate them towards the bottom half of the probe, where the activity looks interesting! | ||
|
|
||
| # + | ||
| min_amplitude = 50 | ||
| max_amplitude = 150 | ||
| templates_scaled = sgen.scale_template_to_range( | ||
| templates=templates_selected, | ||
| min_amplitude=min_amplitude, | ||
| max_amplitude=max_amplitude | ||
| ) | ||
|
|
||
| min_displacement = 1000 | ||
| max_displacement = 3000 | ||
| templates_relocated = sgen.relocate_templates( | ||
| templates=templates_scaled, | ||
| min_displacement=min_displacement, | ||
| max_displacement=max_displacement | ||
| ) | ||
| # - | ||
|
|
||
| # Let's plot the selected templates: | ||
|
|
||
| sparsity_plot = si.compute_sparsity(templates_relocated) | ||
| fig = plt.figure(figsize=(10, 10)) | ||
| w = sw.plot_unit_templates(templates_relocated, sparsity=sparsity_plot, ncols=4, figure=fig) | ||
| w.figure.subplots_adjust(wspace=0.5, hspace=0.7) | ||
|
|
||
| # ## Constructing hybrid recordings | ||
| # | ||
| # We can construct now hybrid recordings with the selected templates. | ||
| # | ||
| # We will do this in two ways to show how important it is to account for drifts when injecting hybrid spikes. | ||
| # | ||
| # - For the first recording we will not pass the estimated motion (`recording_hybrid_ignore_drift`). | ||
| # - For the second recording, we will pass and account for the estimated motion (`recording_hybrid_with_drift`). | ||
|
|
||
| recording_hybrid_ignore_drift, sorting_hybrid = sgen.generate_hybrid_recording( | ||
| recording=recording_preproc, templates=templates_relocated, seed=2308 | ||
| ) | ||
| recording_hybrid_ignore_drift | ||
|
|
||
| # Note that the `generate_hybrid_recording` is warning us that we might want to account for drift! | ||
|
|
||
| # by passing the `sorting_hybrid` object, we make sure that injected spikes are the same | ||
| # this will take a bit more time because it's interpolating the templates to account for drifts | ||
| recording_hybrid_with_drift, sorting_hybrid = sgen.generate_hybrid_recording( | ||
| recording=recording_preproc, | ||
| templates=templates_relocated, | ||
| motion=motion_info["motion"], | ||
| sorting=sorting_hybrid, | ||
| seed=2308, | ||
| ) | ||
| recording_hybrid_with_drift | ||
|
|
||
| # We can use the `SortingAnalyzer` to estimate spike locations and plot them: | ||
|
|
||
| # + | ||
| # construct analyzers and compute spike locations | ||
| analyzer_hybrid_ignore_drift = si.create_sorting_analyzer(sorting_hybrid, recording_hybrid_ignore_drift) | ||
| analyzer_hybrid_ignore_drift.compute(["random_spikes", "templates"]) | ||
| analyzer_hybrid_ignore_drift.compute("spike_locations", method="grid_convolution") | ||
|
|
||
| analyzer_hybrid_with_drift = si.create_sorting_analyzer(sorting_hybrid, recording_hybrid_with_drift) | ||
| analyzer_hybrid_with_drift.compute(["random_spikes", "templates"]) | ||
| analyzer_hybrid_with_drift.compute("spike_locations", method="grid_convolution") | ||
| # - | ||
|
|
||
| # Let's plot the added hybrid spikes using the drift maps: | ||
|
|
||
| fig, axs = plt.subplots(ncols=2, figsize=(10, 7), sharex=True, sharey=True) | ||
| _ = sw.plot_drift_raster_map( | ||
| peaks=motion_info["peaks"], | ||
| peak_locations=motion_info["peak_locations"], | ||
| recording=recording_preproc, | ||
| cmap="Greys_r", | ||
| scatter_decimate=10, | ||
| ax=axs[0], | ||
| ) | ||
| _ = sw.plot_drift_raster_map( | ||
| sorting_analyzer=analyzer_hybrid_ignore_drift, | ||
| color_amplitude=False, | ||
| color="r", | ||
| scatter_decimate=10, | ||
| ax=axs[0] | ||
| ) | ||
| _ = sw.plot_drift_raster_map( | ||
| peaks=motion_info["peaks"], | ||
| peak_locations=motion_info["peak_locations"], | ||
| recording=recording_preproc, | ||
| cmap="Greys_r", | ||
| scatter_decimate=10, | ||
| ax=axs[1], | ||
| ) | ||
| _ = sw.plot_drift_raster_map( | ||
| sorting_analyzer=analyzer_hybrid_with_drift, | ||
| color_amplitude=False, | ||
| color="b", | ||
| scatter_decimate=10, | ||
| ax=axs[1] | ||
| ) | ||
| axs[0].set_title("Hybrid spikes\nIgnoring drift") | ||
| axs[1].set_title("Hybrid spikes\nAccounting for drift") | ||
| axs[0].set_xlim(1000, 1500) | ||
| axs[0].set_ylim(500, 2500) | ||
|
|
||
| # We can see that clearly following drift is essential in order to properly blend the hybrid spikes into the recording! | ||
|
|
||
| # ## Ground-truth study | ||
| # | ||
| # In this section we will use the hybrid recording to benchmark a few spike sorters: | ||
| # | ||
| # - `Kilosort2.5` | ||
| # - `Kilosort3` | ||
| # - `Kilosort4` | ||
| # - `Spyking-CIRCUS 2` | ||
|
|
||
| # to speed up computations, let's first dump the recording to binary | ||
| recording_hybrid_bin = recording_hybrid_with_drift.save( | ||
| folder=workdir / "hybrid_bin", | ||
| overwrite=True | ||
| ) | ||
|
|
||
| # + | ||
| datasets = { | ||
| "hybrid": (recording_hybrid_bin, sorting_hybrid), | ||
| } | ||
|
|
||
| cases = { | ||
| ("kilosort2.5", "hybrid"): { | ||
| "label": "KS2.5", | ||
| "dataset": "hybrid", | ||
| "run_sorter_params": { | ||
| "sorter_name": "kilosort2_5", | ||
| }, | ||
| }, | ||
| ("kilosort3", "hybrid"): { | ||
| "label": "KS3", | ||
| "dataset": "hybrid", | ||
| "run_sorter_params": { | ||
| "sorter_name": "kilosort3", | ||
| }, | ||
| }, | ||
| ("kilosort4", "hybrid"): { | ||
| "label": "KS4", | ||
| "dataset": "hybrid", | ||
| "run_sorter_params": {"sorter_name": "kilosort4", "nblocks": 5}, | ||
| }, | ||
| ("sc2", "hybrid"): { | ||
| "label": "spykingcircus2", | ||
| "dataset": "hybrid", | ||
| "run_sorter_params": { | ||
| "sorter_name": "spykingcircus2", | ||
| }, | ||
| }, | ||
| } | ||
|
|
||
| # + | ||
| study_folder = workdir / "gt_study" | ||
|
|
||
| gtstudy = sc.GroundTruthStudy(study_folder) | ||
|
|
||
| # - | ||
|
|
||
| # run the spike sorting jobs | ||
| gtstudy.run_sorters(verbose=False, keep=True) | ||
|
|
||
| # run the comparisons | ||
| gtstudy.run_comparisons(exhaustive_gt=False) | ||
|
|
||
| # ## Plot performances | ||
| # | ||
| # Given that we know the exactly where we injected the hybrid spikes, we can now compute and plot performance metrics: accuracy, precision, and recall. | ||
| # | ||
| # In the following plot, the x axis is the unit index, while the y axis is the performance metric. The units are sorted by performance. | ||
|
|
||
| w_perf = sw.plot_study_performances(gtstudy, figsize=(12, 7)) | ||
| w_perf.axes[0, 0].legend(loc=4) | ||
|
|
||
| # From the performance plots, we can see that there is no clear "winner", but `Kilosort3` definitely performs worse than the other options. | ||
| # | ||
| # Although non of the sorters find all units perfectly, `Kilosort2.5`, `Kilosort4`, and `SpyKING CIRCUS 2` all find around 10-12 hybrid units with accuracy greater than 80%. | ||
| # `Kilosort4` has a better overall curve, being able to find almost all units with an accuracy above 50%. `Kilosort2.5` performs well when looking at precision (finding all spikes in a hybrid unit), at the cost of lower recall (finding spikes when it shouldn't). | ||
| # | ||
| # | ||
| # In this example, we showed how to: | ||
| # | ||
| # - Access and fetch templates from the SpikeInterface template database | ||
| # - Manipulate templates (scaling/relocating) | ||
| # - Construct hybrid recordings accounting for drifts | ||
| # - Use the `GroundTruthStudy` to benchmark different sorters | ||
| # | ||
| # The hybrid framework can be extended to target multiple recordings from different brain regions and species and creating recordings of increasing complexity to challenge the existing sorters! | ||
| # | ||
| # In addition, hybrid studies can also be used to fine-tune spike sorting parameters on specific datasets. | ||
| # | ||
| # **Are you ready to try it on your data?** |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.