def initWindow(self): # self.pp.setData(self.test_start) # something related to frame buffer, still trying to figure out what it is ... # visual.useFBO=True #if available (try without for comparison) # improve inter frame interval stability by changing the process priority if self.process_priority == 'normal': pass elif self.process_priority == 'high': core.rush(True) elif self.process_priority == 'realtime': # Only makes a diff compared to 'high' on Windows. core.rush(True, realtime=True) else: print 'Invalid process priority:', self.process_priority, "Process running at normal." self.process_priority = 'normal' self.win = visual.Window(fullscr=True, size=self.win_size, allowGUI=False, screen=0, monitor='testMonitor', color=self.bgcolor) self.win.setRecordFrameIntervals(True) # arise 'warning' level message if inter frame interval exceeds tolerance of 0.05ms self.win._refreshThreshold = 1 / 60.0 + 0.05 logging.console.setLevel(logging.WARNING)
def run_instructions(instruct_schedule_file, g): #instructions from schedule file along with audio core.rush(True) directory = os.path.dirname(instruct_schedule_file) fin = open(instruct_schedule_file, 'r') lines = fin.readlines() fin.close() slides = [] for i in lines: slides.append(i.split(',')) isounds = load_inst_sounds(slides, directory, g) i = 0 while i < len(slides): i = max( i + do_one_slide(slides[i], isounds[i], directory, g), 0 ) #do_one_slide may increment or decrement i, depending on whether session_params['right'] or session_params['left'] is pressed--don't let them go back on the first slide core.rush(False)
def accelerateComputer(slowFast, process_priority, disable_gc): # process_priority = 'normal' 'high' or 'realtime' if slowFast: if process_priority == 'normal': pass elif process_priority == 'high': core.rush(True) elif process_priority == 'realtime': # Only makes a diff compared to 'high' on Windows. core.rush(True, realtime = True) else: print('Invalid process priority:',process_priority,"Process running at normal.") process_priority = 'normal' if disable_gc: gc.disable() if slowFast==0: #turn off the speed-up if disable_gc: gc.enable() core.rush(False)
#the ability to set the psychopy experiment runtime process priority #and disable python garbage collection to see if either influences #the precision of your frame flips. import gc, numpy from psychopy import visual, logging, core, event nIntervals = 500 visual.useFBO = True #if available (try without for comparison) disable_gc = False process_priority = 'normal' # 'high' or 'realtime' if process_priority == 'normal': pass elif process_priority == 'high': core.rush(True) elif process_priority == 'realtime': # Only makes a diff compared to 'high' on Windows. core.rush(True, realtime=True) else: print 'Invalid process priority:', process_priority, "Process running at normal." process_priority = 'normal' if disable_gc: gc.disable() import matplotlib matplotlib.use('Qt4Agg') #change this to control the plotting 'back end' import pylab win = visual.Window([1280, 1024],
for SOA in SOA_list: corrected_SOA = SOA - 1 #correct for 10ms audio lag trial_count += 1 fixation.draw() win.flip() #trigger fixation start here #jitter initial fixation jitter = random.randint(100, 150) for frameN in range(jitter): fixation.draw() win.flip() core.rush(True) #give psychopy priority during stimulus presentation fixation.draw() win.flip() if corrected_SOA < 0: #auditory then visual #beep beep.play() #SOA for frameN in range(-1 * corrected_SOA): fixation.draw() win.flip() #flash
""" from __future__ import division import gc, numpy from psychopy import visual, logging, core, event nIntervals = 500 visual.useFBO = True # if available (try without for comparison) disable_gc = False process_priority = 'normal' # 'high' or 'realtime' if process_priority == 'normal': pass elif process_priority == 'high': core.rush(True) elif process_priority == 'realtime': # Only makes a diff compared to 'high' on Windows. core.rush(True, realtime=True) else: print 'Invalid process priority:', process_priority, "Process running at normal." process_priority = 'normal' if disable_gc: gc.disable() import matplotlib matplotlib.use('Qt4Agg') # change this to control the plotting 'back end' import pylab win = visual.Window([1280, 1024], fullscr=True, allowGUI=False, waitBlanking=True)
from __future__ import division from psychopy import visual, data, event, core, gui, parallel import time import numpy as np from numpy import random import os import math import pandas send_eegtriggers = False trigger_on_time = .04 core.rush(True) if send_eegtriggers: # Address for the parallel port in the biosemi setup parallel.setPortAddress(0xC020) # this sends the trigger, usually initialize it at zero # then the trigger, then a wait-function for e.g. 30 ms, and zero again parallel.setData(0) core.wait(trigger_on_time) #define amounts of everything Ngratings = 2 Nresp = 2 Nfeedback = 2 Nrules = 2 Nparts = 8 #per block Nblocks = 2 mean_switch = 30 std_switch = 15 #range around mean switch