Skip to content

Commit

Permalink
Merge pull request #2236 from yger/debug_sc2
Browse files Browse the repository at this point in the history
Adding a debug mode to SC2
  • Loading branch information
samuelgarcia authored Nov 23, 2023
2 parents 4b10e37 + 20b89e8 commit 91cfa2a
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
13 changes: 12 additions & 1 deletion src/spikeinterface/sorters/internal/spyking_circus2.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ class Spykingcircus2Sorter(ComponentsBasedSorter):
"apply_preprocessing": True,
"shared_memory": True,
"job_kwargs": {"n_jobs": -1},
"debug": False,
}

handle_multi_segment = True
Expand Down Expand Up @@ -137,8 +138,13 @@ def _run_from_folder(cls, sorter_output_folder, params, verbose):
selected_peaks["sample_index"][mask], peak_labels[mask].astype(int), sampling_rate
)
clustering_folder = sorter_output_folder / "clustering"
if clustering_folder.exists():
clustering_folder.mkdir(parents=True, exist_ok=True)

if not params["debug"]:
shutil.rmtree(clustering_folder)
else:
np.save(clustering_folder / "labels", labels)
np.save(clustering_folder / "peaks", selected_peaks)

## We get the templates our of such a clustering
waveforms_params = params["waveforms"].copy()
Expand Down Expand Up @@ -180,6 +186,11 @@ def _run_from_folder(cls, sorter_output_folder, params, verbose):
recording_f, method="circus-omp-svd", method_kwargs=matching_params, **matching_job_params
)

if params["debug"]:
fitting_folder = sorter_output_folder / "fitting"
fitting_folder.mkdir(parents=True, exist_ok=True)
np.save(fitting_folder / "spikes", spikes)

if verbose:
print("We found %d spikes" % len(spikes))

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ class RandomProjectionClustering:
"smoothing_kwargs": {"window_length_ms": 0.25},
"shared_memory": True,
"tmp_folder": None,
"debug": False,
"job_kwargs": {"n_jobs": os.cpu_count(), "chunk_memory": "100M", "verbose": True, "progress_bar": True},
}

Expand Down

0 comments on commit 91cfa2a

Please sign in to comment.