Skip to content

Commit f902c01

Browse files
galenlynchclaude
andcommitted
perf: FIR phase-shift alternative + apply_raised_cosine_taper extract
Adds a sinc-FIR alternative to the FFT-based PhaseShift path, and factors the FFT-specific raised-cosine taper out of get_chunk_with_margin so bounded-support FIR consumers don't have to pay for it. Changes ------- - PhaseShiftRecording(method="fft"|"fir", n_taps=32, output_dtype=None) - method="fir": 32-tap Kaiser-windowed sinc, numba-jit with prange over time - Per-channel kernels cached once per segment - Int16-native fast path: reads int16 directly, writes float32 when output_dtype=np.float32 (skips round-back-to-int16) - FIR margin = n_taps // 2 (16 for 32-tap default), vs FFT path's 40 ms - Default "fft" preserves existing behavior - apply_raised_cosine_taper(data, margin, *, inplace=True) public function in spikeinterface.core.time_series_tools - get_chunk_with_margin(window_on_margin=True) emits DeprecationWarning and delegates to apply_raised_cosine_taper; old behavior preserved Whittaker-Shannon justification ------------------------------- Both FFT and FIR paths are numerical realisations of the same ideal sinc-interpolation implied by the sampling theorem. FFT does it spectrally (phase ramp = DFT of full sinc kernel); FIR does it in time against a Kaiser-windowed 32-tap truncation of the same sinc. Approximations: sinc truncation (32 taps captures >99% of kernel energy for any d ∈ [0,1)) and Kaiser windowing (-80 dB stopband, two orders of magnitude below NP's ~50 dB SNR). Measured 0.19% spike-band RMS vs FFT on real NP 2.0 data. Performance (1M × 384 int16 AIND pipeline, PS → HP → CMR, 24-core host) ----------------------------------------------------------------------- stock FFT FIR speedup single-call get_traces 82.1 s 6.28 s 13.1× same, f32 propagated 85.8 s 4.40 s 19.5× TimeSeriesChunkExecutor n=24 4.98 s 1.62 s 3.1× on top of CRE n=24 Memory (same pipeline, n_jobs=24, chunk=1s): FFT peak RSS: 10.8 GB FIR peak RSS: 3.9 GB (2.8× less) Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent a2fee4e commit f902c01

6 files changed

Lines changed: 882 additions & 113 deletions

File tree

0 commit comments

Comments
 (0)