# read in the input files and display the instructions
experiment.quickInit(logFilename, \
		     RATINGS_STIM_FILENAME, \
		     RATINGS_FILELIST_FILENAME, \
		     visualAngleFilename, \
		     instructions)

########################################
# Add Experiment Handlers              #
########################################

############### Key Handlers ####################

# add a handler that will display the text that the user types
# in the bottom of the screen
experiment.addKeyHandler(TextEntryKeyHandler(experiment))

################## Null Stim Handlers ################

# tell the experiment to give the user a break every time it encounters a null stim
experiment.addNullStimHandler(BreakNullStimHandler(experiment))

################# Trial Finished Handler #################

# set the TrialFinished handler to finish when a response is made
# in this case it's when the user has entered a sentence in TextEntryKeyHandler
experiment.setTrialFinishedHandler(ResponseTrialFinishedHandler(experiment, count=1))

########################################
# Start the Experiment Loop            #
########################################
instructionsText = ''
if validationRun:
	instructionsText = 'In this experiment you will see a series of images that repeat multiple times. There will be a white fixation cross (+) located in the center of the screen. We ask that you maintain focus on the cross at all times. \n\n Your task is to judge whether they are negative, neutral or positive. For negative press the leftmost button with your index finger, for neutral the second button with your middle finger, and for positive the third button with your ring finger. Categorize each image as quickly as you can. Since you will see multiple presentations of eaceh image, it is ok if you change your rating for successive viewings.\n\nPlease let your experimenter know when you are ready to continue...'
else:
 	instructionsText = 'In this experiment you will see a series of images. There will be a white fixation cross (+) located in the center of the screen. We ask that you maintain focus on the cross at all times. \n\n Your task is to judge whether they are negative, neutral or positive. For negative press the leftmost button with your index finger, for neutral the second button with your middle finger, and for positive the third button with your ring finger. Categorize each image as quickly as you can.\n\nPlease let your experimenter know when you are ready to continue...'

# use this function to initialize vision egg, open the log file,
# read in the input files and display the instructions
experiment.quickInit(logFilename, stimFilename, imagesFilename, visualAngleFilename, instructionsText)

########################################
# Add all Experiment handlers          #
########################################

# add a time handler which will turn the stimulus off after 1 second
experiment.addTimeHandler(StimOffTimeHandler(experiment,offTime=1))

# add a handler that will record the inputs from the scanner's 4 Button response box
experiment.addKeyHandler(Scanner4ButtonKeyHandler(experiment))

# tell the experiment that a trial ends after 4 seconds
experiment.setTrialFinishedHandler(TimeTrialFinishedHandler(experiment,seconds=4.0))

########################################
# Start the Experiment Loop            #
########################################

# finally, start the experiment loop which will display
# all the stimuli using the handlers crated above
experiment.runExperiment()
# read in the input files and display the instructions
experiment.quickInit(logFilename, RATINGS_STIM_FILENAME, RATINGS_FILELIST_FILENAME, visualAngleFilename, instructions)

########################################
# Add Experiment Handlers              #
########################################

######## Viewports ######################

# add a viewport that will display the 1 to 9 valence rating scale at the top 
experiment.addViewport(name=VALENCE_SCALE_VIEWPORT)

############### Key Handlers ####################

# add a handler that will log key presses between 1 and 9, the valence rating here
experiment.addKeyHandler(Rate1To9KeyHandler(experiment))

################## Null Stim Handlers ################

# tell the experiment to give the user a break every time it encounters a null stim
experiment.addNullStimHandler(BreakNullStimHandler(experiment))

################# Trial Finished Handler

# set the TrialFinished handler to move one once the user has given a response
# in this case we're using the Rate1To9 key handler for the response
experiment.setTrialFinishedHandler(ResponseTrialFinishedHandler(experiment, count=1))

########################################
# Start the Experiment Loop            #
########################################