Browse Source

addFilemanagment

windowsdev
Nicole Weber 3 years ago
parent
commit
7028038643

+ 2
- 0
Masterarbeit/Projekte/OpenViBE_visual_BCI-master/openvibe_visual_bci/datasets/test.md View File

@@ -0,0 +1,2 @@
# OpenViBE_visual_BCI


BIN
Masterarbeit/Projekte/OpenViBE_visual_BCI-master/openvibe_visual_bci/datasets/test.ov View File


BIN
Masterarbeit/Projekte/OpenViBE_visual_BCI-master/openvibe_visual_bci/datasets/test2.ov View File


BIN
Masterarbeit/Projekte/OpenViBE_visual_BCI-master/openvibe_visual_bci/signals/p300-xdawn-train2.ov View File


+ 22
- 7
Masterarbeit/UIController.py View File

@@ -1,6 +1,7 @@
import UIModellVisuell as modelVisuell
import UIModellTaktil as modelsTaktil
import UIViewTKinter as viewTkinter
from shutil import copyfile



@@ -9,6 +10,8 @@ class Controller():
def __init__(self):
self.view = viewTkinter.View(self)
self.modi = "visuellesBCI"
self.pathOVFile = "Projekte/OpenViBE_visual_BCI-master/openvibe_visual_bci/signals/p300-xdawn-train2.ov"
self.infotext = ""

self.commands = {
"copySpelling": self.commandoCopySpelling,
@@ -16,12 +19,13 @@ class Controller():
"freeSpelling": self.commandFreeSpelling,
"test": self.test,
"wechsel": self.wechsel,
"speicherort": self.speicherort
"speicherort": self.setDataset
}

self.nexts = {
"filterXdawn" : self.filterXdawn,
"filterClassic": self.filterClassic
"filterClassic": self.filterClassic,
"save": self.speichern
}

self.pagesTaktil = {
@@ -66,11 +70,17 @@ class Controller():
self.view.setChangeBtnText("Wechsel zu visuellen BCI")
self.modi = "taktilesBCI"

def speicherort(self):
pass
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.file = self.view.savefiledialog()
if(self.modi == "taktilesBCI"):
self.model = modelsTaktil.Modell(self)
elif(self.modi == "visuellesBCI"):
@@ -80,6 +90,7 @@ class Controller():

#wird durch Btn gestartet -> startet copyspelling als thread
def commandoCopySpelling(self):
self.file = self.view.savefiledialog()
if(self.modi == "taktilesBCI"):
self.model = modelsTaktil.Modell(self)
elif(self.modi == "visuellesBCI"):
@@ -116,7 +127,7 @@ class Controller():

def commandStop(self):
if(self.model is not None):
self.setInfos("Action: STOP-Command")
self.addInfoText("Action: STOP-Command")
self.model.stop()
self.model.join()
self.model.killProzess()
@@ -133,8 +144,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)

BIN
Masterarbeit/UIController.pyc View File


+ 15
- 21
Masterarbeit/UIModellTaktil.py View File

@@ -11,7 +11,6 @@ class Modell(Thread):
self.controller = c
self.aktiv= True
self.openVibeAktiv = False
self.infoText = ''
def stop(self):
print("stop thread")
@@ -35,8 +34,8 @@ class Modell(Thread):
def startCopySpelling(self):
print("start copySpelling")
self.infoText = 'start copyspelling -- '
self.controller.setInfos(self.infoText)
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'],
@@ -51,14 +50,13 @@ class Modell(Thread):
if(x != -1):
print("Training finished")
process.terminate()
self.infoText = self.infoText + 'finished Copyspelling\n'
self.controller.setInfos(self.infoText)
self.controller.addInfoText('finished Copyspelling\n')
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")
self.controller.addInfoText("Fehler beim Copyspelling aufgetaucht\n")
process.terminate()
self.controller.stop()
break
@@ -70,8 +68,7 @@ class Modell(Thread):
def trainXDawn(self):
print("start training Xdawn")
self.infoText = self.infoText + 'start training XDawn -- '
self.controller.setInfos(self.infoText)
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'],
@@ -86,14 +83,13 @@ class Modell(Thread):
if(x != -1):
print("Training finished")
process.terminate()
self.infoText = self.infoText + 'finished Training\n'
self.controller.setInfos(self.infoText)
self.controller.addInfoText('finished Training\n')
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.addInfoText("Fehler beim XDawn Training aufgetaucht\n")
self.controller.stop()
process.terminate()
break
@@ -105,8 +101,7 @@ class Modell(Thread):

def trainClassifier(self):
print("start training Classifier")
self.infoText = self.infoText + "start training with Classifier -- "
self.controller.setInfos(self.infoText)
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'],
@@ -125,14 +120,14 @@ class Modell(Thread):
#counter = 18
if(counter >= 17):
print("Training finished")
self.infoText = self.infoText + 'finished Training\n'
self.controller.setInfos(self.infoText)
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.setInfos(self.infoText + "Fehler beim Classifier Training aufgetaucht\n")
self.controller.addInfoText("Fehler beim Classifier Training aufgetaucht\n")
process.terminate()
break
elif(accuracy != -1):
@@ -144,8 +139,8 @@ class Modell(Thread):
def freeSpelling(self):
#bei error auch abrechen?
print("start freeSpelling")
self.infoText = 'start free spelling -- '
self.controller.setInfos(self.infoText)
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,
@@ -159,15 +154,14 @@ class Modell(Thread):
if(x != -1):
print("End Spelling")
process.terminate()
self.infoText = self.infoText + 'finished freespelling\n'
self.controller.setInfos(self.infoText)
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.setInfos(self.infoText + "Fehler beim Freespelling aufgetaucht\n")
self.controller.addInfoText("Fehler beim Freespelling aufgetaucht\n")
process.terminate()
self.controller.stop()
break

BIN
Masterarbeit/UIModellTaktil.pyc View File


+ 31
- 31
Masterarbeit/UIModellVisuell.py View File

@@ -11,7 +11,6 @@ class Modell(Thread):
self.controller = c
self.aktiv= True
self.openVibeAktiv = False
self.infoText = ''
def stop(self):
print("stop thread")
@@ -35,14 +34,14 @@ class Modell(Thread):
def startCopySpelling(self):
print("start copySpelling")
self.infoText = 'start copyspelling -- '
self.controller.setInfos(self.infoText)
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
self.openVibeAktiv = True
while True:
output = process.stdout.readline()
print(output.strip())
@@ -51,17 +50,17 @@ class Modell(Thread):
if(x != -1):
print("Training finished")
process.terminate()
self.infoText = self.infoText + 'finished Copyspelling\n'
self.controller.setInfos(self.infoText)
self.controller.addInfoText('finished Copyspelling\n')
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")
self.controller.addInfoText("Fehler beim Copyspelling aufgetaucht\n")
process.terminate()
self.controller.stop()
break

self.controller.stop()
#self.killProzess()
@@ -69,9 +68,9 @@ class Modell(Thread):
def trainXDawn(self):
print("start training Xdawn")
self.infoText = self.infoText + 'start training XDawn -- '
self.controller.setInfos(self.infoText)
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)
@@ -84,14 +83,13 @@ class Modell(Thread):
if(x != -1):
print("Training finished")
process.terminate()
self.infoText = self.infoText + 'finished Training\n'
self.controller.setInfos(self.infoText)
self.controller.addInfoText('finished Training\n')
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.addInfoText("Fehler beim XDawn Training aufgetaucht\n")
self.controller.stop()
process.terminate()
break
@@ -103,31 +101,37 @@ class Modell(Thread):

def trainClassifier(self):
print("start training Classifier")
self.infoText = self.infoText + "start training with Classifier -- "
self.controller.setInfos(self.infoText)
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
self.openVibeAktiv = True
counter = 0
while True:
output = process.stdout.readline()
print(output.strip())
x = output.find("schlagwort?")
x = output.find("aka Classifier trainer")
accuracy = output.find("Training set accuracy is")
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
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.setInfos(self.infoText + "Fehler beim Classifier Training aufgetaucht\n")
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()
@@ -135,8 +139,8 @@ class Modell(Thread):
def freeSpelling(self):
#bei error auch abrechen?
print("start freeSpelling")
self.infoText = 'start free spelling -- '
self.controller.setInfos(self.infoText)
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,
@@ -150,15 +154,14 @@ class Modell(Thread):
if(x != -1):
print("End Spelling")
process.terminate()
self.infoText = self.infoText + 'finished freespelling\n'
self.controller.setInfos(self.infoText)
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.setInfos(self.infoText + "Fehler beim Freespelling aufgetaucht\n")
self.controller.addInfoText("Fehler beim Freespelling aufgetaucht\n")
process.terminate()
self.controller.stop()
break
@@ -185,7 +188,4 @@ class Modell(Thread):
Popen(["kill", "-TERM", str(pidOV)], stdout=PIPE).communicate()


print("killed openvibe-designer")



print("killed openvibe-designer")

BIN
Masterarbeit/UIModellVisuell.pyc View File


+ 16
- 2
Masterarbeit/UIViewTKinter.py View File

@@ -1,7 +1,9 @@
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 *
@@ -63,8 +65,9 @@ class View(Tk):
def createTopFrame(self):
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="Aenderung des Speicherorts", command=lambda: self.controller.actionPerformed("speicherort"), height=2, width = 25, font=self.layout["fontSmall"], bg=self.layout["backgroundBtn"], fg=self.layout["fontColor"])
self.toplabel = Label(self.topFrame, text="visuelles Buchstabieren", font=self.layout["font"], bg=self.layout["backgroundBar"], 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)
@@ -72,6 +75,7 @@ class View(Tk):

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):
@@ -114,6 +118,16 @@ class View(Tk):
def setChangeBtnText(self,text):
self.changeBtn["text"] = text

def openfiledialog(self):
path = "Projekte/OpenViBE_visual_BCI-master/openvibe_visual_bci/datasets"
file = fd.askopenfilename(initialdir=path)
return file

def savefiledialog(self):
path = "Projekte/OpenViBE_visual_BCI-master/openvibe_visual_bci/datasets"
file = fd.asksaveasfilename(initialdir=path)
return file


class StartPage(Frame):
def __init__(self, parent, controller, layout):

BIN
Masterarbeit/UIViewTKinter.pyc View File


Loading…
Cancel
Save