calculate FFT graph from Cyton samples, using python
Hi,
I recently purchased the cyton+daisy board with the electrode cap.
I am trying to get the data that I log in the openbci gui into python in the fft format (the data that the gui uses to produce the live fft plot). Is there a way to do this?
Since the gui creates files in the .txt or .bdf format, is there a command that can read in the file and then transform to the fft format? Or does the board itself do the fft?
Thanks in advance for your help!
@wjcroft @retiutut @ Andrey1994 @evaesteban
Comments
@Andrey1994
You can collect data directly using BrainFlow Python Binding. Then, you can retrieve user defined Band Power levels.
https://brainflow.readthedocs.io/en/stable/Examples.html#python-band-power
I'm not a big MNE user, but there is also compatibility with MNE:
https://brainflow.readthedocs.io/en/stable/Examples.html#python-mne-integration
"I am trying to get the data that I log in the openbci gui into python in the fft format"
GUI stores raw unprocessed data, you can read it as a tsv file(with custom multiline header) and convert to pandas dataframe but you will need to calc fft by yourself. Another option to get fft data from the gui is networking widget.
@Andrey1994
Thanks!
If the file from the gui was at location "eeg/example.txt", what would my command be to read it in? I am just a little confused since the file is in .txt format and you are suggesting to read it in as a tsv.
Thanks in advance!
Using the raw data that is logged from the openbci gui, how can you process it into power vs frequency?
I have been trying to do this for the last two days and Im not really making any progress so any help would be greatly appreciated!
@gregpalmer, hi.
I merged your new thread (with above comment), into this existing thread you previously started. There are many Python DSP (digital signal processing) libraries available, that can perform FFT.
https://www.google.com/search?q=python+dsp+fft
https://realpython.com/python-scipy-fft/
As Andrey and Richard mentioned previously, there are (at least) two ways to approach this:
Regards, William
https://www.google.com/search?q=python+parse+csv+file
@wjcroft, Thank you very much! That really solves it for me!
This does spark an additional question: Does the Cyton board do a different FFT than a python library? In other words, is there any reason to prefer one method on the grounds of signal quality?
All FFT libraries should produce accurate results. The OpenBCI_GUI is not written in Python, but instead in Processing / Java. It's calling on Brainflow library routines.
https://brainflow.org/
Brainflow has language bindings for a wide range of popular languages, including Python, Java, C++, C#, Matlab, etc.
William