Archived
96 lines
3.4 KiB
Python
96 lines
3.4 KiB
Python
# --------------------------------------------------------------------------
|
|
# Authors:
|
|
# ------ MATlAB ------
|
|
# Paolo Toffanin <p.toffanin@umcg.nl>, RuG, UMCG, Groningen, NL
|
|
# Jacqueline Libert
|
|
# Leanne Nagels < leanne.nagels@rug.nl >
|
|
# Etienne Gaudrain <etienne.gaudrain@cnrs.fr> - 2017-12-05
|
|
# CNRS, CRNL, Lyon, FR | RuG, UMCG, Groningen, NL
|
|
# ------ Python ------
|
|
# 2020-04-13: Luke Meyer < l.meyer.5@student.rug.nl >
|
|
|
|
# Copyright MRC-CBSU(UK), CNRS(FR), UMCG(NL) and the author(s).
|
|
|
|
# This program is free software: you can redistribute it and/or modify
|
|
# it under the terms of the GNU General Public License as published by
|
|
# the Free Software Foundation, either version 3 of the License, or
|
|
# (at your option) any later version.
|
|
|
|
# This program is distributed in the hope that it will be useful,
|
|
# but WITHOUT ANY WARRANTY
|
|
# without even the implied warranty of
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
# GNU General Public License for more details.
|
|
|
|
# You should have received a copy of the GNU General Public License
|
|
# along with this program. If not, see < http: // www.gnu.org/licenses/>.
|
|
# --------------------------------------------------------------------------
|
|
import os
|
|
import sys
|
|
from scipy.io import savemat
|
|
from emotion_options import expe_options as emotion_options
|
|
from emotion_build_conditions import expe_build_conditions as build_conditions
|
|
from emotion_robot import robot
|
|
|
|
|
|
def main(options, subject, phase, lang, p_exists, ip, port):
|
|
options = {}
|
|
options["subject_name"] = subject
|
|
options["language"] = lang
|
|
options = emotion_options(options)
|
|
if p_exists is not None:
|
|
|
|
res_tracker = os.path.join(
|
|
options["result_path"], '{}_tracker.mat'.format(subject))
|
|
options["res_tracker"] = res_tracker
|
|
if not os.path.exists(res_tracker):
|
|
track = {}
|
|
track["experiment_begin"] = 1
|
|
track["experiments"] = {}
|
|
track["experiments"]["fishy"] = 0
|
|
track["experiments"]["gender"] = 0
|
|
track["experiments"]["emotion"] = 0
|
|
track["experiments"]["crm"] = 0
|
|
|
|
savemat(res_tracker, mdict={"tracker": track})
|
|
|
|
if not p_exists:
|
|
build_conditions(options)
|
|
else:
|
|
res_tracker = os.path.join(
|
|
options["result_path"], '{}_tracker.mat'.format(subject))
|
|
options["res_tracker"] = res_tracker
|
|
if not os.path.exists(res_tracker):
|
|
track = {}
|
|
track["experiment_begin"] = 1
|
|
track["experiments"] = {}
|
|
track["experiments"]["fishy"] = 0
|
|
track["experiments"]["gender"] = 0
|
|
track["experiments"]["emotion"] = 0
|
|
track["experiments"]["crm"] = 0
|
|
|
|
savemat(res_tracker, mdict={"tracker": track})
|
|
|
|
if not os.path.exists(options["res_filename"]):
|
|
msg = "The subject '{}' does not exist. Create it?".format(
|
|
options["subject_name"])
|
|
print msg
|
|
ans = raw_input("(Y/n): ")
|
|
|
|
if ans.lower() == 'y':
|
|
build_conditions(options)
|
|
elif ans.lower() == 'n':
|
|
sys.exit()
|
|
else:
|
|
raise "that is not a valid choice"
|
|
|
|
else:
|
|
msg = "Found {}. Use this file?".format(subject)
|
|
print msg
|
|
ans = raw_input("(Y/n): ")
|
|
|
|
if ans.lower() == 'n':
|
|
sys.exit()
|
|
|
|
robot(ip, port, lang, options, phase)
|