Skip to content

Commit 2d1f629

Browse files
committed
rfft() is used now because it efficiently computes only the necessary positive frequency components, reducing computation time and memory usage for real-time EEG processing.
1 parent 49f54c6 commit 2d1f629

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

ffteeg.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -118,9 +118,9 @@ def update_plot(self):
118118
def process_fft_and_brainpower(self):
119119
window = np.hanning(len(self.moving_window))
120120
buffer_windowed = np.array(self.moving_window) * window
121-
fft_result = np.abs(fft(buffer_windowed))[:len(buffer_windowed) // 2]
121+
fft_result = np.abs(np.fft.rfft(buffer_windowed))
122122
fft_result /= len(buffer_windowed)
123-
freqs = np.fft.fftfreq(len(buffer_windowed), 1 / self.sampling_rate)[:len(buffer_windowed) // 2]
123+
freqs = np.fft.rfftfreq(len(buffer_windowed), 1 / self.sampling_rate)
124124
self.fft_curve.setData(freqs, fft_result)
125125

126126
brainwave_power = self.calculate_brainwave_power(fft_result, freqs)

0 commit comments

Comments
 (0)