Skip to content

Commit ed26b47

Browse files
committed
default channel detection thresholds adapt to LF or AP band
1 parent 8fe4acf commit ed26b47

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

ibllib/dsp/voltage.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -480,7 +480,7 @@ def normalize(z):
480480
return rcor
481481

482482

483-
def detect_bad_channels(raw, fs, similarity_threshold=(-0.5, 1), psd_hf_threshold=0.02):
483+
def detect_bad_channels(raw, fs, similarity_threshold=(-0.5, 1), psd_hf_threshold=None):
484484
"""
485485
Bad channels detection for Neuropixel probes
486486
Labels channels
@@ -544,7 +544,9 @@ def nxcor(x, ref):
544544
raw = raw - np.mean(raw, axis=-1)[:, np.newaxis] # removes DC offset
545545
xcor = channels_similarity(raw)
546546
fscale, psd = scipy.signal.welch(raw * 1e6, fs=fs) # units; uV ** 2 / Hz
547-
547+
if psd_hf_threshold is None:
548+
# the LFP band data is obviously much stronger so auto-adjust the default threshold
549+
psd_hf_threshold = 1.4 if fs < 5000 else 0.02
548550
sos_hp = scipy.signal.butter(**{'N': 3, 'Wn': 300 / fs * 2, 'btype': 'highpass'}, output='sos')
549551
hf = scipy.signal.sosfiltfilt(sos_hp, raw)
550552
xcorf = channels_similarity(hf)

0 commit comments

Comments
 (0)