Compare commits
8 Commits
dev
...
windowsdev
Author | SHA1 | Date | |
---|---|---|---|
29e2cf8850 | |||
7028038643 | |||
9a08c137d1 | |||
5f42ed7d6f | |||
eee80a907d | |||
![]() |
838abd4625 | ||
![]() |
417776994b | ||
![]() |
34d78660c3 |
@ -0,0 +1,2 @@
|
||||
# OpenViBE_visual_BCI
|
||||
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -1,75 +1,135 @@
|
||||
from UIModell import *
|
||||
from UIModellVisuell import *
|
||||
from UIModellTaktil import *
|
||||
import UIViewTKinter as viewTkinter
|
||||
import UIViewPySide as viewPySide
|
||||
from threading import Thread
|
||||
from shutil import copyfile
|
||||
|
||||
|
||||
|
||||
class Controller():
|
||||
|
||||
def __init__(self):
|
||||
self.view = viewTkinter.View(self)
|
||||
def __init__(self, pathOVFile, path_ov, path_files, path_default):
|
||||
self.view = viewTkinter.View(self, path_default)
|
||||
self.modi = "visuellesBCI"
|
||||
self.pathOVFile = pathOVFile
|
||||
self.PATH_OV = path_ov
|
||||
self.PATH_FILES = path_files
|
||||
self.infotext = ""
|
||||
|
||||
self.commands = {
|
||||
"copySpelling": self.commandoCopySpelling,
|
||||
"stop": self.commandStop,
|
||||
"freeSpelling": self.commandFreeSpelling,
|
||||
"test": self.test
|
||||
"test": self.test,
|
||||
"wechsel": self.wechsel,
|
||||
"speicherort": self.setDataset
|
||||
}
|
||||
|
||||
self.nexts = {
|
||||
"filterXdawn" : self.filterXdawn,
|
||||
"filterClassic": self.filterClassic
|
||||
"filterClassic": self.filterClassic,
|
||||
"save": self.speichern
|
||||
}
|
||||
|
||||
self.pages = {
|
||||
self.pagesTaktil = {
|
||||
"stop": "StartPage",
|
||||
"copySpelling": "WorkingPage",
|
||||
"freeSpelling": "WorkingPage",
|
||||
"test": "WorkingPage"
|
||||
"copySpelling": "WorkingPageTaktil",
|
||||
"freeSpelling": "WorkingPageTaktil",
|
||||
"test": "WorkingPageTaktil"
|
||||
}
|
||||
self.pagesVisuell = {
|
||||
"stop": "StartPage",
|
||||
"copySpelling": "WorkingPageVisuell",
|
||||
"freeSpelling": "WorkingPageVisuell",
|
||||
"test": "WorkingPageVisuell"
|
||||
}
|
||||
|
||||
self.model = None
|
||||
self.view.mainloop()
|
||||
|
||||
def actionPerformed(self, action):
|
||||
self.view.changeFrame(self.pages.get(action))
|
||||
self.changePage(action)
|
||||
func = self.commands.get(action)
|
||||
if(func is not None):
|
||||
func()
|
||||
else:
|
||||
print("Kommado existiert nicht")
|
||||
|
||||
def changePage(self,action):
|
||||
if(self.modi == "taktilesBCI"):
|
||||
page = self.pagesTaktil.get(action)
|
||||
elif(self.modi == "visuellesBCI"):
|
||||
page = self.pagesVisuell.get(action)
|
||||
if(page is not None):
|
||||
self.view.changeFrame(page)
|
||||
|
||||
def wechsel(self):
|
||||
if(self.modi == "taktilesBCI"):
|
||||
self.view.setChangeBtnText("Wechsel zu taktilen BCI")
|
||||
self.view.setTitleText("visuelles BCI")
|
||||
self.modi = "visuellesBCI"
|
||||
elif(self.modi == "visuellesBCI"):
|
||||
self.setTitle("taktiles BCI")
|
||||
self.view.setChangeBtnText("Wechsel zu visuellen BCI")
|
||||
self.modi = "taktilesBCI"
|
||||
|
||||
def speichern(self):
|
||||
print("saveFile")
|
||||
copyfile(self.pathOVFile, self.file)
|
||||
|
||||
def setDataset(self):
|
||||
file = self.view.openfiledialog()
|
||||
copyfile(file, self.pathOVFile)
|
||||
|
||||
|
||||
def test(self):
|
||||
self.model = Modell(self)
|
||||
self.file = self.view.savefiledialog()
|
||||
if(self.modi == "taktilesBCI"):
|
||||
self.model = ModellTaktil(self, path_files= self.PATH_FILES, path_ov= self.PATH_OV)
|
||||
elif(self.modi == "visuellesBCI"):
|
||||
self.model = ModellVisuell(self, path_files= self.PATH_FILES, path_ov= self.PATH_OV)
|
||||
self.model.setFunktion(self.model.trainXDawn)
|
||||
self.model.start()
|
||||
|
||||
#wird durch Btn gestartet -> startet copyspelling als thread
|
||||
def commandoCopySpelling(self):
|
||||
self.model = Modell(self)
|
||||
self.file = self.view.savefiledialog()
|
||||
if(self.modi == "taktilesBCI"):
|
||||
self.model = ModellTaktil(self, path_files= self.PATH_FILES, path_ov= self.PATH_OV)
|
||||
elif(self.modi == "visuellesBCI"):
|
||||
self.model = ModellVisuell(self, path_files= self.PATH_FILES, path_ov= self.PATH_OV)
|
||||
self.model.setFunktion(self.model.startCopySpelling)
|
||||
self.model.start()
|
||||
|
||||
#wird durch Copy-Speller Thread copystelling gestartet -> startete filtern als thread
|
||||
def filterXdawn(self):
|
||||
self.model = Modell(self)
|
||||
if(self.modi == "taktilesBCI"):
|
||||
self.model = ModellTaktil(self, path_files= self.PATH_FILES, path_ov= self.PATH_OV)
|
||||
elif(self.modi == "visuellesBCI"):
|
||||
self.model = ModellVisuell(self, path_files= self.PATH_FILES, path_ov= self.PATH_OV)
|
||||
self.model.setFunktion(self.model.trainXDawn)
|
||||
self.model.start()
|
||||
|
||||
#wird durch XDawn-Thread copystelling gestartet -> startete filtern als thread
|
||||
def filterClassic(self):
|
||||
self.model = Modell(self)
|
||||
if(self.modi == "taktilesBCI"):
|
||||
self.model = ModellTaktil(self, path_files= self.PATH_FILES, path_ov= self.PATH_OV)
|
||||
elif(self.modi == "visuellesBCI"):
|
||||
self.model = ModellVisuell(self, path_files= self.PATH_FILES, path_ov= self.PATH_OV)
|
||||
self.model.setFunktion(self.model.trainClassifier)
|
||||
self.model.start()
|
||||
|
||||
def commandFreeSpelling(self):
|
||||
print("freespelling")
|
||||
self.model = Modell(self)
|
||||
if(self.modi == "taktilesBCI"):
|
||||
self.model = ModellTaktil(self, path_files= self.PATH_FILES, path_ov= self.PATH_OV)
|
||||
elif(self.modi == "visuellesBCI"):
|
||||
self.model = ModellVisuell(self, path_files= self.PATH_FILES, path_ov= self.PATH_OV)
|
||||
self.model.setFunktion(self.model.freeSpelling)
|
||||
self.model.start()
|
||||
|
||||
def commandStop(self):
|
||||
self.setInfos("Action: STOP-Command")
|
||||
if(self.model is not None):
|
||||
self.addInfoText("Action: STOP-Command")
|
||||
self.model.stop()
|
||||
self.model.join()
|
||||
self.model.killProzess()
|
||||
@ -86,8 +146,12 @@ class Controller():
|
||||
func = self.nexts.get(next)
|
||||
func()
|
||||
|
||||
def setInfos(self,text):
|
||||
self.view.setInfoText(text)
|
||||
def addInfoText(self,text):
|
||||
self.infotext = self.infotext + text
|
||||
self.view.setInfoText(self.infotext)
|
||||
|
||||
def resetInfo(self):
|
||||
self.infotext = ""
|
||||
|
||||
def setTitle(self,text):
|
||||
self.view.setTitleText(text)
|
||||
@ -95,5 +159,8 @@ class Controller():
|
||||
def changeScreen(self, pageName):
|
||||
self.view.changeFrame(pageName=pageName)
|
||||
|
||||
def getModi(self):
|
||||
return self.modi
|
||||
|
||||
|
||||
|
||||
|
Binary file not shown.
@ -3,189 +3,25 @@ from threading import Thread
|
||||
import time
|
||||
|
||||
class Modell(Thread):
|
||||
PATH_OV = 'meta/dist/designer-Release/openvibe-designer.sh'
|
||||
PATH_FILES = 'Projekte/OpenViBE_visual_BCI-master/openvibe_visual_bci/'
|
||||
|
||||
def __init__(self,c):
|
||||
Thread.__init__(self)
|
||||
self.controller = c
|
||||
self.aktiv= True
|
||||
self.openVibeAktiv = False
|
||||
self.infoText = ''
|
||||
|
||||
def stop(self):
|
||||
print("stop thread")
|
||||
self.aktiv = False
|
||||
|
||||
def setFunktion(self, func, args=None, kwargs=None):
|
||||
self.func = func
|
||||
self.args = args or []
|
||||
self.kwargs = kwargs or {}
|
||||
|
||||
def run(self):
|
||||
print("start thread")
|
||||
#self.aktiv = True
|
||||
t = Thread(target=self.func, args=self.args, kwargs=self.kwargs)
|
||||
t.setDaemon(True)
|
||||
t.start()
|
||||
|
||||
while self.aktiv:
|
||||
time.sleep(0.1)
|
||||
|
||||
pass
|
||||
|
||||
def startCopySpelling(self):
|
||||
print("start copySpelling")
|
||||
self.infoText = 'start copyspelling -- '
|
||||
self.controller.setInfos(self.infoText)
|
||||
self.controller.setTitle("Copy Spelling")
|
||||
path = self.PATH_FILES + 'p300-visual-1-acquisition.xml'
|
||||
process = Popen(['bash', self.PATH_OV, '--play', path, '--no-gui'],
|
||||
stdout=PIPE,
|
||||
universal_newlines=True)
|
||||
self.openVibeAktiv = True
|
||||
while True:
|
||||
output = process.stdout.readline()
|
||||
print(output.strip())
|
||||
x = output.find("schlagwort?")
|
||||
y = output.find("Error")
|
||||
if(x != -1):
|
||||
print("Training finished")
|
||||
process.terminate()
|
||||
self.infoText = self.infoText + 'finished Copyspelling\n'
|
||||
self.controller.setInfos(self.infoText)
|
||||
self.controller.stop("filterXdawn")
|
||||
break
|
||||
elif(y != -1 ):
|
||||
print("Error occured")
|
||||
self.controller.changeScreen("StartPage")
|
||||
self.controller.setInfos(self.infoText + "Fehler beim Copyspelling aufgetaucht\n")
|
||||
process.terminate()
|
||||
self.controller.stop()
|
||||
break
|
||||
|
||||
self.controller.stop()
|
||||
#self.killProzess()
|
||||
#self.controller.filterXdawn()
|
||||
pass
|
||||
|
||||
def trainXDawn(self):
|
||||
print("start training Xdawn")
|
||||
self.infoText = self.infoText + 'start training XDawn -- '
|
||||
self.controller.setInfos(self.infoText)
|
||||
path = self.PATH_FILES + 'p300-visual-2-train-xDAWN.xml'
|
||||
process = Popen(['bash', self.PATH_OV, '--play', path, '--no-gui'],
|
||||
stdout=PIPE,
|
||||
universal_newlines=True)
|
||||
self.openVibeAktiv = True
|
||||
while self.aktiv:
|
||||
output = process.stdout.readline()
|
||||
print(output.strip())
|
||||
x = output.find("Training finished and saved")
|
||||
y = output.find("Error")
|
||||
if(x != -1):
|
||||
print("Training finished")
|
||||
process.terminate()
|
||||
self.infoText = self.infoText + 'finished Training\n'
|
||||
self.controller.setInfos(self.infoText)
|
||||
self.controller.stop("filterClassic")
|
||||
break
|
||||
elif(y != -1 ):
|
||||
print("Error occured")
|
||||
self.controller.changeScreen("StartPage")
|
||||
self.controller.setInfos(self.infoText + "Fehler beim XDawn Training aufgetaucht\n")
|
||||
self.controller.stop()
|
||||
process.terminate()
|
||||
break
|
||||
|
||||
self.controller.stop()
|
||||
|
||||
#self.controller.filterClassic()
|
||||
|
||||
pass
|
||||
|
||||
def trainClassifier(self):
|
||||
print("start training Classifier")
|
||||
self.infoText = self.infoText + "start training with Classifier -- "
|
||||
self.controller.setInfos(self.infoText)
|
||||
|
||||
path = self.PATH_FILES + 'p300-visual-3-train-classifier.xml'
|
||||
process = Popen(['bash', self.PATH_OV, '--play', path, '--no-gui'],
|
||||
stdout=PIPE,
|
||||
universal_newlines=True)
|
||||
self.openVibeAktiv = True
|
||||
while True:
|
||||
output = process.stdout.readline()
|
||||
print(output.strip())
|
||||
x = output.find("schlagwort?")
|
||||
y = output.find("Error")
|
||||
if(x != -1):
|
||||
print("Training finished")
|
||||
self.infoText = self.infoText + 'finished Training\n'
|
||||
self.controller.setInfos(self.infoText)
|
||||
process.terminate()
|
||||
break
|
||||
elif(y != -1 ):
|
||||
print("Error occured")
|
||||
self.controller.changeScreen("StartPage")
|
||||
self.controller.setInfos(self.infoText + "Fehler beim Classifier Training aufgetaucht\n")
|
||||
process.terminate()
|
||||
break
|
||||
|
||||
self.controller.changeScreen("StartPage")
|
||||
self.controller.stop()
|
||||
pass
|
||||
|
||||
def freeSpelling(self):
|
||||
#bei error auch abrechen?
|
||||
print("start freeSpelling")
|
||||
self.infoText = 'start free spelling -- '
|
||||
self.controller.setInfos(self.infoText)
|
||||
path = self.PATH_FILES + 'p300-visual-4-online.xml'
|
||||
process = Popen(['bash', self.PATH_OV, '--play', path, '--no-gui'],
|
||||
stdout=PIPE,
|
||||
universal_newlines=True)
|
||||
self.openVibeAktiv = True
|
||||
while True:
|
||||
output = process.stdout.readline()
|
||||
print(output.strip())
|
||||
y = output.find("Error")
|
||||
x = output.find("Schlagwort")
|
||||
if(x != -1):
|
||||
print("End Spelling")
|
||||
process.terminate()
|
||||
self.infoText = self.infoText + 'finished freespelling\n'
|
||||
self.controller.setInfos(self.infoText)
|
||||
self.controller.changeScreen("StartPage")
|
||||
self.controller.stop()
|
||||
break
|
||||
elif(y != -1 ):
|
||||
print("Error occured")
|
||||
self.controller.changeScreen("StartPage")
|
||||
self.controller.setInfos(self.infoText + "Fehler beim Freespelling aufgetaucht\n")
|
||||
process.terminate()
|
||||
self.controller.stop()
|
||||
break
|
||||
|
||||
self.controller.changeScreen("StartPage")
|
||||
self.controller.stop()
|
||||
pass
|
||||
|
||||
def killProzess(self):
|
||||
if(self.openVibeAktiv):
|
||||
self.openVibeAktiv = False
|
||||
print('start killing')
|
||||
pidOV = 0
|
||||
items = []
|
||||
|
||||
prozesse = Popen(["ps", "-e"], stdout=PIPE).communicate()[0].strip()
|
||||
zeilen = prozesse.split('\n')
|
||||
for z in zeilen:
|
||||
if(z.find("openvibe-design") != -1):
|
||||
z = z.strip()
|
||||
items = z.split(' ')
|
||||
pidOV = items[0]
|
||||
|
||||
#kill -TERM veranlasst dem Prozess sich selbst zu beenden (nicht erzwungen)
|
||||
Popen(["kill", "-TERM", str(pidOV)], stdout=PIPE).communicate()
|
||||
|
||||
|
||||
print("killed openvibe-designer")
|
||||
|
||||
|
||||
|
||||
pass
|
Binary file not shown.
195
Masterarbeit/UIModellTaktil.py
Normal file
195
Masterarbeit/UIModellTaktil.py
Normal file
@ -0,0 +1,195 @@
|
||||
from subprocess import *
|
||||
from threading import Thread
|
||||
import time
|
||||
from UIModell import *
|
||||
|
||||
class ModellTaktil(Modell):
|
||||
|
||||
def __init__(self,c, path_ov, path_files):
|
||||
Thread.__init__(self)
|
||||
Modell.__init__(self, c)
|
||||
self.PATH_FILES = path_files
|
||||
self.PATH_OV = path_ov
|
||||
self.aktiv= True
|
||||
self.openVibeAktiv = False
|
||||
|
||||
def stop(self):
|
||||
print("stop thread")
|
||||
self.aktiv = False
|
||||
|
||||
def setFunktion(self, func, args=None, kwargs=None):
|
||||
self.func = func
|
||||
self.args = args or []
|
||||
self.kwargs = kwargs or {}
|
||||
|
||||
def run(self):
|
||||
print("start thread")
|
||||
#self.aktiv = True
|
||||
t = Thread(target=self.func, args=self.args, kwargs=self.kwargs)
|
||||
t.setDaemon(True)
|
||||
t.start()
|
||||
|
||||
while self.aktiv:
|
||||
time.sleep(0.1)
|
||||
|
||||
|
||||
def startCopySpelling(self):
|
||||
print("start copySpelling")
|
||||
self.controller.resetInfo()
|
||||
self.controller.addInfoText('start copyspelling -- ')
|
||||
self.controller.setTitle("Copy Spelling")
|
||||
path = self.PATH_FILES + 'p300-visual-1-acquisition.xml'
|
||||
process = Popen(['bash', self.PATH_OV, '--play', path, '--no-gui'],
|
||||
stdout=PIPE,
|
||||
universal_newlines=True)
|
||||
self.openVibeAktiv = True
|
||||
while True:
|
||||
output = process.stdout.readline()
|
||||
print(output.strip())
|
||||
x = output.find("schlagwort?")
|
||||
y = output.find("Error")
|
||||
if(x != -1):
|
||||
print("Training finished")
|
||||
process.terminate()
|
||||
self.controller.addInfoText('finished Copyspelling\n')
|
||||
self.controller.stop("filterXdawn")
|
||||
break
|
||||
elif(y != -1 ):
|
||||
print("Error occured")
|
||||
self.controller.changeScreen("StartPage")
|
||||
self.controller.addInfoText("Fehler beim Copyspelling aufgetaucht\n")
|
||||
process.terminate()
|
||||
self.controller.stop()
|
||||
break
|
||||
|
||||
|
||||
self.controller.stop()
|
||||
#self.killProzess()
|
||||
#self.controller.filterXdawn()
|
||||
|
||||
def trainXDawn(self):
|
||||
print("start training Xdawn")
|
||||
self.controller.addInfoText('start training XDawn -- ')
|
||||
path = self.PATH_FILES + 'p300-visual-2-train-xDAWN.xml'
|
||||
#path = 'Projekte/test.xml'
|
||||
process = Popen(['bash', self.PATH_OV, '--play', path, '--no-gui'],
|
||||
stdout=PIPE,
|
||||
universal_newlines=True)
|
||||
self.openVibeAktiv = True
|
||||
while self.aktiv:
|
||||
output = process.stdout.readline()
|
||||
print(output.strip())
|
||||
x = output.find("Training finished and saved")
|
||||
y = output.find("Error")
|
||||
if(x != -1):
|
||||
print("Training finished")
|
||||
process.terminate()
|
||||
self.controller.addInfoText('finished Training\n')
|
||||
self.controller.stop("filterClassic")
|
||||
break
|
||||
elif(y != -1 ):
|
||||
print("Error occured")
|
||||
self.controller.changeScreen("StartPage")
|
||||
self.controller.addInfoText("Fehler beim XDawn Training aufgetaucht\n")
|
||||
self.controller.stop()
|
||||
process.terminate()
|
||||
break
|
||||
|
||||
self.controller.stop()
|
||||
|
||||
#self.controller.filterClassic()
|
||||
|
||||
|
||||
def trainClassifier(self):
|
||||
print("start training Classifier")
|
||||
self.controller.addInfoText("start training with Classifier -- ")
|
||||
|
||||
path = self.PATH_FILES + 'p300-visual-3-train-classifier.xml'
|
||||
process = Popen(['bash', self.PATH_OV, '--play', path, '--no-gui'],
|
||||
stdout=PIPE,
|
||||
universal_newlines=True)
|
||||
self.openVibeAktiv = True
|
||||
counter = 0
|
||||
while True:
|
||||
output = process.stdout.readline()
|
||||
print(output.strip())
|
||||
x = output.find("aka Classifier trainer")
|
||||
accuracy = output.find("Training set accuracy is")
|
||||
y = output.find("Error")
|
||||
if(x != -1):
|
||||
counter = counter +1
|
||||
#counter = 18
|
||||
if(counter >= 17):
|
||||
print("Training finished")
|
||||
self.controller.addInfoText('finished Training\n')
|
||||
process.terminate()
|
||||
self.controller.stop("save")
|
||||
break
|
||||
elif(y != -1 ):
|
||||
print("Error occured")
|
||||
self.controller.changeScreen("StartPage")
|
||||
self.controller.addInfoText("Fehler beim Classifier Training aufgetaucht\n")
|
||||
process.terminate()
|
||||
break
|
||||
elif(accuracy != -1):
|
||||
print("ACCURACY" + output)
|
||||
|
||||
self.controller.changeScreen("StartPage")
|
||||
self.controller.stop()
|
||||
|
||||
def freeSpelling(self):
|
||||
#bei error auch abrechen?
|
||||
print("start freeSpelling")
|
||||
self.controller.resetInfo()
|
||||
self.controller.addInfoText('start free spelling -- ')
|
||||
path = self.PATH_FILES + 'p300-visual-4-online.xml'
|
||||
process = Popen(['bash', self.PATH_OV, '--play', path, '--no-gui'],
|
||||
stdout=PIPE,
|
||||
universal_newlines=True)
|
||||
self.openVibeAktiv = True
|
||||
while True:
|
||||
output = process.stdout.readline()
|
||||
print(output.strip())
|
||||
y = output.find("Error")
|
||||
x = output.find("Schlagwort")
|
||||
if(x != -1):
|
||||
print("End Spelling")
|
||||
process.terminate()
|
||||
self.controller.addInfoText('finished freespelling\n')
|
||||
self.controller.changeScreen("StartPage")
|
||||
self.controller.stop()
|
||||
break
|
||||
elif(y != -1 ):
|
||||
print("Error occured")
|
||||
self.controller.changeScreen("StartPage")
|
||||
self.controller.addInfoText("Fehler beim Freespelling aufgetaucht\n")
|
||||
process.terminate()
|
||||
self.controller.stop()
|
||||
break
|
||||
|
||||
self.controller.changeScreen("StartPage")
|
||||
self.controller.stop()
|
||||
|
||||
def killProzess(self):
|
||||
if(self.openVibeAktiv):
|
||||
self.openVibeAktiv = False
|
||||
print('start killing')
|
||||
pidOV = 0
|
||||
items = []
|
||||
|
||||
prozesse = Popen(["ps", "-e"], stdout=PIPE).communicate()[0].strip()
|
||||
zeilen = prozesse.split('\n')
|
||||
for z in zeilen:
|
||||
if(z.find("openvibe-design") != -1):
|
||||
z = z.strip()
|
||||
items = z.split(' ')
|
||||
pidOV = items[0]
|
||||
|
||||
#kill -TERM veranlasst dem Prozess sich selbst zu beenden (nicht erzwungen)
|
||||
Popen(["kill", "-TERM", str(pidOV)], stdout=PIPE).communicate()
|
||||
|
||||
|
||||
print("killed openvibe-designer")
|
||||
|
||||
|
||||
|
BIN
Masterarbeit/UIModellTaktil.pyc
Normal file
BIN
Masterarbeit/UIModellTaktil.pyc
Normal file
Binary file not shown.
193
Masterarbeit/UIModellVisuell.py
Normal file
193
Masterarbeit/UIModellVisuell.py
Normal file
@ -0,0 +1,193 @@
|
||||
from subprocess import *
|
||||
from threading import Thread
|
||||
import time
|
||||
|
||||
from UIModell import Modell
|
||||
|
||||
class ModellVisuell(Modell):
|
||||
|
||||
def __init__(self,c, path_ov, path_files):
|
||||
Thread.__init__(self)
|
||||
Modell.__init__(self, c)
|
||||
self.PATH_FILES = path_files
|
||||
self.PATH_OV = path_ov
|
||||
self.aktiv= True
|
||||
self.openVibeAktiv = False
|
||||
|
||||
def stop(self):
|
||||
print("stop thread")
|
||||
self.aktiv = False
|
||||
|
||||
def setFunktion(self, func, args=None, kwargs=None):
|
||||
self.func = func
|
||||
self.args = args or []
|
||||
self.kwargs = kwargs or {}
|
||||
|
||||
def run(self):
|
||||
print("start thread")
|
||||
#self.aktiv = True
|
||||
t = Thread(target=self.func, args=self.args, kwargs=self.kwargs)
|
||||
t.setDaemon(True)
|
||||
t.start()
|
||||
|
||||
while self.aktiv:
|
||||
time.sleep(0.1)
|
||||
|
||||
|
||||
def startCopySpelling(self):
|
||||
print("start copySpelling")
|
||||
self.controller.resetInfo()
|
||||
self.controller.addInfoText('start copyspelling -- ')
|
||||
self.controller.setTitle("Copy Spelling")
|
||||
path = self.PATH_FILES + 'p300-visual-1-acquisition.xml'
|
||||
process = Popen(['bash', self.PATH_OV, '--play', path, '--no-gui'],
|
||||
stdout=PIPE,
|
||||
universal_newlines=True)
|
||||
self.openVibeAktiv = True
|
||||
while True:
|
||||
output = process.stdout.readline()
|
||||
print(output.strip())
|
||||
x = output.find("schlagwort?")
|
||||
y = output.find("Error")
|
||||
if(x != -1):
|
||||
print("Training finished")
|
||||
process.terminate()
|
||||
self.controller.addInfoText('finished Copyspelling\n')
|
||||
self.controller.stop("filterXdawn")
|
||||
break
|
||||
elif(y != -1 ):
|
||||
print("Error occured")
|
||||
self.controller.changeScreen("StartPage")
|
||||
self.controller.addInfoText("Fehler beim Copyspelling aufgetaucht\n")
|
||||
process.terminate()
|
||||
self.controller.stop()
|
||||
break
|
||||
|
||||
|
||||
self.controller.stop()
|
||||
#self.killProzess()
|
||||
#self.controller.filterXdawn()
|
||||
|
||||
def trainXDawn(self):
|
||||
print("start training Xdawn")
|
||||
self.controller.addInfoText('start training XDawn -- ')
|
||||
path = self.PATH_FILES + 'p300-visual-2-train-xDAWN.xml'
|
||||
#path = 'Projekte/test.xml'
|
||||
process = Popen(['bash', self.PATH_OV, '--play', path, '--no-gui'],
|
||||
stdout=PIPE,
|
||||
universal_newlines=True)
|
||||
self.openVibeAktiv = True
|
||||
while self.aktiv:
|
||||
output = process.stdout.readline()
|
||||
print(output.strip())
|
||||
x = output.find("Training finished and saved")
|
||||
y = output.find("Error")
|
||||
if(x != -1):
|
||||
print("Training finished")
|
||||
process.terminate()
|
||||
self.controller.addInfoText('finished Training\n')
|
||||
self.controller.stop("filterClassic")
|
||||
break
|
||||
elif(y != -1 ):
|
||||
print("Error occured")
|
||||
self.controller.changeScreen("StartPage")
|
||||
self.controller.addInfoText("Fehler beim XDawn Training aufgetaucht\n")
|
||||
self.controller.stop()
|
||||
process.terminate()
|
||||
break
|
||||
|
||||
self.controller.stop()
|
||||
|
||||
#self.controller.filterClassic()
|
||||
|
||||
|
||||
def trainClassifier(self):
|
||||
print("start training Classifier")
|
||||
self.controller.addInfoText("start training with Classifier -- ")
|
||||
|
||||
path = self.PATH_FILES + 'p300-visual-3-train-classifier.xml'
|
||||
process = Popen(['bash', self.PATH_OV, '--play', path, '--no-gui'],
|
||||
stdout=PIPE,
|
||||
universal_newlines=True)
|
||||
self.openVibeAktiv = True
|
||||
counter = 0
|
||||
while True:
|
||||
output = process.stdout.readline()
|
||||
print(output.strip())
|
||||
x = output.find("aka Classifier trainer")
|
||||
accuracy = output.find("Training set accuracy is")
|
||||
y = output.find("Error")
|
||||
if(x != -1):
|
||||
counter = counter +1
|
||||
#counter = 18
|
||||
if(counter >= 17):
|
||||
print("Training finished")
|
||||
self.controller.addInfoText('finished Training\n')
|
||||
process.terminate()
|
||||
self.controller.stop("save")
|
||||
break
|
||||
elif(y != -1 ):
|
||||
print("Error occured")
|
||||
self.controller.changeScreen("StartPage")
|
||||
self.controller.addInfoText("Fehler beim Classifier Training aufgetaucht\n")
|
||||
process.terminate()
|
||||
break
|
||||
elif(accuracy != -1):
|
||||
print("ACCURACY" + output)
|
||||
|
||||
self.controller.changeScreen("StartPage")
|
||||
self.controller.stop()
|
||||
|
||||
def freeSpelling(self):
|
||||
#bei error auch abrechen?
|
||||
print("start freeSpelling")
|
||||
self.controller.resetInfo()
|
||||
self.controller.addInfoText('start free spelling -- ')
|
||||
path = self.PATH_FILES + 'p300-visual-4-online.xml'
|
||||
process = Popen(['bash', self.PATH_OV, '--play', path, '--no-gui'],
|
||||
stdout=PIPE,
|
||||
universal_newlines=True)
|
||||
self.openVibeAktiv = True
|
||||
while True:
|
||||
output = process.stdout.readline()
|
||||
print(output.strip())
|
||||
y = output.find("Error")
|
||||
x = output.find("Schlagwort")
|
||||
if(x != -1):
|
||||
print("End Spelling")
|
||||
process.terminate()
|
||||
self.controller.addInfoText('finished freespelling\n')
|
||||
self.controller.changeScreen("StartPage")
|
||||
self.controller.stop()
|
||||
break
|
||||
elif(y != -1 ):
|
||||
print("Error occured")
|
||||
self.controller.changeScreen("StartPage")
|
||||
self.controller.addInfoText("Fehler beim Freespelling aufgetaucht\n")
|
||||
process.terminate()
|
||||
self.controller.stop()
|
||||
break
|
||||
|
||||
self.controller.changeScreen("StartPage")
|
||||
self.controller.stop()
|
||||
|
||||
def killProzess(self):
|
||||
if(self.openVibeAktiv):
|
||||
self.openVibeAktiv = False
|
||||
print('start killing')
|
||||
pidOV = 0
|
||||
items = []
|
||||
|
||||
prozesse = Popen(["ps", "-e"], stdout=PIPE).communicate()[0].strip()
|
||||
zeilen = prozesse.split('\n')
|
||||
for z in zeilen:
|
||||
if(z.find("openvibe-design") != -1):
|
||||
z = z.strip()
|
||||
items = z.split(' ')
|
||||
pidOV = items[0]
|
||||
|
||||
#kill -TERM veranlasst dem Prozess sich selbst zu beenden (nicht erzwungen)
|
||||
Popen(["kill", "-TERM", str(pidOV)], stdout=PIPE).communicate()
|
||||
|
||||
|
||||
print("killed openvibe-designer")
|
BIN
Masterarbeit/UIModellVisuell.pyc
Normal file
BIN
Masterarbeit/UIModellVisuell.pyc
Normal file
Binary file not shown.
@ -1,7 +0,0 @@
|
||||
#from PySide import *
|
||||
|
||||
|
||||
class View():
|
||||
def __init__(self):
|
||||
pass
|
||||
|
Binary file not shown.
@ -1,22 +1,35 @@
|
||||
try:
|
||||
from Tkinter import *
|
||||
import tkFileDialog as fd
|
||||
except ImportError:
|
||||
from tkinter import *
|
||||
from tkinter import filedialog as fd
|
||||
|
||||
#from tkinter import font
|
||||
from UIController import *
|
||||
|
||||
|
||||
|
||||
class View(Tk):
|
||||
def __init__(self, c, *args, **kwargs):
|
||||
def __init__(self, c, path_default, *args, **kwargs):
|
||||
Tk.__init__(self, *args, **kwargs)
|
||||
self.controller = c
|
||||
self.title("Taktiles Spelling")
|
||||
self.h = 400
|
||||
self.w = 500
|
||||
self.faktor = [(0.125),(0.625), (0.25)]
|
||||
#self.resizable(height=False, width= False)
|
||||
self.PATH_DEFAULT = path_default
|
||||
self.title("Visuelles Spelling")
|
||||
self.h = 800
|
||||
self.w = 1000
|
||||
self.geometry('{}x{}'.format(self.w,self.h))
|
||||
self.faktor = [(0.0675),(0.7325), (0.2)]
|
||||
#self.resizable(height=False, width= False)
|
||||
self.layout = {
|
||||
"background": "#00001E",
|
||||
"backgroundBtn": "#1C86EE",
|
||||
"fontColor": "#FFFFFF",
|
||||
"backgroundBar": "#00002E",
|
||||
"font": ('Calibri', 25, 'bold'),
|
||||
"fontSmall": ('Calibri', 10, 'bold'),
|
||||
"fontInfo": ('Calibri', 25)
|
||||
}
|
||||
|
||||
self.createTopFrame()
|
||||
self.createMainFrame()
|
||||
@ -40,52 +53,55 @@ class View(Tk):
|
||||
self.container.configure(height=(self.h*self.faktor[1]), width=self.w)
|
||||
for f in self.frames:
|
||||
self.frames[f].configure(height=(self.h*self.faktor[1]), width=self.w)
|
||||
self.frames[f].adjustSize(height=(self.h*self.faktor[1]), width=self.w/2)
|
||||
self.frames[f].adjustSize(height=(self.h*self.faktor[1]), width=self.w)
|
||||
|
||||
|
||||
def onClosing(self):
|
||||
print("closing")
|
||||
self.controller.commandStop()
|
||||
print("destroy")
|
||||
self.destroy()
|
||||
|
||||
|
||||
def createTopFrame(self):
|
||||
self.topFrame = Frame(self, bg="blue", height=50, width=500) #, padx=460, pady=10)
|
||||
self.toplabel = Label(self.topFrame, text="taktilles Buchstabieren")
|
||||
|
||||
self.topFrame.columnconfigure(0, weight=1) # Set weight to row and
|
||||
self.topFrame.rowconfigure(0, weight=1) # column where the widget is
|
||||
self.topFrame = Frame(self, bg=self.layout["backgroundBar"], height=50, width=500)
|
||||
self.changeBtn = Button(self.topFrame, text="Wechsel zu taktilen BCI", command=lambda: self.controller.actionPerformed("wechsel"), height=2, width = 25, font=self.layout["fontSmall"], bg=self.layout["backgroundBtn"], fg=self.layout["fontColor"])
|
||||
self.saveBtn = Button(self.topFrame, text="Auswaehlen der Datei", command=lambda: self.controller.actionPerformed("speicherort"), height=2, width = 25, font=self.layout["fontSmall"], bg=self.layout["backgroundBtn"], fg=self.layout["fontColor"])
|
||||
#self.setBtn = Button(self.topFrame, text="Auswaehlen der Datei", command=lambda: self.controller.actionPerformed("setFile"), height=2, width = 25, font=self.layout["fontSmall"], bg=self.layout["backgroundBtn"], fg=self.layout["fontColor"])
|
||||
self.toplabel = Label(self.topFrame, text="visuelles BCI", font=self.layout["font"], bg=self.layout["backgroundBar"], fg=self.layout["fontColor"], )
|
||||
|
||||
self.topFrame.grid(column=0, row=0)
|
||||
self.topFrame.grid_propagate(0)
|
||||
self.topFrame.pack_propagate(0)
|
||||
self.toplabel.grid()
|
||||
|
||||
self.changeBtn.grid(column=0, row=0, padx=10,pady=5)
|
||||
self.saveBtn.grid(column=1, row=0, padx=10, pady=5)
|
||||
#self.setBtn.grid(column=2, row=0, padx=10, pady=5)
|
||||
self.toplabel.grid(column=2, row=0, padx=100, pady=2)
|
||||
|
||||
def createMainFrame(self):
|
||||
|
||||
self.mainFrame = Frame(self, bg="red", height=250, width=500)
|
||||
self.mainFrame = Frame(self, bg=self.layout["background"], height=250, width=500)
|
||||
self.mainFrame.grid(column=0, row=1)
|
||||
self.mainFrame.pack_propagate(0)
|
||||
|
||||
self.container = Frame(self.mainFrame, bg="cyan", height=250, width=500)
|
||||
self.container = Frame(self.mainFrame, bg=self.layout["background"], height=250, width=500)
|
||||
self.container.pack(side="top", fill="both", expand = True)
|
||||
self.container.pack_propagate(0)
|
||||
self.container.grid_propagate(0)
|
||||
|
||||
self.frames = {}
|
||||
for F in (StartPage, WorkingPage):
|
||||
for F in (StartPage, WorkingPageTaktil, WorkingPageVisuell):
|
||||
page_name = F.__name__
|
||||
frame = F(parent=self.container, controller=self.controller)
|
||||
frame = F(parent=self.container, controller=self.controller, layout=self.layout)
|
||||
self.frames[page_name] = frame
|
||||
frame.grid(row=0, column=0, sticky="nsew")
|
||||
|
||||
self.changeFrame("StartPage")
|
||||
|
||||
def createBottomFrame(self):
|
||||
self.bottomFrame = Frame(self, bg="green", height=100, width=500)
|
||||
self.bottomlabel = Label(self.bottomFrame, text="Hier stehen Infos\nGanz viele", justify='left')
|
||||
|
||||
#self.bottomFrame.columnconfigure(0, weight=1) # Set weight to row and
|
||||
#self.bottomFrame.rowconfigure(0, weight=1) # column where the widget is
|
||||
self.bottomFrame = Frame(self, bg=self.layout["backgroundBar"], height=100, width=500)
|
||||
self.bottomlabel = Label(self.bottomFrame, text="Hier stehen Infos\nGanz viele", justify='left', font=self.layout["fontInfo"], bg=self.layout["backgroundBar"], fg=self.layout["fontColor"])
|
||||
|
||||
self.bottomFrame.grid(column=0, row=2)
|
||||
self.bottomFrame.pack_propagate(0)
|
||||
@ -97,50 +113,90 @@ class View(Tk):
|
||||
self.bottomlabel['text'] = text
|
||||
|
||||
def setTitleText(self,text):
|
||||
self.toplabel['text'] = text
|
||||
self.title(text)
|
||||
self.toplabel["text"] = text
|
||||
|
||||
def setChangeBtnText(self,text):
|
||||
self.changeBtn["text"] = text
|
||||
|
||||
def openfiledialog(self):
|
||||
path = self.PATH_DEFAULT
|
||||
file = fd.askopenfilename(initialdir=path)
|
||||
return file
|
||||
|
||||
def savefiledialog(self):
|
||||
path = self.PATH_DEFAULT
|
||||
file = fd.asksaveasfilename(initialdir=path)
|
||||
return file
|
||||
|
||||
|
||||
class StartPage(Frame):
|
||||
def __init__(self, parent, controller):
|
||||
Frame.__init__(self, parent, height=250, width=500, bg="red")
|
||||
def __init__(self, parent, controller, layout):
|
||||
self.layout = layout
|
||||
|
||||
Frame.__init__(self, parent, height=250, width=500, bg=self.layout["background"])
|
||||
self.grid_propagate(0)
|
||||
self.pack_propagate(0)
|
||||
self.controller = controller
|
||||
|
||||
self.leftFrame = Frame(self, bg="cyan", height=250, width=250)
|
||||
self.rightFrame = Frame(self, bg="blue", height=250, width=250)
|
||||
self.container = Frame(self, bg=self.layout["background"], height=250, width=500)
|
||||
self.btnFrame = Frame(self.container, bg=self.layout["background"], height=250, width=250)
|
||||
|
||||
self.leftFrame.columnconfigure(0, weight=1) # Set weight to row and
|
||||
self.leftFrame.rowconfigure(0, weight=1) # column where the widget is
|
||||
self.leftFrame.grid_propagate(0)
|
||||
self.leftFrame.pack_propagate(0)
|
||||
self.container.columnconfigure(0, weight=1) # Set weight to row and
|
||||
self.container.rowconfigure(0, weight=1) # column where the widget is
|
||||
self.container.grid_propagate(0)
|
||||
self.container.pack_propagate(0)
|
||||
|
||||
self.rightFrame.columnconfigure(0, weight=1) # Set weight to row and
|
||||
self.rightFrame.rowconfigure(0, weight=1) # column where the widget is
|
||||
self.rightFrame.grid_propagate(0)
|
||||
self.rightFrame.pack_propagate(0)
|
||||
self.container.pack()
|
||||
self.btnFrame.grid()
|
||||
|
||||
self.leftFrame.grid(column=0, row=0)
|
||||
self.rightFrame.grid(column=1, row=0)
|
||||
testBtn = Button(self.btnFrame, text="copySpelling", command=lambda: self.controller.actionPerformed("test"), height=6, width = 20, font=self.layout["font"], bg=self.layout["backgroundBtn"], fg=self.layout["fontColor"])
|
||||
testBtn.grid(row=0,column=0, padx=25,pady=25)
|
||||
|
||||
testBtn = Button(self.leftFrame, text="test", command=lambda: self.controller.actionPerformed("test"), height=6, width = 10)
|
||||
testBtn.grid()
|
||||
|
||||
freeSpellingBtn = Button(self.rightFrame, text="freeSpelling", command=lambda: self.controller.actionPerformed("freeSpelling"), height=6, width = 10)
|
||||
freeSpellingBtn.grid()
|
||||
freeSpellingBtn = Button(self.btnFrame, text="freeSpelling", command=lambda: self.controller.actionPerformed("freeSpelling"), height=6, width = 20, font=self.layout["font"], bg=self.layout["backgroundBtn"], fg=self.layout["fontColor"])
|
||||
freeSpellingBtn.grid(row=0, column=1, padx=25,pady=25)
|
||||
|
||||
def adjustSize(self, height, width):
|
||||
self.leftFrame.configure(height=height, width= width)
|
||||
self.rightFrame.configure(height=height, width= width)
|
||||
self.container.configure(height=height, width= width)
|
||||
self.btnFrame.configure(height=(height*4)/5, width= width/2)
|
||||
|
||||
class WorkingPage(Frame):
|
||||
def __init__(self, parent, controller):
|
||||
Frame.__init__(self, parent)
|
||||
class WorkingPageTaktil(Frame):
|
||||
def __init__(self, parent, controller, layout):
|
||||
self.layout = layout
|
||||
|
||||
Frame.__init__(self, parent, height=250, width=500, bg=self.layout["background"])
|
||||
self.controller = controller
|
||||
|
||||
|
||||
self.columnconfigure(0, weight=1) # Set weight to row and
|
||||
self.rowconfigure(0, weight=1) # column where the widget is
|
||||
|
||||
stopBtn = Button(self, text="stop", command=lambda: self.controller.actionPerformed("stop"), height=6, width = 10)
|
||||
stopBtn = Button(self, text="stop", command=lambda: self.controller.actionPerformed("stop"), height=4, width = 15, font=self.layout["font"], bg=self.layout["backgroundBtn"], fg=self.layout["fontColor"])
|
||||
stopBtn.grid()
|
||||
|
||||
def adjustSize(self, height, width):
|
||||
pass
|
||||
|
||||
class WorkingPageVisuell(Frame):
|
||||
def __init__(self, parent, controller, layout):
|
||||
self.layout = layout
|
||||
|
||||
Frame.__init__(self, parent, height=250, width=500, bg=self.layout["background"])
|
||||
self.controller = controller
|
||||
self.grid_propagate(0)
|
||||
self.pack_propagate(0)
|
||||
|
||||
self.windowFrame = Frame(self, height=200, width=500, bg=self.layout["background"])
|
||||
self.windowFrame.grid(column=0, row=0)
|
||||
|
||||
self.buttonFrame = Frame(self, height=200, width=500, bg=self.layout["background"])
|
||||
self.buttonFrame.grid(column=0, row=1)
|
||||
self.buttonFrame.columnconfigure(0, weight=1) # Set weight to row and
|
||||
self.buttonFrame.rowconfigure(0, weight=1) # column where the widget is
|
||||
|
||||
stopBtn = Button(self.buttonFrame, text="stop", command=lambda: self.controller.actionPerformed("stop"), height=1, width = 15, font=self.layout["font"], bg=self.layout["backgroundBtn"], fg=self.layout["fontColor"])
|
||||
stopBtn.grid()
|
||||
|
||||
def adjustSize(self, height, width):
|
||||
self.windowFrame.configure(height=(height*4)/5, width= width)
|
||||
self.buttonFrame.configure(height=(height)/10, width= width)
|
Binary file not shown.
BIN
Masterarbeit/__pycache__/UIController.cpython-39.pyc
Normal file
BIN
Masterarbeit/__pycache__/UIController.cpython-39.pyc
Normal file
Binary file not shown.
BIN
Masterarbeit/__pycache__/UIModell.cpython-39.pyc
Normal file
BIN
Masterarbeit/__pycache__/UIModell.cpython-39.pyc
Normal file
Binary file not shown.
BIN
Masterarbeit/__pycache__/UIModellTaktil.cpython-39.pyc
Normal file
BIN
Masterarbeit/__pycache__/UIModellTaktil.cpython-39.pyc
Normal file
Binary file not shown.
BIN
Masterarbeit/__pycache__/UIModellVisuell.cpython-39.pyc
Normal file
BIN
Masterarbeit/__pycache__/UIModellVisuell.cpython-39.pyc
Normal file
Binary file not shown.
BIN
Masterarbeit/__pycache__/UIViewPySide.cpython-39.pyc
Normal file
BIN
Masterarbeit/__pycache__/UIViewPySide.cpython-39.pyc
Normal file
Binary file not shown.
BIN
Masterarbeit/__pycache__/UIViewTKinter.cpython-39.pyc
Normal file
BIN
Masterarbeit/__pycache__/UIViewTKinter.cpython-39.pyc
Normal file
Binary file not shown.
@ -1,7 +1,8 @@
|
||||
from UIController import *
|
||||
|
||||
PATH_OV = 'meta/dist/designer-Release/openvibe-designer.sh'
|
||||
PATH_FILES = 'Projekte/OpenViBE_visual_BCI-master/openvibe_visual_bci/'
|
||||
pathOVFile = "Projekte/OpenViBE_visual_BCI-master/openvibe_visual_bci/signals/p300-xdawn-train2.ov"
|
||||
PATH_DEFAULT = "Projekte/OpenViBE_visual_BCI-master/openvibe_visual_bci/datasets"
|
||||
|
||||
controller = Controller()
|
||||
|
||||
|
||||
#controller.test()
|
||||
controller = Controller(pathOVFile= pathOVFile, path_ov= PATH_OV, path_files = PATH_FILES, path_default=PATH_DEFAULT)
|
||||
|
@ -1,22 +1,16 @@
|
||||
try:
|
||||
from Tkinter import *
|
||||
except ImportError:
|
||||
from tkinter import *
|
||||
from subprocess import *
|
||||
|
||||
root = Tk()
|
||||
root.geometry('300x200')
|
||||
root.columnconfigure(0, weight=1) # Set weight to row and
|
||||
root.rowconfigure(0, weight=1) # column where the widget is
|
||||
name = "firefox"
|
||||
positionX = 350
|
||||
positionY = 150
|
||||
width = 500
|
||||
height = 400
|
||||
windowID = Popen(["xdotool", "search", "--onlyvisible", "--name", name], stdout=PIPE).communicate()[0].strip()
|
||||
Popen(["xdotool", "windowsize", windowID, str(width), str(height)], stdout=PIPE).communicate()
|
||||
Popen(["xdotool", "windowmove", windowID, str(positionX), str(positionY)], stdout=PIPE).communicate()
|
||||
Popen(["xdotool", "windowactivate", windowID], stdout=PIPE).communicate()[0].strip()
|
||||
|
||||
#windowminimize ums ein fenster klein zu machen
|
||||
|
||||
container = Frame(root, bg='tan') # bg color to show extent
|
||||
container.grid(row=0, column=0) # Grid cell with weight
|
||||
|
||||
# A couple of widgets to illustrate the principle.
|
||||
b1 = Button(container, text='First', width=10)
|
||||
b1.grid()
|
||||
b2 = Button(container, text='second', width=10)
|
||||
b2.grid()
|
||||
|
||||
root.mainloop()
|
||||
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user