Cyton signal processing, UDP, Python, MATLAB, drone control

edited January 2022 in OpenBCI_GUI

I am sending the EEG signal acquired by Cyton's 8ch to python by UDP. Therefore, I would like to know the details of the UDP signal of the EEG signal acquired by Cyton's 8ch.
How many signals do you receive when sending EEG signals over UDP? (Hz, amount of information per packet, amount of information per channel when FFT is applied, etc.)

Comments

  • edited January 2022
    import socket
    import time
    import re
    import numpy as np
    import matlab
    
    class matserver:
        def __init__(self,ip,port):
    
            self.ip = ip                        # 受信元IP
            self.port = port                                 # 受信元ポート番号
            self.SrcAddr = (self.ip,int(self.port))                 # アドレスをtupleに格納
            self.BUFSIZE = 1024                             # バッファサイズ指定
            self.sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)  # ソケット作成
            self.sock.bind(self.SrcAddr)             # 受信元アドレスでバインド
    
        def start_listening(self,callback=None):
                try :
                    message, cli_addr = self.sock.recvfrom(self.BUFSIZE)
                    message = message.decode(encoding='utf-8')
                    d = re.findall(r"[-+]?\d*\.\d+|\d+", message)
                    a = np.array(d)
                    return a
    
                except KeyboardInterrupt:
                    self.sock.close()
                    return False   
    

    If you use this code, how many HZ can you send by UDP at one time?

  • wjcroftwjcroft Mount Shasta, CA

    Yumino, You did not mention how you have configured your Networking Widget. Mentioning Richard @retiutut.

  • I used UDP in networking. Data type is time serious.

  • wjcroftwjcroft Mount Shasta, CA
    edited January 2022

    I believe that the "[OpenBCI_GUI Networking Data Formats]" document, quoted above, implies that one JSON string is sent per packet. So one sample per UDP packet. At normal Cyton sample rates that would mean 250 UDPs per second. Is that right Richard @retiutut ? If that is the true packet rate, then your program receiving the data must be capable of some buffering. The OS IP/TCP/UDP stack does do some of this for you, but I don't know how much.

    Richard, perhaps you could also clarify the UDP packet details for Network Widget FFT data format? Do I have the wrong impression that 125 floats per channel (= 125 * 8 * say 4 text_bytes = 4000 bytes??) Which would exceed default IP / UDP packet size of around 512 bytes:

    https://stackoverflow.com/questions/1098897/what-is-the-largest-safe-udp-packet-size-on-the-internet

    It is possible to negotiate larger IP datagram size (MTU, max transfer unit).

    https://www.google.com/search?q=how+to+negotiate+larger+ip+packet+size

    Regards, William

  • retiututretiutut Louisiana, USA
    edited January 2022

    I don't recommend sending TimeSeries data over UDP if the GUI is being used. TimeSeries can be sent over LSL in chunks, but it's actually a lot of information to be sent over UDP for all channels. The GUI is actually able to "crunch some numbers" to provide more meaningful information than simply raw data. There are also a number of other configurations that can be done to collect data using BrainFlow and the GUI.

    I do recommend using another DataType, such as BandPower, EMG, or Focus when sending data from the GUI over UDP to another device, app, or process.

    Important Question: What is this data being sent to and the end goal? @YuminosukeSato

  • edited January 2022

    I'm trying to move the drone with brain waves. I'm trying to send commands from OPEBCI to python via UDP and analyze them in MATLAB. I would appreciate it if you could tell me how to use it. @retiutut

  • wjcroftwjcroft Mount Shasta, CA

    @YuminosukeSato said:
    I'm trying to move the drone with brain waves.

    If you want to control multiple flight parameters (such as up/down, rotation, forward/reverse, speed, etc.) this is quite difficult using MATLAB and simplistic BCI paradigms such as band power, P300, Motor Imagery, etc. A better approach may be to write your drone control program using the free open source BCI, MindAffect. By directing your gaze to different control-button boxes on the screen, you select that command.

    https://openbci.com/forum/index.php?p=/discussion/2783/mindaffect-announces-open-source-release-of-their-cvep-bci-speller-games-etc
    https://www.mindaffect.nl/

  • I want to process brain waves in MATLAB instead of python. So, is there any open platform that can be used with MATLAB?

  • wjcroftwjcroft Mount Shasta, CA

    MindAffect is your best bet, it uses Python. What BCI paradigm would you use with MATLAB?

  • This is a BCI paradigm that can acquire brain waves in real time in MATLAB.

  • wjcroftwjcroft Mount Shasta, CA

    Below is a list of typical BCI 'paradigms', what I am pointing to as paradigm. For example, an extremely simplistic paradigm would allow you to change the height of the drone (no other parameter), by the amplitude of the alpha band power. Alpha increases when eyes are closed.

    https://www.gtec.at/product/bcisystem/

  • Hold your right hand to move forward. Hold your left hand to move backwards. The signal of the muscle of the hand is read by the brain wave and the drone is moved.

  • wjcroftwjcroft Mount Shasta, CA

    Your original post stated you were using EEG. Muscle sensing is called EMG, and sensors are applied not to the scalp, but to the appropriate body part. See:

    https://docs.openbci.com/GettingStarted/Biosensing-Setups/EMGSetup/

  • I get the brain waves when I move my right hand and the brain waves when I move my left hand. It's not myoelectric. Specifically, I want to acquire brain waves that I want to move my right hand. Use that brain wave as a command to move the drone.

  • wjcroftwjcroft Mount Shasta, CA

    The closest BCI paradigm to that is called Motor Imagery.

    https://www.google.com/search?as_q=motor+imagery&as_sitesearch=openbci.com

    https://docs.openbci.com/Examples/EEGProjects/MotorImagery/

    Your comment: "The signal of the muscle of the hand is read by the brain wave and the drone is moved.", this signal is not easily present at the scalp, and requires a fair amount of signal processing. Flying a drone with only forward / back 'may' be possible, but in general the MindAffect approach, with many more degrees of freedom, would allow a more pleasant operator experience.

  • thank you.

Sign In or Register to comment.