Example #1
0
def flush_buffer(port):
    ftc = FieldTrip2.Client()  # create buffer object
    ftc.connect("localhost", port)  # connect to buffer
    hdr = ftc.getHeader()  # get header
    ftc.putHeader(hdr.nChannels, 0, FieldTrip2.DATATYPE_FLOAT32, None,
                  None)  # clears the buffer memory! hack?
    ftc.disconnect()
Example #2
0
def buffer_trial(port, array):

    path_buffer_executable = "D:\\Network.Buffer.DRP.19.07.20\\realtimeHack.10.11.17\\buffer.exe"

    host = 'localhost'

    command = "start cmd /K " + path_buffer_executable + " " + host.__str__(
    ) + " " + port.__str__() + " -&"
    print(command)

    subprocess.Popen(command, shell=True)  # start buffer

    ftc = FieldTrip2.Client()  # create buffer object
    ftc.connect(host, port)  # connect to buffer
    ftc.putHeader(Number.axes, 0, FieldTrip2.DATATYPE_FLOAT32, None,
                  None)  # put header - clears the buffer memory?

    ftc.putData(array.astype((np.float32)))  # put data

    hdr = ftc.getHeader()  # get header
    # print(hdr)  # print header

    D2 = ftc.getData((0, hdr.nSamples - 1))  # get data
    # print(np.shape(D2))  # print data

    return (D2)
Example #3
0
    def start_buffer_and_put_data(port, array):
        start_buffer(port, array.shape[1])

        ftc = FieldTrip2.Client()  # create buffer object
        ftc.connect("localhost", port)  # connect to buffer
        ftc.putData(array.astype(np.float32))  # put data
        hdr = ftc.getHeader()  # get header
        D2 = ftc.getData((0, hdr.nSamples-1))  # get data
        return D2
Example #4
0
    def start_buffer(port, nChannels):
        path_buffer_executable = "D:\\Network.Buffer.DRP.19.07.20\\realtimeHack.10.11.17\\buffer.exe"
        host = 'localhost'

        command = "start cmd /K " + path_buffer_executable + " " + host.__str__() + " " + port.__str__() + " -&"
        print(command)

        subprocess.Popen(command, shell=True)  # start buffer

        ftc = FieldTrip2.Client()  # create buffer object
        ftc.connect(host, port)  # connect to buffer
        ftc.putHeader(nChannels, 0, FieldTrip2.DATATYPE_FLOAT32, None, None)  # put header - clears the buffer memory?
        ftc.disconnect()
Example #5
0
 def get_number_of_samples(port):
     ftc = FieldTrip2.Client()  # create buffer object
     ftc.connect("localhost", port)  # connect to buffer
     hdr = ftc.getHeader()
     return hdr.nSamples
Example #6
0
 def put_data(port, array):
     ftc = FieldTrip2.Client()  # create buffer object
     ftc.connect("localhost", port)  # connect to buffer
     ftc.putData(array.astype(np.float32))  # put data
Example #7
0
 def get_all_data(port):
     ftc = FieldTrip2.Client()  # create buffer object
     ftc.connect("localhost", port)  # connect to buffer
     hdr = ftc.getHeader()
     data = ftc.getData([0, hdr.nSamples-1])
     return data