做实验的时候一种条件下一般会多个trials,我们不可能把每一个刺激的呈现过程都写一遍,会烦死的。过程一样,内容不同,用循环就变得非常简单了。
比如上次我们对一张图片做等级评定,评定它好不好看,喜欢程度如何。现在我有一组图片,都要做评定,怎么让它循环呢?
把前次的程序复制过来,作为这次的起始代码:
#!/usr/bin/env python2
# -*- coding: utf-8 -*-
#示例4
'''
等级评定
'''
#载入所需要的库
from psychopy import visual, core, event
#创建窗口
win = visual.Window(fullscr = False, size = (1000,600),
color = (-1.0,-1.0,-1.0), units = 'norm', monitor = 'testMonitor')
#评定内容
pic = visual.ImageStim(win, image = 'test_1.jpg', pos = (0.0,0.4))
item = visual.TextStim(win, text = u'', pos = (0.0,-0.1))
#量表
scale_1 = visual.RatingScale(win, choices = [u'ugly',u'WTH',u'nice'], pos = (0.0,-0.6))
scale_2 = visual.RatingScale(win, scale = u'1=非常不喜欢 . . . . . . . . . . . 7=非常喜欢',
low =1, high = 7