Ejemplo n.º 1
0
 def setup(self):
     # Make blank experiment
     self.exp = experiment.Experiment()
     # Make blank routine
     self.routine = Routine(name="testRoutine", exp=self.exp)
     self.exp.addRoutine("testRoutine", self.routine)
     self.exp.flow.addRoutine(self.routine, 0)
     # Add loop around routine
     self.loop = TrialHandler(exp=self.exp, name="testLoop")
     self.exp.flow.addLoop(self.loop, 0, -1)
     # Make Mouse component
     self.comp = CodeComponent(exp=self.exp, parentName="testRoutine", name="testCode")
     self.routine.addComponent(self.comp)
Ejemplo n.º 2
0
 def setup(self):
     # Make blank experiment
     self.exp = Experiment()
     # Make blank routine
     self.routine = Routine(name="testRoutine", exp=self.exp)
     self.exp.addRoutine("testRoutine", self.routine)
     self.exp.flow.addRoutine(self.routine, 0)
     # Add loop around routine
     self.loop = TrialHandler(exp=self.exp, name="testLoop")
     self.exp.flow.addLoop(self.loop, 0, -1)
     # Make a rect for when we need something to click on
     self.comp = PolygonComponent(exp=self.exp,
                                  parentName="testRoutine",
                                  name="testPolygon")
     self.routine.addComponent(self.comp)
Ejemplo n.º 3
0
    def __init__(self, prefs=None):
        super(Experiment, self).__init__()
        self.name = ''
        self.filename = ''  # update during load/save xml
        self.flow = Flow(exp=self)  # every exp has exactly one flow
        self.routines = {}
        # get prefs (from app if poss or from cfg files)
        if prefs is None:
            prefs = psychopy.prefs
        # deepCopy doesn't like the full prefs object to be stored, so store
        # each subset
        self.prefsAppDataCfg = prefs.appDataCfg
        self.prefsGeneral = prefs.general
        self.prefsApp = prefs.app
        self.prefsCoder = prefs.coder
        self.prefsBuilder = prefs.builder
        self.prefsPaths = prefs.paths
        # this can be checked by the builder that this is an experiment and a
        # compatible version
        self.psychopyVersion = __version__
        # What libs are needed (make sound come first)
        self.psychopyLibs = [
            'sound', 'gui', 'visual', 'core', 'data', 'event', 'logging',
            'clock'
        ]
        _settingsComp = getComponents(fetchIcons=False)['SettingsComponent']
        self.settings = _settingsComp(parentName='', exp=self)
        # this will be the xml.dom.minidom.doc object for saving
        self._doc = xml.ElementTree()
        self.namespace = NameSpace(self)  # manage variable names

        #  _expHandler is a hack to allow saving data from components not
        # inside a loop. data-saving machinery relies on loops, not worth
        # rewriting. `thisExp` will be an ExperimentHandler when used in
        # the generated script, but its easier to use treat it as a
        # TrialHandler during script generation to avoid effectively
        # duplicating code just to work around any differences
        # in writeRoutineEndCode
        self._expHandler = TrialHandler(exp=self, name='thisExp')
        self._expHandler.type = 'ExperimentHandler'  # true at run-time
        self._expHandler.name = self._expHandler.params['name'].val  # thisExp
        self._compileLoop = True