Skip to content

PR to restore the "no matching" functionality in circus2 #4095

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

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 13 additions & 11 deletions src/spikeinterface/sorters/internal/spyking_circus2.py
Original file line number Diff line number Diff line change
Expand Up @@ -322,7 +322,11 @@ def _run_from_folder(cls, sorter_output_folder, params, verbose):
),
}

outputs = find_cluster_from_peaks(
matching_method = params["matching"].pop("method")
if matching_method is None:
templates_from_svd = True

clustering_outputs = find_cluster_from_peaks(
recording_w,
selected_peaks,
method=clustering_method,
Expand All @@ -331,8 +335,8 @@ def _run_from_folder(cls, sorter_output_folder, params, verbose):
**job_kwargs,
)

if len(outputs) == 2:
_, peak_labels = outputs
if len(clustering_outputs) == 2:
_, peak_labels = clustering_outputs
from spikeinterface.sortingcomponents.clustering.tools import get_templates_from_peaks_and_recording

templates = get_templates_from_peaks_and_recording(
Expand All @@ -346,8 +350,7 @@ def _run_from_folder(cls, sorter_output_folder, params, verbose):
else:
from spikeinterface.sortingcomponents.clustering.tools import get_templates_from_peaks_and_svd

# _, peak_labels, svd_model, svd_features, sparsity_mask = outputs
_, peak_labels, more_outs = outputs
_, peak_labels, more_outs = clustering_outputs

templates, _ = get_templates_from_peaks_and_svd(
recording_w,
Expand All @@ -360,9 +363,6 @@ def _run_from_folder(cls, sorter_output_folder, params, verbose):
more_outs["peak_svd_sparse_mask"],
operator="median",
)
# this release the peak_svd memmap file
del more_outs
del outputs

templates = clean_templates(
templates,
Expand All @@ -379,7 +379,6 @@ def _run_from_folder(cls, sorter_output_folder, params, verbose):
templates.to_zarr(folder_path=clustering_folder / "templates")

## We launch a OMP matching pursuit by full convolution of the templates and the raw traces
matching_method = params["matching"].pop("method")
gather_mode = params["matching"].pop("gather_mode", "memory")
gather_kwargs = params["matching"].pop("gather_kwargs", {})
matching_params = params["matching"].get("method_kwargs", {}).copy()
Expand Down Expand Up @@ -421,8 +420,8 @@ def _run_from_folder(cls, sorter_output_folder, params, verbose):
recording_w,
peaks,
templates=templates,
svd_model=svd_model,
sparse_mask=sparsity_mask,
svd_model=more_outs["svd_model"],
sparse_mask=more_outs["peak_svd_sparse_mask"],
**job_kwargs,
)

Expand All @@ -435,6 +434,9 @@ def _run_from_folder(cls, sorter_output_folder, params, verbose):
sorting["segment_index"] = peaks["segment_index"]
sorting = NumpySorting(sorting, sampling_frequency, templates.unit_ids)

# this release the peak_svd memmap file
del clustering_outputs

merging_params = params["merging"].copy()
merging_params["debug_folder"] = sorter_output_folder / "merging"

Expand Down
Loading