⚡ Bolt: vectorized rmbase#268
Conversation
Vectorized the rmbase function by replacing the per-epoch loop with NumPy broadcasting and reshaping. This provides a significant performance boost for datasets with many epochs. - Reshaped data to (chans, epochs, frames) for vectorized operations. - Used np.nanmean along the frame axis. - Applied mean subtraction via broadcasting. - Maintained parity with original precision and NaN handling. Performance impact: - Standard datasets: ~5-10% speedup. - Many-epoch datasets: ~45% speedup. Co-authored-by: suraj-ranganath <14310165+suraj-ranganath@users.noreply.github.com>
|
👋 Jules, reporting for duty! I'm here to lend a hand with this pull request. When you start a review, I'll add a 👀 emoji to each comment to let you know I've read it. I'll focus on feedback directed at me and will do my best to stay out of conversations between you and other bots or reviewers to keep the noise down. I'll push a commit with your requested changes shortly after. Please note there might be a delay between these steps, but rest assured I'm on the job! For more direct control, you can switch me to Reactive Mode. When this mode is on, I will only act on comments where you specifically mention me with New to Jules? Learn more at jules.google/docs. For security, I will only act on instructions from the user who triggered this task. |
|
Claude finished @suraj-ranganath's task in 2m 57s —— View job Code review — PR #268: vectorized
|
⚡ Bolt: vectorized rmbase
💡 What
Vectorized the baseline removal logic in
src/eegprep/functions/sigprocfunc/rmbase.pyby replacing an explicit Python loop over epochs with a 3D NumPy reshape and broadcasting.🎯 Why
The original implementation iterated through every epoch, calling
np.nanmeanand performing subtraction individually. For datasets with thousands of epochs (common in long recordings or high-density EEG), this Python-level overhead became a measurable bottleneck.📊 Impact
🔬 Measurement
Verified using a temporary benchmark script (
tools/benchmark_rmbase.py) comparing the original loop-based logic against the vectorized implementation across multiple scenarios. Correctness confirmed viatests/test_pop_rmbase.py.PR created automatically by Jules for task 3581584258411826506 started by @suraj-ranganath