function [response_all,RT_all,params]=fim3d_dyn_dual(param,vals,nReps) rng(0) % accuracy_all, RT_all: trials x iterations % vals: trials x options [HV LV D], the third one must be D % nReps: number of iterations vals=vals'; drift = param(:,1); % drift rate (units/sec) 0.1 drift_noise = param(:,2); % standard deviation of drift (units/sec) drift_borns = 1; % boundaries frac = .5;% fractional part of mutual inhibition (set to .5 as in Niwa and Ditterich, 2008) disable_distractor_choices = 1; %% Define variables for the random walk: p.dt = 1/60; %step size for simulations (seconds) dec_time_sec = 6; %decision time (seconds) dec_time_dt = round(dec_time_sec/p.dt); %% Output parameters params.script = 'fim3d_dyn_dual'; params.drift = [num2str(drift(1)) ', ' num2str(drift(2))]; params.noise = [num2str(drift_noise(1)) ', ' num2str(drift_noise(2))]; params.inh = num2str(frac); %% Simulating %inialize some parameters: accuracy = NaN(1,nReps); % will be filled with -1 or 1 for incorrect and correct RT = NaN(1,nReps); % will be filled with RT values in seconds accuracy_all = NaN(size(vals,2),nReps); % will be filled with 0 or 1 for incorrect and correct choices RT_all = NaN(size(vals,2),nReps); % will be filled with RT values in seconds for t=1:size(vals,2) %% Mutual inhibition model u = vals(:,t); p.u = (u.*drift(1))'; for n=1:length(p.u) dy_exc(n,:,:) = ones(dec_time_dt,nReps)*p.u(n)*p.dt + drift_noise(1)*sqrt(p.dt)*randn(dec_time_dt,nReps); % accumulation end dy_inh = repmat(mean(dy_exc,1),length(p.u),1); % pooled_inhibition dy_mi = dy_exc-frac.*dy_inh; y_mi = cumsum(dy_mi,2); % current position of each walk %% disable distractor choices if disable_distractor_choices && size(y_mi,1)>2 y_mi(3,find(y_mi(3,:)>=drift_borns))=0; end %% Divisive normalization u = vals(1:2,t)./sum(vals(:,t)); p.u = (u.*drift(2))'; dy_exc = [];dy_inh = []; for n=1:length(p.u) dy_exc(n,:,:) = ones(dec_time_dt,nReps)*p.u(n)*p.dt + drift_noise(2)*sqrt(p.dt)*randn(dec_time_dt,nReps); % accumulation end dy_inh = repmat(mean(dy_exc,1),length(p.u),1); % pooled_inhibition dy_dn = dy_exc-frac.*dy_inh; y_dn = cumsum(dy_dn,2); %% assign choices y_mi = [y_mi ones([size(y_mi,1) 1 size(y_mi,3)]).*drift_borns]; %to help identifying non-decision trials [~,ind_pos] = max((y_mi>=drift_borns),[],2); ind = squeeze(ind_pos); [RT_mi,choice_mi] = min(ind,[],1); y_dn = [y_dn ones([size(y_dn,1) 1 size(y_dn,3)]).*drift_borns]; %to help identifying non-decision trials [~,ind_pos] = max((y_dn>=drift_borns),[],2); ind = squeeze(ind_pos); [RT_dn,choice_dn] = min(ind,[],1); mi_choice = double(RT_mi