- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我在 PsychoPy 中使用 MovieStim2 播放 3 个视频。不过,我怀疑这个问题源于没有真正理解循环。
我想在参与者按下某个键时跳到下一个视频。我了解当参与者按“q”时我的代码如何退出,但我不确定如何使其在按“b”时跳到下一个视频。这是我当前的代码:
vidNum = 1
for f in ['clip1.mpg', 'clip2.mpg', 'clip3.mpg']:
clock.reset()
#logfile.write("AfterForLoopTime,%s,Video %s\n" % (core.getTime(), vidNum))
# Create your movie stim.
mov = visual.MovieStim2(win, videopath+f,
size=640,
# pos specifies the /center/ of the movie stim location
pos=[0, 0],
flipVert=False,
flipHoriz=False,
) # loop=False - need to comment this to use a loop
# Start the movie stim by preparing it to play
shouldflip = mov.play()
logfile.write("AfterShouldflipLine58,%s, Video %s\n" % (clock.getTime(), vidNum))
while mov.status != visual.FINISHED:
# Only flip when a new frame should be displayed. Can significantly reduce
# CPU usage. This only makes sense if the movie is the only /dynamic/ stim
# displayed.
if shouldflip:
# Movie has already been drawn , so just draw text stim and flip
#text.draw()
win.flip()
else:
# Give the OS a break if a flip is not needed
time.sleep(0.001)
# Drawn movie stim again. Updating of movie stim frames as necessary
# is handled internally.
shouldflip = mov.draw()
# Check for action keys.....
for key in event.getKeys():
if key in ['escape', 'q']:
win.close()
core.quit()
我尝试添加类似于最后一个 block 的代码,该代码在 q 之后退出:
elif key in ['b']:
break
但我意识到我真的想打破这个循环:
for f in ['clip1.mpg', 'clip2.mpg', 'clip3.mpg']:
但是,这似乎也不起作用
for f in ['clip1.mpg', 'clip2.mpg', 'clip3.mpg']:
for key in event.getKeys():
if key in ['b']:
break
最佳答案
您真正想要中断
的循环是:
while mov.status != visual.FINISHED:
我能想到的最简单的方法是,如果用户按下按键,将电影状态设置为 -1
(或 visual.FINISHED
)。
例如:
if key in ['b']:
mov.status = -1
据我所知,这将使您脱离当前的视频。
关于python - 使用 MovieStim2 在 PsychoPy 中基于按键跳过视频(循环),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32082951/
我知道当持续时间固定时,例程将使用防滑计时,如流程中的绿色所示。我的例行程序的持续时间在某种程度上是固定的,因为结束例行程序并不依赖于响应。然而,组件的持续时间确实会改变预定义的量(由电子表格中的条件
我有一个测试 PsychoPy Builder 脚本,我用它来调查一些反直觉的行为。其结构为四个例程: “Init”,不在循环中,“Begin Experiment”中的代码如下: x = 0 y =
我使用 Psychopy/iohub 和 Tobii TX300 眼动仪记录了注视数据。加载 hdf5 文件会在 BinlingualEyeSampleEvent 中显示以下条目: ['experim
已结束。此问题正在寻求书籍、工具、软件库等的推荐。它不满足Stack Overflow guidelines 。目前不接受答案。 我们不允许提出寻求书籍、工具、软件库等推荐的问题。您可以编辑问题,以便
我在通过Psychopy播放自定义音频文件时遇到困难。我收到一条消息说: AttributeError: No audio API found. Try installing pyo 0.6.8+,
我正在尝试编写一段代码,需要依次查看 200 个文本刺激 1 秒,但我无法让我的代码正常工作。 每个刺激都被预定义为一个变量: redkey = visual.textStim(win, "key",
我正在 Psychopy 1.85.1 中实现一个实验。 该任务将在 1920 x 1080 显示器(即 16:9 宽高比)上执行。 而不是通过以下方式更改我使用的每个单独视觉图像对象的大小: som
我使用 Standalone PsychoPy v1.80.03 编写了一个点探测范式。在点探针之后,我需要一个看起来与点探针相同的修改任务。因此,我在第二个任务的构造函数中传递了点探测对象,以重新使
我现在正在 PsychoPy 中闲逛,试图为类项目修改 Sternberg 演示。我希望刺激文本(数字集)以多种颜色显示:比如说,一个数字是红色的,下一个是蓝色的,下一个是棕色的,等等。同一刺激中的多
我在 Windows 7 计算机上使用 Psychopy v1.82.01(编码器 View )来运行 fMRI 实验。我想从并行端口读取数据()(用于记录按钮按下和从扫描仪接收触发器以进行同步)。但
我正在使用 psychopy 在这样的窗口上获取图像: from psychopy import visual window = visual.Window(size= (1000,600), uni
我最近开始学习如何使用 PsychoPy、psychopy.parallel 模块和二进制表示。我希望有人可以让我知道我是否理解正确。 关于 PsychoPy 的 website ,它说这两个函数将引
我需要记录每次试验最后一次移动滚轮的时间。我有针对按键执行此操作的代码(lastTrialTime 变量): lastTime = 0 # setting up to get RT at last
Psychopy 中的纯音以滴答声结束。我怎样才能删除这些点击?在 psychopy 中生成的音调和作为 .wav 导入的音调都有同样的问题。我尝试在使用 Audacity 生成的 .wav 音调中添
我想在同一帧内显示一个包含不同颜色单词的句子。但我见过的所有代码只是改变整个刺激的颜色,而不是其中的一部分......这是我的尝试代码,但失败了 #!/usr/bin/env python2 # -*
我想通过编码在 Pyschopy 上显示一些日语句子,我使用了这样的代码: from Psychopy import visual,core win=visual.Window([400,400])
我正在尝试在我的心理任务中捕捉定时屏幕截图。我有一个固定十字,然后是屏幕左右两侧的 2 张面孔,然后是一个点。我只想要两张脸出现在屏幕上的 1 秒时间段的屏幕截图。例程中有 10 对不同的面孔,例程循
我的代码在这里可以工作,但是我目前的方法效率很低而且很耗时。我正在生成 4 个笛卡尔坐标并将它们附加到列表中。然后我创建 4 个 Psychopy 线对象 (visual.Line) 并从我的坐标列表
我正在致力于将心理实验与 Eyelink 眼球追踪系统相结合。做到这一点的方法似乎是通过 pylink 。不幸的是,我真的不熟悉 pylink,我希望有一个将两者结合起来的实验示例。我还没找到。如果有
这似乎是一个愚蠢的问题,但我无法在文档中找到如何在 PsychoPy Builder 实验中从用户那里获取文本输入。 例如,如果我有一个文本组件来显示消息“你叫什么名字?” 我想获取文本答案(按键回显
我是一名优秀的程序员,十分优秀!