#!/usr/bin/env python # -*- coding: utf-8 -*- """ This experiment was created using PsychoPy3 Experiment Builder (v3.0.6), on mars 17, 2019, at 19:20 If you publish work using this script please cite the PsychoPy publications: Peirce, JW (2007) PsychoPy - Psychophysics software in Python. Journal of Neuroscience Methods, 162(1-2), 8-13. Peirce, JW (2009) Generating stimuli for neuroscience using PsychoPy. Frontiers in Neuroinformatics, 2:10. doi: 10.3389/neuro.11.010.2008 """ from __future__ import absolute_import, division from psychopy import locale_setup, sound, gui, visual, core, data, event, logging, clock from psychopy.constants import (NOT_STARTED, STARTED, PLAYING, PAUSED, STOPPED, FINISHED, PRESSED, RELEASED, FOREVER) import numpy as np # whole numpy lib is available, prepend 'np.' from numpy import (sin, cos, tan, log, log10, pi, average, sqrt, std, deg2rad, rad2deg, linspace, asarray) from numpy.random import random, randint, normal, shuffle import os # handy system and path functions import sys # to get file system encoding # Ensure that relative paths start from the same directory as this script _thisDir = os.path.dirname(os.path.abspath(__file__)) os.chdir(_thisDir) # Store info about the experiment session psychopyVersion = '3.0.6' expName = 'Derivation_flexion' # from the Builder filename that created this script expInfo = {'participant': '', 'session': '001'} dlg = gui.DlgFromDict(dictionary=expInfo, title=expName) if dlg.OK == False: core.quit() # user pressed cancel expInfo['date'] = data.getDateStr() # add a simple timestamp expInfo['expName'] = expName expInfo['psychopyVersion'] = psychopyVersion # Data file name stem = absolute path + name; later add .psyexp, .csv, .log, etc filename = _thisDir + os.sep + u'data/%s_%s_%s' % (expInfo['participant'], expName, expInfo['date']) # An ExperimentHandler isn't essential but helps with data saving thisExp = data.ExperimentHandler(name=expName, version='', extraInfo=expInfo, runtimeInfo=None, originPath='C:\\Users\\marie\\Documents\\UQAM\\PsychoPy\\MORPHO\\Derivation_flexion_lastrun.py', savePickle=True, saveWideText=True, dataFileName=filename) # save a log file for detail verbose info logFile = logging.LogFile(filename+'.log', level=logging.EXP) logging.console.setLevel(logging.WARNING) # this outputs to the screen, not a file endExpNow = False # flag for 'escape' or other condition => quit the exp # Start Code - component code to be run before the window creation # Setup the Window win = visual.Window( size=[1536, 864], fullscr=True, screen=0, allowGUI=False, allowStencil=False, monitor='testMonitor', color=[0,0,0], colorSpace='rgb', blendMode='avg', useFBO=True, units='height') # store frame rate of monitor if we can measure it expInfo['frameRate'] = win.getActualFrameRate() if expInfo['frameRate'] != None: frameDur = 1.0 / round(expInfo['frameRate']) else: frameDur = 1.0 / 60.0 # could not measure, so guess # Initialize components for Routine "Consignes_Derivation_flexion" Consignes_Derivation_flexionClock = core.Clock() background_Consignes_Derivation_flexion = visual.Rect( win=win, name='background_Consignes_Derivation_flexion', width=(2, 2)[0], height=(2, 2)[1], ori=0, pos=(0, 0), lineWidth=1, lineColor='white', lineColorSpace='rgb', fillColor='white', fillColorSpace='rgb', opacity=1, depth=0.0, interpolate=True) text_Consignes_Derivation_flexion = visual.TextStim(win=win, name='text_Consignes_Derivation_flexion', text="Consignes :\n\nUn mot apparait en haut de l'écran.\n\nIl y a une phrase juste en dessous, mais il manque un mot dedans!\n\nTu dois compléter la phrase en écrivant un mot qui ressemble à celui qui est en haut de l'écran, et qui rend la phrase correcte.\n\nQuand tu as fini d'écrire ton mot, appuie sur Entrée.", font='Arial', pos=(0, 0), height=0.03, wrapWidth=None, ori=0, color='grey', colorSpace='rgb', opacity=1, languageStyle='LTR', depth=-1.0); # Initialize components for Routine "Epreuve_Derivation_flexion" Epreuve_Derivation_flexionClock = core.Clock() background_Derivation_flexion = visual.Rect( win=win, name='background_Derivation_flexion', width=(2, 2)[0], height=(2, 2)[1], ori=0, pos=(0, 0), lineWidth=1, lineColor='white', lineColorSpace='rgb', fillColor='white', fillColorSpace='rgb', opacity=1, depth=0.0, interpolate=True) Mot_Derivation_flexion = visual.TextStim(win=win, name='Mot_Derivation_flexion', text='default text', font='Arial', pos=(0, 0.3), height=0.08, wrapWidth=None, ori=0, color='grey', colorSpace='rgb', opacity=1, languageStyle='LTR', depth=-1.0); inputText = "" Phrase_Derivation_flexion = visual.TextStim(win=win, name='Phrase_Derivation_flexion', text='default text', font='Arial', pos=(0, 0), height=0.05, wrapWidth=None, ori=0, color='grey', colorSpace='rgb', opacity=1, languageStyle='LTR', depth=-4.0); Reponse_Derivation_flexion = visual.TextStim(win=win, name='Reponse_Derivation_flexion', text='default text', font='Arial', pos=(0, -0.1), height=0.05, wrapWidth=None, ori=0, color='red', colorSpace='rgb', opacity=1, languageStyle='LTR', depth=-5.0); # Initialize components for Routine "Consignes_Decomposition" Consignes_DecompositionClock = core.Clock() background_Consignes_Decomposition = visual.Rect( win=win, name='background_Consignes_Decomposition', width=(2, 2)[0], height=(2, 2)[1], ori=0, pos=(0, 0), lineWidth=1, lineColor='white', lineColorSpace='rgb', fillColor='white', fillColorSpace='rgb', opacity=1, depth=0.0, interpolate=True) text_Consignes_Decomposition = visual.TextStim(win=win, name='text_Consignes_Decomposition', text="Consignes :\n\nUn mot apparait en haut de l'écran.\n\nIl y a une phrase juste en dessous, mais il manque un mot dedans!\n\nTu dois compléter la phrase en écrivant un mot qui ressemble à celui qui est en haut de l'écran, et qui rend la phrase correcte.\n\nQuand tu as fini d'écrire ton mot, appuie sur Entrée.", font='Arial', pos=(0, 0), height=0.03, wrapWidth=None, ori=0, color='grey', colorSpace='rgb', opacity=1, languageStyle='LTR', depth=-1.0); # Initialize components for Routine "Epreuve_Decomposition" Epreuve_DecompositionClock = core.Clock() background_Decomposition = visual.Rect( win=win, name='background_Decomposition', width=(2, 2)[0], height=(2, 2)[1], ori=0, pos=(0, 0), lineWidth=1, lineColor='white', lineColorSpace='rgb', fillColor='white', fillColorSpace='rgb', opacity=1, depth=0.0, interpolate=True) Mot_Decomposition = visual.TextStim(win=win, name='Mot_Decomposition', text='default text', font='Arial', pos=(0, 0.3), height=0.08, wrapWidth=None, ori=0, color='grey', colorSpace='rgb', opacity=1, languageStyle='LTR', depth=-1.0); inputText = "" Phrase_Decomposition = visual.TextStim(win=win, name='Phrase_Decomposition', text='default text', font='Arial', pos=(0, 0), height=0.05, wrapWidth=None, ori=0, color='grey', colorSpace='rgb', opacity=1, languageStyle='LTR', depth=-4.0); Reponse_Decomposition = visual.TextStim(win=win, name='Reponse_Decomposition', text='default text', font='Arial', pos=(0, -0.1), height=0.05, wrapWidth=None, ori=0, color='red', colorSpace='rgb', opacity=1, languageStyle='LTR', depth=-5.0); # Create some handy timers globalClock = core.Clock() # to track the time since experiment started routineTimer = core.CountdownTimer() # to track time remaining of each (non-slip) routine # ------Prepare to start Routine "Consignes_Derivation_flexion"------- t = 0 Consignes_Derivation_flexionClock.reset() # clock frameN = -1 continueRoutine = True # update component parameters for each repeat key_resp_Consignes_Derivation_flexion = event.BuilderKeyResponse() # keep track of which components have finished Consignes_Derivation_flexionComponents = [background_Consignes_Derivation_flexion, text_Consignes_Derivation_flexion, key_resp_Consignes_Derivation_flexion] for thisComponent in Consignes_Derivation_flexionComponents: if hasattr(thisComponent, 'status'): thisComponent.status = NOT_STARTED # -------Start Routine "Consignes_Derivation_flexion"------- while continueRoutine: # get current time t = Consignes_Derivation_flexionClock.getTime() frameN = frameN + 1 # number of completed frames (so 0 is the first frame) # update/draw components on each frame # *background_Consignes_Derivation_flexion* updates if t >= 0.0 and background_Consignes_Derivation_flexion.status == NOT_STARTED: # keep track of start time/frame for later background_Consignes_Derivation_flexion.tStart = t background_Consignes_Derivation_flexion.frameNStart = frameN # exact frame index background_Consignes_Derivation_flexion.setAutoDraw(True) # *text_Consignes_Derivation_flexion* updates if t >= 0.0 and text_Consignes_Derivation_flexion.status == NOT_STARTED: # keep track of start time/frame for later text_Consignes_Derivation_flexion.tStart = t text_Consignes_Derivation_flexion.frameNStart = frameN # exact frame index text_Consignes_Derivation_flexion.setAutoDraw(True) # *key_resp_Consignes_Derivation_flexion* updates if t >= 5 and key_resp_Consignes_Derivation_flexion.status == NOT_STARTED: # keep track of start time/frame for later key_resp_Consignes_Derivation_flexion.tStart = t key_resp_Consignes_Derivation_flexion.frameNStart = frameN # exact frame index key_resp_Consignes_Derivation_flexion.status = STARTED # keyboard checking is just starting event.clearEvents(eventType='keyboard') if key_resp_Consignes_Derivation_flexion.status == STARTED: theseKeys = event.getKeys() # check for quit: if "escape" in theseKeys: endExpNow = True if len(theseKeys) > 0: # at least one key was pressed # a response ends the routine continueRoutine = False # check for quit (typically the Esc key) if endExpNow or event.getKeys(keyList=["escape"]): core.quit() # check if all components have finished if not continueRoutine: # a component has requested a forced-end of Routine break continueRoutine = False # will revert to True if at least one component still running for thisComponent in Consignes_Derivation_flexionComponents: if hasattr(thisComponent, "status") and thisComponent.status != FINISHED: continueRoutine = True break # at least one component has not yet finished # refresh the screen if continueRoutine: # don't flip if this routine is over or we'll get a blank screen win.flip() # -------Ending Routine "Consignes_Derivation_flexion"------- for thisComponent in Consignes_Derivation_flexionComponents: if hasattr(thisComponent, "setAutoDraw"): thisComponent.setAutoDraw(False) # the Routine "Consignes_Derivation_flexion" was not non-slip safe, so reset the non-slip timer routineTimer.reset() # set up handler to look after randomisation of conditions etc Loop_Derivation_flexion = data.TrialHandler(nReps=1, method='random', extraInfo=expInfo, originPath=-1, trialList=data.importConditions('Derivation_flexion_epreuve.xlsx'), seed=None, name='Loop_Derivation_flexion') thisExp.addLoop(Loop_Derivation_flexion) # add the loop to the experiment thisLoop_Derivation_flexion = Loop_Derivation_flexion.trialList[0] # so we can initialise stimuli with some values # abbreviate parameter names if possible (e.g. rgb = thisLoop_Derivation_flexion.rgb) if thisLoop_Derivation_flexion != None: for paramName in thisLoop_Derivation_flexion: exec('{} = thisLoop_Derivation_flexion[paramName]'.format(paramName)) for thisLoop_Derivation_flexion in Loop_Derivation_flexion: currentLoop = Loop_Derivation_flexion # abbreviate parameter names if possible (e.g. rgb = thisLoop_Derivation_flexion.rgb) if thisLoop_Derivation_flexion != None: for paramName in thisLoop_Derivation_flexion: exec('{} = thisLoop_Derivation_flexion[paramName]'.format(paramName)) # ------Prepare to start Routine "Epreuve_Derivation_flexion"------- t = 0 Epreuve_Derivation_flexionClock.reset() # clock frameN = -1 continueRoutine = True # update component parameters for each repeat Mot_Derivation_flexion.setText(Mot) key_resp_Derivation_flexion = event.BuilderKeyResponse() theseKeys= key_resp_Derivation_flexion.keys shift_flag = False Phrase_Derivation_flexion.setText(Phrase) # keep track of which components have finished Epreuve_Derivation_flexionComponents = [background_Derivation_flexion, Mot_Derivation_flexion, key_resp_Derivation_flexion, Phrase_Derivation_flexion, Reponse_Derivation_flexion] for thisComponent in Epreuve_Derivation_flexionComponents: if hasattr(thisComponent, 'status'): thisComponent.status = NOT_STARTED # -------Start Routine "Epreuve_Derivation_flexion"------- while continueRoutine: # get current time t = Epreuve_Derivation_flexionClock.getTime() frameN = frameN + 1 # number of completed frames (so 0 is the first frame) # update/draw components on each frame # *background_Derivation_flexion* updates if t >= 0.0 and background_Derivation_flexion.status == NOT_STARTED: # keep track of start time/frame for later background_Derivation_flexion.tStart = t background_Derivation_flexion.frameNStart = frameN # exact frame index background_Derivation_flexion.setAutoDraw(True) # *Mot_Derivation_flexion* updates if t >= 0.0 and Mot_Derivation_flexion.status == NOT_STARTED: # keep track of start time/frame for later Mot_Derivation_flexion.tStart = t Mot_Derivation_flexion.frameNStart = frameN # exact frame index Mot_Derivation_flexion.setAutoDraw(True) # *key_resp_Derivation_flexion* updates if t >= 0.0 and key_resp_Derivation_flexion.status == NOT_STARTED: # keep track of start time/frame for later key_resp_Derivation_flexion.tStart = t key_resp_Derivation_flexion.frameNStart = frameN # exact frame index key_resp_Derivation_flexion.status = STARTED # keyboard checking is just starting win.callOnFlip(key_resp_Derivation_flexion.clock.reset) # t=0 on next screen flip if key_resp_Derivation_flexion.status == STARTED: theseKeys = event.getKeys() # check for quit: if "escape" in theseKeys: endExpNow = True if len(theseKeys) > 0: # at least one key was pressed key_resp_Derivation_flexion.keys.extend(theseKeys) # storing all keys key_resp_Derivation_flexion.rt.append(key_resp_Derivation_flexion.clock.getTime()) n= len(theseKeys) i = 0 while i < n: if (theseKeys[i] == 'return' and inputText != ""): continueRoutine = False break elif theseKeys[i] == 'return': i = 1 + 1 elif theseKeys[i] == 'backspace': inputText = inputText[:-1] i = i + 1 elif theseKeys[i] == 'space': inputText += ' ' i = i + 1 elif theseKeys[i] in ['lshift', 'rshift']: shift_flag = True i = i + 1 else: if len(theseKeys[i]) == 1: if shift_flag: inputText += chr( ord(theseKeys[i]) - ord(' ')) shift_flag = False else: inputText += theseKeys[i] i = i + 1 # *Phrase_Derivation_flexion* updates if t >= 0.0 and Phrase_Derivation_flexion.status == NOT_STARTED: # keep track of start time/frame for later Phrase_Derivation_flexion.tStart = t Phrase_Derivation_flexion.frameNStart = frameN # exact frame index Phrase_Derivation_flexion.setAutoDraw(True) # *Reponse_Derivation_flexion* updates if t >= 0.0 and Reponse_Derivation_flexion.status == NOT_STARTED: # keep track of start time/frame for later Reponse_Derivation_flexion.tStart = t Reponse_Derivation_flexion.frameNStart = frameN # exact frame index Reponse_Derivation_flexion.setAutoDraw(True) if Reponse_Derivation_flexion.status == STARTED: # only update if drawing Reponse_Derivation_flexion.setText(inputText, log=False) # check for quit (typically the Esc key) if endExpNow or event.getKeys(keyList=["escape"]): core.quit() # check if all components have finished if not continueRoutine: # a component has requested a forced-end of Routine break continueRoutine = False # will revert to True if at least one component still running for thisComponent in Epreuve_Derivation_flexionComponents: if hasattr(thisComponent, "status") and thisComponent.status != FINISHED: continueRoutine = True break # at least one component has not yet finished # refresh the screen if continueRoutine: # don't flip if this routine is over or we'll get a blank screen win.flip() # -------Ending Routine "Epreuve_Derivation_flexion"------- for thisComponent in Epreuve_Derivation_flexionComponents: if hasattr(thisComponent, "setAutoDraw"): thisComponent.setAutoDraw(False) # check responses if key_resp_Derivation_flexion.keys in ['', [], None]: # No response was made key_resp_Derivation_flexion.keys=None Loop_Derivation_flexion.addData('key_resp_Derivation_flexion.keys',key_resp_Derivation_flexion.keys) if key_resp_Derivation_flexion.keys != None: # we had a response Loop_Derivation_flexion.addData('key_resp_Derivation_flexion.rt', key_resp_Derivation_flexion.rt) thisExp.addData('inputText', inputText) inputText="" # the Routine "Epreuve_Derivation_flexion" was not non-slip safe, so reset the non-slip timer routineTimer.reset() thisExp.nextEntry() # completed 1 repeats of 'Loop_Derivation_flexion' # get names of stimulus parameters if Loop_Derivation_flexion.trialList in ([], [None], None): params = [] else: params = Loop_Derivation_flexion.trialList[0].keys() # save data for this loop Loop_Derivation_flexion.saveAsExcel(filename + '.xlsx', sheetName='Loop_Derivation_flexion', stimOut=params, dataOut=['n','all_mean','all_std', 'all_raw']) # ------Prepare to start Routine "Consignes_Decomposition"------- t = 0 Consignes_DecompositionClock.reset() # clock frameN = -1 continueRoutine = True # update component parameters for each repeat key_resp_Consignes_Decomposition = event.BuilderKeyResponse() # keep track of which components have finished Consignes_DecompositionComponents = [background_Consignes_Decomposition, text_Consignes_Decomposition, key_resp_Consignes_Decomposition] for thisComponent in Consignes_DecompositionComponents: if hasattr(thisComponent, 'status'): thisComponent.status = NOT_STARTED # -------Start Routine "Consignes_Decomposition"------- while continueRoutine: # get current time t = Consignes_DecompositionClock.getTime() frameN = frameN + 1 # number of completed frames (so 0 is the first frame) # update/draw components on each frame # *background_Consignes_Decomposition* updates if t >= 0.0 and background_Consignes_Decomposition.status == NOT_STARTED: # keep track of start time/frame for later background_Consignes_Decomposition.tStart = t background_Consignes_Decomposition.frameNStart = frameN # exact frame index background_Consignes_Decomposition.setAutoDraw(True) # *text_Consignes_Decomposition* updates if t >= 0.0 and text_Consignes_Decomposition.status == NOT_STARTED: # keep track of start time/frame for later text_Consignes_Decomposition.tStart = t text_Consignes_Decomposition.frameNStart = frameN # exact frame index text_Consignes_Decomposition.setAutoDraw(True) # *key_resp_Consignes_Decomposition* updates if t >= 5 and key_resp_Consignes_Decomposition.status == NOT_STARTED: # keep track of start time/frame for later key_resp_Consignes_Decomposition.tStart = t key_resp_Consignes_Decomposition.frameNStart = frameN # exact frame index key_resp_Consignes_Decomposition.status = STARTED # keyboard checking is just starting event.clearEvents(eventType='keyboard') if key_resp_Consignes_Decomposition.status == STARTED: theseKeys = event.getKeys() # check for quit: if "escape" in theseKeys: endExpNow = True if len(theseKeys) > 0: # at least one key was pressed # a response ends the routine continueRoutine = False # check for quit (typically the Esc key) if endExpNow or event.getKeys(keyList=["escape"]): core.quit() # check if all components have finished if not continueRoutine: # a component has requested a forced-end of Routine break continueRoutine = False # will revert to True if at least one component still running for thisComponent in Consignes_DecompositionComponents: if hasattr(thisComponent, "status") and thisComponent.status != FINISHED: continueRoutine = True break # at least one component has not yet finished # refresh the screen if continueRoutine: # don't flip if this routine is over or we'll get a blank screen win.flip() # -------Ending Routine "Consignes_Decomposition"------- for thisComponent in Consignes_DecompositionComponents: if hasattr(thisComponent, "setAutoDraw"): thisComponent.setAutoDraw(False) # the Routine "Consignes_Decomposition" was not non-slip safe, so reset the non-slip timer routineTimer.reset() # set up handler to look after randomisation of conditions etc Loop_Decomposition = data.TrialHandler(nReps=1, method='random', extraInfo=expInfo, originPath=-1, trialList=data.importConditions('Decomposition_epreuve.xlsx'), seed=None, name='Loop_Decomposition') thisExp.addLoop(Loop_Decomposition) # add the loop to the experiment thisLoop_Decomposition = Loop_Decomposition.trialList[0] # so we can initialise stimuli with some values # abbreviate parameter names if possible (e.g. rgb = thisLoop_Decomposition.rgb) if thisLoop_Decomposition != None: for paramName in thisLoop_Decomposition: exec('{} = thisLoop_Decomposition[paramName]'.format(paramName)) for thisLoop_Decomposition in Loop_Decomposition: currentLoop = Loop_Decomposition # abbreviate parameter names if possible (e.g. rgb = thisLoop_Decomposition.rgb) if thisLoop_Decomposition != None: for paramName in thisLoop_Decomposition: exec('{} = thisLoop_Decomposition[paramName]'.format(paramName)) # ------Prepare to start Routine "Epreuve_Decomposition"------- t = 0 Epreuve_DecompositionClock.reset() # clock frameN = -1 continueRoutine = True # update component parameters for each repeat Mot_Decomposition.setText(Mot) key_resp_Decomposition = event.BuilderKeyResponse() theseKeys=key_resp_Decomposition.keys shift_flag = False Phrase_Decomposition.setText(Phrase) # keep track of which components have finished Epreuve_DecompositionComponents = [background_Decomposition, Mot_Decomposition, key_resp_Decomposition, Phrase_Decomposition, Reponse_Decomposition] for thisComponent in Epreuve_DecompositionComponents: if hasattr(thisComponent, 'status'): thisComponent.status = NOT_STARTED # -------Start Routine "Epreuve_Decomposition"------- while continueRoutine: # get current time t = Epreuve_DecompositionClock.getTime() frameN = frameN + 1 # number of completed frames (so 0 is the first frame) # update/draw components on each frame # *background_Decomposition* updates if t >= 0.0 and background_Decomposition.status == NOT_STARTED: # keep track of start time/frame for later background_Decomposition.tStart = t background_Decomposition.frameNStart = frameN # exact frame index background_Decomposition.setAutoDraw(True) # *Mot_Decomposition* updates if t >= 0.0 and Mot_Decomposition.status == NOT_STARTED: # keep track of start time/frame for later Mot_Decomposition.tStart = t Mot_Decomposition.frameNStart = frameN # exact frame index Mot_Decomposition.setAutoDraw(True) # *key_resp_Decomposition* updates if t >= 0.0 and key_resp_Decomposition.status == NOT_STARTED: # keep track of start time/frame for later key_resp_Decomposition.tStart = t key_resp_Decomposition.frameNStart = frameN # exact frame index key_resp_Decomposition.status = STARTED # keyboard checking is just starting win.callOnFlip(key_resp_Decomposition.clock.reset) # t=0 on next screen flip if key_resp_Decomposition.status == STARTED: theseKeys = event.getKeys() # check for quit: if "escape" in theseKeys: endExpNow = True if len(theseKeys) > 0: # at least one key was pressed key_resp_Decomposition.keys.extend(theseKeys) # storing all keys key_resp_Decomposition.rt.append(key_resp_Decomposition.clock.getTime()) n= len(theseKeys) i = 0 while i < n: if (theseKeys[i] == 'return' and inputText != ""): continueRoutine = False break elif theseKeys[i] == 'return': i = 1 + 1 elif theseKeys[i] == 'backspace': inputText = inputText[:-1] i = i + 1 elif theseKeys[i] == 'space': inputText += ' ' i = i + 1 elif theseKeys[i] in ['lshift', 'rshift']: shift_flag = True i = i + 1 else: if len(theseKeys[i]) == 1: if shift_flag: inputText += chr( ord(theseKeys[i]) - ord(' ')) shift_flag = False else: inputText += theseKeys[i] i = i + 1 # *Phrase_Decomposition* updates if t >= 0.0 and Phrase_Decomposition.status == NOT_STARTED: # keep track of start time/frame for later Phrase_Decomposition.tStart = t Phrase_Decomposition.frameNStart = frameN # exact frame index Phrase_Decomposition.setAutoDraw(True) # *Reponse_Decomposition* updates if t >= 0.0 and Reponse_Decomposition.status == NOT_STARTED: # keep track of start time/frame for later Reponse_Decomposition.tStart = t Reponse_Decomposition.frameNStart = frameN # exact frame index Reponse_Decomposition.setAutoDraw(True) if Reponse_Decomposition.status == STARTED: # only update if drawing Reponse_Decomposition.setText(inputText, log=False) # check for quit (typically the Esc key) if endExpNow or event.getKeys(keyList=["escape"]): core.quit() # check if all components have finished if not continueRoutine: # a component has requested a forced-end of Routine break continueRoutine = False # will revert to True if at least one component still running for thisComponent in Epreuve_DecompositionComponents: if hasattr(thisComponent, "status") and thisComponent.status != FINISHED: continueRoutine = True break # at least one component has not yet finished # refresh the screen if continueRoutine: # don't flip if this routine is over or we'll get a blank screen win.flip() # -------Ending Routine "Epreuve_Decomposition"------- for thisComponent in Epreuve_DecompositionComponents: if hasattr(thisComponent, "setAutoDraw"): thisComponent.setAutoDraw(False) # check responses if key_resp_Decomposition.keys in ['', [], None]: # No response was made key_resp_Decomposition.keys=None Loop_Decomposition.addData('key_resp_Decomposition.keys',key_resp_Decomposition.keys) if key_resp_Decomposition.keys != None: # we had a response Loop_Decomposition.addData('key_resp_Decomposition.rt', key_resp_Decomposition.rt) thisExp.addData('inputText', inputText) inputText="" # the Routine "Epreuve_Decomposition" was not non-slip safe, so reset the non-slip timer routineTimer.reset() thisExp.nextEntry() # completed 1 repeats of 'Loop_Decomposition' # get names of stimulus parameters if Loop_Decomposition.trialList in ([], [None], None): params = [] else: params = Loop_Decomposition.trialList[0].keys() # save data for this loop Loop_Decomposition.saveAsExcel(filename + '.xlsx', sheetName='Loop_Decomposition', stimOut=params, dataOut=['n','all_mean','all_std', 'all_raw']) # these shouldn't be strictly necessary (should auto-save) thisExp.saveAsWideText(filename+'.csv') thisExp.saveAsPickle(filename) logging.flush() # make sure everything is closed down thisExp.abort() # or data files will save again on exit win.close() core.quit()