Browse Source

Add menu for TactileMode

master
Igor Beloschapkin 4 years ago
parent
commit
af7aa85bb7
2 changed files with 35 additions and 23 deletions
  1. 34
    23
      app.py
  2. 1
    0
      config.ini

+ 34
- 23
app.py View File

@@ -41,14 +41,12 @@ class PythonBCIgui:
# button generation
self.BtacFilter = makeBtn(self, "Filter", "pink", self.btn_tacFilter)

self.BtacCal = makeBtn(self, "Kalibrierung:\nMotoren", "lightgreen", self.btn_tacCal)
self.BtacCalNested = makeBtn(self, "Kalibrierung:\nKategorien", "lightgreen", self.btn_tacCalNested)
self.BtacCal = makeBtn(self, "Kalibrierung", "lightgreen", self.btn_tacCal)
self.BvisCal = makeBtn(self, "Kalibrierung", "lightgreen", self.btn_visCal)

self.Bp300 = makeBtn(self, "P300 Klassifizierung", "orange", self.btn_p300)

self.BtacFree = makeBtn(self, "Freies Buchstabieren:\nMotoren", "lightblue", self.btn_tacFree)
self.BtacFreeNested = makeBtn(self, "Freies Buchstabieren:\nKategorien", "lightyellow", self.btn_tacFreeNested)
self.BtacFree = makeBtn(self, "Freies Buchstabieren", "lightblue", self.btn_tacFree)
self.BvisFree = makeBtn(self, "Freies Buchstabieren", "lightblue", self.btn_visFree)

self.pack_layout()
@@ -59,16 +57,15 @@ class PythonBCIgui:

# KALIBRIERUNGEN ###########################
def btn_tacCal(self):
subprocess.Popen([config['PATH']['bci2000'] + r'\prog\Operator.exe', '--OnConnect', '-LOAD PARAMETERFILE TactileCalibration.prm'])
if config['SETTINGS']['tactilemode'] == 'Motors':
subprocess.Popen([config['PATH']['bci2000'] + r'\prog\Operator.exe', '--OnConnect', '-LOAD PARAMETERFILE TactileCalibration.prm'])
elif config['SETTINGS']['tactilemode'] == 'Nested':
subprocess.Popen([config['PATH']['bci2000'] + r'\prog\Operator.exe', '--OnConnect', '-LOAD PARAMETERFILE TactileCalibrationNested.prm'])
# TODO Throw error if else
subprocess.Popen([config['PATH']['bci2000'] + r'\prog\gUSBampSource.exe', '127.0.0.1'])
subprocess.Popen([config['PATH']['bci2000'] + r'\prog\P3SignalProcessing.exe', '127.0.0.1'])
subprocess.Popen([config['PATH']['bci2000'] + r'\prog\P3Speller.exe', '127.0.0.1'])
# TODO Lock einführen und bei Returnwert Lock öffnen mit tkinter.Button.config(state = tkinter.DISABLED)
def btn_tacCalNested(self):
subprocess.Popen([config['PATH']['bci2000'] + r'\prog\Operator.exe', '--OnConnect', '-LOAD PARAMETERFILE TactileCalibrationNested.prm'])
subprocess.Popen([config['PATH']['bci2000'] + r'\prog\gUSBampSource.exe', '127.0.0.1'])
subprocess.Popen([config['PATH']['bci2000'] + r'\prog\P3SignalProcessing.exe', '127.0.0.1'])
subprocess.Popen([config['PATH']['bci2000'] + r'\prog\P3Speller.exe', '127.0.0.1'])
def btn_visCal(self):
subprocess.Popen([config['PATH']['bci2000'] + r'\prog\Operator.exe', '--OnConnect', '-LOAD PARAMETERFILE gUSBampVisualCalibration.prm'])
subprocess.Popen([config['PATH']['bci2000'] + r'\prog\gUSBampSource.exe', '127.0.0.1'])
@@ -81,12 +78,11 @@ class PythonBCIgui:

# FREESPELL ###############################
def btn_tacFree(self):
subprocess.Popen([config['PATH']['bci2000'] + r'\prog\Operator.exe', '--OnConnect', '-LOAD PARAMETERFILE TactileFree.prm'])
subprocess.Popen([config['PATH']['bci2000'] + r'\prog\gUSBampSource.exe', '127.0.0.1'])
subprocess.Popen([config['PATH']['bci2000'] + r'\prog\P3SignalProcessing.exe', '127.0.0.1'])
subprocess.Popen([config['PATH']['bci2000'] + r'\prog\P3Speller.exe', '127.0.0.1'])
def btn_tacFreeNested(self):
subprocess.Popen([config['PATH']['bci2000'] + r'\prog\Operator.exe', '--OnConnect', '-LOAD PARAMETERFILE TactileFreeNested.prm'])
if config['SETTINGS']['tactilemode'] == 'Motors':
subprocess.Popen([config['PATH']['bci2000'] + r'\prog\Operator.exe', '--OnConnect', '-LOAD PARAMETERFILE TactileFree.prm'])
elif config['SETTINGS']['tactilemode'] == 'Nested':
subprocess.Popen([config['PATH']['bci2000'] + r'\prog\Operator.exe', '--OnConnect', '-LOAD PARAMETERFILE TactileFreeNested.prm'])
# TODO throw error if else
subprocess.Popen([config['PATH']['bci2000'] + r'\prog\gUSBampSource.exe', '127.0.0.1'])
subprocess.Popen([config['PATH']['bci2000'] + r'\prog\P3SignalProcessing.exe', '127.0.0.1'])
subprocess.Popen([config['PATH']['bci2000'] + r'\prog\P3Speller.exe', '127.0.0.1'])
@@ -101,10 +97,8 @@ class PythonBCIgui:
if config['SETTINGS']['paradigm'] == 'Tactile':
self.BtacFilter.pack()
self.BtacCal.pack()
self.BtacCalNested.pack()
self.Bp300.pack()
self.BtacFree.pack()
self.BtacFreeNested.pack()
elif config['SETTINGS']['paradigm'] == 'Visual':
self.BvisCal.pack()
self.Bp300.pack()
@@ -115,11 +109,9 @@ class PythonBCIgui:
# Add ALL your Buttons here
self.BtacFilter.pack_forget()
self.BtacCal.pack_forget()
self.BtacCalNested.pack_forget()
self.BvisCal.pack_forget()
self.Bp300.pack_forget()
self.BtacFree.pack_forget()
self.BtacFreeNested.pack_forget()
self.BvisFree.pack_forget()

# set paths
@@ -129,7 +121,6 @@ config = configparser.ConfigParser()
configPath = pathOrigin + '/config.ini'
config.read(configPath)


# This Function sets the Paradigm to 'Visual'
def setVisual():
if config['SETTINGS']['paradigm'] == 'Visual':
@@ -152,8 +143,19 @@ def setTactile():
app.unpack_layout()
app.pack_layout()

root = tkinter.Tk()
root.title('PythonBCIgui v' + str(__version__))
def setTactileModeMotors():
if config['SETTINGS']['tactilemode'] == 'Motors':
return
else:
config['SETTINGS']['tactilemode'] = 'Motors'
config.write(open(configPath,'w'))

def setTactileModeNested():
if config['SETTINGS']['tactilemode'] == 'Nested':
return
else:
config['SETTINGS']['tactilemode'] = 'Nested'
config.write(open(configPath,'w'))

# This Function sets the BCI2000 Path
def setPathBci2000():
@@ -183,6 +185,7 @@ def setConfigDefault():
config['PATH']['bci2000'] = r'C:\Users\EEG-Gruppe\Desktop\BCI Paket\Paradigmen\Tactile\BCI2000\BCI2000-06-13\BCI2000src'
config['SETTINGS']['paradigm'] = r'Visual'
config['SETTINGS']['hardware'] = r'gUSBamp' # TODO Add gNautilus parameters
config['SETTINGS']['tactilemode'] = r'Motors'
config.write(open(configPath,'w'))
app.Lparadigm.config(text = config['SETTINGS']['paradigm'] + ' BCI')
app.unpack_layout()
@@ -193,6 +196,9 @@ def on_closing():
root.destroy()
# root.quit()

root = tkinter.Tk()
root.title('PythonBCIgui v' + str(__version__))

root.protocol("WM_DELETE_WINDOW", on_closing)

leistenMenu = tkinter.Menu(root)
@@ -214,6 +220,11 @@ pathMenu.add_command(label="BCI2000", command=setPathBci2000)
pathMenu.add_separator()
pathMenu.add_command(label="TactileBCIFilter", command=setPathTactileBCIFilter)

tactileModeMenu = tkinter.Menu(leistenMenu)
leistenMenu.add_cascade(label="Taktiler Modus", menu=tactileModeMenu)
tactileModeMenu.add_command(label="Motoren", command=setTactileModeMotors)
tactileModeMenu.add_command(label="Kategorien", command=setTactileModeNested)

root.config(menu = leistenMenu)

app = PythonBCIgui(root)

+ 1
- 0
config.ini View File

@@ -1,6 +1,7 @@
[SETTINGS]
paradigm = Visual
hardware = gUSBamp
tactilemode = Motors

[PATH]
bci2000 = C:\Users\EEG-Gruppe\Desktop\BCI Paket\Paradigmen\Tactile\BCI2000\BCI2000-06-13\BCI2000src

Loading…
Cancel
Save