PsychoPy:"Conditional" 但从二维列表中随机选择

PsychoPy: "Conditional" but random selection from list across two dimensions

在我的实验中,我展示了在两个维度上不同的图像(面孔):面孔身份和情感

有5张脸表现出5种不同的情绪;总共制作 25 个独特的刺激。这些只需要呈现一次(因此 25 次试验)。

在我展示其中一张脸后,下一张脸必须在情感或身份上有所不同,而在另一张上相同。

示例:

Face 1, emotion 1 -> face 3, emotion 1 -> face 3, emotion 4 -> ... etc.

1:心理学能胜任这项任务吗?到目前为止,除了一些数据记录代码外,我主要使用构建器,但我很乐意使用编码器获得更多经验。

我的预感是我需要在试验列表中添加两列,一列用于身份,一列用于情感。然后以某种方式使用 getEarlierTrial 调用,但此时我几乎迷路了。

2:有人愿意给我指明正确的方向吗?

非常感谢。

这在 Builder 的正常操作模式下很难实现,即从固定的条件列表中驱动试验。虽然行的顺序可以在受试者之间随机化,但列之间的值配对保持不变。

这个问题的标准答案是您在上面的评论中提到的:在代码中,在每个实验开始时随机播放条件文件,因此每个受试者本质上都是由一个独特的条件文件驱动的试验。

你似乎很乐意在 Matlab 中做这件事。那会很好,因为这些东西甚至可以在 PsychoPy 启动之前完成。但它也可以很容易地用 Python 代码实现。这样你就可以在 PsychoPy 中做任何事情,在这种情况下就没有必要放弃 Builder。您只需在定制条件文件的实验开始时将带有一些代码的代码组件插入 运行。

您需要创建三个列表,而不是两个,即您还需要一个伪随机选择列表,以便在每次试验中交替保留面部或情感:如果您完全随机地执行此操作,您会变得不平衡,并在另一个属性之前耗尽一个属性。

from numpy.random import shuffle

# make a list of 25 dictionaries of unique face/emotion pairs:
pairsList = []
for face in ['1', '2', '3', '4', '5']:
    for emotion in ['1', '2', '3', '4', '5']:
        pairsList.append({'faceNum': face, 'emotionNum': emotion})
shuffle(pairsList)

# a list of whether to alternate between preserving face or emotion across trials:
attributes = ['faceNum', 'emotionNum'] * 12 # length 24
shuffle(attributes) 

# need to create an initial selection before cycling though the 
# next 24 randomised but balanced choices:
pair = pairsList.pop()
currentFace = pair['faceNum']
currentEmotion = pair['emotionNum']
images = ['face_' + currentFace + '_emotion_' + currentEmotion + '.jpg']

for attribute in attributes:
    if attribute == 'faceNum':
        selection = currentFace
    else:
        selection = currentEmotion

    # find another pair with the same selected attribute:
    for pair in pairsList:

        if pair[attribute] == selection:
            # store the combination for this trial:
            currentFace = pair['faceNum']
            currentEmotion = pair['emotionNum']
            images.append('face_' + currentFace + '_emotion_' + currentEmotion + '.jpg')

            # remove this combination so it can't be used again
            pairsList.remove(pair)

images.reverse()
print(images)

然后只需将 images 列表写入单列 .csv 文件以用作条件文件。

记得将 Builder 中的循环设置为固定顺序,而不是随机顺序,因为列表本身内置了随机顺序。