From ad8a062c6769b060fa46d68e892bc728b8290189 Mon Sep 17 00:00:00 2001 From: Julien Verplanken Date: Fri, 7 Jun 2024 10:41:13 +0200 Subject: [PATCH 1/3] add whiteningRange as kilosort2_5 parameter --- src/spikeinterface/sorters/external/kilosort2_5.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/spikeinterface/sorters/external/kilosort2_5.py b/src/spikeinterface/sorters/external/kilosort2_5.py index abde2ab324..beccba3481 100644 --- a/src/spikeinterface/sorters/external/kilosort2_5.py +++ b/src/spikeinterface/sorters/external/kilosort2_5.py @@ -53,6 +53,7 @@ class Kilosort2_5Sorter(KilosortBase, BaseSorter): "nPCs": 3, "ntbuff": 64, "nfilt_factor": 4, + "whiteningRange": 32.0, "NT": None, "AUCsplit": 0.9, "do_correction": True, @@ -82,6 +83,7 @@ class Kilosort2_5Sorter(KilosortBase, BaseSorter): "ntbuff": "Samples of symmetrical buffer for whitening and spike detection", "nfilt_factor": "Max number of clusters per good channel (even temporary ones) 4", "do_correction": "If True drift registration is applied", + "whiteningRange": "Number of channels to use for whitening each channel", "NT": "Batch size (if None it is automatically computed)", "AUCsplit": "Threshold on the area under the curve (AUC) criterion for performing a split in the final step", "keep_good_only": "If True only 'good' units are returned", @@ -220,7 +222,7 @@ def _get_specific_options(cls, ops, params): ops["NT"] = params[ "NT" ] # must be multiple of 32 + ntbuff. This is the batch size (try decreasing if out of memory). - ops["whiteningRange"] = 32.0 # number of channels to use for whitening each channel + ops["whiteningRange"] = params["whiteningRange"] # number of channels to use for whitening each channel ops["nSkipCov"] = 25.0 # compute whitening matrix from every N-th batch ops["nPCs"] = params["nPCs"] # how many PCs to project the spikes into ops["useRAM"] = 0.0 # not yet available From a54612bfc0d4f8e704800854a3a119a05129be1c Mon Sep 17 00:00:00 2001 From: Julien Verplanken Date: Fri, 7 Jun 2024 10:54:09 +0200 Subject: [PATCH 2/3] reorder to match positions in param dictionaries --- src/spikeinterface/sorters/external/kilosort2_5.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/spikeinterface/sorters/external/kilosort2_5.py b/src/spikeinterface/sorters/external/kilosort2_5.py index beccba3481..b3d1718d59 100644 --- a/src/spikeinterface/sorters/external/kilosort2_5.py +++ b/src/spikeinterface/sorters/external/kilosort2_5.py @@ -41,6 +41,7 @@ class Kilosort2_5Sorter(KilosortBase, BaseSorter): "detect_threshold": 6, "projection_threshold": [10, 4], "preclust_threshold": 8, + "whiteningRange": 32.0, "momentum": [20.0, 400.0], "car": True, "minFR": 0.1, @@ -53,7 +54,6 @@ class Kilosort2_5Sorter(KilosortBase, BaseSorter): "nPCs": 3, "ntbuff": 64, "nfilt_factor": 4, - "whiteningRange": 32.0, "NT": None, "AUCsplit": 0.9, "do_correction": True, @@ -70,6 +70,7 @@ class Kilosort2_5Sorter(KilosortBase, BaseSorter): "detect_threshold": "Threshold for spike detection", "projection_threshold": "Threshold on projections", "preclust_threshold": "Threshold crossings for pre-clustering (in PCA projection space)", + "whiteningRange": "Number of channels to use for whitening each channel", "momentum": "Number of samples to average over (annealed from first to second value)", "car": "Enable or disable common reference", "minFR": "Minimum spike rate (Hz), if a cluster falls below this for too long it gets removed", @@ -83,7 +84,6 @@ class Kilosort2_5Sorter(KilosortBase, BaseSorter): "ntbuff": "Samples of symmetrical buffer for whitening and spike detection", "nfilt_factor": "Max number of clusters per good channel (even temporary ones) 4", "do_correction": "If True drift registration is applied", - "whiteningRange": "Number of channels to use for whitening each channel", "NT": "Batch size (if None it is automatically computed)", "AUCsplit": "Threshold on the area under the curve (AUC) criterion for performing a split in the final step", "keep_good_only": "If True only 'good' units are returned", From b2b9001b343a285c07640693ea41fc6facdebbfd Mon Sep 17 00:00:00 2001 From: Julien Verplanken Date: Fri, 7 Jun 2024 15:35:37 +0200 Subject: [PATCH 3/3] added whiteningRange parameter to KS2 and KS3 --- src/spikeinterface/sorters/external/kilosort2.py | 4 +++- src/spikeinterface/sorters/external/kilosort3.py | 4 +++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/src/spikeinterface/sorters/external/kilosort2.py b/src/spikeinterface/sorters/external/kilosort2.py index bdc0372789..0425ad5e53 100644 --- a/src/spikeinterface/sorters/external/kilosort2.py +++ b/src/spikeinterface/sorters/external/kilosort2.py @@ -37,6 +37,7 @@ class Kilosort2Sorter(KilosortBase, BaseSorter): "detect_threshold": 6, "projection_threshold": [10, 4], "preclust_threshold": 8, + "whiteningRange": 32, # samples of the template to use for whitening "spatial" dimension "momentum": [20.0, 400.0], "car": True, "minFR": 0.1, @@ -62,6 +63,7 @@ class Kilosort2Sorter(KilosortBase, BaseSorter): "detect_threshold": "Threshold for spike detection", "projection_threshold": "Threshold on projections", "preclust_threshold": "Threshold crossings for pre-clustering (in PCA projection space)", + "whiteningRange": "Number of channels to use for whitening each channel", "momentum": "Number of samples to average over (annealed from first to second value)", "car": "Enable or disable common reference", "minFR": "Minimum spike rate (Hz), if a cluster falls below this for too long it gets removed", @@ -199,7 +201,7 @@ def _get_specific_options(cls, ops, params): ops["NT"] = params[ "NT" ] # must be multiple of 32 + ntbuff. This is the batch size (try decreasing if out of memory). - ops["whiteningRange"] = 32.0 # number of channels to use for whitening each channel + ops["whiteningRange"] = params["whiteningRange"] # number of channels to use for whitening each channel ops["nSkipCov"] = 25.0 # compute whitening matrix from every N-th batch ops["nPCs"] = params["nPCs"] # how many PCs to project the spikes into ops["useRAM"] = 0.0 # not yet available diff --git a/src/spikeinterface/sorters/external/kilosort3.py b/src/spikeinterface/sorters/external/kilosort3.py index 3d2103ea66..f560fd7e1e 100644 --- a/src/spikeinterface/sorters/external/kilosort3.py +++ b/src/spikeinterface/sorters/external/kilosort3.py @@ -38,6 +38,7 @@ class Kilosort3Sorter(KilosortBase, BaseSorter): "detect_threshold": 6, "projection_threshold": [9, 9], "preclust_threshold": 8, + "whiteningRange": 32, "car": True, "minFR": 0.2, "minfr_goodchannels": 0.2, @@ -65,6 +66,7 @@ class Kilosort3Sorter(KilosortBase, BaseSorter): "detect_threshold": "Threshold for spike detection", "projection_threshold": "Threshold on projections", "preclust_threshold": "Threshold crossings for pre-clustering (in PCA projection space)", + "whiteningRange": "number of channels to use for whitening each channel", "car": "Enable or disable common reference", "minFR": "Minimum spike rate (Hz), if a cluster falls below this for too long it gets removed", "minfr_goodchannels": "Minimum firing rate on a 'good' channel", @@ -212,7 +214,7 @@ def _get_specific_options(cls, ops, params): ops["NT"] = params[ "NT" ] # must be multiple of 32 + ntbuff. This is the batch size (try decreasing if out of memory). - ops["whiteningRange"] = 32.0 # number of channels to use for whitening each channel + ops["whiteningRange"] = params["whiteningRange"] # number of channels to use for whitening each channel ops["nSkipCov"] = 25.0 # compute whitening matrix from every N-th batch ops["scaleproc"] = 200.0 # int16 scaling of whitened data ops["nPCs"] = params["nPCs"] # how many PCs to project the spikes into