save FFT data and band data in a file?

lunarbrainlunarbrain India
edited February 2023 in OpenBCI_GUI

Is there a way to save the FFT data and EEG Bands (alpha,beta,gamma,delta,theta) data in file from OpenBCI GUI in a separate file other than the raw eeg data?

Comments

  • wjcroftwjcroft Mount Shasta, CA

    The Networking Widget allows sending FFT or Bands to other apps. So you could send via LSL to OpenViBE and write a file there.

    https://docs.openbci.com/Software/OpenBCISoftware/GUIWidgets/#networking
    http://openvibe.inria.fr/how-to-use-labstreaminglayer-in-openvibe/
    http://openvibe.inria.fr/documentation/3.3.0/Doc_BoxAlgorithm_CSVFileWriter.html

    There is no direct file output of these streams.

  • @wjcroft thank you so much again. I figured that out already. I will share an app with the community soon.

  • Here is the sample app to get the stream of band power data from OpenBCI GUI via UDP connection to write to files. Also, we can't send FFT data.

        const dgram = require('dgram')
        const server = dgram.createSocket('udp4')
        const fs = require('fs')
        const log = []
    
        // create seperate log files for channels 
        for (let i = 0; i < 15; i++) {
            log[i] = fs.createWriteStream(`ch-${i}-bandpower.csv`, {
                flags: 'a'
            });
        }
    
        // listen to UDP server from OpenBCI GUI
        server.on('listening', () => {
            console.log("UDP server listening")
        })
    
        // read new data from UDP Stream
        server.on('message', (msg, rinfo) => {
    
            // convert buffer data to utf8 format 
            const stream = msg.toString('utf8')
    
            // conver string to json and get data object 
            const bandpower = JSON.parse(stream).data
    
            // iterate over data object to get bandpower associated with each channel 
            for (let i = 0; i < bandpower.length - 1; i++) {
                log[i].write(`${bandpower[i]}\n`);
            }
        })
    
        const PORT = 12345
        const HOST = '127.0.0.1'
        server.bind(PORT, HOST)
    
Sign In or Register to comment.