% Script to perform simulations of the three models compared in the paper % "Consistent patterns of distractor effects during decision making", by % Chau et al. % The user can define the model used to simulate the behavioral data on % line 21. Requires 2 additional functions: fim3d_dyn.m and % fim3d_dyn_dual.m. % Proof-read and commented by Alizee Lopez-Persem, 12/2019 % Written by Bolton K. H. Chau, 10/2019. clear close all clc tic %% VARIABLE DEFINITIONS % Model to simulate run_model='dual_route'; % number of simulations iter = 5000; % Define options vs = 3:.2:5; % value sum HV+LV vd = 0.6:.2:2; % value difference HV-LV dhv = -1.2:0.4:4.8; % D-HV [v1,v2,v3] = ndgrid(vs,vd,dhv); % generate all value combinations vals = round([(v1(:)+v2(:))/2 ... (v1(:)-v2(:))/2 ... v3(:)+(v1(:)+v2(:))/2],2); % to get the values of HV, LV and D if ~all(vals(:)>0) error('vals<=0') end %% SIMULATIONS % Run simulations switch run_model case 'mutual_inhibition' param=[1.3 1]; % drift rate and noise model=@fim3d_dyn; [accuracy,RT,params_all]=model(param,vals,iter); case 'div_norm' param=[5.5 0.6]; % drift rate and noise model=@fim3d_dyn; [accuracy,RT,params_all]=model(param,vals(:,[1 2])./repmat(sum(vals,2),1,2),iter); case 'dual_route' param=[1.2 0.8;0.8 0.8]; % drift rate and noise; first row=mutual inhition; second row=divisive normalization model=@fim3d_dyn_dual; [accuracy,RT,params_all]=model(param,vals,iter); end % Stock info of simulation params_all.model = run_model; x = length(fieldnames(params_all)); params_all = orderfields(params_all,[x 1:x-1]); % results of simulations vals_all = repmat(vals,iter,1); accuracy = accuracy(:); RT = RT(:); %% STATISTICS [b,~,stats]=glmfit(normalise([vals_all(:,1)-vals_all(:,2) vals_all(:,3)-vals_all(:,1) normalise(vals_all(:,1)-vals_all(:,2)).*normalise(vals_all(:,3)-vals_all(:,1))]),accuracy(:),'binomial'); %% FIGURES % Compute D-HV and HV-LV dhv = unique(round(vals_all(:,3)-vals_all(:,1),2))'; hvlv = unique(round(vals_all(:,1)-vals_all(:,2),2))'; % Bin accuracy for matrix figures (1b, 1f or 1j): for x=1:length(dhv) for y=1:length(hvlv) % find indices to include in the bins ind = find(round(vals_all(:,3)-vals_all(:,1),2)==dhv(x) & round(vals_all(:,1)-vals_all(:,2),2)==hvlv(y)); acc_bin(y,x) = nanmean(accuracy(ind,1)); end end figure; % matrix figures (1b, 1f or 1j) subplot(2,5,[1 2 6 7]) imagesc(acc_bin); set(gca,'YDir','normal');colorbar; set(gca,'XTick',[1:3:13],'XTickLabel',cellstr(num2str(dhv([1:3:13])')),'YTick',[1:2:13],'YTickLabel',cellstr(num2str(vd([1:2:end])')),'FontSize',20) colormap('hot') subplot(2,5,[4 5 9 10]) % Barplots in figure 1d, 1h, and 1l hold on; bar(b(2:end)); errorbar(b(2:end),stats.se(2:end),'.k'); set(gca,'xtick',[1:3],'XTickLabel',{'HV-LV','D-HV','(HV-LV)(D-HV)'},'FontSize',20); ylabel('Effect size on accuracy (a.u.)') % Figures 1c, 1g and 1j % lines? subplot(2,5,[3]) plot(dhv,acc_bin(end,:),'r') xlim([-1.2 4.8]) set(gca,'xtick',[-1.2 4.8],'FontSize',12); ylabel('Accuracy') subplot(2,5,[8]) plot(dhv,acc_bin(1,:),'b') set(gca,'xtick',[-1.2 4.8],'FontSize',12); xlabel('D-HV (a.u.)') ylabel('Accuracy') toc function x=normalise(x,dim) % normalise(X) % Removes the Average or mean value and makes the std=1 % % normalise(X,DIM) % Removes the mean and makes the std=1 along the dimension DIM of X. if(nargin==1) dim = 1; if(size(x,1) > 1) dim = 1; elseif(size(x,2) > 1) dim = 2; end end dims = size(x); dimsize = size(x,dim); dimrep = ones(1,length(dims)); dimrep(dim) = dimsize; x = x - repmat(nanmean(x,dim),dimrep); x = x./repmat(nanstd(x,0,dim),dimrep); end