Skip to content
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

Change some default parameters for better user experience #2071

Merged
merged 17 commits into from
Oct 6, 2023
Merged
Show file tree
Hide file tree
Changes from 9 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
6 changes: 5 additions & 1 deletion src/spikeinterface/core/sparsity.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,11 @@ def __init__(self, mask, unit_ids, channel_ids):

self.num_channels = self.channel_ids.size
self.num_units = self.unit_ids.size
self.max_num_active_channels = self.mask.sum(axis=1).max()
if self.mask.shape[0]:
self.max_num_active_channels = self.mask.sum(axis=1).max()
else:
# empty sorting without units
self.max_num_active_channels = 0

def __repr__(self):
density = np.mean(self.mask)
Expand Down
3 changes: 2 additions & 1 deletion src/spikeinterface/core/tests/test_waveform_extractor.py
Original file line number Diff line number Diff line change
Expand Up @@ -556,4 +556,5 @@ def test_non_json_object():
# test_portability()
# test_recordingless()
# test_compute_sparsity()
test_non_json_object()
# test_non_json_object()
test_empty_sorting()
9 changes: 5 additions & 4 deletions src/spikeinterface/core/waveform_extractor.py
Original file line number Diff line number Diff line change
Expand Up @@ -1457,13 +1457,13 @@ def extract_waveforms(
folder=None,
mode="folder",
precompute_template=("average",),
ms_before=3.0,
ms_after=4.0,
ms_before=1.0,
ms_after=2.0,
max_spikes_per_unit=500,
overwrite=False,
return_scaled=True,
dtype=None,
sparse=False,
sparse=True,
sparsity=None,
num_spikes_for_sparsity=100,
allow_unfiltered=False,
Expand Down Expand Up @@ -1507,7 +1507,7 @@ def extract_waveforms(
If True and recording has gain_to_uV/offset_to_uV properties, waveforms are converted to uV.
dtype: dtype or None
Dtype of the output waveforms. If None, the recording dtype is maintained.
sparse: bool (default False)
sparse: bool, default: True
If True, before extracting all waveforms the `precompute_sparsity()` function is run using
a few spikes to get an estimate of dense templates to create a ChannelSparsity object.
Then, the waveforms will be sparse at extraction time, which saves a lot of memory.
Expand Down Expand Up @@ -1726,6 +1726,7 @@ def precompute_sparsity(
max_spikes_per_unit=num_spikes_for_sparsity,
return_scaled=False,
allow_unfiltered=allow_unfiltered,
sparse=False,
**job_kwargs,
)
local_sparsity = compute_sparsity(local_we, **sparse_kwargs)
Expand Down
4 changes: 2 additions & 2 deletions src/spikeinterface/postprocessing/correlograms.py
Original file line number Diff line number Diff line change
Expand Up @@ -137,8 +137,8 @@ def compute_crosscorrelogram_from_spiketrain(spike_times1, spike_times2, window_
def compute_correlograms(
waveform_or_sorting_extractor,
load_if_exists=False,
window_ms: float = 100.0,
bin_ms: float = 5.0,
window_ms: float = 50.0,
bin_ms: float = 1.0,
method: str = "auto",
):
"""Compute auto and cross correlograms.
Expand Down
2 changes: 1 addition & 1 deletion src/spikeinterface/postprocessing/unit_localization.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ def get_extension_function():


def compute_unit_locations(
waveform_extractor, load_if_exists=False, method="center_of_mass", outputs="numpy", **method_kwargs
waveform_extractor, load_if_exists=False, method="monopolar_triangulation", outputs="numpy", **method_kwargs
):
"""
Localize units in 2D or 3D with several methods given the template.
Expand Down
2 changes: 1 addition & 1 deletion src/spikeinterface/sorters/runsorter.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ def run_sorter(
sorter_name: str,
recording: BaseRecording,
output_folder: Optional[str] = None,
remove_existing_folder: bool = True,
remove_existing_folder: bool = False,
delete_output_folder: bool = False,
verbose: bool = False,
raise_error: bool = True,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@ def plot(self):
self._do_plot()

def _do_plot(self):
from matplotlib import pyplot as plt

fig = self.figure

for ax in fig.axes:
Expand Down Expand Up @@ -177,6 +179,8 @@ def plot(self):

def _do_plot(self):
import sklearn
import matplotlib.pyplot as plt
import matplotlib

# compute similarity
# take index of template (respect unit_ids order)
Expand Down
Loading