function [gdat, dat] = makeSummaryStructure_ave(data,qps) %input: data [Participant, Condition, Value (1=high, 2 = low), Correct, RT] %qps: quantiles %output %gdat - group averaged data %dat - individual data % get quantiles and other summary statistics of the raw data: % put all real data in a handy structure (just copying Donkin & Heathcote (2009) approach): % n contains the trial numbers for each condition, separating error (row 1), correct (row 2) and miss (row 3) % pb contains the number of trials in each quantile bin % q contains the quantile RT values (e.g. the value for the .1 quantile is the timepoint below which 10% of the RTs lie) % p contains the proportion correct for each condition. subjects = unique(data(:,1))'; cond = unique(data(:,2))'; % so the conditions can be labelled as any number val = unique(data(:,3))'; for c=1:length(cond) for s = 1:length(subjects) for v=1:length(val) for ce = 0:2 % error (0) / correct (1) / miss (2) trl = find(data(:,1) ==subjects(s) & data(:,2)==cond(c) & data(:,3)==val(v) & data(:,end-1)==ce); dat.n(ce+1,v,c,s) = length(trl); if ce<2 dat.pb(:,ce+1,v,c,s) = dat.n(ce+1,v,c,s).*diff([0 qps 1])'; if dat.n(ce+1,v,c,s) dat.q(:,ce+1,v,c,s) = quantile(data(trl,end),qps); % First column is error, second column correct else % what if there are no trials of this condition?? dat.q(:,ce+1,v,c,s) = min(data(data(:,1) ==subjects(s),end))+[1:length(qps)]'*(max(data(data(:,1) ==subjects(s),end))-min(data(data(:,1) ==subjects(s),end)))/length(qps); % some default quantiles (cos there may be trials in this condition in the simulation) end end end dat.p(v,c,s) = dat.n(2,v,c,s)/(dat.n(1,v,c,s)+dat.n(2,v,c,s)); end end gdat.n = mean(dat.n, 4); gdat.pb = mean(dat.pb, 5); gdat.q = mean(dat.q, 5); gdat.p = mean(dat.p, 3); end