Exemple #1
0
    def record(self, forever=True):
        epocrec = Epoc()
        epocrec.connect()

        while True:
            if self.threadsDieNow:
                break

            # if self.O1: 
            #     self.chan=9
            # if self.O2: 
            #     self.chan=14

            #two individual arrays to allow for the recording of the data
            datarray = numpy.zeros((1, 4))
            datarray2 = numpy.zeros((1, 4))         

            #data = numpy.random.randint(4000, 5000, size=(1, 4))
            # gets raw data from channel that is stated in the epoc

            #datarray & datarray2 get the data which is being recorded from channels 9 and 14
            data = epocrec.aquire([9])
            datarray = numpy.concatenate((datarray, data), axis=1)
            
            data2= epocrec.aquire([14])
            datarray2= numpy.concatenate((datarray2, data2), axis=1)


            self.newRecord = True

            temp = [] * 4
            for i in xrange(0, len(datarray[0])):
                if datarray[0][i] > 0:
                    temp.append(datarray[0][i])
            

            
            temp2 = [] * 4
            for i in xrange(0, len(datarray2[0])):
                if datarray2[0][i] > 0:
                    temp2.append(datarray2[0][i])

            self.ys = numpy.roll(self.ys, -4)
            for i in xrange(0, 4):
                self.ys[508 + i] = temp[i]

            self.ys2 = numpy.roll(self.ys2, -4)
            for i in xrange(0, 4):
                self.ys2[508 + i] = temp2[i]


            # import time
            # time.sleep(0.015)

            # print self.ys

            if not forever:
                break
Exemple #2
0
def emotiv(e):
    epoc = Epoc()
    fid = open('emotiv.dat', 'w')
    e.wait()

    t0 = time.time()
    tp = time.time()
    while tp - t0 < WINL:
        tp = time.time()
        data = epoc.get_raw()
        m, n = data.shape
        for i in range(n):
            fid.write(
                "%8.12f %8.12f %8.12f %8.12f %8.12f %8.12f %8.12f %8.12f %8.12f %8.12f %8.12f %8.12f %8.12f %8.12f\n" % tuple(
                    data[:, i]))

    fid.close()
    print 'Emotiv stop...'
Exemple #3
0
	def initUI(self): 
		
		# Emotiv Initialization and data acquisition
		
		epoc= Epoc()

		# collecting data from the headset and placing into two different arrays

		data= epoc.aquire([9]) 
		#data2= epoc.aquire([14]) 
		datarray = np.concatenate((datarray, data), axis = 1)
		#datarray2= np.concatenate((datarray2, data2), axis=1)



		#self.clab = ['F3', 'F4', 'P7', 'FC6', 'F7', 'F8', 'T7', 'P8', 'FC5', 'AF4','T8', 'O2', 'O1', 'AF3']
		self.timek = 512 
		self.x = np.arange(0,self.timek,1)
		self.y = [[0] for i in xrange(len(self.datarray[0]))]
		self.offset = [2500.0*i for i in xrange(len(self.datarray[0]))]
		
		self.cancel = False		
from pyemotiv import Epoc
import matplotlib.pyplot as plt
import matplotlib.animation as animation
import time, config
import numpy as np
import csv

fig = plt.figure()
ax = fig.add_subplot(1, 1, 1)

nScan=0

epoc = Epoc()

t=[]
sensor={}
for name in config.SENSORNAME:
    sensor[name]=[]

start_time=time.time()

def countdown(self):
    #waiting
    print "scan in 3 seconds"
    time.sleep(1)
    print "scan in 2 seconds"
    time.sleep(1)
    print "scan in 1 seconds"
    time.sleep(1)

def animate(i,t,sensor,data):
Exemple #5
0
from pyemotiv import Epoc
import numpy as np
from gzp import save
import time
"""
Sample Emotiv experiment.

Gathers data over two phases. Use a keyboard interrupt (control-c) to end a phase.

Saves data to disk afterwards.
"""

headset = Epoc()

data = headset.get_raw()
times = headset.times
t0 = time.time()

print "First phase..."
while True:  #first phase (eg. 'resting')
    try:
        x = headset.get_raw()
        t = headset.times
        data = np.concatenate((data, x), axis=1)
        times = np.concatenate((times, t), axis=-1)

    except KeyboardInterrupt:
        break

breaktime = times[-1]
Exemple #6
0
from pyemotiv import Epoc
import numpy as np
import scipy
import time
from scipy import signal
import matplotlib.mlab as mlab
from matplotlib import pyplot
import matplotlib.pyplot as plt
from math import *


epoc=Epoc()

power_avg=[]
power_store=[]
time= 0
#sth=[]



while time<4:
	print time
	datarray=np.zeros((1,4)) #resets datarray every time we run the loop
	
	for t in range(0,100):
		
		#data= epoc.get_raw() #gets raw data from all the channels.. unnecessary once connect is made
		data= epoc.aquire([9]) #gets raw data from channel O1
		#data2= epoc.aquire([14]) #connection on hardware is to AF4:not an issue at all on S/w
		#print data.shape
		datarray = np.concatenate((datarray, data), axis = 1)
from pyemotiv import Epoc
import time
import numpy as np
import keyboard
import csv

esc = False

with open("avanti.csv", "wb") as csvavanti:
    avanti = csv.writer(csvavanti)
    with open("indietro.csv", "wb") as csvindietro:
        indietro = csv.writer(csvindietro)

        time_passed = 0.0

        epoc = Epoc()
        while not esc:
            data = epoc.get_raw()

            if (keyboard.is_pressed('q')):
                esc = True

            if (keyboard.is_pressed('a')):
                print "INVIO AVANTI"

                avanti.writerow(
                    [str(time_passed), 'af3, ',
                     str(np.average(data[0]))])
                avanti.writerow(
                    [str(time_passed), 'f7, ',
                     str(np.average(data[1]))])
Exemple #8
0
from pyemotiv import Epoc
from time import sleep
from gzp import save
import numpy as np
        
if __name__=="__main__":
    epoc=Epoc()
    channels= epoc.channels
    acq = False
    while True:
        try:
            raw = epoc.get_raw() 
            if not acq:
                data = raw
            else:
                data = np.concatenate((data, raw), axis = 1)
        except KeyboardInterrupt:
            save(data, "data.dat")
Exemple #9
0
from pyemotiv import Epoc
from time import sleep
from gzp import save
import numpy as np

if __name__ == "__main__":
    epoc = Epoc()
    channels = epoc.channels
    acq = False
    while True:
        try:
            raw = epoc.get_raw()
            if not acq:
                data = raw
            else:
                data = np.concatenate((data, raw), axis=1)
        except KeyboardInterrupt:
            save(data, "data.dat")
Exemple #10
0
from pyemotiv import Epoc
import numpy as np
from gzp import save
import time

"""
Sample Emotiv experiment.

Gathers data over two phases. Use a keyboard interrupt (control-c) to end a phase.

Saves data to disk afterwards.
"""

headset = Epoc()

data = headset.get_raw()
times = headset.times
t0 = time.time()

print "First phase..."
while True: #first phase (eg. 'resting')
    try:
        x = headset.get_raw()
        t = headset.times
        data = np.concatenate((data, x), axis  = 1)
        times = np.concatenate((times, t), axis  = -1)
    
    except KeyboardInterrupt:
        break

breaktime = times[-1]