circle = visual.Circle(myWin, radius=0.2, edges=32, size=1.0, lineWidth=1.5, contrast=1.0,
opacity=1.0, units='norm', autoDraw=False, autoLog=False, name='circle')for frameN in range(EXP_DURATION):
dt = getEYELINK().getNewestSample() # check for new sample update
if(dt != None):
gaze_position = dt.getRightEye().getGaze()
gazex = float(info['gainX']) * gaze_position[0] + float(info['offsetX'])
gazey = float(info['gainY']) * gaze_position[1] + float(info['offsetY'])
mask.setPos([gazex, gazey])
if (frameN % periodColor) < periodColorOn:
circle.fillColor = "#FF8C00"
circle.lineColor = "#FF8C00"
else:
circle.fillColor = "#FFF8DC"
circle.lineColor = "#FFF8DC"
if (frameN % periodPos) > periodPosRight:
circle.pos=(-0.5,0)
else:
circle.pos=(0.5,0)
if circle.contains([gazex, gazey]):
circle.fillColor = "#7FFF00"
circle.lineColor = "#7FFF00"
circle.radius *= 1.5
mask.draw()
circle.draw()
myWin.flip()
if frameN % 119 == 0:
print gazex, gazey
device.send_message("DIO{0/0}:VALUE=1")
reward = True
if (reward == True) & (frameN % 119 == 110):
device.send_message("DIO{0/0}:VALUE=0")
reward = False
if ((frameN + stimPeriodFrames) % stimPeriodFrames) == 1: #switch stimulation on
time_now0 = datetime.now()
time1 = time_now0.strftime("%H%M%S%f")
getEYELINK().sendMessage('TRIALID %s'%(trial_id));
getEYELINK().sendMessage('StimOn %s' % time1);
device.send_message("DIO{0/1}:VALUE=1")
highA.play()
optogenetics = True
timer = core.CountdownTimer(1)
trial_id +=1
if timer.getTime() <= 0:
time_now1 = datetime.now()
time2 = time_now1.strftime("%H%M%S%f")
getEYELINK().sendMessage('StimOff %s' % time2);
if (optogenetics == True) and ((frameN + stimPeriodFrames) % stimPeriodFrames) == 3: #switch stimulation off
device.send_message("DIO{0/1}:VALUE=0")
optogenetics = False
if event.getKeys(keyList=['escape','q']):
closingMessage.draw()
myWin.flip()
getEYELINK().sendMessage("TRIAL_RESULT -1");
dataFile.close()
fi.stop_eyetracker()
core.wait(0.2)
core.quit() #abort experimentcircle = visual.GratingStim(myWin,tex="sin",mask="gauss",texRes=256,
size=[0.5,0.5], sf=[4,0], ori = 0, name='gabor1')
from pylink import *
import gc
import sys
import os
from psychopy import core, visual, event, sound, data, monitors, gui, logging
from psychopy.tools.filetools import fromFile, toFile
import time, numpy, random, math
from datetime import datetime, timedelta, date
import usb.core #import usb module to control the reward-delivery pump
import usb.util
import daqflex
import Optogen_fixation_info as fi--
You received this message because you are subscribed to the Google Groups "psychopy-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to psychopy-user...@googlegroups.com.
To post to this group, send email to psychop...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/psychopy-users/842994a5-a113-4fca-88bc-51fe8ce8a177%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
-- Jonathan Peirce University of Nottingham http://www.peirce.org.uk
This message and any attachment are intended solely for the addressee and may contain confidential information. If you have received this message in error, please send it back to me, and immediately delete it. Please do not use, copy or disclose the information contained in this message or in any attachment. Any views or opinions expressed by the author of this email do not necessarily reflect the views of the University of Nottingham. This message has been checked for viruses but the contents of an attachment may still contain software viruses which could damage your computer system, you are advised to perform your own checks. Email communications with the University of Nottingham may be monitored as permitted by UK legislation.
mask = visual.RadialStim(win, tex='sqrXsqr', color=[0,90,1], colorSpace='dkl', pos=(0, 0),
units='pix', size=(100,100), mask=[0,0,0,0,0,0,0,1], radialCycles=0,
angularCycles=0, opacity=0.5, contrast=1.0, interpolate=False)from psychopy import visual, event, core
from math import sin, cos
"""ShapeStim can be used to make geometric shapes where you specify the locations of each vertex
relative to some anchor point.
NB for now the fill of objects is performed using glBegin(GL_POLYGON) and that is limited to convex
shapes. With concavities you get unpredictable results (e.g. add a fill colour to the arrow stim below).
To create concavities, you can combine multiple shapes, or stick to just outlines. (If anyone wants
to rewrite ShapeStim to use glu tesselators that would be great!)
"""
win = visual.Window([600,600], monitor='testMonitor', units='norm', waitBlanking=False)
arrowVertices=[ [-0.2,0.05], [-0.2,-0.05], [0.0,-0.05], [0.0,-0.1], [0.2,0], [0.0,0.1], [0.0,0.05] ]
sqrVertices = [ [0.2,-0.2], [-0.2,-0.2], [-0.2,0.2], [0.2,0.2] ]
stim1 = visual.ShapeStim(win,
lineColor='red',
lineWidth=2.0, #in pixels
fillColor=None, #beware, with convex shapes fill colors don't work
vertices=arrowVertices,#choose something from the above or make your own
closeShape=True,#do you want the final vertex to complete a loop with 1st?
pos= [0,0], #the anchor (rotation and vertices are position with respect to this)
interpolate=True,
opacity=0.9,
autoLog=False)#this stim changes too much for autologging to be useful
stim2 = visual.ShapeStim(win,
lineColor='green',
lineWidth=2.0, #in pixels
fillColor=[-0.5,0.5,-0.5], #beware, with convex shapes this won't work
fillColorSpace='rgb',
vertices=sqrVertices,#choose something from the above or make your own
closeShape=True,#do you want the final vertex to complete a loop with 1st?
pos= [0.5,0.5], #the anchor (rotation and vertices are position with respect to this)
interpolate=True,
opacity=0.9,
autoLog=False)#this stim changes too much for autologging to be useful
circle = visual.Circle(win, radius=0.2, edges=32, size=1.0, lineWidth=1.5, contrast=1.0,
fillColor = "#FF8C00", lineColor = "#FF8C00", opacity=1.0, units='norm',
autoDraw=False, autoLog=False, name='circle')
mask = visual.RadialStim(win, tex='sqrXsqr', color=[0,90,1], colorSpace='dkl', pos=(0, 0),
units='pix', size=(100,100), mask=[0,0,0,0,0,0,0,1], radialCycles=0,
angularCycles=0, opacity=0.5, contrast=1.0, interpolate=False)
circle3 = visual.Rect(win, width=100, height=100, lineWidth=1.5, contrast=1.0, opacity=1.0, fillColor = "#FF8C00", pos=(0, -150),
lineColor = "#FF8C00", units='pix', autoDraw=False, autoLog=False)
clock = core.Clock()
periodColor = 20 #period of biphasic color
periodColorOn = 10 #Duty cicle with light color
periodPos = 60 #30 seconds full period of left-right
periodPosRight = 30 #15 seconds at the right side
# beginning of the control loop
for frameN in range(30):
if (frameN % periodColor) > periodColorOn:
print 'yes'
circle.fillColor = "#FF8C00"
circle.lineColor = "#FF8C00"
else:
print 'no'
circle.fillColor = "#FFF8DC"
circle.lineColor = "#FFF8DC"
if (frameN % periodPos) > periodPosRight:
print 'left'
circle.pos=(-0.5,0)
else:
print 'right'
circle.pos=(0.5,0)
mask.draw()
circle.draw()
win.flip()
while True:
stim1.ori += 2 # increment by 2
stim1.draw()
sqrVertices[1] = [ -0.2-sin(clock.getTime())/6.0, -0.2-cos(clock.getTime())/6.0 ]#change one of the vertices
stim2.vertices = sqrVertices
stim2.draw()
circle.draw()
win.flip()
if event.getKeys(keyList=['escape', 'q']):
core.quit()
...
mask = visual.RadialStim(win, tex='sqrXsqr', color=[0,90,1], colorSpace='dkl', pos=(0, 0),
units='pix', size=(100,100), mask=[0,0,0,0,0,0,0,1], radialCycles=0,
angularCycles=0, opacity=0.5, contrast=1.0, interpolate=False)mask.draw()mask = visual.RadialStim(myWin, tex='sqrXsqr', color=[0,90,1], colorSpace='dkl', pos=(0, 0), units='pix', size=(100,100), mask=[0,0,0,0,0,0,0,1], radialCycles=0, angularCycles=0, opacity=0.5, contrast=1.0, interpolate=False)
mov = visual.MovieStim3(myWin, 'somemovie.mp4', size=[1280,1024],
flipVert=False, flipHoriz=False, loop=False)