def __init__(self, name=u'experiment', string=None, pool_folder=None, experiment_path=None, fullscreen=False, auto_response=False, logfile=u'defaultlog.csv', subject_nr=0, workspace=None, resources={}, heartbeat_interval=1): """ desc: Constructor. The experiment is created automatically be OpenSesame and you will generally not need to create it yourself. keywords: name: desc: The name of the experiment. type: [str, unicode] string: desc: A string containing the experiment definition, the name of an OpenSesame experiment file, or `None` to create a blank experiment. type: [str, unicode, NoneType] pool_folder: desc: A specific folder to be used for the file pool, or `None` to use a new temporary folder. type: [str, unicode, NoneType] experiment_path: desc: The path of the experiment file. This is the folder that the experiment is in, not the path to the experiment file. type: str fullscreen: desc: Indicates whether the experiment should be executed in fullscreen. type: bool auto_response: desc: Indicates whether auto-response mode should be enabled. type: bool logfile: desc: The logfile path. type: [unicode, str] subject_nr: desc: The subject number. type: int workspace: desc: A `python_workspace` object to be used for executing custom Python code, or `None` to create a new workspace. type: [python_workspace, NoneType] resources: desc: A dictionary with names as keys and paths as values. This serves as a look-up table for resources. type: dict heartbeat_interval: desc: A heartbeat interval in seconds, or <= 0 to disable heartbeats. type: [int, float] """ self.var = var_store(self) self.pool = file_pool_store(self, folder=pool_folder) self._responses = response_store(self) # The _syntax and items objects may already have been created by # libqtopensesame.experiment. if not hasattr(self, u'_syntax'): self._syntax = syntax(self) if not hasattr(self, u'items'): self.items = item_store(self) if workspace is None: self._python_workspace = python_workspace(self) else: self._python_workspace = workspace self.running = False self.auto_response = auto_response self.heartbeat_interval = heartbeat_interval self.plugin_folder = u'plugins' self._start_response_interval = None self.cleanup_functions = [] self.restart = False self.resources = resources self.paused = False self.output_channel = None # Set default variables self.var.start = u'experiment' self.var.title = self.default_title self.var.bidi = u'no' self.var.round_decimals = 2 self.var.form_clicks = u'no' # In version 2.9.X and before, the sketchpad used 0,0 for the screen # center, whereas scripting items used 0,0 for the top-left. By setting # uniform_coordinates to 'yes', 0,0 is used for the center in all cases. self.var.uniform_coordinates = u'no' # Sound parameters self.var.sound_freq = 48000 self.var.sound_sample_size = -16 # Negative values mean signed self.var.sound_channels = 2 self.var.sound_buf_size = 1024 # Default backend self.var.canvas_backend = u'xpyriment' # Display parameters self.var.width = 1024 self.var.height = 768 self.var.background = u'black' self.var.foreground = u'white' if fullscreen: self.var.fullscreen = u'yes' else: self.var.fullscreen = u'no' # Font parameters self.var.font_size = 18 self.var.font_family = u'mono' self.var.font_italic = u'no' self.var.font_bold = u'no' self.var.font_underline = u'no' # Logfile parameters self._log = None self.logfile = logfile # A list of data files, which may include more than just the OpenSesame # logfile, for example if data is also recorded using some other method. self.data_files = [] # This is some duplication of the option parser in qtopensesame, # but nevertheless keep it so we don't need qtopensesame self.debug = debug.enabled if string is not None: string = self.open(string) item.item.__init__(self, name, self, string) # Default subject info self.set_subject(subject_nr) # Restore experiment path, which is either the full path (including # filename), only the folder, or None. if experiment_path is not None: if os.path.isfile(experiment_path): self.var.experiment_path, self.var.experiment_file = \ self.experiment_path, self.experiment_file = \ os.path.split(experiment_path) else: self.var.experiment_path = self.experiment_path \ = experiment_path
def __init__(self, name=u'experiment', string=None, pool_folder=None, experiment_path=None, fullscreen=False, auto_response=False, logfile=u'defaultlog.csv', subject_nr=0, workspace=None, resources={}, heartbeat_interval=1): """ desc: Constructor. The experiment is created automatically be OpenSesame and you will generally not need to create it yourself. keywords: name: desc: The name of the experiment. type: [str, unicode] string: desc: A string containing the experiment definition, the name of an OpenSesame experiment file, or `None` to create a blank experiment. type: [str, unicode, NoneType] pool_folder: desc: A specific folder to be used for the file pool, or `None` to use a new temporary folder. type: [str, unicode, NoneType] experiment_path: desc: The path of the experiment file. This is the folder that the experiment is in, not the path to the experiment file. type: str fullscreen: desc: Indicates whether the experiment should be executed in fullscreen. type: bool auto_response: desc: Indicates whether auto-response mode should be enabled. type: bool logfile: desc: The logfile path. type: [unicode, str] subject_nr: desc: The subject number. type: int workspace: desc: A `python_workspace` object to be used for executing custom Python code, or `None` to create a new workspace. type: [python_workspace, NoneType] resources: desc: A dictionary with names as keys and paths as values. This serves as a look-up table for resources. type: dict heartbeat_interval: desc: A heartbeat interval in seconds, or <= 0 to disable heartbeats. type: [int, float] """ self.var = var_store(self) self.pool = file_pool_store(self, folder=pool_folder) # The _syntax and items objects may already have been created by # libqtopensesame.experiment. if not hasattr(self, u'_syntax'): self._syntax = syntax(self) if not hasattr(self, u'items'): self.items = item_store(self) if workspace is None: self._python_workspace = python_workspace(self) else: self._python_workspace = workspace self.running = False self.auto_response = auto_response self.heartbeat_interval = heartbeat_interval self.plugin_folder = u'plugins' self._start_response_interval = None self.cleanup_functions = [] self.restart = False self.resources = resources self.paused = False self.output_channel = None # Set default variables self.var.start = u'experiment' self.var.title = u'My Experiment' self.var.bidi = u'no' self.var.round_decimals = 2 self.var.form_clicks = u'no' # In version 2.9.X and before, the sketchpad used 0,0 for the screen # center, whereas scripting items used 0,0 for the top-left. By setting # uniform_coordinates to 'yes', 0,0 is used for the center in all cases. self.var.uniform_coordinates = u'no' # Sound parameters self.var.sound_freq = 48000 self.var.sound_sample_size = -16 # Negative values mean signed self.var.sound_channels = 2 self.var.sound_buf_size = 1024 # Default backend self.var.canvas_backend = u'xpyriment' # Display parameters self.var.width = 1024 self.var.height = 768 self.var.background = u'black' self.var.foreground = u'white' if fullscreen: self.var.fullscreen = u'yes' else: self.var.fullscreen = u'no' # Font parameters self.var.font_size = 18 self.var.font_family = u'mono' self.var.font_italic = u'no' self.var.font_bold = u'no' self.var.font_underline = u'no' # Logfile parameters self._log = None self.logfile = logfile # This is some duplication of the option parser in qtopensesame, # but nevertheless keep it so we don't need qtopensesame self.debug = debug.enabled if string is not None: string = self.open(string) item.item.__init__(self, name, self, string) # Default subject info self.set_subject(subject_nr) # Restore experiment path if experiment_path is not None: self.experiment_path = experiment_path
def __init__(self, name=u'experiment', string=None, pool_folder=None, experiment_path=None, fullscreen=False, auto_response=False, logfile=u'defaultlog.csv', subject_nr=0, workspace=None, resources={}, heartbeat_interval=1): """ desc: Constructor. The experiment is created automatically be OpenSesame and you will generally not need to create it yourself. keywords: name: desc: The name of the experiment. type: [str, unicode] string: desc: A string containing the experiment definition, the name of an OpenSesame experiment file, or `None` to create a blank experiment. type: [str, unicode, NoneType] pool_folder: desc: A specific folder to be used for the file pool, or `None` to use a new temporary folder. type: [str, unicode, NoneType] experiment_path: desc: The path of the experiment file. This is the folder that the experiment is in, not the path to the experiment file. type: str fullscreen: desc: Indicates whether the experiment should be executed in fullscreen. type: bool auto_response: desc: Indicates whether auto-response mode should be enabled. type: bool logfile: desc: The logfile path. type: [unicode, str] subject_nr: desc: The subject number. type: int workspace: desc: A `python_workspace` object to be used for executing custom Python code, or `None` to create a new workspace. type: [python_workspace, NoneType] resources: desc: A dictionary with names as keys and paths as values. This serves as a look-up table for resources. type: dict heartbeat_interval: desc: A heartbeat interval in seconds, or <= 0 to disable heartbeats. type: [int, float] """ self.var = var_store(self) self.pool = file_pool_store(self, folder=pool_folder) self._responses = response_store(self) # The _syntax and items objects may already have been created by # libqtopensesame.experiment. if not hasattr(self, u'_syntax'): self._syntax = syntax(self) if not hasattr(self, u'items'): self.items = item_store(self) if workspace is None: self._python_workspace = python_workspace(self) else: self._python_workspace = workspace self.running = False self.auto_response = auto_response self.heartbeat_interval = heartbeat_interval self.plugin_folder = u'plugins' self._start_response_interval = None self.cleanup_functions = [] self.restart = False self.resources = resources self.paused = False self.output_channel = None self.reset() # Logfile parameters self._log = None self.logfile = logfile # A list of data files, which may include more than just the OpenSesame # logfile, for example if data is also recorded using some other method. self.data_files = [] # This is some duplication of the option parser in qtopensesame, # but nevertheless keep it so we don't need qtopensesame self.debug = debug.enabled if string is not None: string = self.open(string) item.item.__init__(self, name, self, string) # Default subject info self.set_subject(subject_nr) # Fullscreen needs to be set after the experiment has been parsed from # script, otherwise it will be overridden by the script. self.var.fullscreen = u'yes' if fullscreen else u'no' # Restore experiment path, which is either the full path (including # filename), only the folder, or None. if experiment_path is not None: if os.path.isfile(experiment_path): self.var.experiment_path, self.var.experiment_file = \ self.experiment_path, self.experiment_file = \ os.path.split(experiment_path) else: self.var.experiment_path = self.experiment_path \ = experiment_path