Skip to content

Commit 28a60ed

Browse files
committed
Edit warning for whitening with more than 32 channels in KilosortSorter
1 parent e914c5f commit 28a60ed

1 file changed

Lines changed: 9 additions & 5 deletions

File tree

src/spikeinterface/sorters/external/kilosort.py

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
from pathlib import Path
44
import os
55
from typing import Union
6+
from warnings import warn
67
import numpy as np
78

89
from spikeinterface.sorters.basesorter import BaseSorter
@@ -226,14 +227,17 @@ def _get_specific_options(cls, ops, params) -> dict:
226227
"whitening"
227228
] # type of whitening (default 'full', for 'noSpikes' set options for spike detection below)
228229
ops["nSkipCov"] = params["nSkipCov"] # compute whitening matrix from every N-th batch (1)
230+
231+
if params["whiteningRange"] > 32:
232+
n_channels_whitening = params["whiteningRange"] if np.isfinite(params["whiteningRange"]) else "all"
233+
warn(
234+
"Kilosort recommends whitening with 32 or fewer channels. " \
235+
f"However, you are whitening with {n_channels_whitening} channels."
236+
)
237+
229238
ops["whiteningRange"] = params[
230239
"whiteningRange"
231240
] # how many channels to whiten together (Inf for whole probe whitening, should be fine if Nchan<=32)
232-
if ops["whiteningRange"] == np.inf and ops["Nchan"] > 32:
233-
print(
234-
"Warning: Kilosort is set to use full probe whitening, but the "
235-
"number of channels is greater than 32."
236-
)
237241

238242
# ops['criterionNoiseChannels'] = 0.2 # fraction of "noise" templates allowed to span all channel groups (see createChannelMapFile for more info).
239243

0 commit comments

Comments
 (0)