上一篇利用PsychToolBox呈现刺激并收集被试者的反应时间、判断,得到的结果绘图,如下图是我实验140次得到的结果图:
代码:
clear
load mask_result4.mat
%整理数据
Acc = stats.response{2};
RT = stats.response{1};
Mask_pool = stats.Masks(1:length(Acc));%获取140试次对应mask的值
SOA_pool = stats.SOAs(1:length(Acc)); %获取140试次对应SOA的值
type_soa = unique(SOA_pool);
type_mask = unique(Mask_pool); %返回不包含重复项的排序后的数据
for soa = 1:length(type_soa)
for mask = 1:length(type_mask)
idx = find((SOA_pool == type_soa(soa))&(Mask_pool == type_mask(mask)));%取出不同mask下对应试次
%如本次实验中 当mask=1 soa=1时 idx=6 为第六试次;
rt_now = RT(idx); %获取当前试次的反应时间 本次实验时间为0.6789
acc_now = Acc(idx); %获取当前试次的正确与否 本次实验为1
acc_summary(soa,mask) = mean(acc_now); %(soa,mask)对应的准确率数组均值
rt_summary(soa,mask) = mean(rt_now); %(soa,nask)对应的反应时间数据均值
error_rt(soa,mask) = std(rt_now)/sqrt(length(rt_now));%反应时的标准差
end
end
%绘图
figure
soas = [6.1:6.1:24.4000];
subplot(1,2,1);
p1 = plot(soas,acc_summary(:,1),'--k');%绘制虚心
hold on
p2 = plot(soas,acc_summary(:,2),'k');
colors = ['rgbm'];
for i = 1:4
scatter(soas(i),acc_summary(i,:),50,colors(i),"filled");%节点绘制颜色大小为50
%scatter(x,y,sz,c)
%scatter(___,'filled')
end
yline(0.33,'--'); %准确率均值
hold off
legend([p1,p2],{'without mask','with mask'},'Location','best');
ylabel('performance')
xlabel('SOA(ms)')
xticks(soas) %设置x轴坐标点
text(20,0.5,'n=144'); %设置文字
xlim([0,30]); %设置x轴坐标范围
%反映时间绘制
soas = [6.1:6.1:24.4000];
subplot(1,2,2);
p3 = errorbar(soas,rt_summary(:,1),error_rt(:,1),'--k');
%创建 y 中数据的线图,并在每个数据点处绘制一个垂直误差条
%err 中的值确定数据点上方和下方的每个误差条的长度
%errorbar(x,y,neg,pos)
hold on
p4 = errorbar(soas,rt_summary(:,2),error_rt(:,2),'k');
for i = 1:4
scatter(soas(i),rt_summary(i,:),20,colors(i),"filled");
end
hold off
legend([p3,p4],{'with mask','without mask'},'Location','best');
ylabel('RT');
xlabel('SOA(ms)');
xticks(soas);
text(20,0.9,'n=144');
xlim([0,30]);
sgtitle('Joey Now'); %标题
saveas(gca,'wu.png'); %保存图片
mask_result4.mat文件网盘:链接:https://pan.baidu.com/s/1JEIaJqK9PLzsALd1GRvYFA
提取码:xqyq