Skip to content

Commit

Permalink
Merge pull request #2375 from yger/fix_silence
Browse files Browse the repository at this point in the history
Fix for Silence periods (saving noise levels)
  • Loading branch information
yger authored Jan 2, 2024
2 parents c97415a + 914058a commit a509470
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions src/spikeinterface/preprocessing/silence_periods.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ class SilencedPeriodsRecording(BasePreprocessor):
The recording extractor to silance periods
list_periods: list of lists/arrays
One list per segment of tuples (start_frame, end_frame) to silence
noise_levels: array
Noise levels if already computed
mode: "zeros" | "noise, default: "zeros"
Determines what periods are replaced by. Can be one of the following:
Expand All @@ -39,9 +41,7 @@ class SilencedPeriodsRecording(BasePreprocessor):

name = "silence_periods"

def __init__(self, recording, list_periods, mode="zeros", **random_chunk_kwargs):
import scipy.interpolate

def __init__(self, recording, list_periods, mode="zeros", noise_levels=None, **random_chunk_kwargs):
available_modes = ("zeros", "noise")
num_seg = recording.get_num_segments()

Expand All @@ -67,7 +67,10 @@ def __init__(self, recording, list_periods, mode="zeros", **random_chunk_kwargs)
), "Intervals should not overlap"

if mode in ["noise"]:
noise_levels = get_noise_levels(recording, return_scaled=False, concatenated=True, **random_chunk_kwargs)
if noise_levels is None:
noise_levels = get_noise_levels(
recording, return_scaled=False, concatenated=True, **random_chunk_kwargs
)
else:
noise_levels = None

Expand All @@ -79,9 +82,7 @@ def __init__(self, recording, list_periods, mode="zeros", **random_chunk_kwargs)
rec_segment = SilencedPeriodsRecordingSegment(parent_segment, periods, mode, noise_levels)
self.add_recording_segment(rec_segment)

self._kwargs = dict(
recording=recording.to_dict(), list_periods=list_periods, mode=mode, noise_levels=noise_levels
)
self._kwargs = dict(recording=recording, list_periods=list_periods, mode=mode, noise_levels=noise_levels)


class SilencedPeriodsRecordingSegment(BasePreprocessorSegment):
Expand Down

0 comments on commit a509470

Please sign in to comment.