Baseline normalization for source localization

The goal is to remove the offset present at the time of the spike, so looking for a time window of low variance may still include a large offset that’s different from your spike time, if it’s not close enough. Whatever is happening at the time of the spike is what you want to deal with, so I’d stick with the time nearest to the onset of the signal of interest.

If your spikes are short enough duration and high frequency content (spiky), you may benefit instead from a high-pass filter to get rid of the really slow large amplitude changes in your channels. You could then still select a time window close to your spike for baseline removal, or if your high-pass is high enough it might not be necessary anymore.

As for the follow-up question of what frequency to use for the high-pass, I’d say this is subjective and depends on your data. You want to balance removing as much uninteresting fluctuations as possible while keeping the spike mostly unaltered.

I haven’t dealt with single event mapping however. I think there’s no perfect solution here, it will always be noisy. If the spikes are very consistent in shape, you could also average them before localizing, which would reduce the need for cleaning: you could possibly get away with not filtering, and just selecting a baseline window.