python-3.x - 在 PsychoPy 中生成一个精确定时的扩张圈
问题描述
使用 PsychoPy,我正在尝试编写一个简单的脚本来生成一个扩大的圆圈:
1) 在 250 毫秒内将视角从 2 度扩展到 20 度。
2) 在 20 度再保持 250 毫秒。
3) 重复 n 次,重复之间的刺激间隔为 500 ms(空白,灰屏)。
到目前为止我的 Python 代码:
from psychopy import visual, core, event
# Define the window/background.
win=visual.Window([800,600],monitor="testMonitor",units="deg")
# Setting up some variables: I'm not sure how best to use them:
# Number of epochs (repetitions)
EPOCH=15
# Stimulus initial size
INIT_RAD=2
# Stimulus end size
END_RAD=10
# Duration of expansion
EXPANSION_MS=250
# Hold duration
HOLD_TIME_MS=250
# ISI duration
ISI_MS=500
# Time-to-frame conversion assuming a 60Hz FR and RR
FRAMES=int((60*EXPANSION_MS)/1000)
print(FRAMES)
# Define the stimulus
circle=visual.Circle(win,radius=1,edges=1000,fillColor='black',lineColor='black')
for e in range(EPOCH):
for f in range(FRAMES):
while circle.radius<10:
circle.radius+=1
circle.draw()
win.flip()
# for f in range(FRAMES): # Doesn't seem to work - takes much longer than 250 ms.
# circle.radius=20
# circle.draw()
# win.flip()
print(circle.radius)
circle.radius=1
# Get keys to quit.
if len(event.getKeys())>0:
event.clearEvents()
win.close()
我对 Python 还是很陌生,如果有人能提供一些建议,我将不胜感激。
解决方案
推荐阅读
- python - Python 子进程从 Node.js 父进程遍历标准输入
- python - Python - Outlook 没有看到今天的电子邮件
- r - 如何根据中心的不同绝对值向雷达图添加颜色渐变
- python-3.x - matplotlib 动画函数需要一个不需要的参数
- websocket - 如何让 Netty 服务/接受来自不同端口上不同服务器(“节点”)上的 web 应用程序的 websocket
- json - 使用 jq,如何根据对象属性的值将 JSON 对象流拆分为单独的文件?
- java - 具有多个构造函数的 Java 改造类与多个类
- c++ - C++ 似乎正在将我的十六进制微不足道的零变成 Fs
- python - 如何摆脱 f 字符串中的空格?
- assembly - 汇编程序给了我段错误