Question about correct parameters for recording data
apavlo89 opened this issue · 2 comments
Hello,
My protocol is either 15 minutes of EEG recording or 30 minutes during a relaxation session. I want to get absolute bandpower values (delta,.... gamma) for each minute of recording (0-1, 1-2,... 29-30).
I'm confused on how the EEG recording should be sampled...
For example, you have the following example in your code:
eeg$.pipe(epoch({ duration: 1024, interval: 100, samplingRate: 256 }))
In your example does this mean that the recording is 4 seconds (1024/256)? Is the interval a small "pause" between each sampling? E.g., in the first second of recording 256 samples are acquired, then there is a pause of 100ms and then another 256 samples are acquired etc?? If so can the interval be set to continuous (e.g., by putting 0)?
If this logic is correct, then in order to record 30 minutes of EEG data, the values should be:
eeg$.pipe(epoch({ duration: 460,800, interval: 0, samplingRate: 256 }))
?????
I basically want to record and analyse bandpower of 30 minutes (in 1 minute intervals) using settings similar to this: https://raphaelvallat.com/bandpower.html
e.g., 256 samples per second, 0.5-45 bandpass filter with a 4-second sliding window.
Any help would be super appreciated
Hey there!
Thanks for writing such a clear issue! I thinked you've pointed out something lacking in our documentation that we should address.
EEG Pipes uses a sliding window approach that's similar to what's described in that article you linked. In a sliding window, the interval
is not a pause, but refers to the distance between the starts of consecutive and overlapping windows (aka epochs). Here's an illustration to show what I'm talking about.
A sliding window is really useful when performing real-time analyses on the EEG that require many samples of the EEG to compute spectral information. Since you are interested in spectral info like band powers and using a very long window length (4s), I'd recommend adding a little bit of overlap between your windows, maybe something like duration: 1024, interval: 256, samplingRate: 256
). If your sampling rate is 256hz, this will give you a stream of four second windows emitted every 1 second with 768 samples of overlap between consecutive windows. By the way, the duration
parameter does not correspond to the duration of the whole recording, but the number of samples in each window!
The whole pipeline for what you want to do is something like this, I believe
const eeg4$ = createEEG({ samplingRate: 256 }).pipe(
bandpassFilter({
nbChannels: 4, // adjust for however many channels your EEG device has
cutoffFrequencies: [0.5, 45],
samplingRate: 256
}),
epoch({
duration: 1024,
interval: 256,
samplingRate: 256 }),
fft({ bins: 1024 }), // FFT bin size is usually equal to the number of samples in the window
powerByBand()
);
This totally makes sense now and the result data produced is similar to the ones I get using other eeg analysis software. Thank you!