Skip to content

Commit 154f526

Browse files
committed
audio welchogram: expose threshold for detections
1 parent 3745569 commit 154f526

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

ibllib/io/extractors/training_audio.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ def _get_conversion_factor(unit=UNIT, ready_tone_spl=READY_TONE_SPL):
6262
return fac
6363

6464

65-
def welchogram(fs, wav, nswin=NS_WIN, overlap=OVERLAP, nperseg=NS_WELCH):
65+
def welchogram(fs, wav, nswin=NS_WIN, overlap=OVERLAP, nperseg=NS_WELCH, detect_kwargs=None):
6666
"""
6767
Computes a spectrogram on a very large audio file.
6868
@@ -71,6 +71,7 @@ def welchogram(fs, wav, nswin=NS_WIN, overlap=OVERLAP, nperseg=NS_WELCH):
7171
:param nswin: n samples of the sliding window
7272
:param overlap: n samples of the overlap between windows
7373
:param nperseg: n samples for the computation of the spectrogram
74+
:param detect_kwargs: specified paramaters for detection
7475
:return: tscale, fscale, downsampled_spectrogram
7576
"""
7677
ns = wav.shape[0]
@@ -84,7 +85,8 @@ def welchogram(fs, wav, nswin=NS_WIN, overlap=OVERLAP, nperseg=NS_WELCH):
8485
# load the current window into memory
8586
w = np.float64(wav[first:last]) * _get_conversion_factor()
8687
# detection of ready tones
87-
a = [d + first for d in detect_ready_tone(w, fs)]
88+
detect_kwargs = detect_kwargs or {}
89+
a = [d + first for d in detect_ready_tone(w, fs, **detect_kwargs)]
8890
if len(a):
8991
detect += a
9092
# the last window may not allow a pwelch

0 commit comments

Comments
 (0)