Neural and computational mechanisms of effort under the pressure of a deadline.
The 1 match
- [1] § Results › Deadline pressure leads to seeking effort ↔ Code/analyse_population.m, lines 2267–2296 · score 0.60 · logistic regression, low pressure blocks, high pressure blocks, predicting choices, coefficient, model
Paper
Loaded from Europe PMC by your browser, not stored by OSCR: doi.org · Europe PMC
The paper is loaded when this pane is shown.
The authors' code
MATLAB · 2,330 lines · 117 KB · no license · 1 match
- %% for groups of offline subjects split by precise parameters
- % subjects = {'SH_200519';'DC_200519';'SS_200519';'GE_230519';'TZ_230519';'MS_230519';'LGW_280519';'HB_280519';'CS_280519';'KD_290519';'CJ_290519';'EA_290519';'KR_050619';'ML_050619';'LA_050619';'YC_060619';'AT_060619';'CK_070619';'CL_190619';'LX_190619'};
- % subjects = {'SW_100619';'SM_100619';'VK_100619';'BS_110619';'BR_130619';'CY_140619';'RG_140619';'RD_140619';'LM_170619';'AL_170619';'AS_170619';'DR_170619';'FH_170619';'FS_170619';'HS_180619';'ACV_180619';'VC_180619'};%;'JC_200619'};
- % subjects = {'TS_250619';'WK_260619';'MZ_260619';'EN_270619';'HD_030719';'AK_300719';'MR_300719';'RP_020819';'VS_020819'}; % discount = 1
- % subjects = {'AD_030719';'FT_040719';'LI_040719';'MW_120719';'AR_120719';'ND_300719'}; % discount factor = .6
- cd('D:\Data - fmri dataset')
- dataset_flag = 1; %1=fMRI 2=Offline 3=Offline without pressure modulation
- if dataset_flag == 1 %fMRI
- subjects = {'RR_270220';'HR_090320';'KL_100320';'MB_120320';'MJ_230921';'TK_230921';'BL_300921';'AJ_131021';'MR_251021';'FB_151121';'CS_291121';'TK_291121';'JJ_011221';'JM_031221';'LR_061221';'HD_061221';'AD_131221';'AE_161221';'NP_171221';'PD_201221';'AF_201221';'AK_221221';'NA_231221';'CS_231221';'KY_231221';'IK_110322';'VS_110322';'HG_300921_combined';'SJ_111021_combined';'OH_011121_combined'};
- elseif dataset_flag == 2 %Offline change in pressure across blocks
- subjects = {'TS_250619';'WK_260619';'MZ_260619';'EN_270619';'HD_030719';'AK_300719';'MR_300719';'RP_020819';'VS_020819';'AD_030719';'FT_040719';'LI_040719';'MW_120719';'AR_120719';'ND_300719'};
- elseif dataset_flag == 3 %Daniele dataset1 no change in pressure across blocks
- subjects = {'SH_200519';'DC_200519';'SS_200519';'GE_230519';'TZ_230519';'MS_230519';'LGW_280519';'HB_280519';'CS_280519';'KD_290519';'CJ_290519';'EA_290519';'KR_050619';'ML_050619';'LA_050619';'YC_060619';'AT_060619';'CK_070619';'CL_190619';'LX_190619';'SW_100619';'SM_100619';'VK_100619';'BS_110619';'BR_130619';'CY_140619';'RG_140619';'RD_140619';'LM_170619';'AL_170619';'AS_170619';'DR_170619';'FH_170619';'FS_170619';'HS_180619';'ACV_180619';'VC_180619';};%'JC_200619'};
- end
- %% load model parameters
- if dataset_flag == 1 %fMRI
- load('C:\Users\apisauro\Documents\MATLAB\Goal Pressure\Parameters used for the paper\PAR_fMRI.mat')
- load('C:\Users\apisauro\Documents\MATLAB\Goal Pressure\Parameters used for the paper\k_pre_fMRI')
- bad_subj = [];
- best_model_id = 3;
- elseif dataset_flag == 2
- load('C:\Users\apisauro\Documents\MATLAB\Goal Pressure\Parameters used for the paper\PAR_offline.mat')
- load('C:\Users\apisauro\Documents\MATLAB\Goal Pressure\Parameters used for the paper\k_pre_offline')
- bad_subj = [3 12];
- best_model_id = 3;
- end
- %% IMPORTANT FLAGS/PARS
- skip_bad_trial = 1; %to only use trials from good blocks (goal reached)
- threshold = 1; %trials above this advancement threshold are excluded
- n_choices = 3; %including time outs
- %less important
- pressure0_flag = 0; %don't subtract pressure
- reward_max_flag = 2; % =1 assuming Max = Max(Rewards) =2 Max = Mean(Rewards) =3 Max = Mean(Rewards(3),Rewards(4)) for homeostasis
- %% GRAPHICS STUFF
- trasp = 0.7; %for figures 1 for saving for illustrator 0.7 for plotting
- MeanWidth = 0.05; %for jittering points
- n_sub = length(subjects);
- nrow = ceil(n_sub/5);
- ncol = 6;
- %% LOAD DATA
- block_completed = zeros(n_sub,1);
- for i_sub = 1:n_sub
- [result{i_sub},choices{i_sub},reward{i_sub},reward0{i_sub},reward1{i_sub},reward2{i_sub},effort{i_sub},effort1{i_sub},effort2{i_sub},RT{i_sub},tiredness{i_sub}] = analyse_results(subjects{i_sub},0);
- block_completed(i_sub) = sum(result{i_sub}.block_completed);
- end
- bad_subj = find(block_completed<8);
- good_subjects = [1:n_sub];
- good_subjects(bad_subj) = [];
- n_good_sub = length(good_subjects);
- ForceLevels = result{1}.params.ForceLevel;
- Rewards = result{1}.params.Reward;
- if isfield(result{i_sub}.params,'blocks_pressure')
- variable_pressure_flag = 1;
- else
- variable_pressure_flag = 0;
- end
- n_blocks = result{1}.params.blocks;
- n_trials = result{1}.params.blockLen-1;
- n_efforts = length(ForceLevels);
- n_rewards = length(Rewards);
- %% indeces and initialitations
- all_trials = (1:n_blocks*n_trials);
- all_trials_pop = (1:n_blocks*n_trials*n_good_sub);
- % 1D index
- early_blocks = (1:n_blocks/2);
- late_blocks = n_blocks/2+1:n_blocks;
- early_trials = (1:n_trials/2);
- late_trials = n_trials/2+1:n_trials;
- % 2D indeces for n_blocks x n_trials
- early_trials_ind = (1:round(n_blocks*n_trials/2));
- late_trials_ind = all_trials;
- late_trials_ind(early_trials_ind) = [];
- early_blocks_ind = early_blocks; %first 15 blocks = first 15 rows
- for i_trial = 2:n_trials
- early_blocks_ind = [early_blocks_ind early_blocks+n_blocks*(i_trial-1)];
- end
- late_blocks_ind = all_trials;
- late_blocks_ind(early_blocks_ind) = [];
- % 3D indeces for n_blocks x n_trials x n_good_sub
- early_blocks_indeces = early_blocks_ind;
- for i_sub = 2:n_good_sub
- early_blocks_indeces = [early_blocks_indeces early_blocks_ind+n_blocks*n_trials*(i_sub-1)];
- end
- late_blocks_indeces = all_trials_pop;
- late_blocks_indeces(early_blocks_indeces)=[];
- if variable_pressure_flag
- % hard = high pressure easy = low_pressure
- hard_blocks_indeces = [];
- easy_blocks_indeces = [];
- hard_blocks_ind = {n_good_sub,1};
- easy_blocks_ind = {n_good_sub,1};
- for i_sub = 1:n_good_sub
- i = good_subjects(i_sub);
- % 1D index
- easy_blocks = find(result{i}.params.blocks_pressure==2)';
- hard_blocks = find(result{i}.params.blocks_pressure==1)';
- % 2D index
- hard_blocks_ind{i_sub} = hard_blocks;
- easy_blocks_ind{i_sub} = easy_blocks;
- for i_trial = 2:n_trials
- easy_blocks_ind{i_sub} = [easy_blocks_ind{i_sub} easy_blocks+n_blocks*(i_trial-1)];
- hard_blocks_ind{i_sub} = [hard_blocks_ind{i_sub} hard_blocks+n_blocks*(i_trial-1)];
- end
- % 3D indeces for n_blocks x n_trials x n_good_sub
- easy_blocks_indeces = [easy_blocks_indeces easy_blocks_ind{i_sub}+n_blocks*n_trials*(i_sub-1)];
- hard_blocks_indeces = [hard_blocks_indeces hard_blocks_ind{i_sub}+n_blocks*n_trials*(i_sub-1)];
- end
- population_choices_sortedbyblockpressure = zeros(n_blocks,n_trials,n_good_sub); %first 15 rows are easy and the latter 15 are hard
- population_simulated_choices_sortedbyblockpressure = zeros(n_blocks,n_trials,n_good_sub); %first 15 rows are easy and the latter 15 are hard
- population_delta_tiredness_sortedbyblockpressure = zeros(n_blocks,n_good_sub); %first 15 rows are easy and the latter 15 are hard
- end
- % trail based data structure
- population_choices = zeros(n_blocks,n_trials,n_good_sub);
- population_reward = zeros(n_blocks,n_trials,n_good_sub);
- population_reward_tot = zeros(n_blocks,n_trials,n_good_sub);
- population_effort = zeros(n_blocks,n_trials,n_good_sub);
- population_vigor = zeros(n_blocks,n_trials,n_good_sub);
- population_max_vigor = zeros(n_blocks,n_trials,n_good_sub);
- population_RT = zeros(n_blocks,n_trials,n_good_sub);
- population_drew = zeros(n_blocks,n_trials,n_good_sub);
- population_deff = zeros(n_blocks,n_trials,n_good_sub);
- population_rew1 = zeros(n_blocks,n_trials,n_good_sub);
- population_rew2 = zeros(n_blocks,n_trials,n_good_sub);
- population_eff1 = zeros(n_blocks,n_trials,n_good_sub);
- population_eff2 = zeros(n_blocks,n_trials,n_good_sub);
- population_advancement = zeros(n_blocks,n_trials,n_good_sub);
- population_reward_advancement_homeostasis = zeros(n_blocks,n_trials,n_good_sub);
- population_pressure = zeros(n_blocks,n_trials,n_good_sub);
- population_step_factor = zeros(n_blocks,n_trials,n_good_sub);
- % block based data structure
- population_tiredness = zeros(n_blocks,n_good_sub);
- population_delta_tiredness = zeros(n_blocks,n_good_sub);
- population_goals = zeros(n_blocks,n_good_sub); %1/0 whether or not goal was reached
- population_goals_trials = NaN(n_blocks,n_good_sub); %number of the trial in which goal reached
- population_block_pressure = zeros(n_blocks,n_good_sub); %1/2 high/low pressure block
- % derived data structure
- population_choices_percentage = zeros(5,n_choices,n_good_sub); %alltrials/earlytrials/latetrials/earlyblocks/lateblocks x n_choices x n_good_sub
- population_efforts_percentage = zeros(5,n_efforts,n_good_sub);
- population_rewards_percentage = zeros(5,n_rewards,n_good_sub);
- population_choices_efforts = zeros(5,n_choices,n_good_sub); %alltrials/earlytrials/latetrials/earlyblocks/lateblocks x n_choices x n_good_sub
- population_choices_rewards = zeros(5,n_choices,n_good_sub);
- population_efforts_rewards = zeros(5,n_rewards,n_good_sub);
- population_rewards_efforts = zeros(5,n_efforts,n_good_sub);
- max_pressure = zeros(n_good_sub,1);
- max_reward = zeros(n_good_sub,1);
- %% pressure0 trajectory
- advancement_target_experiment = 0.9697; %target advancement before last trial as experimented by subjects
- minimum_effort_step = min(result{end}.params.ForceLevel)/mean(result{end}.params.ForceLevel); %how much I advance if I chose minimum effort
- advancement_target_theory = 1-minimum_effort_step*1/n_trials; %target advancement before last trial so that one wins with minimum effort
- advancement0 = zeros(n_trials,1);
- pressure00 = zeros(n_trials,1);
- prudency_factor = (1:0.05:1.5); %mean advancement (on first data set) before last trial is 0.9697
- h_pressure0 = figure('Name','Pressure 0 trajectory');
- for i_prudency = 1: length(prudency_factor)
- for i_trial = 1:n_trials
- advancement0(i_prudency,i_trial) = (i_trial-1)/(n_trials)*prudency_factor(i_prudency);
- advancement_exp(i_trial) = (i_trial-1)/(n_trials-1)*advancement_target_experiment;
- avancement_theory(i_trial) = (i_trial-1)/(n_trials-1)*advancement_target_theory;
- pressure00(i_prudency,i_trial) = (1-advancement0(i_prudency,i_trial))/(n_trials+1-i_trial);
- pressure00_exp(i_trial) = (1-advancement_exp(i_trial))/(n_trials+1-i_trial);
- pressure00_theory(i_trial) = (1-avancement_theory(i_trial))/(n_trials+1-i_trial);
- end
- subplot(2,2,1)
- plot(1:n_trials,advancement0(i_prudency,:))
- ylabel('advancement')
- hold on
- xlim([1 n_trials])
- subplot(2,2,3)
- hold on
- plot(1:n_trials,pressure00(i_prudency,:))
- ylabel('pressure')
- xlim([1 n_trials])
- xlabel('trial')
- end
- subplot(2,2,2)
- hold on
- plot(1:n_trials,advancement_exp,'b')
- hold on
- plot(1:n_trials,avancement_theory,'g')
- xlim([1 n_trials])
- subplot(2,2,4)
- hold on
- plot(1:n_trials,pressure00_exp,'b')
- hold on
- plot(1:n_trials,pressure00_theory,'g')
- xlim([1 n_trials])
- xlabel('trial')
- legend('exp','theory')
- if pressure0_flag == 1
- pressure0 = pressure00_theory;
- else
- pressure0 = zeros(n_trials,1);
- end
- %% store data
- for i_sub = 1:n_good_sub
- i = good_subjects(i_sub);
- % max_pressure(i_sub) = max(ForceLevels)/result{i}.params.effort_step;
- if reward_max_flag == 1
- max_reward(i_sub) = max(Rewards)*n_trials;
- elseif reward_max_flag == 2
- max_reward(i_sub) = mean(Rewards)*n_trials;
- elseif reward_max_flag == 3
- max_reward(i_sub) = mean(Rewards(3),Rewards(4))*n_trials;
- end
- for i_block =1:n_blocks
- population_tiredness(i_block,i_sub) = tiredness{i}(i_block);
- if i_block >1
- population_delta_tiredness(i_block,i_sub) = population_tiredness(i_block,i_sub)-population_tiredness(i_block-1,i_sub);
- else
- population_delta_tiredness(1,i_sub) = population_tiredness(1,i_sub)-result{i}.data(1).fatigueRating;
- end
- for i_trial =1:n_trials
- try
- if choices{i}(i_block,i_trial)== 0 %it's a time out
- population_choices(i_block,i_trial,i_sub) = NaN;
- else %it's any other trial
- population_choices(i_block,i_trial,i_sub) = choices{i}(i_block,i_trial);
- end
- population_reward(i_block,i_trial,i_sub) = reward{i}(i_block,i_trial);
- population_reward_tot(i_block,i_trial,i_sub) = sum(population_reward(i_block,1:i_trial-1,i_sub),2);
- population_effort(i_block,i_trial,i_sub) = effort{i}(i_block,i_trial);
- population_vigor(i_block,i_trial,i_sub) = nanmean(result{i}.data(i_trial+(i_block-1)*(n_trials+1)).data1);
- population_max_vigor(i_block,i_trial,i_sub) = result{i}.data(i_trial+(i_block-1)*(n_trials+1)).maximumForce;
- population_RT(i_block,i_trial,i_sub) = RT{i}(i_block,i_trial);
- population_advancement(i_block,i_trial,i_sub) = result{i}.data(i_trial+(i_block-1)*(n_trials+1)).advancement;
- if i_trial>1
- population_reward_advancement_homeostasis(i_block,i_trial,i_sub)= population_reward_tot(i_block,i_trial,i_sub)/max_reward(i_sub) - population_advancement(i_block,i_trial-1,i_sub);
- else
- population_reward_advancement_homeostasis(i_block,i_trial,i_sub)= 0;
- end
- population_rew1(i_block,i_trial,i_sub) = reward1{i}(i_block,i_trial);
- population_rew2(i_block,i_trial,i_sub) = reward2{i}(i_block,i_trial);
- population_eff1(i_block,i_trial,i_sub) = effort1{i}(i_block,i_trial);
- population_eff2(i_block,i_trial,i_sub) = effort2{i}(i_block,i_trial);
- population_drew(i_block,i_trial,i_sub) = reward1{i}(i_block,i_trial)-reward2{i}(i_block,i_trial);
- population_deff(i_block,i_trial,i_sub) = effort1{i}(i_block,i_trial)-effort2{i}(i_block,i_trial);
- if i_trial >1
- population_pressure(i_block,i_trial,i_sub) = ((1-population_advancement(i_block,i_trial-1,i_sub))/(n_trials-(i_trial-1)))-pressure0(i_trial); %take the advancement/trial left of the previous trial
- else
- population_pressure(i_block,i_trial,i_sub) = 1/n_trials-pressure0(i_trial); %first trial have fixed pressure
- end
- if variable_pressure_flag
- population_step_factor(i_block,i_trial,i_sub) = result{i}.data(i_trial+(i_block-1)*(n_trials+1)).pressure;
- end
- catch
- fprintf('skipped trial %d block %d subject %d\n',i_trial,i_block,i_sub)
- end
- end
- if (result{i}.data(i_block*(n_trials+1)-1).advancement >=1) %% && i_sub>1) || result{i}.data(i_block*(n_trials+1)).advancement >= 1 %advancement after each block last trial advancemen
- population_goals(i_block,i_sub) = 1;
- trial_n = find(squeeze(population_advancement(i_block,:,i_sub))>=1,1); %trial in which goal is reached
- if ~isempty(trial_n)
- population_goals_trials(i_block,i_sub) = trial_n;
- else
- fprintf('problem with advancement in block %d subject %d\n',i_block,i_sub);
- end
- end
- end
- if variable_pressure_flag
- population_block_pressure(:,i_sub) = result{i}.params.blocks_pressure; %2 = easy 1 = hard
- ind_tosortbyblockpressure = [find(population_block_pressure(:,i_sub)==2)' find(population_block_pressure(:,i_sub)==1)' find(isnan(population_block_pressure(:,i_sub)))'];
- population_choices_sortedbyblockpressure(:,:,i_sub) = population_choices(ind_tosortbyblockpressure,:,i_sub);
- population_delta_tiredness_sortedbyblockpressure(:,i_sub) = population_delta_tiredness(ind_tosortbyblockpressure,i_sub);
- end
- end
- %% SIMULATE CHOICE DATA FOR WINNING MODEL
- population_simulated_choices = zeros(size(population_choices));
- for i_sub = 1:n_good_sub
- i = i_sub;
- beta = PAR{i}{3}(1);
- pressure_weight = PAR{i}{3}(2);
- base = 1;
- for i_block =1:n_blocks
- for i_trial =1:n_trials
- R1 = population_rew1(i_block,i_trial,i_sub);
- R2 = population_rew2(i_block,i_trial,i_sub);
- E1 = population_eff1(i_block,i_trial,i_sub);
- E2 = population_eff2(i_block,i_trial,i_sub);
- PR = population_pressure(i_block,i_trial,i_sub);
- V1 = R1+pressure_weight*E1.*PR;
- V2 = R2+pressure_weight*E2.*PR;
- prob_V1_winning = exp((V1-V2).*beta)./(exp(base*beta) + exp(beta.*(V1-V2)));
- if prob_V1_winning > 0.5 %it's V1 winning it's a 1
- population_simulated_choices(i_block,i_trial,i_sub) = 1;
- else %it's V2 winning it's a 2
- population_simulated_choices(i_block,i_trial,i_sub) = 2;
- end
- end
- end
- if variable_pressure_flag
- population_block_pressure(:,i_sub) = result{i}.params.blocks_pressure; %2 = easy 1 = hard
- ind_tosortbyblockpressure = [find(population_block_pressure(:,i_sub)==2)' find(population_block_pressure(:,i_sub)==1)' find(isnan(population_block_pressure(:,i_sub)))'];
- population_simulated_choices_sortedbyblockpressure(:,:,i_sub) = population_simulated_choices(ind_tosortbyblockpressure,:,i_sub);
- end
- end
- %% to compute number of successful trials
- population_choices_made = ~isnan(population_choices); %1 = trials in which a choice was made
- population_reward_choice_made = population_reward; % reward for trials in which a choice was made
- population_reward_choice_made(population_choices_made==0)=NaN; %set to NaN reward for trials were no choice was made
- population_success_trials_choice_made = population_reward_choice_made;
- population_success_trials_choice_made(population_reward_choice_made>0)=1; %succesful trials is when a choice is made and a reward obtained
- population_success_trials_choice_made_good_blocks = population_success_trials_choice_made;
- % to skip trials in failed blocks
- if skip_bad_trial
- for i_sub = 1:n_good_sub
- for i_block = 1:n_blocks
- if population_goals(i_block,i_sub)==0
- population_choices(i_block,:,i_sub) = NaN;
- population_reward(i_block,:,i_sub) = NaN;
- population_reward_tot(i_block,:,i_sub) = NaN;
- population_effort(i_block,:,i_sub) = NaN;
- population_RT(i_block,:,i_sub) = NaN;
- population_drew (i_block,:,i_sub) = NaN;
- population_deff(i_block,:,i_sub) = NaN;
- population_advancement(i_block,:,i_sub) = NaN;
- population_pressure(i_block,:,i_sub)= NaN;
- population_reward_advancement_homeostasis(i_block,:,i_sub)= NaN;
- population_success_trials_choice_made_good_blocks(i_block,:,i_sub) = NaN; %in bad blocks all trials are a failure
- end
- for i_trial = 4:n_trials
- if population_advancement(i_block,i_trial-1,i_sub)>threshold %skip if it's a trial done after crossing the line
- population_choices(i_block,i_trial,i_sub) = NaN;
- population_RT(i_block,i_trial,i_sub) = NaN;
- population_drew (i_block,i_trial,i_sub) = NaN;
- population_deff(i_block,i_trial,i_sub) = NaN;
- population_pressure(i_block,i_trial,i_sub)= NaN;
- population_reward_advancement_homeostasis(i_block,i_trial,i_sub)= NaN;
- end
- end
- end
- end
- end
- %% population averages/percentages
- mean_population_choices = nanmean(population_choices,3);
- std_population_choices = nanstd(population_choices,[],3);
- mean_population_simulated_choices = nanmean(population_simulated_choices,3);
- std_population_simulated_choices = nanstd(population_simulated_choices,[],3);
- mean_population_reward = nanmean(population_reward,3);
- std_population_reward = nanstd(population_reward,[],3);
- mean_population_reward_tot = nanmean(population_reward_tot,3);
- std_population_reward_tot = nanstd(population_reward_tot,[],3);
- mean_population_effort = nanmean(population_effort,3);
- std_population_effort = nanstd(population_effort,[],3);
- mean_population_RT = nanmean(population_RT,3);
- std_population_RT = nanstd(population_RT,[],3);
- mean_population_advancement = nanmean(population_advancement,3);
- std_population_advancement = nanstd(population_advancement,[],3);
- mean_population_reward_advancement_homeostasis = nanmean(population_reward_advancement_homeostasis,3);
- std_population_reward_advancement_homeostasis = nanstd(population_reward_advancement_homeostasis,[],3);
- mean_population_pressure = nanmean(population_pressure,3);
- std_population_pressure = nanstd(population_pressure,[],3);
- X_rew = unique(population_drew(~isnan(population_drew(:))));
- X_eff = unique(population_deff(~isnan(population_deff(:))));
- mean_population_choices_sortedbyblockpressure = nanmean(population_choices_sortedbyblockpressure,3);
- std_population_choices_sortedbyblockpressure = nanstd(population_choices_sortedbyblockpressure,[],3);
- mean_population_simulated_choices_sortedbyblockpressure = nanmean(population_simulated_choices_sortedbyblockpressure,3);
- std_population_simulated_choices_sortedbyblockpressure = nanstd(population_simulated_choices_sortedbyblockpressure,[],3);
- for i_sub=1:n_good_sub
- sub_choices = population_choices(:,:,i_sub);
- sub_rewards = population_reward(:,:,i_sub);
- sub_efforts = population_effort(:,:,i_sub);
- % percentage choices
- population_choices_percentage(1,1,i_sub) = nansum(sub_choices(:)==1)/length(sub_choices(:)); %all trials
- population_choices_percentage(1,2,i_sub) = nansum(sub_choices(:)==2)/length(sub_choices(:));
- population_choices_percentage(1,3,i_sub) = nansum(isnan(sub_choices(:)))/length(sub_choices(:));
- population_choices_percentage(2,1,i_sub) = nansum(sub_choices(early_trials_ind)==1)/length(sub_choices(early_trials_ind)); %early_trials
- population_choices_percentage(2,2,i_sub) = nansum(sub_choices(early_trials_ind)==2)/length(sub_choices(early_trials_ind));
- population_choices_percentage(2,3,i_sub) = nansum(isnan(sub_choices(early_trials_ind)))/length(sub_choices(early_trials_ind));
- population_choices_percentage(3,1,i_sub) = nansum(sub_choices(late_trials_ind)==1)/length(sub_choices(late_trials_ind)); %late_trials
- population_choices_percentage(3,2,i_sub) = nansum(sub_choices(late_trials_ind)==2)/length(sub_choices(late_trials_ind));
- population_choices_percentage(3,3,i_sub) = nansum(isnan(sub_choices(late_trials_ind)))/length(sub_choices(late_trials_ind));
- population_choices_percentage(4,1,i_sub) = nansum(sub_choices(early_blocks_ind)==1)/length(sub_choices(early_blocks_ind)); %early_blocks
- population_choices_percentage(4,2,i_sub) = nansum(sub_choices(early_blocks_ind)==2)/length(sub_choices(early_blocks_ind));
- population_choices_percentage(4,3,i_sub) = nansum(isnan(sub_choices(early_blocks_ind)))/length(sub_choices(early_blocks_ind));
- population_choices_percentage(5,1,i_sub) = nansum(sub_choices(late_blocks_ind)==1)/length(sub_choices(late_blocks_ind)); %late_blocks
- population_choices_percentage(5,2,i_sub) = nansum(sub_choices(late_blocks_ind)==2)/length(sub_choices(late_blocks_ind));
- population_choices_percentage(5,3,i_sub) = nansum(isnan(sub_choices(late_blocks_ind)))/length(sub_choices(late_blocks_ind));
- % average reward choices
- population_choices_rewards(1,1,i_sub) = nanmean(sub_rewards(sub_choices(:)==1)); %all trials
- population_choices_rewards(1,2,i_sub) = nanmean(sub_rewards(sub_choices(:)==2));
- population_choices_rewards(1,3,i_sub) = nanmean(sub_rewards(isnan(sub_choices(:))));
- population_choices_rewards(2,1,i_sub) = nanmean(sub_rewards(intersect(find(sub_choices(:)==1),early_trials_ind))); %early_trials
- population_choices_rewards(2,2,i_sub) = nanmean(sub_rewards(intersect(find(sub_choices(:)==2),early_trials_ind)));
- population_choices_rewards(2,3,i_sub) = nanmean(sub_rewards(intersect(find(isnan(sub_choices(:))),early_trials_ind)));
- population_choices_rewards(3,1,i_sub) = nanmean(sub_rewards(intersect(find(sub_choices(:)==1),late_trials_ind)));
- population_choices_rewards(3,2,i_sub) = nanmean(sub_rewards(intersect(find(sub_choices(:)==2),late_trials_ind)));
- population_choices_rewards(3,3,i_sub) = nanmean(sub_rewards(intersect(find(isnan(sub_choices(:))),late_trials_ind)));
- population_choices_rewards(4,1,i_sub) = nanmean(sub_rewards(intersect(find(sub_choices(:)==1),early_blocks_ind)));
- population_choices_rewards(4,2,i_sub) = nanmean(sub_rewards(intersect(find(sub_choices(:)==2),early_blocks_ind)));
- population_choices_rewards(4,3,i_sub) = nanmean(sub_rewards(intersect(find(isnan(sub_choices(:))),early_blocks_ind)));
- population_choices_rewards(5,1,i_sub) = nanmean(sub_rewards(intersect(find(sub_choices(:)==1),late_blocks_ind)));
- population_choices_rewards(5,2,i_sub) = nanmean(sub_rewards(intersect(find(sub_choices(:)==2),late_blocks_ind)));
- population_choices_rewards(5,3,i_sub) = nanmean(sub_rewards(intersect(find(isnan(sub_choices(:))),late_blocks_ind)));
- % average effort choices
- population_choices_efforts(1,1,i_sub) = nanmean(sub_efforts(sub_choices(:)==1)); %all trials
- population_choices_efforts(1,2,i_sub) = nanmean(sub_efforts(sub_choices(:)==2));
- population_choices_efforts(1,3,i_sub) = nanmean(sub_efforts(isnan(sub_choices(:))));
- population_choices_efforts(2,1,i_sub) = nanmean(sub_efforts(intersect(find(sub_choices(:)==1),early_trials_ind))); %early_trials
- population_choices_efforts(2,2,i_sub) = nanmean(sub_efforts(intersect(find(sub_choices(:)==2),early_trials_ind)));
- population_choices_efforts(2,3,i_sub) = nanmean(sub_efforts(intersect(find(isnan(sub_choices(:))),early_trials_ind)));
- population_choices_efforts(3,1,i_sub) = nanmean(sub_efforts(intersect(find(sub_choices(:)==1),late_trials_ind)));
- population_choices_efforts(3,2,i_sub) = nanmean(sub_efforts(intersect(find(sub_choices(:)==2),late_trials_ind)));
- population_choices_efforts(3,3,i_sub) = nanmean(sub_efforts(intersect(find(isnan(sub_choices(:))),late_trials_ind)));
- population_choices_efforts(4,1,i_sub) = nanmean(sub_efforts(intersect(find(sub_choices(:)==1),early_blocks_ind)));
- population_choices_efforts(4,2,i_sub) = nanmean(sub_efforts(intersect(find(sub_choices(:)==2),early_blocks_ind)));
- population_choices_efforts(4,3,i_sub) = nanmean(sub_efforts(intersect(find(isnan(sub_choices(:))),early_blocks_ind)));
- population_choices_efforts(5,1,i_sub) = nanmean(sub_efforts(intersect(find(sub_choices(:)==1),late_blocks_ind)));
- population_choices_efforts(5,2,i_sub) = nanmean(sub_efforts(intersect(find(sub_choices(:)==2),late_blocks_ind)));
- population_choices_efforts(5,3,i_sub) = nanmean(sub_efforts(intersect(find(isnan(sub_choices(:))),late_blocks_ind)));
- for i_rew=1:n_rewards
- population_rewards_percentage(1,i_rew,i_sub)=nansum(sub_rewards(:)==Rewards(i_rew))/length(sub_rewards(:));
- population_rewards_percentage(2,i_rew,i_sub)=nansum(sub_rewards(early_trials_ind)==Rewards(i_rew))/length(sub_rewards(early_trials_ind));
- population_rewards_percentage(3,i_rew,i_sub)=nansum(sub_rewards(late_trials_ind)==Rewards(i_rew))/length(sub_rewards(late_trials_ind));
- population_rewards_percentage(4,i_rew,i_sub)=nansum(sub_rewards(early_blocks_ind)==Rewards(i_rew))/length(sub_rewards(early_blocks_ind));
- population_rewards_percentage(5,i_rew,i_sub)=nansum(sub_rewards(late_blocks_ind)==Rewards(i_rew))/length(sub_rewards(late_blocks_ind));
- population_efforts_rewards(1,i_rew,i_sub)=nanmean(sub_efforts(sub_rewards(:)==Rewards(i_rew)));
- population_efforts_rewards(2,i_rew,i_sub)=nanmean(sub_efforts(intersect(find(sub_rewards(:)==Rewards(i_rew)),early_trials_ind)));
- population_efforts_rewards(3,i_rew,i_sub)=nanmean(sub_efforts(intersect(find(sub_rewards(:)==Rewards(i_rew)),late_trials_ind)));
- population_efforts_rewards(4,i_rew,i_sub)=nanmean(sub_efforts(intersect(find(sub_rewards(:)==Rewards(i_rew)),early_blocks_ind)));
- population_efforts_rewards(5,i_rew,i_sub)=nanmean(sub_efforts(intersect(find(sub_rewards(:)==Rewards(i_rew)),late_blocks_ind)));
- end
- for i_level=1:n_efforts
- population_efforts_percentage(1,i_level,i_sub)=nansum(sub_efforts(:)==ForceLevels(i_level))/length(sub_efforts(:));
- population_efforts_percentage(2,i_level,i_sub)=nansum(sub_efforts(early_trials_ind)==ForceLevels(i_level))/length(sub_efforts(early_trials_ind));
- population_efforts_percentage(3,i_level,i_sub)=nansum(sub_efforts(late_trials_ind)==ForceLevels(i_level))/length(sub_efforts(late_trials_ind));
- population_efforts_percentage(4,i_level,i_sub)=nansum(sub_efforts(early_blocks_ind)==ForceLevels(i_level))/length(sub_efforts(early_blocks_ind));
- population_efforts_percentage(5,i_level,i_sub)=nansum(sub_efforts(late_blocks_ind)==ForceLevels(i_level))/length(sub_efforts(late_blocks_ind));
- population_rewards_efforts(1,i_level,i_sub)=nanmean(sub_rewards(sub_efforts(:)==ForceLevels(i_level)));
- population_rewards_efforts(2,i_level,i_sub)=nanmean(sub_rewards(intersect(find(sub_efforts(:)==ForceLevels(i_level)),early_trials_ind)));
- population_rewards_efforts(3,i_level,i_sub)=nanmean(sub_rewards(intersect(find(sub_efforts(:)==ForceLevels(i_level)),late_trials_ind)));
- population_rewards_efforts(4,i_level,i_sub)=nanmean(sub_rewards(intersect(find(sub_efforts(:)==ForceLevels(i_level)),early_blocks_ind)));
- population_rewards_efforts(5,i_level,i_sub)=nanmean(sub_rewards(intersect(find(sub_efforts(:)==ForceLevels(i_level)),late_blocks_ind)));
- end
- end
- %% saving figures in
- if dataset_flag == 1 %fMRI
- cd('C:\Users\apisauro\Pictures\Goal Pressure project\Results\Behavioural results\Task\fMRI experiment\Latest plots')
- elseif dataset_flag == 2 %Offline change in pressure across blocks
- cd('C:\Users\apisauro\Pictures\Goal Pressure project\Results\Behavioural results\Task\Offline Experiment (Daniele)\Latest plots')
- elseif dataset_flag == 3 %Daniele dataset1 no change in pressure across blocks
- cd('C:\Users\apisauro\Pictures\Goal Pressure project\Results\Behavioural results\Task\Offline Experiment (Daniele)\No pressure modulation across blocks')
- end
- %% subject performance
- h_goal = figure('Name','Goal and Reward','units','normalized','outerposition',[0 0 1 1]);
- subplot(4,3,1:2)
- imagesc([population_goals' nanmean(population_goals,1)'])
- ylabel('subjects')
- title('goal completed')
- colormap parula
- colorbar
- subplot(4,3,4:5)
- population_goals_trials2 = 9-population_goals_trials;
- population_goals_trials2(isnan(population_goals_trials)) = -1;
- imagesc([population_goals_trials2' nanmean(population_goals_trials2,1)'])
- ylabel('subjects')
- title('n trials before deadline goal reached')
- colorbar
- subplot(4,3,7:8)
- block_rewards = squeeze(sum(population_reward,2))';
- imagesc([block_rewards nanmean(block_rewards,2)]); %average across trials
- title('reward collected')
- colorbar
- ylabel('subjects')
- subplot(4,3,10:11)
- population_success_trials = population_reward>0;
- imagesc(squeeze(mean(population_success_trials,2))')
- title('trials successful')
- colorbar
- xlabel('blocks')
- ylabel('subjects')
- %avg goal reached
- subplot(4,3,3)
- bar(1,nanmean(population_goals(:)),'b')
- hold on
- plot(ones(n_good_sub,1)+MeanWidth*rand(n_good_sub,1),mean(population_goals,1),'.k')
- %jitterplot(mean(population_goals,1),ones(n_good_sub,1),1)
- if variable_pressure_flag
- ind_high_pressure = find(population_block_pressure==1);
- ind_low_pressure = find(population_block_pressure==2);
- hold on
- bar(2,nanmean(population_goals(ind_high_pressure)),'r')
- hold on
- bar(3,nanmean(population_goals(ind_low_pressure)),'g')
- for i_sub=1:n_good_sub
- hold on
- plot(2+MeanWidth*rand,nanmean(population_goals(population_block_pressure(:,i_sub)==1,i_sub),1),'.k')
- hold on
- plot(3+MeanWidth*rand,nanmean(population_goals(population_block_pressure(:,i_sub)==2,i_sub),1),'.k')
- end
- end
- ylim([0 1])
- ylabel('% goals')
- %avg trial at which goal reached
- subplot(4,3,6)
- bar(1,nanmean(population_goals_trials(:)),'b')
- hold on
- plot(ones(n_good_sub,1)+MeanWidth*rand(n_good_sub,1),nanmean(population_goals_trials,1),'.k')
- ylim([5 8])
- ylabel('trial')
- if variable_pressure_flag
- hold on
- bar(2,nanmean(population_goals_trials(ind_high_pressure)),'r')
- hold on
- bar(3,nanmean(population_goals_trials(ind_low_pressure)),'g')
- for i_sub=1:n_good_sub
- hold on
- plot(2+MeanWidth*rand,nanmean(population_goals_trials(population_block_pressure(:,i_sub)==1,i_sub),1),'.k')
- hold on
- plot(3+MeanWidth*rand,nanmean(population_goals_trials(population_block_pressure(:,i_sub)==2,i_sub),1),'.k')
- end
- end
- % rewards
- subplot(4,3,9)
- bar(1,nanmean(block_rewards(:)),'b')
- hold on
- %jitterplot(nanmean(block_rewards,2),ones(n_good_sub,1),1)
- plot(ones(n_good_sub,1)+MeanWidth*rand(n_good_sub,1),nanmean(block_rewards,2),'.k')
- ylabel('reward')
- if variable_pressure_flag
- hold on
- bar(2,nanmean(block_rewards(ind_high_pressure)),'r')
- hold on
- bar(3,nanmean(block_rewards(ind_low_pressure)),'g')
- for i_sub=1:n_good_sub
- hold on
- plot(2+MeanWidth*rand,nanmean(block_rewards(i_sub,population_block_pressure(:,i_sub)==1),2),'.k')
- hold on
- plot(3+MeanWidth*rand,nanmean(block_rewards(i_sub,population_block_pressure(:,i_sub)==2),2),'.k')
- end
- set(gca,'XTick',[1 2 3],'XTicklabel',{'all blocks';'high p blocks';'low p blocks'});
- end
- %different failure rates
- subplot(4,3,12)
- bar(1,1-nanmean(population_choices_made(:)),'b') %time outs
- hold on
- plot(ones(n_good_sub,1)+MeanWidth*rand(n_good_sub,1),1-squeeze(nanmean(mean(population_choices_made,2),1)),'.k')
- hold on
- bar(2,1-nanmean(population_success_trials_choice_made(:)),'b') %choice made effort failed
- hold on
- plot(2*ones(n_good_sub,1)+MeanWidth*rand(n_good_sub,1),1-squeeze(nanmean(mean(population_success_trials_choice_made,2),1)),'.k')
- hold on
- bar(3,1-nanmean(population_success_trials_choice_made_good_blocks(:)),'b') %choice made effort failed in good blocks
- hold on
- plot(3*ones(n_good_sub,1)+MeanWidth*rand(n_good_sub,1),1-squeeze(nanmean(mean(population_success_trials_choice_made_good_blocks,2),1)),'.k')
- set(gca,'XTick',[1 2 3],'XTicklabel',{'time outs';'fail';'fail(goal)'},'YTick',[0 0.5 1],'YTicklabel',[0 50 100]);
- ylim([0 1])
- ylabel('%')
- % if variable_pressure_flag
- % hold on
- % bar(2,nanmean(block_rewards(ind_high_pressure)),'w')
- % hold on
- % bar(3,nanmean(block_rewards(ind_low_pressure)),'w')
- % for i_sub=1:n_good_sub
- % hold on
- % plot(2,nanmean(block_rewards(population_block_pressure(:,i_sub)==1,i_sub),1),'.k')
- % hold on
- % plot(3,nanmean(block_rewards(population_block_pressure(:,i_sub)==2,i_sub),1),'.k')
- % end
- % set(gca,'XTick',[1 2 3],'XTicklabel',{'all';'high p';'low p'});
- % end
- %% figure %high progress
- h_choice_high_progress = figure('Name','Population choices high progress','units','normalized','outerposition',[0 0 1 1]);
- bar(1,nanmean(population_choices(:))-1,'b')
- hold on
- plot(ones(n_good_sub,1)+MeanWidth*rand(n_good_sub,1),nanmean(squeeze(nanmean(population_choices,2)),1)-1,'.k')
- ylim([0 1])
- ylabel('% high progress')
- %% percentage behaviour
- h_choice_reward_effort = figure('Name','Population choices','units','normalized','outerposition',[0 0 1 1]);
- subplot(3,5,1)
- for i_sub=1:n_good_sub
- plot([1 2 3],100*population_choices_percentage(1,:,i_sub),'-o','Color',[(i_sub)/n_good_sub 0.5 (n_good_sub-i_sub)/n_good_sub])
- hold on
- end
- hold on
- plot([1 2 3],100*mean(population_choices_percentage(1,:,:),3),'sk','MarkerSize',10,'MarkerFaceColor',[0 0 0])
- ylim([0 100])
- set(gca,'xtick',[1 2 3],'xticklabel',{'left', 'right', 'timeout'})
- title('all trials')
- ylabel('choices')
- subplot(3,5,2)
- for i_sub=1:n_good_sub
- plot([1 2 3],100*population_choices_percentage(2,:,i_sub),'-o','Color',[(i_sub)/n_good_sub 0.5 (n_good_sub-i_sub)/n_good_sub])
- hold on
- end
- hold on
- plot([1 2 3],100*mean(population_choices_percentage(2,:,:),3),'sk','MarkerSize',10,'MarkerFaceColor',[0 0 0])
- set(gca,'xtick',[1 2 3],'xticklabel',{'left', 'right', 'timeout'})
- ylim([0 100])
- title('early trials')
- subplot(3,5,3)
- for i_sub=1:n_good_sub
- plot([1 2 3],100*population_choices_percentage(3,:,i_sub),'-o','Color',[(i_sub)/n_good_sub 0.5 (n_good_sub-i_sub)/n_good_sub])
- hold on
- end
- hold on
- plot([1 2 3],100*mean(population_choices_percentage(3,:,:),3),'sk','MarkerSize',10,'MarkerFaceColor',[0 0 0])
- set(gca,'xtick',[1 2 3],'xticklabel',{'left', 'right', 'timeout'})
- ylim([0 100])
- title('late trials')
- subplot(3,5,4)
- for i_sub=1:n_good_sub
- plot([1 2 3],100*population_choices_percentage(4,:,i_sub),'-o','Color',[(i_sub)/n_good_sub 0.5 (n_good_sub-i_sub)/n_good_sub])
- hold on
- end
- hold on
- plot([1 2 3],100*mean(population_choices_percentage(4,:,:),3),'sk','MarkerSize',10,'MarkerFaceColor',[0 0 0])
- set(gca,'xtick',[1 2 3],'xticklabel',{'left', 'right', 'timeout'})
- ylim([0 100])
- title('early blocks')
- subplot(3,5,5)
- for i_sub=1:n_good_sub
- plot([1 2 3],100*population_choices_percentage(5,:,i_sub),'-o','Color',[(i_sub)/n_good_sub 0.5 (n_good_sub-i_sub)/n_good_sub])
- hold on
- end
- hold on
- plot([1 2 3],100*mean(population_choices_percentage(5,:,:),3),'sk','MarkerSize',10,'MarkerFaceColor',[0 0 0])
- set(gca,'xtick',[1 2 3],'xticklabel',{'left', 'right', 'timeout'})
- ylim([0 100])
- title('late blocks')
- subplot(3,5,6)
- for i_sub=1:n_good_sub
- plot([1 2 3 4],100*population_rewards_percentage(1,:,i_sub),'-o','Color',[(i_sub)/n_good_sub 0.5 (n_good_sub-i_sub)/n_good_sub])
- hold on
- end
- hold on
- plot([1 2 3 4],100*mean(population_rewards_percentage(1,:,:),3),'sk','MarkerSize',10,'MarkerFaceColor',[0 0 0])
- set(gca,'xtick',[1 2 3 4],'xticklabel',{num2str(Rewards(:))})
- ylim([0 100])
- xlim([1 4])
- ylabel('reward')
- subplot(3,5,7)
- for i_sub=1:n_good_sub
- plot([1 2 3 4],100*population_rewards_percentage(2,:,i_sub),'-o','Color',[(i_sub)/n_good_sub 0.5 (n_good_sub-i_sub)/n_good_sub])
- hold on
- end
- hold on
- plot(100*mean(population_rewards_percentage(2,:,:),3),'sk','MarkerSize',10,'MarkerFaceColor',[0 0 0])
- set(gca,'xtick',[1 2 3 4],'xticklabel',{num2str(Rewards(:))})
- ylim([0 100])
- xlim([1 4])
- subplot(3,5,8)
- for i_sub=1:n_good_sub
- plot([1 2 3 4],100*population_rewards_percentage(3,:,i_sub),'-o','Color',[(i_sub)/n_good_sub 0.5 (n_good_sub-i_sub)/n_good_sub])
- hold on
- end
- hold on
- plot(100*mean(population_rewards_percentage(3,:,:),3),'sk','MarkerSize',10,'MarkerFaceColor',[0 0 0])
- set(gca,'xtick',[1 2 3 4],'xticklabel',{num2str(Rewards(:))})
- ylim([0 100])
- xlim([1 4])
- subplot(3,5,9)
- for i_sub=1:n_good_sub
- plot([1 2 3 4],100*population_rewards_percentage(4,:,i_sub),'-o','Color',[(i_sub)/n_good_sub 0.5 (n_good_sub-i_sub)/n_good_sub])
- hold on
- end
- hold on
- plot(100*mean(population_rewards_percentage(4,:,:),3),'sk','MarkerSize',10,'MarkerFaceColor',[0 0 0])
- set(gca,'xtick',[1 2 3 4],'xticklabel',{num2str(Rewards(:))})
- ylim([0 100])
- xlim([1 4])
- subplot(3,5,10)
- for i_sub=1:n_good_sub
- plot([1 2 3 4],100*population_rewards_percentage(5,:,i_sub),'-o','Color',[(i_sub)/n_good_sub 0.5 (n_good_sub-i_sub)/n_good_sub])
- hold on
- end
- hold on
- plot(100*mean(population_rewards_percentage(5,:,:),3),'sk','MarkerSize',10,'MarkerFaceColor',[0 0 0])
- set(gca,'xtick',[1 2 3 4],'xticklabel',{num2str(Rewards(:))})
- ylim([0 100])
- xlim([1 4])
- subplot(3,5,11)
- for i_sub=1:n_good_sub
- plot([1 2 3 4],100*population_efforts_percentage(1,:,i_sub),'-o','Color',[(i_sub)/n_good_sub 0.5 (n_good_sub-i_sub)/n_good_sub])
- hold on
- end
- hold on
- plot(100*mean(population_efforts_percentage(1,:,:),3),'sk','MarkerSize',10,'MarkerFaceColor',[0 0 0])
- set(gca,'xtick',[1 2 3 4],'xticklabel',{num2str(ForceLevels(:))})
- ylabel('effort')
- ylim([0 100])
- xlim([1 4])
- subplot(3,5,12)
- for i_sub=1:n_good_sub
- plot([1 2 3 4],100*population_efforts_percentage(2,:,i_sub),'-o','Color',[(i_sub)/n_good_sub 0.5 (n_good_sub-i_sub)/n_good_sub])
- hold on
- end
- hold on
- plot(100*mean(population_efforts_percentage(2,:,:),3),'sk','MarkerSize',10,'MarkerFaceColor',[0 0 0])
- set(gca,'xtick',[1 2 3 4],'xticklabel',{num2str(ForceLevels(:))})
- ylim([0 100])
- xlim([1 4])
- subplot(3,5,13)
- for i_sub=1:n_good_sub
- plot([1 2 3 4],100*population_efforts_percentage(3,:,i_sub),'-o','Color',[(i_sub)/n_good_sub 0.5 (n_good_sub-i_sub)/n_good_sub])
- hold on
- end
- hold on
- plot(100*mean(population_efforts_percentage(3,:,:),3),'sk','MarkerSize',10,'MarkerFaceColor',[0 0 0])
- set(gca,'xtick',[1 2 3 4],'xticklabel',{num2str(ForceLevels(:))})
- ylim([0 100])
- xlim([1 4])
- subplot(3,5,14)
- for i_sub=1:n_good_sub
- plot([1 2 3 4],100*population_efforts_percentage(4,:,i_sub),'-o','Color',[(i_sub)/n_good_sub 0.5 (n_good_sub-i_sub)/n_good_sub])
- hold on
- end
- hold on
- plot(100*mean(population_efforts_percentage(4,:,:),3),'sk','MarkerSize',10,'MarkerFaceColor',[0 0 0])
- set(gca,'xtick',[1 2 3 4],'xticklabel',{num2str(ForceLevels(:))})
- ylim([0 100])
- xlim([1 4])
- subplot(3,5,15)
- for i_sub=1:n_good_sub
- plot([1 2 3 4],100*population_efforts_percentage(5,:,i_sub),'-o','Color',[(i_sub)/n_good_sub 0.5 (n_good_sub-i_sub)/n_good_sub])
- hold on
- end
- hold on
- plot(100*mean(population_efforts_percentage(5,:,:),3),'sk','MarkerSize',10,'MarkerFaceColor',[0 0 0])
- set(gca,'xtick',[1 2 3 4],'xticklabel',{num2str(ForceLevels(:))})
- ylim([0 100])
- xlim([1 4])
- %% avg reward/effort for choice type
- h_choice_reward_effort2 = figure('Name','Population average reward-effort','units','normalized','outerposition',[0 0 1 1]);
- subplot(4,5,1)
- for i_sub=1:n_good_sub
- plot([1 2 3],population_choices_efforts(1,:,i_sub),'-o','Color',[(i_sub)/n_good_sub 0.5 (n_good_sub-i_sub)/n_good_sub])
- hold on
- end
- hold on
- plot([1 2 3],nanmean(population_choices_efforts(1,:,:),3),'sk','MarkerSize',10,'MarkerFaceColor',[0 0 0])
- ylim([0 1])
- set(gca,'xtick',[1 2 3],'xticklabel',{'left', 'right', 'timeout'})
- title('all trials')
- ylabel('efforts')
- subplot(4,5,2)
- for i_sub=1:n_good_sub
- plot([1 2 3],population_choices_efforts(2,:,i_sub),'-o','Color',[(i_sub)/n_good_sub 0.5 (n_good_sub-i_sub)/n_good_sub])
- hold on
- end
- hold on
- plot([1 2 3],nanmean(population_choices_efforts(2,:,:),3),'sk','MarkerSize',10,'MarkerFaceColor',[0 0 0])
- set(gca,'xtick',[1 2 3],'xticklabel',{'left', 'right', 'timeout'})
- ylim([0 1])
- title('early trials')
- subplot(4,5,3)
- for i_sub=1:n_good_sub
- plot([1 2 3],population_choices_efforts(3,:,i_sub),'-o','Color',[(i_sub)/n_good_sub 0.5 (n_good_sub-i_sub)/n_good_sub])
- hold on
- end
- hold on
- plot([1 2 3],nanmean(population_choices_efforts(3,:,:),3),'sk','MarkerSize',10,'MarkerFaceColor',[0 0 0])
- set(gca,'xtick',[1 2 3],'xticklabel',{'left', 'right', 'timeout'})
- ylim([0 1])
- title('late trials')
- subplot(4,5,4)
- for i_sub=1:n_good_sub
- plot([1 2 3],population_choices_efforts(4,:,i_sub),'-o','Color',[(i_sub)/n_good_sub 0.5 (n_good_sub-i_sub)/n_good_sub])
- hold on
- end
- hold on
- plot([1 2 3],nanmean(population_choices_efforts(4,:,:),3),'sk','MarkerSize',10,'MarkerFaceColor',[0 0 0])
- set(gca,'xtick',[1 2 3],'xticklabel',{'left', 'right', 'timeout'})
- ylim([0 1])
- title('early blocks')
- subplot(4,5,5)
- for i_sub=1:n_good_sub
- plot([1 2 3],population_choices_efforts(5,:,i_sub),'-o','Color',[(i_sub)/n_good_sub 0.5 (n_good_sub-i_sub)/n_good_sub])
- hold on
- end
- hold on
- plot([1 2 3],nanmean(population_choices_efforts(5,:,:),3),'sk','MarkerSize',10,'MarkerFaceColor',[0 0 0])
- set(gca,'xtick',[1 2 3],'xticklabel',{'left', 'right', 'timeout'})
- ylim([0 1])
- title('late blocks')
- subplot(4,5,6)
- for i_sub=1:n_good_sub
- plot([1 2 3],population_choices_rewards(1,:,i_sub),'-o','Color',[(i_sub)/n_good_sub 0.5 (n_good_sub-i_sub)/n_good_sub])
- hold on
- end
- hold on
- plot([1 2 3],nanmean(population_choices_rewards(1,:,:),3),'sk','MarkerSize',10,'MarkerFaceColor',[0 0 0])
- ylim([0 10])
- set(gca,'xtick',[1 2 3],'xticklabel',{'left', 'right', 'timeout'})
- title('all trials')
- ylabel('rewards')
- subplot(4,5,7)
- for i_sub=1:n_good_sub
- plot([1 2 3],population_choices_rewards(2,:,i_sub),'-o','Color',[(i_sub)/n_good_sub 0.5 (n_good_sub-i_sub)/n_good_sub])
- hold on
- end
- hold on
- plot([1 2 3],nanmean(population_choices_rewards(2,:,:),3),'sk','MarkerSize',10,'MarkerFaceColor',[0 0 0])
- set(gca,'xtick',[1 2 3],'xticklabel',{'left', 'right', 'timeout'})
- ylim([0 10])
- title('early trials')
- subplot(4,5,8)
- for i_sub=1:n_good_sub
- plot([1 2 3],population_choices_rewards(3,:,i_sub),'-o','Color',[(i_sub)/n_good_sub 0.5 (n_good_sub-i_sub)/n_good_sub])
- hold on
- end
- hold on
- plot([1 2 3],nanmean(population_choices_rewards(3,:,:),3),'sk','MarkerSize',10,'MarkerFaceColor',[0 0 0])
- set(gca,'xtick',[1 2 3],'xticklabel',{'left', 'right', 'timeout'})
- ylim([0 10])
- title('late trials')
- subplot(4,5,9)
- for i_sub=1:n_good_sub
- plot([1 2 3],population_choices_rewards(4,:,i_sub),'-o','Color',[(i_sub)/n_good_sub 0.5 (n_good_sub-i_sub)/n_good_sub])
- hold on
- end
- hold on
- plot([1 2 3],nanmean(population_choices_rewards(4,:,:),3),'sk','MarkerSize',10,'MarkerFaceColor',[0 0 0])
- set(gca,'xtick',[1 2 3],'xticklabel',{'left', 'right', 'timeout'})
- ylim([0 10])
- title('early blocks')
- subplot(4,5,10)
- for i_sub=1:n_good_sub
- plot([1 2 3],population_choices_rewards(5,:,i_sub),'-o','Color',[(i_sub)/n_good_sub 0.5 (n_good_sub-i_sub)/n_good_sub])
- hold on
- end
- hold on
- plot([1 2 3],nanmean(population_choices_rewards(5,:,:),3),'sk','MarkerSize',10,'MarkerFaceColor',[0 0 0])
- set(gca,'xtick',[1 2 3],'xticklabel',{'left', 'right', 'timeout'})
- ylim([0 10])
- title('late blocks')
- subplot(4,5,11)
- for i_sub=1:n_good_sub
- plot([1 2 3 4],population_efforts_rewards(1,:,i_sub),'-o','Color',[(i_sub)/n_good_sub 0.5 (n_good_sub-i_sub)/n_good_sub])
- hold on
- end
- hold on
- plot([1 2 3 4],mean(population_efforts_rewards(1,:,:),3),'sk','MarkerSize',10,'MarkerFaceColor',[0 0 0])
- set(gca,'xtick',[1 2 3 4],'xticklabel',{num2str(Rewards(:))})
- ylim([0 1])
- xlim([1 4])
- ylabel('effort')
- subplot(4,5,12)
- for i_sub=1:n_good_sub
- plot([1 2 3 4],population_efforts_rewards(2,:,i_sub),'-o','Color',[(i_sub)/n_good_sub 0.5 (n_good_sub-i_sub)/n_good_sub])
- hold on
- end
- hold on
- plot(nanmean(population_efforts_rewards(2,:,:),3),'sk','MarkerSize',10,'MarkerFaceColor',[0 0 0])
- set(gca,'xtick',[1 2 3 4],'xticklabel',{num2str(Rewards(:))})
- ylim([0 1])
- xlim([1 4])
- subplot(4,5,13)
- for i_sub=1:n_good_sub
- plot([1 2 3 4],population_efforts_rewards(3,:,i_sub),'-o','Color',[(i_sub)/n_good_sub 0.5 (n_good_sub-i_sub)/n_good_sub])
- hold on
- end
- hold on
- plot(nanmean(population_efforts_rewards(3,:,:),3),'sk','MarkerSize',10,'MarkerFaceColor',[0 0 0])
- set(gca,'xtick',[1 2 3 4],'xticklabel',{num2str(Rewards(:))})
- ylim([0 1])
- xlim([1 4])
- subplot(4,5,14)
- for i_sub=1:n_good_sub
- plot([1 2 3 4],population_efforts_rewards(4,:,i_sub),'-o','Color',[(i_sub)/n_good_sub 0.5 (n_good_sub-i_sub)/n_good_sub])
- hold on
- end
- hold on
- plot(nanmean(population_efforts_rewards(4,:,:),3),'sk','MarkerSize',10,'MarkerFaceColor',[0 0 0])
- set(gca,'xtick',[1 2 3 4],'xticklabel',{num2str(Rewards(:))})
- ylim([0 1])
- xlim([1 4])
- subplot(4,5,15)
- for i_sub=1:n_good_sub
- plot([1 2 3 4],population_efforts_rewards(5,:,i_sub),'-o','Color',[(i_sub)/n_good_sub 0.5 (n_good_sub-i_sub)/n_good_sub])
- hold on
- end
- hold on
- plot(nanmean(population_efforts_rewards(5,:,:),3),'sk','MarkerSize',10,'MarkerFaceColor',[0 0 0])
- set(gca,'xtick',[1 2 3 4],'xticklabel',{num2str(Rewards(:))})
- ylim([0 1])
- xlim([1 4])
- subplot(4,5,16)
- for i_sub=1:n_good_sub
- plot([1 2 3 4],population_rewards_efforts(1,:,i_sub),'-o','Color',[(i_sub)/n_good_sub 0.5 (n_good_sub-i_sub)/n_good_sub])
- hold on
- end
- hold on
- plot(nanmean(population_rewards_efforts(1,:,:),3),'sk','MarkerSize',10,'MarkerFaceColor',[0 0 0])
- set(gca,'xtick',[1 2 3 4],'xticklabel',{num2str(ForceLevels(:))})
- ylabel('rewards')
- ylim([0 10])
- xlim([1 4])
- subplot(4,5,17)
- for i_sub=1:n_good_sub
- plot([1 2 3 4],population_rewards_efforts(2,:,i_sub),'-o','Color',[(i_sub)/n_good_sub 0.5 (n_good_sub-i_sub)/n_good_sub])
- hold on
- end
- hold on
- plot(nanmean(population_rewards_efforts(2,:,:),3),'sk','MarkerSize',10,'MarkerFaceColor',[0 0 0])
- set(gca,'xtick',[1 2 3 4],'xticklabel',{num2str(ForceLevels(:))})
- ylim([0 10])
- xlim([1 4])
- subplot(4,5,18)
- for i_sub=1:n_good_sub
- plot([1 2 3 4],population_rewards_efforts(3,:,i_sub),'-o','Color',[(i_sub)/n_good_sub 0.5 (n_good_sub-i_sub)/n_good_sub])
- hold on
- end
- hold on
- plot(nanmean(population_rewards_efforts(3,:,:),3),'sk','MarkerSize',10,'MarkerFaceColor',[0 0 0])
- set(gca,'xtick',[1 2 3 4],'xticklabel',{num2str(ForceLevels(:))})
- ylim([0 10])
- xlim([1 4])
- subplot(4,5,19)
- for i_sub=1:n_good_sub
- plot([1 2 3 4],population_rewards_efforts(4,:,i_sub),'-o','Color',[(i_sub)/n_good_sub 0.5 (n_good_sub-i_sub)/n_good_sub])
- hold on
- end
- hold on
- plot(nanmean(population_rewards_efforts(4,:,:),3),'sk','MarkerSize',10,'MarkerFaceColor',[0 0 0])
- set(gca,'xtick',[1 2 3 4],'xticklabel',{num2str(ForceLevels(:))})
- ylim([0 10])
- xlim([1 4])
- subplot(4,5,20)
- for i_sub=1:n_good_sub
- plot([1 2 3 4],population_rewards_efforts(5,:,i_sub),'-o','Color',[(i_sub)/n_good_sub 0.5 (n_good_sub-i_sub)/n_good_sub])
- hold on
- end
- hold on
- plot(nanmean(population_rewards_efforts(5,:,:),3),'sk','MarkerSize',10,'MarkerFaceColor',[0 0 0])
- set(gca,'xtick',[1 2 3 4],'xticklabel',{num2str(ForceLevels(:))})
- ylim([0 10])
- xlim([1 4])
- %% distance analysis
- D1 = 0;
- D2 = prctile(1-population_advancement(:),90);
- X_distance = [D1:abs(D2-D1)/10:D2];
- [N_distance,X_distance] = hist(1-population_advancement(:),X_distance); %10 bins between the 10th and 90th perctile of population_pressure
- for i_distance = 1:length(X_distance)
- if i_distance==1
- indeces_this_distance{i_distance} = find((1-population_advancement(:))<X_distance(i_distance));
- elseif i_distance<length(X_distance)
- indeces_this_distance{i_distance} = find((1-population_advancement(:))<X_distance(i_distance+1)&(1-population_advancement(:))>X_distance(i_distance));
- else
- indeces_this_distance{i_distance} = find((1-population_advancement(:))>X_distance(i_distance));
- end
- indeces_this_distance_early_blocks{i_distance} = intersect(indeces_this_distance{i_distance},early_blocks_indeces);
- indeces_this_distance_late_blocks{i_distance} = intersect(indeces_this_distance{i_distance},late_blocks_indeces);
- indeces_this_distance_hard_blocks{i_distance} = intersect(indeces_this_distance{i_distance},hard_blocks_indeces);
- indeces_this_distance_easy_blocks{i_distance} = intersect(indeces_this_distance{i_distance},easy_blocks_indeces);
- population_choices_vs_distance(i_distance)= nanmean(population_choices(indeces_this_distance{i_distance}));
- population_choices_vs_distance_se(i_distance) = nanstd(population_choices(indeces_this_distance{i_distance}))/sqrt(length(~isnan(population_choices(indeces_this_distance{i_distance})))/n_good_sub);
- population_choices_vs_distance_early_blocks(i_distance)= nanmean(population_choices(indeces_this_distance_early_blocks{i_distance}));
- population_choices_vs_distance_late_blocks(i_distance)= nanmean(population_choices(indeces_this_distance_late_blocks{i_distance}));
- population_choices_vs_distance_hard_blocks(i_distance)= nanmean(population_choices(indeces_this_distance_hard_blocks{i_distance}));
- population_choices_vs_distance_easy_blocks(i_distance)= nanmean(population_choices(indeces_this_distance_easy_blocks{i_distance}));
- end
- %% choice vs goal pressure analysis
- P1 = prctile(population_pressure(:),10);
- P2 = prctile(population_pressure(:),90);
- X_pressure = [P1:abs(P2-P1)/10:P2];
- [N_pressure,X_pressure] = hist(population_pressure(:),X_pressure); %10 bins between the 10th and 90th perctile of population_pressure
- for i_pressure = 1:length(X_pressure)
- if i_pressure==1
- indeces_this_pressure{i_pressure} = find(population_pressure(:)<X_pressure(i_pressure));
- elseif i_pressure<length(X_pressure)
- indeces_this_pressure{i_pressure} = find((population_pressure(:)<X_pressure(i_pressure+1))&population_pressure(:)>X_pressure(i_pressure));
- else
- indeces_this_pressure{i_pressure} = find(population_pressure(:)>X_pressure(i_pressure));
- end
- indeces_this_pressure_early_blocks{i_pressure} = intersect(indeces_this_pressure{i_pressure},early_blocks_indeces);
- indeces_this_pressure_late_blocks{i_pressure} = intersect(indeces_this_pressure{i_pressure},late_blocks_indeces);
- indeces_this_pressure_hard_blocks{i_pressure} = intersect(indeces_this_pressure{i_pressure},hard_blocks_indeces);
- indeces_this_pressure_easy_blocks{i_pressure} = intersect(indeces_this_pressure{i_pressure},easy_blocks_indeces);
- population_choices_vs_pressure(i_pressure)= nanmean(population_choices(indeces_this_pressure{i_pressure}));
- population_choices_vs_pressure_se(i_pressure) = nanstd(population_choices(indeces_this_pressure{i_pressure}))/sqrt(length(~isnan(population_choices(indeces_this_pressure{i_pressure})))/n_good_sub);
- population_choices_vs_pressure_std(i_pressure) = nanstd(population_choices(indeces_this_pressure{i_pressure}));
- population_choices_vs_pressure_early_blocks(i_pressure)= nanmean(population_choices(indeces_this_pressure_early_blocks{i_pressure}));
- population_choices_vs_pressure_late_blocks(i_pressure)= nanmean(population_choices(indeces_this_pressure_late_blocks{i_pressure}));
- population_choices_vs_pressure_hard_blocks(i_pressure)= nanmean(population_choices(indeces_this_pressure_hard_blocks{i_pressure}));
- population_choices_vs_pressure_easy_blocks(i_pressure)= nanmean(population_choices(indeces_this_pressure_easy_blocks{i_pressure}));
- population_choices_vs_pressure_hard_blocks_se(i_pressure)= nanstd(population_choices(indeces_this_pressure_hard_blocks{i_pressure}))/sqrt(length(~isnan(population_choices(indeces_this_pressure_hard_blocks{i_pressure})))/n_good_sub);
- population_choices_vs_pressure_easy_blocks_se(i_pressure)= nanstd(population_choices(indeces_this_pressure_easy_blocks{i_pressure}))/sqrt(length(~isnan(population_choices(indeces_this_pressure_easy_blocks{i_pressure})))/n_good_sub);
- population_choices_vs_pressure_hard_blocks_std(i_pressure)= nanstd(population_choices(indeces_this_pressure_hard_blocks{i_pressure}));
- population_choices_vs_pressure_easy_blocks_std(i_pressure)= nanstd(population_choices(indeces_this_pressure_easy_blocks{i_pressure}));
- end
- %% simulated choice vs goal pressure analysis
- for i_pressure = 1:length(X_pressure)
- population_sim_choices_vs_pressure(i_pressure)= nanmean(population_simulated_choices(indeces_this_pressure{i_pressure}));
- population_sim_choices_vs_pressure_se(i_pressure) = nanstd(population_simulated_choices(indeces_this_pressure{i_pressure}))/sqrt(length(~isnan(population_simulated_choices(indeces_this_pressure{i_pressure})))/n_good_sub);
- population_sim_choices_vs_pressure_std(i_pressure) = nanstd(population_simulated_choices(indeces_this_pressure{i_pressure}));
- population_sim_choices_vs_pressure_early_blocks(i_pressure)= nanmean(population_simulated_choices(indeces_this_pressure_early_blocks{i_pressure}));
- population_sim_choices_vs_pressure_late_blocks(i_pressure)= nanmean(population_simulated_choices(indeces_this_pressure_late_blocks{i_pressure}));
- population_sim_choices_vs_pressure_hard_blocks(i_pressure)= nanmean(population_simulated_choices(indeces_this_pressure_hard_blocks{i_pressure}));
- population_sim_choices_vs_pressure_easy_blocks(i_pressure)= nanmean(population_simulated_choices(indeces_this_pressure_easy_blocks{i_pressure}));
- population_sim_choices_vs_pressure_hard_blocks_se(i_pressure)= nanstd(population_simulated_choices(indeces_this_pressure_hard_blocks{i_pressure}))/sqrt(length(~isnan(population_simulated_choices(indeces_this_pressure_hard_blocks{i_pressure})))/n_good_sub);
- population_sim_choices_vs_pressure_easy_blocks_se(i_pressure)= nanstd(population_simulated_choices(indeces_this_pressure_easy_blocks{i_pressure}))/sqrt(length(~isnan(population_simulated_choices(indeces_this_pressure_easy_blocks{i_pressure})))/n_good_sub);
- population_sim_choices_vs_pressure_hard_blocks_std(i_pressure)= nanstd(population_simulated_choices(indeces_this_pressure_hard_blocks{i_pressure}));
- population_sim_choices_vs_pressure_easy_blocks_std(i_pressure)= nanstd(population_simulated_choices(indeces_this_pressure_easy_blocks{i_pressure}));
- end
- %% choice vs reaction time analysis
- RT1 = prctile(population_RT(:),5);
- RT2 = prctile(population_RT(:),95);
- logRT1 = prctile(log(population_RT(:)),5);
- logRT2 = prctile(log(population_RT(:)),95);
- X_RT = [RT1:abs(RT2-RT1)/20:RT2];
- X_log_RT = [logRT1:abs(logRT2-logRT1)/20:logRT2];
- [N_RT,X_RT] = hist(population_RT(:),X_RT); %10 bins between the 10th and 90th perctile of population_RT
- [N_log_RT,X_log_RT] = hist(log(population_RT(:)),X_log_RT); %10 bins between the 10th and 90th perctile of population_RT
- for i_RT = 1:length(X_RT)
- if i_RT==1
- indeces_this_RT{i_RT} = find(population_RT(:)<X_RT(i_RT));
- indeces_this_log_RT{i_RT} = find(log(population_RT(:))<X_log_RT(i_RT));
- elseif i_RT<length(X_RT)
- indeces_this_RT{i_RT} = find((population_RT(:)<X_RT(i_RT+1))&population_RT(:)>X_RT(i_RT));
- indeces_this_log_RT{i_RT} = find((log(population_RT(:))<X_log_RT(i_RT+1))&log(population_RT(:))>X_log_RT(i_RT));
- else
- indeces_this_RT{i_RT} = find(population_RT(:)>X_RT(i_RT));
- indeces_this_log_RT{i_RT} = find(log(population_RT(:))>X_log_RT(i_RT));
- end
- indeces_this_RT_early_blocks{i_RT} = intersect(indeces_this_RT{i_RT},early_blocks_indeces);
- indeces_this_RT_late_blocks{i_RT} = intersect(indeces_this_RT{i_RT},late_blocks_indeces);
- indeces_this_RT_hard_blocks{i_RT} = intersect(indeces_this_RT{i_RT},hard_blocks_indeces);
- indeces_this_RT_easy_blocks{i_RT} = intersect(indeces_this_RT{i_RT},easy_blocks_indeces);
- population_choices_vs_RT(i_RT)= nanmean(population_choices(indeces_this_RT{i_RT}));
- population_choices_vs_RT_se(i_RT) = nanstd(population_choices(indeces_this_RT{i_RT}))/sqrt(length(indeces_this_RT{i_RT})/n_good_sub);
- population_choices_vs_RT_std(i_RT) = nanstd(population_choices(indeces_this_RT{i_RT}));
- population_choices_vs_log_RT(i_RT)= nanmean(population_choices(indeces_this_log_RT{i_RT}));
- population_choices_vs_log_RT_se(i_RT) = nanstd(population_choices(indeces_this_log_RT{i_RT}))/sqrt(length(indeces_this_log_RT{i_RT})/n_good_sub);
- population_choices_vs_log_RT_std(i_RT) = nanstd(population_choices(indeces_this_log_RT{i_RT}));
- population_choices_vs_RT_early_blocks(i_RT)= nanmean(population_choices(indeces_this_RT_early_blocks{i_RT}));
- population_choices_vs_RT_late_blocks(i_RT)= nanmean(population_choices(indeces_this_RT_late_blocks{i_RT}));
- population_choices_vs_RT_hard_blocks(i_RT)= nanmean(population_choices(indeces_this_RT_hard_blocks{i_RT}));
- population_choices_vs_RT_easy_blocks(i_RT)= nanmean(population_choices(indeces_this_RT_easy_blocks{i_RT}));
- end
- %% RT vs goal pressure analysis
- P1 = prctile(population_pressure(:),5);
- P2 = prctile(population_pressure(:),95);
- X_pressure = [P1:abs(P2-P1)/10:P2];
- [N_pressure,X_pressure] = hist(population_pressure(:),X_pressure); %10 bins between the 10th and 90th perctile of population_pressure
- for i_pressure = 1:length(X_pressure)
- if i_pressure==1
- indeces_this_pressure{i_pressure} = find(population_pressure(:)<X_pressure(i_pressure));
- elseif i_pressure<length(X_pressure)
- indeces_this_pressure{i_pressure} = find((population_pressure(:)<X_pressure(i_pressure+1))&population_pressure(:)>X_pressure(i_pressure));
- else
- indeces_this_pressure{i_pressure} = find(population_pressure(:)>X_pressure(i_pressure));
- end
- indeces_this_pressure_early_blocks{i_pressure} = intersect(indeces_this_pressure{i_pressure},early_blocks_indeces);
- indeces_this_pressure_late_blocks{i_pressure} = intersect(indeces_this_pressure{i_pressure},late_blocks_indeces);
- indeces_this_pressure_hard_blocks{i_pressure} = intersect(indeces_this_pressure{i_pressure},hard_blocks_indeces);
- indeces_this_pressure_easy_blocks{i_pressure} = intersect(indeces_this_pressure{i_pressure},easy_blocks_indeces);
- population_RT_vs_pressure(i_pressure)= nanmean(population_RT(indeces_this_pressure{i_pressure}));
- population_RT_vs_pressure_se(i_pressure) = nanstd(population_RT(indeces_this_pressure{i_pressure}))/sqrt(length(indeces_this_pressure{i_pressure})/n_good_sub);
- population_RT_vs_pressure_std(i_pressure) = nanstd(population_RT(indeces_this_pressure{i_pressure}));
- population_log_RT_vs_pressure(i_pressure)= nanmean(log(population_RT(indeces_this_pressure{i_pressure})));
- population_log_RT_vs_pressure_se(i_pressure) = nanstd(log(population_RT(indeces_this_pressure{i_pressure})))/sqrt(length(indeces_this_pressure{i_pressure})/n_good_sub);
- population_log_RT_vs_pressure_std(i_pressure) = nanstd(log(population_RT(indeces_this_pressure{i_pressure})));
- population_RT_vs_pressure_early_blocks(i_pressure)= nanmean(population_RT(indeces_this_pressure_early_blocks{i_pressure}));
- population_RT_vs_pressure_late_blocks(i_pressure)= nanmean(population_RT(indeces_this_pressure_late_blocks{i_pressure}));
- population_RT_vs_pressure_hard_blocks(i_pressure)= nanmean(population_RT(indeces_this_pressure_hard_blocks{i_pressure}));
- population_RT_vs_pressure_easy_blocks(i_pressure)= nanmean(population_RT(indeces_this_pressure_easy_blocks{i_pressure}));
- end
- %% choice vs homeostatic analysis
- H1 = prctile(population_reward_advancement_homeostasis(:),5);
- H2 = prctile(population_reward_advancement_homeostasis(:),95);
- X_homeostasis = [H1:abs(H2-H1)/10:H2];
- [N_homeostasis,X_homeostasis] = hist(population_reward_advancement_homeostasis(:),X_homeostasis); %10 bins between the 10th and 90th perctile of population_RT
- for i_homeostasis = 1:length(X_homeostasis)
- if i_homeostasis==1
- indeces_this_homeostasis{i_homeostasis} = find(population_reward_advancement_homeostasis(:)<X_homeostasis(i_homeostasis));
- elseif i_homeostasis<length(X_homeostasis)
- indeces_this_homeostasis{i_homeostasis} = find((population_reward_advancement_homeostasis(:)<X_homeostasis(i_homeostasis+1))&population_reward_advancement_homeostasis(:)>X_homeostasis(i_homeostasis));
- else
- indeces_this_homeostasis{i_homeostasis} = find(population_reward_advancement_homeostasis(:)>X_homeostasis(i_homeostasis));
- end
- indeces_this_homeostasis_early_blocks{i_homeostasis} = intersect(indeces_this_homeostasis{i_homeostasis},early_blocks_indeces);
- indeces_this_homeostasis_late_blocks{i_homeostasis} = intersect(indeces_this_homeostasis{i_homeostasis},late_blocks_indeces);
- indeces_this_homeostasis_hard_blocks{i_homeostasis} = intersect(indeces_this_homeostasis{i_homeostasis},hard_blocks_indeces);
- indeces_this_homeostasis_easy_blocks{i_homeostasis} = intersect(indeces_this_homeostasis{i_homeostasis},easy_blocks_indeces);
- population_choices_vs_homeostasis(i_homeostasis)= nanmean(population_choices(indeces_this_homeostasis{i_homeostasis}));
- population_choices_vs_homeostasis_se(i_homeostasis) = nanstd(population_choices(indeces_this_homeostasis{i_homeostasis}))/sqrt(length(indeces_this_homeostasis{i_homeostasis})/n_good_sub);
- population_choices_vs_homeostasis_early_blocks(i_homeostasis)= nanmean(population_choices(indeces_this_homeostasis_early_blocks{i_homeostasis}));
- population_choices_vs_homeostasis_late_blocks(i_homeostasis)= nanmean(population_choices(indeces_this_homeostasis_late_blocks{i_homeostasis}));
- population_choices_vs_homeostasis_hard_blocks(i_homeostasis)= nanmean(population_choices(indeces_this_homeostasis_hard_blocks{i_homeostasis}));
- population_choices_vs_homeostasis_easy_blocks(i_homeostasis)= nanmean(population_choices(indeces_this_homeostasis_easy_blocks{i_homeostasis}));
- end
- %% pressure distance distribution
- h_pressure_distance = figure('Name',['Population pressure distance distribution '],'units','normalized','outerposition',[0 0 1 1]);
- subplot(2,3,1)
- boundedline(1:n_trials,1-mean(nanmean(mean_population_advancement(:,1:n_trials,:),3),1), nanstd(squeeze(nanmean(mean_population_advancement(:,1:n_trials,:),1)),[],2),'alpha','cmap',[.1 .1 .1],'transparency', trasp);
- hold on
- plot(1:n_trials,1-mean(nanmean(mean_population_advancement(:,1:n_trials,:)),3),'LineWidth',5,'Color',[0.1 0.1 0.1])
- title('distance')
- xlim([1 n_trials])
- ylim([0 1])
- xlabel('trials')
- subplot(2,3,4)
- hist(1-population_advancement(:),20)
- subplot(2,3,2)
- boundedline(1:n_trials,mean(nanmean(mean_population_pressure(:,1:n_trials,:),3),1), nanstd(squeeze(nanmean(mean_population_pressure(:,1:n_trials,:),1)),[],2),'alpha','cmap',[.1 .1 .1],'transparency', trasp);
- hold on
- plot(1:n_trials,mean(nanmean(mean_population_pressure(:,1:n_trials,:)),3),'LineWidth',5,'Color',[0.1 0.1 0.1])
- hold on
- % plot([1 n_trials],[max_pressure(1) max_pressure(1)],'--r')
- title('pressure')
- xlim([1 n_trials])
- xlabel('trials')
- subplot(2,3,5)
- hist(population_pressure(:),20)
- subplot(2,3,3)
- boundedline(1:n_trials,mean(nanmean(mean_population_reward_advancement_homeostasis(:,1:n_trials,:),3),1), nanstd(squeeze(nanmean(mean_population_reward_advancement_homeostasis(:,1:n_trials,:),1)),[],2),'alpha','cmap',[.1 .1 .1],'transparency', trasp);
- hold on
- plot(1:n_trials,mean(nanmean(mean_population_reward_advancement_homeostasis(:,1:n_trials,:)),3),'LineWidth',5,'Color',[0.1 0.1 0.1])
- hold on
- % plot([1 n_trials],[max_pressure(1) max_pressure(1)],'--r')
- title('homeostasis')
- xlim([1 n_trials])
- xlabel('trials')
- subplot(2,3,6)
- hist(population_reward_advancement_homeostasis(:),20)
- %% pressure distance distribution
- h_pressure_homeostasis_distance = figure('Name',['Population pressure distance distribution ']);
- subplot(3,1,1)
- plot(population_pressure(:),population_reward_advancement_homeostasis(:),'o')
- xlabel('pressure')
- ylabel('homeostasis')
- subplot(3,1,2)
- plot(1-population_advancement(:),population_reward_advancement_homeostasis(:),'o')
- xlabel('distance')
- ylabel('homeostasis')
- subplot(3,1,3)
- plot(population_pressure(:),1-population_advancement(:),'o')
- xlabel('pressure')
- ylabel('distance')
- %% simulated choices vs trials/pressure FIG 2 A/B for simulated data
- h_pop0_sim_name = 'Population simulated choices vs trials pressure ';
- h_pop0_sim = figure('Name',h_pop0_sim_name,'units','normalized','outerposition',[0 0 1 1]);
- subplot(2,2,1)
- boundedline(1:n_trials,nanmean(mean_population_simulated_choices,1), mean(std_population_simulated_choices(:,1:n_trials),1)/sqrt(n_blocks),'alpha','cmap',[.5 .5 .5],'transparency', trasp);
- hold on
- plot(1:n_trials,nanmean(mean_population_simulated_choices,1),'LineWidth',5,'Color',[0.1 0.1 0.1])
- hold on
- ylim([0.9 2.1])
- xlim([1 n_trials])
- hold on
- plot([1 n_trials],[1 1],'--r')
- hold on
- plot([1 n_trials],[2 2],'--r')
- set(gca,'YTick',1:2);
- set(gca,'YTickLabel',{'0','100%'});
- ylabel('% high effort sim choice')
- title('N = 30');
- subplot(2,2,2)
- boundedline(X_pressure,population_sim_choices_vs_pressure, population_sim_choices_vs_pressure_se,'alpha','cmap',[.5 .5 .5],'transparency', trasp);
- hold on
- plot(X_pressure,population_sim_choices_vs_pressure,'LineWidth',5,'Color',[0.1 0.1 0.1])
- plot([P1 P2],[1 1],'--r')
- hold on
- plot([P1 P2],[2 2],'--r')
- set(gca,'YTick',1:2);
- set(gca,'YTickLabel',{'0','100%'});
- xlim([P1 P2])
- ylim([0.9 2.1])
- title('Binned pressure');
- fprintf('Correlation sim choice pressure is %f \n',corr(X_pressure',population_sim_choices_vs_pressure'))
- if variable_pressure_flag
- subplot(2,2,3)
- boundedline(1:n_trials,nanmean(mean_population_simulated_choices_sortedbyblockpressure(1:15,:),1), mean(std_population_simulated_choices_sortedbyblockpressure(1:15,1:n_trials),1)/sqrt(n_blocks),'alpha','cmap',[.5 .5 .5],'transparency', trasp);
- hold on
- plot(1:n_trials,nanmean(mean_population_simulated_choices_sortedbyblockpressure(1:15,:),1),'LineWidth',5,'Color',[0 1 0])
- hold on
- boundedline(1:n_trials,nanmean(mean_population_simulated_choices_sortedbyblockpressure(16:30,:),1), mean(std_population_simulated_choices_sortedbyblockpressure(16:30,1:n_trials),1)/sqrt(n_blocks),'alpha','cmap',[.5 .5 .5],'transparency', trasp);
- hold on
- plot(1:n_trials,nanmean(mean_population_simulated_choices_sortedbyblockpressure(16:30,:),1),'LineWidth',5,'Color',[1 0 0])
- plot([1 n_trials],[1 1],'--r')
- hold on
- plot([1 n_trials],[2 2],'--r')
- set(gca,'YTick',1:2);
- set(gca,'YTickLabel',{'0','100%'});
- xlim([1 n_trials])
- ylim([0.9 2.1])
- xlabel('trial')
- ylabel('% high effort choice')
- subplot(2,2,4)
- boundedline(X_pressure,population_sim_choices_vs_pressure_hard_blocks,population_sim_choices_vs_pressure_hard_blocks_se,'alpha','cmap',[.5 .5 .5],'transparency', trasp);
- hold on
- plot(X_pressure,population_sim_choices_vs_pressure_hard_blocks,'LineWidth',5,'Color',[0 1 0])
- hold on
- boundedline(X_pressure,population_sim_choices_vs_pressure_easy_blocks,population_sim_choices_vs_pressure_easy_blocks_se,'alpha','cmap',[.5 .5 .5],'transparency', trasp);
- hold on
- plot(X_pressure,population_sim_choices_vs_pressure_easy_blocks,'LineWidth',5,'Color',[[1 0 0]])
- plot([P1 P2],[1 1],'--r')
- hold on
- plot([P1 P2],[2 2],'--r')
- xlim([P1 P2])
- ylim([0.9 2.1])
- set(gca,'YTick',1:2);
- set(gca,'YTickLabel',{'0','100%'});
- xlabel('pressure = distance/time')
- fprintf('Correlation sim choice pressure in high pr blocks is %f \n',corr(X_pressure',population_sim_choices_vs_pressure_hard_blocks'))
- fprintf('Correlation sim choice pressure in low pr blocks is %f \n',corr(X_pressure',population_sim_choices_vs_pressure_easy_blocks'))
- end
- %% choices vs trials/pressure FIG 2 A/B
- h_pop0_name = 'Population choices vs trials pressure ';
- h_pop0 = figure('Name',h_pop0_name,'units','normalized','outerposition',[0 0 1 1]);
- subplot(2,2,1)
- boundedline(1:n_trials,nanmean(mean_population_choices,1), mean(std_population_choices(:,1:n_trials),1)/sqrt(n_blocks),'alpha','cmap',[.5 .5 .5],'transparency', trasp);
- % boundedline(1:n_trials,nanmean(mean_population_choices,1), mean(std_population_choices(:,1:n_trials),1),'alpha','cmap',[.5 .5 .5],'transparency', trasp);
- hold on
- plot(1:n_trials,nanmean(mean_population_choices,1),'LineWidth',5,'Color',[0.1 0.1 0.1])
- hold on
- ylim([0.9 2.1])
- xlim([1 n_trials])
- hold on
- plot([1 n_trials],[1 1],'--r')
- hold on
- plot([1 n_trials],[2 2],'--r')
- set(gca,'YTick',1:2);
- set(gca,'YTickLabel',{'0','100%'});
- ylabel('% high effort choice')
- title('N = 30');
- subplot(2,2,2)
- boundedline(X_pressure,population_choices_vs_pressure, population_choices_vs_pressure_se,'alpha','cmap',[.5 .5 .5],'transparency', trasp);
- %boundedline(X_pressure,population_choices_vs_pressure, population_choices_vs_pressure_std,'alpha','cmap',[.5 .5 .5],'transparency', trasp);
- hold on
- plot(X_pressure,population_choices_vs_pressure,'LineWidth',5,'Color',[0.1 0.1 0.1])
- plot([P1 P2],[1 1],'--r')
- hold on
- plot([P1 P2],[2 2],'--r')
- set(gca,'YTick',1:2);
- set(gca,'YTickLabel',{'0','100%'});
- xlim([P1 P2])
- ylim([0.9 2.1])
- title('Binned pressure');
- fprintf('Correlation choice pressure is %f \n',corr(X_pressure',population_choices_vs_pressure'))
- if variable_pressure_flag
- subplot(2,2,3)
- boundedline(1:n_trials,nanmean(mean_population_choices_sortedbyblockpressure(1:15,:),1), mean(std_population_choices_sortedbyblockpressure(1:15,1:n_trials),1)/sqrt(n_blocks),'alpha','cmap',[.5 .5 .5],'transparency', trasp);
- hold on
- plot(1:n_trials,nanmean(mean_population_choices_sortedbyblockpressure(1:15,:),1),'LineWidth',5,'Color',[0 1 0])
- hold on
- boundedline(1:n_trials,nanmean(mean_population_choices_sortedbyblockpressure(16:30,:),1), mean(std_population_choices_sortedbyblockpressure(16:30,1:n_trials),1)/sqrt(n_blocks),'alpha','cmap',[.5 .5 .5],'transparency', trasp);
- hold on
- plot(1:n_trials,nanmean(mean_population_choices_sortedbyblockpressure(16:30,:),1),'LineWidth',5,'Color',[1 0 0])
- plot([1 n_trials],[1 1],'--r')
- hold on
- plot([1 n_trials],[2 2],'--r')
- set(gca,'YTick',1:2);
- set(gca,'YTickLabel',{'0','100%'});
- xlim([1 n_trials])
- ylim([0.9 2.1])
- xlabel('trial')
- ylabel('% high effort choice')
- subplot(2,2,4)
- boundedline(X_pressure,population_choices_vs_pressure_hard_blocks,population_choices_vs_pressure_hard_blocks_se,'alpha','cmap',[.5 .5 .5],'transparency', trasp);
- hold on
- plot(X_pressure,population_choices_vs_pressure_hard_blocks,'LineWidth',5,'Color',[0 1 0])
- hold on
- boundedline(X_pressure,population_choices_vs_pressure_easy_blocks,population_choices_vs_pressure_easy_blocks_se,'alpha','cmap',[.5 .5 .5],'transparency', trasp);
- hold on
- plot(X_pressure,population_choices_vs_pressure_easy_blocks,'LineWidth',5,'Color',[[1 0 0]])
- plot([P1 P2],[1 1],'--r')
- hold on
- plot([P1 P2],[2 2],'--r')
- xlim([P1 P2])
- ylim([0.9 2.1])
- set(gca,'YTick',1:2);
- set(gca,'YTickLabel',{'0','100%'});
- xlabel('pressure = distance/time')
- fprintf('Correlation choice pressure in high pr blocks is %f \n',corr(X_pressure',population_choices_vs_pressure_hard_blocks'))
- fprintf('Correlation choice pressure in low pr blocks is %f \n',corr(X_pressure',population_choices_vs_pressure_easy_blocks'))
- end
- %% CHOICES VS TRIALS BLOCKS DISTANCE PRESSURE HOMEOSTASIS
- h_choice = figure('Name',['Population choices vs other things ']);
- subplot(3,2,1)
- boundedline(1:n_trials,nanmean(mean_population_choices(:,1:n_trials),1),std(mean_population_choices(:,1:n_trials),1)/sqrt(n_blocks),'alpha','cmap',[.5 .5 .5],'transparency', trasp);
- hold on
- plot(1:n_trials,nanmean(mean_population_choices(:,1:n_trials),1),'LineWidth',3,'Color',[0.1 0.1 0.1])
- plot([1 n_trials],[1 1],'--r')
- hold on
- plot([1 n_trials],[2 2],'--r')
- ylim([0.9 2.1])
- xlim([1 n_trials])
- xlabel('trials')
- set(gca,'YTick',1:2);
- set(gca,'YTickLabel',{'0','100%'});
- ylabel('% high effort choice')
- subplot(3,2,3)
- boundedline(1:n_blocks,nanmean(mean_population_choices(:,1:n_trials),2),std(mean_population_choices(:,1:n_trials),[],2)/sqrt(n_trials),'alpha','cmap',[.5 .5 .5],'transparency', trasp);
- hold on
- plot(1:n_blocks,nanmean(mean_population_choices(:,1:n_trials),2),'LineWidth',3,'Color',[0.1 0.1 0.1])
- hold on
- plot([1 n_blocks],[1 1],'--r')
- hold on
- plot([1 n_blocks],[2 2],'--r')
- ylim([0.9 2.1])
- set(gca,'YTick',1:2);
- set(gca,'YTickLabel',{'0','100%'});
- ylabel('% high effort choice')
- xlabel('blocks')
- subplot(3,2,2)
- boundedline(X_distance,population_choices_vs_distance,population_choices_vs_distance_se,'alpha','cmap',[.5 .5 .5],'transparency', trasp);
- hold on
- plot(X_distance,population_choices_vs_distance,'LineWidth',3,'Color',[0.1 0.1 0.1])
- plot([D1 D2],[1 1],'--r')
- hold on
- plot([D1 D2],[2 2],'--r')
- set(gca, 'XDir','reverse')
- xlim([D1 D2])
- ylim([0.9 2.1])
- xlabel('distance')
- set(gca,'YTick',1:2);
- set(gca,'YTickLabel',{'0','100%'});
- subplot(3,2,4)
- boundedline(X_pressure,population_choices_vs_pressure,population_choices_vs_pressure_se,'alpha','cmap',[.5 .5 .5],'transparency', trasp);
- hold on
- plot(X_pressure,population_choices_vs_pressure,'LineWidth',3,'Color',[0.1 0.1 0.1])
- plot([P1 P2],[1 1],'--r')
- hold on
- plot([P1 P2],[2 2],'--r')
- xlim([P1 P2])
- ylim([0.9 2.1])
- xlabel('pressure')
- set(gca,'YTick',1:2);
- set(gca,'YTickLabel',{'0','100%'});
- subplot(3,2,6)
- boundedline(X_homeostasis,population_choices_vs_homeostasis,population_choices_vs_homeostasis_se,'alpha','cmap',[.5 .5 .5],'transparency', trasp);
- hold on
- plot(X_homeostasis,population_choices_vs_homeostasis,'LineWidth',3,'Color',[0.1 0.1 0.1])
- plot([H1 H2],[1 1],'--r')
- hold on
- plot([H1 H2],[2 2],'--r')
- xlim([H1 H2])
- ylim([0.9 2.1])
- xlabel('homeostasis')
- set(gca,'YTick',1:2);
- set(gca,'YTickLabel',{'0','100%'});
- %% choices vs trials/blocks early late blocks
- h_choice_early_late_blocks = figure('Name','Population choices vs trials early late blocks','units','normalized','outerposition',[0 0 1 1]);
- subplot(3,2,1)
- plot(nanmean(mean_population_choices(early_blocks,1:n_trials),1),'g')
- hold on
- plot(nanmean(mean_population_choices(late_blocks,1:n_trials),1),'r')
- plot([1 n_trials],[1 1],'--r')
- hold on
- plot([1 n_trials],[2 2],'--r')
- ylim([0.9 2.1])
- xlim([1 n_trials])
- set(gca,'YTick',1:2);
- set(gca,'YTickLabel',{'0','100%'});
- ylabel('% high effort choice')
- xlabel('trials')
- subplot(3,2,3)
- plot(early_blocks,nanmean(mean_population_choices(early_blocks,1:n_trials),2),'g')
- hold on
- plot(early_blocks,nanmean(mean_population_choices(early_blocks,1:n_trials),2)+nanstd(mean_population_choices(early_blocks,1:n_trials),[],2)/sqrt(n_trials),'--g')
- hold on
- plot(early_blocks,nanmean(mean_population_choices(early_blocks,1:n_trials),2)-nanstd(mean_population_choices(early_blocks,1:n_trials),[],2)/sqrt(n_trials),'--g')
- hold on
- subplot(3,2,3)
- plot(late_blocks,nanmean(mean_population_choices(late_blocks,1:n_trials),2),'r')
- hold on
- plot(late_blocks,nanmean(mean_population_choices(late_blocks,1:n_trials),2)+nanstd(mean_population_choices(late_blocks,1:n_trials),[],2)/sqrt(n_trials),'--r')
- hold on
- plot(late_blocks,nanmean(mean_population_choices(late_blocks,1:n_trials),2)-nanstd(mean_population_choices(late_blocks,1:n_trials),[],2)/sqrt(n_trials),'--r')
- hold on
- plot([1 n_blocks],[1 1],'--r')
- hold on
- plot([1 n_blocks],[2 2],'--r')
- ylim([0.9 2.1])
- set(gca,'YTick',1:2);
- set(gca,'YTickLabel',{'0','100%'});
- ylabel('% high effort choice')
- xlabel('blocks')
- subplot(3,2,2)
- plot(X_distance,population_choices_vs_distance_early_blocks,'g')
- hold on
- plot(X_distance,population_choices_vs_distance_late_blocks,'r')
- hold on
- plot([D1 D2],[1 1],'--r')
- hold on
- plot([D1 D2],[2 2],'--r')
- xlim([D1 D2])
- ylim([0.9 2.1])
- set(gca, 'XDir','reverse')
- set(gca,'YTick',1:2);
- set(gca,'YTickLabel',{'0','100%'});
- xlabel('distance')
- subplot(3,2,4)
- plot(X_pressure,population_choices_vs_pressure_early_blocks,'g')
- hold on
- plot(X_pressure,population_choices_vs_pressure_late_blocks,'r')
- plot([P1 P2],[1 1],'--r')
- hold on
- plot([P1 P2],[2 2],'--r')
- xlim([P1 P2])
- ylim([0.9 2.1])
- xlabel('pressure')
- set(gca,'YTick',1:2);
- set(gca,'YTickLabel',{'0','100%'});
- ylabel('% high effort choice')
- subplot(3,2,6)
- plot(X_homeostasis,population_choices_vs_homeostasis_early_blocks,'g')
- hold on
- plot(X_homeostasis,population_choices_vs_homeostasis_late_blocks,'r')
- plot([H1 H2],[1 1],'--r')
- hold on
- plot([H1 H2],[2 2],'--r')
- xlim([H1 H2])
- ylim([0.9 2.1])
- xlabel('homeostasis')
- set(gca,'YTick',1:2);
- set(gca,'YTickLabel',{'0','100%'});
- ylabel('% high effort choice')
- %% choices vs trials/blocks hard easy blocks
- if variable_pressure_flag
- hard_blocks_sorted = (16:30); %this make sense only for population_choices_sortedbyblockpressure
- easy_blocks_sorted = (1:15);
- h_choice_hard_easy_blocks = figure('Name','Population choices vs trials hard easy blocks','units','normalized','outerposition',[0 0 1 1]);
- subplot(3,2,1)
- plot(nanmean(mean_population_choices_sortedbyblockpressure(hard_blocks_sorted,1:n_trials),1),'r')
- hold on
- plot(nanmean(mean_population_choices_sortedbyblockpressure(easy_blocks_sorted,1:n_trials),1),'g')
- plot([1 n_trials],[1 1],'--r')
- hold on
- plot([1 n_trials],[2 2],'--r')
- ylim([0.9 2.1])
- xlim([1 n_trials])
- set(gca,'YTick',1:2);
- set(gca,'YTickLabel',{'0','100%'});
- ylabel('% high effort choice')
- xlabel('trials')
- subplot(3,2,3)
- plot(hard_blocks_sorted,nanmean(mean_population_choices_sortedbyblockpressure(hard_blocks_sorted,1:n_trials),2),'r')
- hold on
- plot(hard_blocks_sorted,nanmean(mean_population_choices_sortedbyblockpressure(hard_blocks_sorted,1:n_trials),2)+nanstd(mean_population_choices_sortedbyblockpressure(hard_blocks_sorted,1:n_trials),[],2)/sqrt(n_trials),'--r')
- hold on
- plot(hard_blocks_sorted,nanmean(mean_population_choices_sortedbyblockpressure(hard_blocks_sorted,1:n_trials),2)-nanstd(mean_population_choices_sortedbyblockpressure(hard_blocks_sorted,1:n_trials),[],2)/sqrt(n_trials),'--r')
- hold on
- subplot(3,2,3)
- plot(easy_blocks_sorted,nanmean(mean_population_choices_sortedbyblockpressure(easy_blocks_sorted,1:n_trials),2),'g')
- hold on
- plot(easy_blocks_sorted,nanmean(mean_population_choices_sortedbyblockpressure(easy_blocks_sorted,1:n_trials),2)+nanstd(mean_population_choices_sortedbyblockpressure(easy_blocks_sorted,1:n_trials),[],2)/sqrt(n_trials),'--g')
- hold on
- plot(easy_blocks_sorted,nanmean(mean_population_choices_sortedbyblockpressure(easy_blocks_sorted,1:n_trials),2)-nanstd(mean_population_choices_sortedbyblockpressure(easy_blocks_sorted,1:n_trials),[],2)/sqrt(n_trials),'--g')
- hold on
- plot([1 n_blocks],[1 1],'--r')
- hold on
- plot([1 n_blocks],[2 2],'--r')
- ylim([0.9 2.1])
- set(gca,'YTick',1:2);
- set(gca,'YTickLabel',{'0','100%'});
- ylabel('% high effort choice')
- xlabel('blocks')
- subplot(3,2,2)
- plot(X_distance,population_choices_vs_distance_hard_blocks,'r')
- hold on
- plot(X_distance,population_choices_vs_distance_easy_blocks,'g')
- hold on
- plot([D1 D2],[1 1],'--r')
- hold on
- plot([D1 D2],[2 2],'--r')
- xlim([D1 D2])
- ylim([0.9 2.1])
- set(gca, 'XDir','reverse')
- xlabel('distance')
- subplot(3,2,4)
- plot(X_pressure,population_choices_vs_pressure_hard_blocks,'r')
- hold on
- plot(X_pressure,population_choices_vs_pressure_easy_blocks,'g')
- plot([P1 P2],[1 1],'--r')
- hold on
- plot([P1 P2],[2 2],'--r')
- xlim([P1 P2])
- ylim([0.9 2.1])
- xlabel('pressure')
- set(gca,'YTick',1:2);
- set(gca,'YTickLabel',{'0','100%'});
- subplot(3,2,6)
- plot(X_homeostasis,population_choices_vs_homeostasis_hard_blocks,'r')
- hold on
- plot(X_homeostasis,population_choices_vs_homeostasis_easy_blocks,'g')
- plot([H1 H2],[1 1],'--r')
- hold on
- plot([H1 H2],[2 2],'--r')
- xlim([H1 H2])
- ylim([0.9 2.1])
- xlabel('homeostasis')
- set(gca,'YTick',1:2);
- set(gca,'YTickLabel',{'0','100%'});
- end
- %% RT vs trials/blocks
- h_RT = figure('Name','Population RT vs time ','units','normalized','outerposition',[0 0 1 1]);
- subplot(2,2,1)
- boundedline(1:n_trials, mean(nanmean(population_RT(:,1:n_trials,:),3),1), nanstd(squeeze(nanmean(population_RT(:,1:n_trials,:),1)),[],2),'alpha','cmap',[.1 .1 .1],'transparency', trasp);
- hold on
- plot(1:n_trials,mean(nanmean(population_RT(:,1:n_trials,:)),3),'LineWidth',5,'Color',[0.1 0.1 0.1])
- ylabel('time(s)')
- xlabel('trials')
- ylim([0.5 1.75])
- subplot(2,2,2)
- boundedline(1:n_blocks, mean(nanmean(population_RT(1:n_blocks,:,:),3),2), nanstd(squeeze(nanmean(population_RT(1:n_blocks,:,:),2)),[],2),'alpha','cmap',[.1 .1 .1],'transparency', trasp);
- hold on
- plot(mean(nanmean(population_RT(:,1:n_trials,:),3),2),'LineWidth',5,'Color',[0.1 0.1 0.1])
- ylabel('time(s)')
- xlabel('blocks')
- ylim([0.5 1.75])
- subplot(2,2,3)
- plot(X_RT,population_choices_vs_RT,'LineWidth',5,'Color',[0.1 0.1 0.1])
- hold on
- boundedline(X_RT, population_choices_vs_RT, population_choices_vs_RT_std,'alpha','cmap',[.1 .1 .1],'transparency', trasp);
- plot([RT1 RT2],[1 1],'--r')
- hold on
- plot([RT1 RT2],[2 2],'--r')
- xlim([RT1 RT2])
- ylim([0.5 2.5])
- xlabel('RT')
- ylabel('% high effort choice')
- set(gca,'YTick',[1 2],'YTickLabel',[0 100]);
- set(gca,'XTick',[1 2]);
- subplot(2,2,4)
- boundedline(X_pressure, population_RT_vs_pressure, population_RT_vs_pressure_std,'alpha','cmap',[.1 .1 .1],'transparency', trasp);
- hold on
- plot(X_pressure,population_RT_vs_pressure,'LineWidth',5,'Color',[0.1 0.1 0.1])
- xlim([P1 P2])
- ylim([0.25 1.75])
- xlabel('pressure')
- ylabel('RT')
- h_logRT = figure('Name','Population RT vs time ','units','normalized','outerposition',[0 0 1 1]);
- subplot(2,2,1)
- plot(mean(nanmean(log(population_RT(:,1:n_trials,:)),3),1),'LineWidth',5,'Color',[0.1 0.1 0.1])
- hold on
- boundedline(1:8, mean(nanmean(log(population_RT(:,1:n_trials,:)),3),1),nanstd(squeeze(nanmean(log(population_RT(:,1:n_trials,:)),1)),[],2),'alpha','cmap',[.1 .1 .1],'transparency', trasp);
- ylabel('log RT')
- xlabel('trials')
- subplot(2,2,2)
- plot(mean(nanmean(log(population_RT(:,1:n_trials,:)),3),2),'LineWidth',5,'Color',[0.1 0.1 0.1])
- hold on
- boundedline(1:n_blocks, mean(nanmean(log(population_RT(1:n_blocks,:,:)),3),2), nanstd(squeeze(mean(log(population_RT(1:n_blocks,:,:)),2)),[],2),'alpha','cmap',[.1 .1 .1],'transparency', trasp);
- subplot(2,2,3)
- plot(X_log_RT,population_choices_vs_log_RT,'LineWidth',5,'Color',[0.1 0.1 0.1])
- hold on
- boundedline(X_log_RT, population_choices_vs_log_RT, population_choices_vs_log_RT_std,'alpha','cmap',[.1 .1 .1],'transparency', trasp);
- plot([logRT1 logRT2],[1 1],'--r')
- hold on
- plot([logRT1 logRT2],[2 2],'--r')
- xlim([logRT1 logRT2])
- ylim([0.5 2.5])
- xlabel('log RT')
- ylabel('% high effort choice')
- set(gca,'YTick',[1 2],'YTickLabel',[0 100]);
- subplot(2,2,4)
- boundedline(X_pressure, population_log_RT_vs_pressure, population_log_RT_vs_pressure_std,'alpha','cmap',[.1 .1 .1],'transparency', trasp);
- hold on
- plot(X_pressure,population_log_RT_vs_pressure,'LineWidth',5,'Color',[0.1 0.1 0.1])
- xlim([P1 P2])
- xlabel('pressure')
- ylabel('log RT')
- %% Trials goal reach vs fatigue/blocks
- T1 = prctile(population_tiredness(:),10);
- T2 = prctile(population_tiredness(:),90);
- X_tiredness = [T1:abs(T2-T1)/10:T2];
- [N_tiredness,X_tiredness] = hist(population_tiredness(:),X_tiredness); %10 bins between the 10th and 90th perctile of population_pressure
- for i_tiredness = 1:length(X_tiredness)
- if i_tiredness==1
- indeces_this_tiredness{i_tiredness} = find(population_tiredness(:)<X_tiredness(i_tiredness));
- elseif i_tiredness<length(X_tiredness)
- indeces_this_tiredness{i_tiredness} = find((population_tiredness(:)<X_tiredness(i_tiredness+1))&population_tiredness(:)>X_tiredness(i_tiredness));
- else
- indeces_this_tiredness{i_tiredness} = find(population_tiredness(:)>X_tiredness(i_tiredness));
- end
- indeces_this_tiredness_early_blocks{i_tiredness} = intersect(indeces_this_tiredness{i_tiredness},early_blocks_indeces);
- indeces_this_tiredness_late_blocks{i_tiredness} = intersect(indeces_this_tiredness{i_tiredness},late_blocks_indeces);
- population_goals_trials_vs_tiredness(i_tiredness)= nanmean(population_goals_trials(indeces_this_tiredness{i_tiredness}));
- population_goals_trials_vs_tiredness_se(i_tiredness) = nanstd(population_goals_trials(indeces_this_tiredness{i_tiredness}))/sqrt(length(indeces_this_tiredness{i_tiredness})/30);
- population_goals_trials_vs_tiredness_early_blocks(i_tiredness)= nanmean(population_goals_trials(indeces_this_tiredness_early_blocks{i_tiredness})/30);
- population_goals_trials_vs_tiredness_late_blocks(i_tiredness)= nanmean(population_goals_trials(indeces_this_tiredness_late_blocks{i_tiredness})/30);
- end
- h_fatigue = figure('Name','Population Goal reach vs fatigue ');
- subplot(2,1,1)
- boundedline(X_tiredness,population_goals_trials_vs_tiredness, population_goals_trials_vs_tiredness_se,'alpha','cmap',[.5 .5 .5],'transparency', trasp);
- hold on
- plot(X_tiredness,population_goals_trials_vs_tiredness,'LineWidth',5,'Color',[0.1 0.1 0.1])
- xlabel('fatigue')
- ylabel('trial')
- subplot(2,1,2)
- boundedline(1:n_blocks,nanmean(population_goals_trials,2), nanstd(population_goals_trials,[],2),'alpha','cmap',[.5 .5 .5],'transparency', trasp);
- hold on
- plot(1:n_blocks,nanmean(population_goals_trials,2),'LineWidth',5,'Color',[0.1 0.1 0.1])
- xlabel('blocks')
- xlim([1 n_blocks])
- %% vigor vs pressure
- h_vigor = figure('Name','Population Vigor vs pressure ','units','normalized','outerposition',[0 0 1 1]);
- indEFF{1} = find(population_effort(:)==0.2 & population_reward(:)>0);
- indEFF{2} = find(population_effort(:)==0.35 & population_reward(:)>0);
- indEFF{3} = find(population_effort(:)==0.5 & population_reward(:)>0);
- indEFF{4} = find(population_effort(:)==0.7 & population_reward(:)>0);
- for i_eff = 1:4
- subplot(3,4,i_eff)
- title(sprintf('EFF %d',i_eff));
- axis off
- subplot(3,4,4+i_eff)
- plot(population_pressure(indEFF{i_eff}),population_vigor(indEFF{i_eff} ),'.');
- plot_correlation2(population_pressure(indEFF{i_eff}),population_vigor(indEFF{i_eff}),['pressure vs mean vigor'],1);
- hold on
- plot([min(population_pressure(indEFF{i_eff})) max(population_pressure(indEFF{i_eff}))],[nanmean(population_vigor(indEFF{i_eff})) nanmean(population_vigor(indEFF{i_eff}))],'--r')
- ylabel('vigor')
- ylim([0 1.5])
- subplot(3,4,8+i_eff)
- plot(population_pressure(indEFF{i_eff}),population_max_vigor(indEFF{i_eff}),'.');
- plot_correlation2(population_pressure(indEFF{i_eff}),population_max_vigor(indEFF{i_eff}),['pressure vs max vigor'],1);
- hold on
- plot([min(population_pressure(indEFF{i_eff})) max(population_pressure(indEFF{i_eff}))],[nanmean(population_max_vigor(indEFF{i_eff})) nanmean(population_max_vigor(indEFF{i_eff}))],'--r')
- ylabel('max vigor')
- xlabel('pressure')
- ylim([0 1.5])
- end
- h_vigor2 = figure('Name','Population Vigor vs fatigue ','units','normalized','outerposition',[0 0 1 1]);
- blocks_vigor = squeeze(mean(population_vigor,2));
- blocks_max_vigor = squeeze(mean(population_max_vigor,2));
- subplot(1,2,1)
- plot(population_tiredness(:),blocks_vigor(:),'.');
- plot_correlation2(population_tiredness(:),blocks_vigor(:),['fatigue vs vigor'],1);
- subplot(1,2,2)
- plot(population_tiredness(:),blocks_max_vigor(:),'.');
- plot_correlation2(population_tiredness(:),blocks_max_vigor(:),['fatigue vs max vigor'],1);
- xlabel('fatigue')
- subject_vigor = nanmean(blocks_vigor,1);
- subject_max_vigor = nanmean(blocks_max_vigor,1);
- %% individual subjects
- h0 = figure('Name','Population choices vs trial _ind subjects ','units','normalized','outerposition',[0 0 1 1]);
- h00 = figure('Name','Population choices vs trial early-late blocks ','units','normalized','outerposition',[0 0 1 1]);
- h1 = figure('Name','Population choices vs blocks _ind subjects ','units','normalized','outerposition',[0 0 1 1]);
- h0b = figure('Name','Population RT vs trial _ind subjects ','units','normalized','outerposition',[0 0 1 1]);
- h1b = figure('Name','Population RT vs blocks _ind subjects ','units','normalized','outerposition',[0 0 1 1]);
- h2 = figure('Name','Population tiredness _ind subjects ','units','normalized','outerposition',[0 0 1 1]);
- h3 = figure('Name','Population distance-pressure ind subjects ','units','normalized','outerposition',[0 0 1 1]);
- h3_2 = figure('Name','Population pressure ind blocks ','units','normalized','outerposition',[0 0 1 1]);
- h3_3 = figure('Name','Population distance ind blocks ','units','normalized','outerposition',[0 0 1 1]);
- if variable_pressure_flag
- h3_4 = figure('Name','Population pressure ind blocks highlowpress','units','normalized','outerposition',[0 0 1 1]);
- h3_5 = figure('Name','Population distance ind blocks highlowpress','units','normalized','outerposition',[0 0 1 1]);
- end
- population_pressure_highlow = NaN(n_trials,1000,2);
- index_low = 0;
- index_high = 0;
- for i_sub = 1:n_good_sub
- figure(h0)
- subplot(nrow,ncol,i_sub)
- try %to deal with subjects with all NaN
- boundedline(1:n_trials,nanmean(population_choices(:,1:n_trials,i_sub),1), nanstd(population_choices(:,1:n_trials,i_sub),[],1)/sqrt(n_blocks),'alpha','cmap',[.5 .5 .5],'transparency', trasp);
- catch %to deal with subjects with all NaN
- boundedline(1:n_trials,zeros(1,8), zeros(1,8),'alpha','cmap',[.5 .5 .5],'transparency', trasp);
- end
- % boundedline(1:n_trials,nanmean(mean_population_choices,1), mean(std_population_choices(:,1:n_trials),1),'alpha','cmap',[.5 .5 .5],'transparency', trasp);
- hold on
- plot(1:n_trials,nanmean(population_choices(:,1:n_trials,i_sub),1),'LineWidth',5,'Color',[0.1 0.1 0.1])
- hold on
- plot([1 n_trials],[1 1],'--r')
- hold on
- plot([1 n_trials],[2 2],'--r')
- ylim([0.9 2.1])
- set(gca,'YTick',1:2);
- set(gca,'YTickLabel',{'0','100%'});
- xlabel('trials')
- figure(h00)
- subplot(nrow,ncol,i_sub)
- plot(nanmean(population_choices(early_blocks,1:n_trials,i_sub),1),'g')
- hold on
- plot(nanmean(population_choices(late_blocks,1:n_trials,i_sub),1),'r')
- hold on
- plot([1 n_trials],[1 1],'--r')
- hold on
- plot([1 n_trials],[2 2],'--r')
- ylim([0.9 2.1])
- xlabel('trials')
- figure(h1)
- subplot(nrow,ncol,i_sub)
- % boundedline(1:n_blocks,nanmean(population_choices(:,1:n_trials,i_sub),2), nanstd(population_choices(:,1:n_trials,i_sub),[],2)/sqrt(n_trials),'alpha','cmap',[.5 .5 .5],'transparency', trasp);
- % hold on
- % plot(1:n_blocks,nanmean(population_choices(:,1:n_trials,i_sub),2),'LineWidth',5,'Color',[0.1 0.1 0.1])
- plot(nanmean(population_choices(:,1:n_trials,i_sub),2))
- hold on
- plot(nanmean(population_choices(:,1:n_trials,i_sub),2)+nanstd(population_choices(:,1:n_trials,i_sub),[],2)/sqrt(n_trials),'--b')
- hold on
- plot(nanmean(population_choices(:,1:n_trials,i_sub),2)-nanstd(population_choices(:,1:n_trials,i_sub),[],2)/sqrt(n_trials),'--b')
- hold on
- plot([1 n_blocks],[1 1],'--r')
- hold on
- plot([1 n_blocks],[2 2],'--r')
- ylim([0.9 2.1])
- set(gca,'YTick',1:2);
- set(gca,'YTickLabel',{'0','100%'});
- xlabel('blocks')
- figure(h0b)
- subplot(nrow,ncol,i_sub)
- plot(nanmean(population_RT(:,1:n_trials,i_sub),1))
- hold on
- plot(nanmean(population_RT(:,1:n_trials,i_sub),1)+nanstd(population_RT(:,1:n_trials,i_sub),[],1)/sqrt(n_blocks),'--b')
- hold on
- plot(nanmean(population_RT(:,1:n_trials,i_sub),1)-nanstd(population_RT(:,1:n_trials,i_sub),[],1)/sqrt(n_blocks),'--b')
- ylim([0 3])
- xlabel('trials')
- figure(h1b)
- subplot(nrow,ncol,i_sub)
- plot(nanmean(population_RT(:,1:n_trials,i_sub),2))
- hold on
- plot(nanmean(population_RT(:,1:n_trials,i_sub),2)+nanstd(population_RT(:,1:n_trials,i_sub),[],2)/sqrt(n_trials),'--b')
- hold on
- plot(nanmean(population_RT(:,1:n_trials,i_sub),2)-nanstd(population_RT(:,1:n_trials,i_sub),[],2)/sqrt(n_trials),'--b')
- ylim([0 3])
- xlabel('blocks')
- figure(h2)
- subplot(nrow,ncol,i_sub)
- plot(population_tiredness(:,i_sub))
- ylim([0 100])
- xlabel('blocks')
- figure(h3)
- subplot(2,3,1)
- hold on
- plot(nanmean(1-population_advancement(:,1:n_trials,i_sub),1))
- hold on
- title('distance')
- xlim([1 n_trials])
- ylim([0 1])
- xlabel('trials')
- subplot(2,3,4)
- sub_advancement = population_advancement(:,:,i_sub);
- hist(1-sub_advancement(:),20)
- subplot(2,3,2)
- hold on
- plot(nanmean(population_pressure(:,1:n_trials,i_sub),1))
- hold on
- % plot([1 n_trials],[max_pressure(1) max_pressure(1)],'--r')
- title('pressure')
- xlim([1 n_trials])
- xlabel('trials')
- subplot(2,3,5)
- sub_pressure = population_pressure(:,:,i_sub);
- hist(sub_pressure(:),20)
- subplot(2,3,3)
- plot(nanmean(population_reward_advancement_homeostasis(:,1:n_trials,i_sub),1))
- hold on
- % plot([1 n_trials],[max_pressure(1) max_pressure(1)],'--r')
- title('homeostasis')
- xlim([1 n_trials])
- xlabel('trials')
- subplot(2,3,6)
- sub_reward_advancement_homeostasis = population_reward_advancement_homeostasis(:,:,i_sub);
- hist(sub_reward_advancement_homeostasis(:),20)
- figure(h3_2)
- subplot(nrow,ncol,i_sub)
- for i_block = 1:n_blocks
- hold on
- plot((1:n_trials),population_pressure(i_block,:,i_sub),'r')
- xlim([1 n_trials])
- end
- figure(h3_3)
- subplot(nrow,ncol,i_sub)
- for i_block = 1:n_blocks
- hold on
- plot((1:n_trials),1-population_advancement(i_block,:,i_sub),'g')
- xlim([1 n_trials])
- ylim([-0.1 1])
- end
- if variable_pressure_flag
- figure(h3_4)
- subplot(nrow,ncol,i_sub)
- for i_block = 1:n_blocks
- hold on
- if population_block_pressure(i_block,i_sub) == 1 %high pressure block
- plot((1:n_trials),population_pressure(i_block,:,i_sub),'r')
- index_high = index_high+1;
- population_pressure_highlow(:,index_high,1) = population_pressure(i_block,:,i_sub);
- else %low pressure block
- plot((1:n_trials),population_pressure(i_block,:,i_sub),'y')
- index_low = index_low+1;
- population_pressure_highlow(:,index_low,2) = population_pressure(i_block,:,i_sub);
- end
- xlim([1 n_trials])
- ylim([-0.5 0.5])
- end
- figure(h3_5)
- subplot(nrow,ncol,i_sub)
- for i_block = 1:n_blocks
- hold on
- if population_block_pressure(i_block,i_sub) == 1 %high pressure block
- plot((1:n_trials),1-population_advancement(i_block,:,i_sub),'g')
- else %low pressure block
- plot((1:n_trials),1-population_advancement(i_block,:,i_sub),'b')
- end
- xlim([1 n_trials])
- ylim([-0.1 1])
- end
- end
- end
- if variable_pressure_flag
- figure(h3_4)
- subplot(nrow,ncol,i_sub+1)
- title('population average')
- plot((1:n_trials),nanmean(population_pressure_highlow(:,:,1),2),'r')
- hold on
- plot((1:n_trials),nanmean(population_pressure_highlow(:,:,2),2),'y')
- ylim([-0.5 0.5])
- end
- %% choice vs DR/DE
- h_choice_delta = figure('Name','choice vs DR/DE','units','normalized','outerposition',[0 0 1 1]);
- population_choices_drew = zeros(length(X_rew),1);
- population_choices_drew_se = zeros(length(X_rew),1);
- subplot(2,1,1)
- for i_drew = 1:length(X_rew)
- population_choices_drew(i_drew) = nanmean(population_choices(population_drew(:)==X_rew(i_drew)));
- population_choices_drew_se(i_drew)= nanstd(population_choices(population_drew(:)==X_rew(i_drew)))/sqrt(sum(population_drew(:)==X_rew(i_drew))/30);
- end
- boundedline(X_rew,population_choices_drew,population_choices_drew_se,'alpha','cmap',[.5 .5 .5],'transparency', trasp);
- hold on
- plot(X_rew,population_choices_drew,'LineWidth',5,'Color',[0.1 0.1 0.1])
- xlabel('delta rew')
- ylabel('choice')
- ylim([1 2])
- ylim([0.9 2.1])
- hold on
- plot([min(X_rew) max(X_rew)],[1 1],'--r')
- hold on
- plot([min(X_rew) max(X_rew)],[2 2],'--r')
- set(gca,'YTick',1:2);
- set(gca,'YTickLabel',{'0','100%'});
- ylabel('% high effort choice')
- subplot(2,1,2)
- population_choices_deff = zeros(length(X_eff),1);
- population_choices_deff_se = zeros(length(X_eff),1);
- for i_deff = 1:length(X_eff)
- population_choices_deff(i_deff) = nanmean(population_choices(population_deff(:)==X_eff(i_deff)));
- population_choices_deff_se(i_deff)= nanstd(population_choices(population_deff(:)==X_eff(i_deff)))/sqrt(sum(population_deff(:)==X_eff(i_deff))/30);
- end
- boundedline(X_eff,population_choices_deff,population_choices_deff_se,'alpha','cmap',[.5 .5 .5],'transparency', trasp);
- hold on
- plot(X_eff,population_choices_deff,'LineWidth',5,'Color',[0.1 0.1 0.1])
- xlabel('delta eff')
- ylabel('choice')
- ylim([1 2])
- ylim([0.9 2.1])
- hold on
- plot([min(X_eff) max(X_eff)],[1 1],'--r')
- hold on
- plot([min(X_eff) max(X_eff)],[2 2],'--r')
- set(gca,'YTick',1:2);
- set(gca,'YTickLabel',{'0','100%'});
- ylabel('% high effort choice')
- %% RT vs DR/DE
- h_RT_delta = figure('Name','RT vs DR/DE','units','normalized','outerposition',[0 0 1 1]);
- subplot(2,1,1)
- for i_drew = 1:length(X_rew)
- errorbar(X_rew(i_drew),mean(population_RT(population_drew(:)==X_rew(i_drew))),std(population_RT(population_drew(:)==X_rew(i_drew)))/sqrt(length(population_RT(:))),'ok')
- hold on
- end
- xlabel('delta rew')
- ylabel('RT')
- ylim([1 2])
- subplot(2,1,2)
- for i_deff = 1:length(X_eff)
- errorbar(X_eff(i_deff),mean(population_RT(population_deff(:)==X_eff(i_deff))),std(population_RT(population_deff(:)==X_eff(i_deff)))/sqrt(length(population_RT(:))),'ok')
- hold on
- end
- xlabel('delta eff')
- ylabel('RT')
- ylim([1 2])
- %% first trials analysis
- subjects_first_trials_choices = squeeze(nanmean(population_choices(:,1,:),1)); %1 x n_subj
- subjects_goals = nanmean(population_goals,1); %1/0 whether or not goal was reached
- subjects_goals_trials = nanmean(population_goals_trials,1); %number of the trial in which goal reached
- subjects_reward_tot = squeeze(nanmean(population_reward_tot(:,end,:),1)); %1 x n_subj
- subjects_RT = nanmean(squeeze(nanmean(population_RT,1)),1); %1 x n_subj
- subjects_advancement = squeeze(nanmean(population_advancement(:,end,:),1));
- subjects_reward_advancement_homeostasis = nanmean(squeeze(nanmean(population_reward_advancement_homeostasis,1)),1);
- subjects_pressure = nanmean(squeeze(nanmean(population_pressure,1)),1);
- h_first_trials = figure('Name','First trials analysis','units','normalized','outerposition',[0 0 1 1]);
- subplot(2,4,1)
- plot(subjects_first_trials_choices,subjects_goals,'o')
- plot_correlation2(subjects_first_trials_choices,subjects_goals,'fit',1);
- axis square
- ylabel('fraction goals reached')
- xlabel('first trials choices')
- set(gca,'XTick',1:2);
- set(gca,'XTickLabel',{'0','100%'});
- xlim([0.9 2.1])
- xlabel('% high effort choice on first trial')
- subplot(2,4,2)
- plot(subjects_first_trials_choices,subjects_goals_trials,'o')
- plot_correlation2(subjects_first_trials_choices,subjects_goals_trials,'fit',1);
- axis square
- ylabel('avg trial when goal reached')
- xlabel('first trials choices')
- set(gca,'XTick',1:2);
- set(gca,'XTickLabel',{'0','100%'});
- xlim([0.9 2.1])
- xlabel('% high effort choice on first trial')
- subplot(2,4,3)
- plot(subjects_first_trials_choices,subjects_reward_tot,'o')
- plot_correlation2(subjects_first_trials_choices,subjects_reward_tot,'fit',1);
- ylabel('avg reward')
- xlabel('first trials choices')
- axis square
- set(gca,'XTick',1:2);
- set(gca,'XTickLabel',{'0','100%'});
- xlim([0.9 2.1])
- xlabel('% high effort choice on first trial')
- subplot(2,4,4)
- plot(subjects_first_trials_choices,subjects_pressure,'o')
- plot_correlation2(subjects_first_trials_choices,subjects_pressure,'fit',1);
- ylabel('avg pressure')
- xlabel('first trials choices')
- axis square
- set(gca,'XTick',1:2);
- set(gca,'XTickLabel',{'0','100%'});
- xlim([0.9 2.1])
- xlabel('% high effort choice on first trial')
- subplot(2,4,5)
- plot(subjects_first_trials_choices,subjects_RT,'o')
- ylabel('avg RT')
- axis square
- set(gca,'XTick',1:2);
- set(gca,'XTickLabel',{'0','100%'});
- xlim([0.9 2.1])
- xlabel('% high effort choice on first trial')
- subplot(2,4,6)
- plot(subjects_first_trials_choices,subjects_reward_advancement_homeostasis,'o')
- ylabel('avg homeostasis')
- xlabel('first trials choices')
- axis square
- set(gca,'XTick',1:2);
- set(gca,'XTickLabel',{'0','100%'});
- xlim([0.9 2.1])
- xlabel('% high effort choice on first trial')
- subplot(2,4,7)
- plot(subjects_first_trials_choices,subjects_advancement,'o')
- ylabel('avg advancement')
- xlabel('first trials choices')
- axis square
- set(gca,'XTick',1:2);
- set(gca,'XTickLabel',{'0','100%'});
- xlim([0.9 2.1])
- xlabel('% high effort choice on first trial')
- %%
- % figure('Name',['RT left/right '])
- % % plot([1 2],[population_RT(population_choices==1) population_RT(population_choices==2)],'o');
- % % hold on
- % errorbar([1 2],[mean(population_RT(population_choices==1)) mean(population_RT(population_choices==2))],[std(population_RT(population_choices==1)) std(population_RT(population_choices==2))],'s');
- % title('Reaction Times')
- % % ylabel('time(s)')
- % h_RT_lr = figure('Name','RT left/right _ind subjects ');
- % for i_sub = 1:n_good_sub
- % figure(h_RT_lr)
- % subplot(nrow,ncol,i_sub)
- % errorbar([1 2],[mean(population_RT(population_choices(:,:,i_sub)==1)) mean(population_RT(population_choices(:,:,i_sub)==2))],[std(population_RT(population_choices(:,:,i_sub)==1)) std(population_RT(population_choices(:,:,i_sub)==2))],'s');
- % ylabel('time(s)')
- % xlim([0.5 2.5])
- %
- % end
- %% save pictures
- threshold_tag = sprintf('t %d',threshold);
- if skip_bad_trial
- trials_tag = ' good trials';
- else
- trials_tag = ' all trials';
- end
- saveas(h_pop0,[h_pop0_name threshold_tag trials_tag],'png');
- saveas(h_pop0,[h_pop0_name threshold_tag trials_tag],'svg');
- saveas(h_pop0_sim,[h_pop0_sim_name threshold_tag trials_tag],'png');
- saveas(h_pop0_sim,[h_pop0_sim_name threshold_tag trials_tag],'svg');
- saveas(h_pressure_distance,['Population pressure distance distribution ' threshold_tag trials_tag],'png');
- saveas(h_pressure_distance,['Population pressure distance distribution ' threshold_tag trials_tag],'svg');
- saveas(h_pressure_homeostasis_distance,['Population pressure homeostasis distance scatterplot ' threshold_tag trials_tag],'png');
- saveas(h_pressure_homeostasis_distance,['Population pressure homeostasis distance scatterplot ' threshold_tag trials_tag],'svg');
- saveas(h_fatigue,['Population Goal reach vs fatigue ' threshold_tag trials_tag],'png');
- saveas(h_fatigue,['Population Goal reach vs fatigue ' threshold_tag trials_tag],'svg');
- saveas(h3,['Population pressure distance distribution _ind subjects' threshold_tag trials_tag],'png');
- saveas(h3,['Population pressure distance distribution _ind subjects' threshold_tag trials_tag],'svg');
- saveas(h3_2,['Population pressure ind blocks ' threshold_tag trials_tag],'png');
- saveas(h3_2,['Population pressure ind blocks ' threshold_tag trials_tag],'svg');
- saveas(h3_3,['Population distance ind blocks ' threshold_tag trials_tag],'png');
- saveas(h3_3,['Population distance ind blocks ' threshold_tag trials_tag],'svg');
- saveas(h_choice_reward_effort,['Population choices rewards efforts ' threshold_tag trials_tag],'png');
- saveas(h_choice_reward_effort,['Population choices rewards efforts ' threshold_tag trials_tag],'svg');
- saveas(h_choice_reward_effort2,['Population average reward-effort ' threshold_tag trials_tag],'png');
- saveas(h_choice_reward_effort2,['Population average reward-effort ' threshold_tag trials_tag],'svg');
- saveas(h_choice,['Population choices vs trials_blocks ' threshold_tag trials_tag],'png');
- saveas(h_choice,['Population choices vs trials_blocks ' threshold_tag trials_tag],'svg');
- saveas(h_choice_early_late_blocks,['Population choices vs trials early-late blocks ' threshold_tag trials_tag],'png');
- saveas(h_choice_early_late_blocks,['Population choices vs trials early-late blocks ' threshold_tag trials_tag],'svg');
- saveas(h0,['Population choices vs trials _ind subjects ' threshold_tag trials_tag],'png');
- saveas(h0,['Population choices vs trials _ind subjects ' threshold_tag trials_tag],'svg');
- saveas(h00,['Population choices vs trials _ind subjects early-late blocks ' threshold_tag trials_tag],'png');
- saveas(h00,['Population choices vs trials _ind subjects early-late blocks ' threshold_tag trials_tag],'svg');
- saveas(h1,['Population choices vs blocks _ind subjects ' threshold_tag trials_tag],'png');
- saveas(h1,['Population choices vs blocks _ind subjects ' threshold_tag trials_tag],'svg');
- saveas(h0b,['Population RT vs trial _ind subjects ' threshold_tag trials_tag],'png');
- saveas(h0b,['Population RT vs trial _ind subjects ' threshold_tag trials_tag],'svg');
- saveas(h1b,['Population RT vs blocks _ind subjects ' threshold_tag trials_tag],'png');
- saveas(h1b,['Population RT vs blocks _ind subjects ' threshold_tag trials_tag],'svg');
- saveas(h2,['Population tiredness _ind subjects ' threshold_tag trials_tag],'png');
- saveas(h2,['Population tiredness _ind subjects ' threshold_tag trials_tag],'svg');
- saveas(h_RT,['Population RT vs trials_blocks ' threshold_tag trials_tag],'png');
- saveas(h_RT,['Population RT vs trials_blocks ' threshold_tag trials_tag],'svg');
- saveas(h_logRT,['Population log RT vs trials_blocks ' threshold_tag trials_tag],'png');
- saveas(h_logRT,['Population log RT vs trials_blocks ' threshold_tag trials_tag],'svg');
- saveas(h_choice_delta,['Population choices vs delta reward ' threshold_tag trials_tag],'png');
- saveas(h_choice_delta,['Population choices vs delta reward ' threshold_tag trials_tag],'svg');
- saveas(h_RT_delta,['Population RT vs delta effort ' threshold_tag trials_tag],'png');
- saveas(h_RT_delta,['Population RT vs delta effort ' threshold_tag trials_tag],'svg');
- saveas(h_goal,['Population Goal Reward ' threshold_tag trials_tag],'png');
- saveas(h_goal,['Population Goal Reward ' threshold_tag trials_tag],'svg');
- saveas(h_first_trials,['First trials analysis' threshold_tag trials_tag],'png');
- saveas(h_first_trials,['First trials analysis' threshold_tag trials_tag],'svg');
- saveas(h_vigor,['Vigor pressure analysis' threshold_tag trials_tag],'png');
- saveas(h_vigor,['Vigor pressure analysis' threshold_tag trials_tag],'svg');
- saveas(h_vigor2,['Vigor fatigue analysis' threshold_tag trials_tag],'png');
- saveas(h_vigor2,['Vigor fatigue analysis' threshold_tag trials_tag],'svg');
- if variable_pressure_flag
- saveas(h_choice_hard_easy_blocks,['Population choices vs trials hard easy blocks' threshold_tag trials_tag],'png');
- saveas(h3_4,['Population pressure ind blocks highlow press' threshold_tag trials_tag],'png');
- saveas(h3_5,['Population distance ind blocks highlow press' threshold_tag trials_tag],'png');
- saveas(h_choice_hard_easy_blocks,['Population choices vs trials hard easy blocks' threshold_tag trials_tag],'svg');
- saveas(h3_4,['Population pressure ind blocks highlow press' threshold_tag trials_tag],'svg');
- saveas(h3_5,['Population distance ind blocks highlow press' threshold_tag trials_tag],'svg');
- hhh = figure('Name','Trials distribution','units','normalized','outerposition',[0 0 1 1]);
- for i_sub = 1:n_good_sub
- ind_high_press = find(population_block_pressure(:,i_sub)==1);
- ind_low_press = find(population_block_pressure(:,i_sub)==2);
- subplot(2,n_good_sub,i_sub)
- this_sub_trials = population_step_factor(ind_high_press,:,i_sub);
- hist(this_sub_trials(:),2);
- if i_sub ==1
- ylabel('high pressure blocks')
- end
- subplot(2,n_good_sub,n_good_sub+i_sub)
- this_sub_trials = population_step_factor(ind_low_press,:,i_sub);
- hist(this_sub_trials(:),2);
- if i_sub ==1
- ylabel('low pressure blocks')
- end
- end
- saveas(hhh,['Population distribution of easy hard trials highlow press' threshold_tag trials_tag],'png');
- saveas(hhh,['Population distribution of easy hard trials highlow press' threshold_tag trials_tag],'svg');
- end
- % saveas(h_RT_lr,'Population RT left-right choices ','png');
- %% print stats
- fprintf('avg pop goals is %f +- %f\n',nanmean(population_goals(:)),nanstd(population_goals(:))/sqrt(30*30))
- fprintf('avg pop reward is %f +- %f\n',nanmean(sum(squeeze(nansum(population_reward,2)),1)),nanstd(sum(squeeze(nansum(population_reward,2)),1))/sqrt(30))
- choices_first_half = population_choices(:,1:4,:);
- choices_second_half = population_choices(:,5:8,:);
- choices_first_half_sub = squeeze(nanmean(nanmean(choices_first_half,2),1));
- choices_second_half_sub = squeeze(nanmean(nanmean(choices_second_half,2),1));
- [H,P,CI,STATS] = ttest(choices_first_half_sub-choices_second_half_sub);
- fprintf('More high effort choices in the first half %d p = %.4f t = %.4f \n',H,P,STATS.tstat)
- effort_first_half = population_effort(:,1:4,:);
- effort_second_half = population_effort(:,5:8,:);
- effort_first_half_sub = squeeze(nanmean(nanmean(effort_first_half,2),1));
- effort_second_half_sub = squeeze(nanmean(nanmean(effort_second_half,2),1));
- [H,P,CI,STATS] = ttest(effort_first_half_sub-effort_second_half_sub);
- fprintf('More effort in the first half %d p = %.4f t = %.4f \n',H,P,STATS.tstat)
- choices_low_pressure = population_choices_sortedbyblockpressure(1:15,:,:);
- choices_high_pressure = population_choices_sortedbyblockpressure(16:30,:,:);
- choices_low_pressure_sub = squeeze(nanmean(nanmean(choices_low_pressure,2),1));
- choices_high_pressure_sub = squeeze(nanmean(nanmean(choices_high_pressure,2),1));
- [H,P,CI,STATS] = ttest(choices_high_pressure_sub-choices_low_pressure_sub);
- fprintf('More high effort choices in high pressure %d p = %.4f t = %.4f \n',H,P,STATS.tstat)
- fatigue_low_pressure = population_delta_tiredness_sortedbyblockpressure(1:15,:,:);
- fatigue_high_pressure = population_delta_tiredness_sortedbyblockpressure(16:30,:,:);
- fatigue_low_pressure_sub = nanmean(fatigue_low_pressure,2);
- fatigue_high_pressure_sub = nanmean(fatigue_high_pressure,2);
- [H,P,CI,STATS] = ttest(fatigue_high_pressure_sub-fatigue_low_pressure_sub);
- fprintf('Does fatigue increase more in high pressure blocks? %d p = %.4f t = %.4f \n',H,P,STATS.tstat)
- population_choice_post_pressure_peplus = NaN(n_blocks,n_trials,n_good_sub);
- population_choice_post_pressure_peminus = NaN(n_blocks,n_trials,n_good_sub);
- for i_sub=1:n_good_sub
- for i_block =1:n_blocks
- for i_trial =2:n_trials
- if population_step_factor(i_block,i_trial-1,i_sub)==1.25
- population_choice_post_pressure_peplus(i_block,i_trial,i_sub) = population_choices(i_block,i_trial,i_sub);
- else
- population_choice_post_pressure_peminus(i_block,i_trial,i_sub) = population_choices(i_block,i_trial,i_sub);
- end
- end
- end
- end
- choice_post_pressure_peplus = squeeze(nanmean(nanmean(population_choice_post_pressure_peplus,1),2));
- choice_post_pressure_peminus = squeeze(nanmean(nanmean(population_choice_post_pressure_peminus,1),2));
- [H,P,CI,STATS] = ttest(choice_post_pressure_peplus(:)-choice_post_pressure_peminus(:));
- fprintf('Are high effort choices more likely following a positive pressure PE? %d p = %.4f t = %.4f \n',H,P,STATS.tstat)
- %% logistic regression all trials
- [mdl,B,p] = log_regress(population_choices(:)-1,population_pressure(:),population_rew1(:),population_rew2(:),population_eff1(:),population_eff2(:));
- h_regr = figure('Name','Choice logistic regression','units','normalized','outerposition',[0 0 1 1]);
- bar(B)
- hold on
- errorbar((1:6),table2array(mdl.Coefficients(1:6,1)),table2array(mdl.Coefficients(1:6,2)),'.')
- set(gca,'XTick',1:6);
- set(gca,'XTickLabel',{'','Pressure','R1','R2','E1','E2'});
- ylabel('Likelihood of high effort choice')
- title('Predicting choices')
- saveas(h_regr,['Choice logistic regression ' threshold_tag trials_tag],'png');
- saveas(h_regr,['Choice logistic regression ' threshold_tag trials_tag],'svg');
- mdl
- regression_matrix.choices = population_choices(:)-1;
- regression_matrix.pressure = population_pressure(:);
- regression_matrix.rew1 = population_rew1(:);
- regression_matrix.rew2 = population_rew2(:);
- regression_matrix.eff1 = population_eff1(:);
- regression_matrix.eff2 = population_eff2(:);
- save regression_matrix regression_matrix
- %% HIGH LOW PRESSURE BLOCKS
- % HIGH PRESSURE BLOCKS
- [mdl_hp,B_hp,p] = log_regress(population_choices(hard_blocks_indeces)'-1,population_pressure(hard_blocks_indeces)',population_rew1(hard_blocks_indeces)',population_rew2(hard_blocks_indeces)',population_eff1(hard_blocks_indeces)',population_eff2(hard_blocks_indeces)');
- h_regr_hp = figure('Name','Choice logistic regression','units','normalized','outerposition',[0 0 1 1]);
- bar(B_hp)
- hold on
- errorbar((1:6),table2array(mdl_hp.Coefficients(:,1)),table2array(mdl_hp.Coefficients(:,2)),'.')
- set(gca,'XTick',1:6);
- set(gca,'XTickLabel',{'','Pressure','R1','R2','E1','E2'});
- ylabel('Likelihood of high effort choice')
- title('Predicting choices in high pressure blocks')
- saveas(h_regr_hp,['Choice logistic regression hp blocks ' threshold_tag trials_tag],'png');
- saveas(h_regr_hp,['Choice logistic regression hp blocks ' threshold_tag trials_tag],'svg');
- % LOW PRESSURE BLOCKS
- [mdl_lp,B_lp,p] = log_regress(population_choices(easy_blocks_indeces)'-1,population_pressure(easy_blocks_indeces)',population_rew1(easy_blocks_indeces)',population_rew2(easy_blocks_indeces)',population_eff1(easy_blocks_indeces)',population_eff2(easy_blocks_indeces)');
- h_regr_lp = figure('Name','Choice logistic regression','units','normalized','outerposition',[0 0 1 1]);
- bar(B_lp)
- hold on
- errorbar((1:6),table2array(mdl_lp.Coefficients(:,1)),table2array(mdl_lp.Coefficients(:,2)),'.')
- set(gca,'XTick',1:6);
- set(gca,'XTickLabel',{'','Pressure','R1','R2','E1','E2'});
- ylabel('Likelihood of high effort choice in high pressure blocks')
- title('Predicting choices in low pressure blocks')
- saveas(h_regr_lp,['Choice logistic regression lp blocks ' threshold_tag trials_tag],'png');
- saveas(h_regr_lp,['Choice logistic regression lp blocks ' threshold_tag trials_tag],'svg');
- t_statistics = (B_hp(6)-B_lp(6))/(sqrt(table2array(mdl_hp.Coefficients(6,2)).^2+table2array(mdl_lp.Coefficients(6,2)).^2));
- fprintf('a higher effect of effort on the higher effort option in hard vs easy blocks Diff = %f t = %.4f \n',B_hp(6)-B_lp(6),t_statistics)
- %% HIGH LOW PRESSURE TRIALS
- median_pr = prctile(population_pressure(:),50);
- hp_trials_indeces = find(population_pressure(:)>median_pr);
- lp_trials_indeces = find(population_pressure(:)<=median_pr);
- % HIGH PRESSURE TRIALS
- [mdl_hpt,B_hpt,p] = log_regress(population_choices(hp_trials_indeces)-1,population_pressure(hp_trials_indeces),population_rew1(hp_trials_indeces),population_rew2(hp_trials_indeces),population_eff1(hp_trials_indeces),population_eff2(hp_trials_indeces));
- h_regr_hpt = figure('Name','Choice logistic regression','units','normalized','outerposition',[0 0 1 1]);
- bar(B_hpt)
- hold on
- errorbar((1:6),table2array(mdl_hpt.Coefficients(:,1)),table2array(mdl_hpt.Coefficients(:,2)),'.')
- set(gca,'XTick',1:6);
- set(gca,'XTickLabel',{'','Pressure','R1','R2','E1','E2'});
- ylabel('Likelihood of high effort choice')
- title('Predicting choices in high pressure trials')
- saveas(h_regr_hpt,['Choice logistic regression hp trials ' threshold_tag trials_tag],'png');
- saveas(h_regr_hpt,['Choice logistic regression hp trials ' threshold_tag trials_tag],'svg');
- % LOW PRESSURE TRIALS
- [mdl_lpt,B_lpt,p] = log_regress(population_choices(lp_trials_indeces)-1,population_pressure(lp_trials_indeces),population_rew1(lp_trials_indeces),population_rew2(lp_trials_indeces),population_eff1(lp_trials_indeces),population_eff2(lp_trials_indeces));
- h_regr_lpt = figure('Name','Choice logistic regression','units','normalized','outerposition',[0 0 1 1]);
- bar(B_lpt)
- hold on
- errorbar((1:6),table2array(mdl_lpt.Coefficients(:,1)),table2array(mdl_lpt.Coefficients(:,2)),'.')
- set(gca,'XTick',1:6);
- set(gca,'XTickLabel',{'','Pressure','R1','R2','E1','E2'});
- ylabel('Likelihood of high effort choice in high pressure blocks')
- title('Predicting choices in low pressure trials')
- saveas(h_regr_lpt,['Choice logistic regression lp trials ' threshold_tag trials_tag],'png');
- saveas(h_regr_lpt,['Choice logistic regression lp trials ' threshold_tag trials_tag],'svg');
- t_statistics = (B_hpt(6)-B_lpt(6))/(sqrt(table2array(mdl_hpt.Coefficients(6,2)).^2+table2array(mdl_lpt.Coefficients(6,2)).^2));
- fprintf('a higher effect of effort on the higher effort option in high vs low pr trials Diff = %f t = %.4f \n',B_hpt(6)-B_lpt(6),t_statistics)
analyse_population.m, no license · at the source
Overview
- Centre for Human Brain Health, School of Psychology, University of Birmingham, Birmingham, UK
- Institute for Mental Health, School of Psychology, University of Birmingham, Birmingham, UK
- Department of Experimental Psychology, University of Oxford, Oxford, UK
- School of Psychology, University of Plymouth, Plymouth, UK
- Department of Psychological and Behavioural Science, London School of Economics and Political Science, London, UK
Abstract
Deadlines fundamentally shape motivation. Research examining effort-based choices finds effort is an avoided cost. However, this overlooks how making progress on longer-term goals to be reached before deadlines motivate people to exert high effort for little immediate reward. Here, we test a framework where motivation depends on deadline pressure (work remaining / time remaining). Across four studies we use computational modelling examining decisions when physical effort makes progress on goals with deadlines. In support of the hypotheses, deadline pressure significantly impacts decision-making, shifting people from avoiding effort, to seeking the progress it makes. Using ultra-high-field fMRI, we show that functionally connected putamen and midcingulate cortex sub-regions process and update estimates of deadline pressure, with distinct anterior cingulate and putamen sub-regions processing effort both when it is being avoided or sought. These results reveal the neurocomputational mechanisms for how deadline pressure shapes motivation, and keep us on track with goals.
Reproduced under the paper's license (CC BY), from the paper cited above.
Repository
Its files are read in the Code ↔ Paper reader above, with 1 match between paragraphs and lines of code.
OSF 5kjgb
Availability: 1 check, the latest on 27 September 2026: the link answers (HTTP 200)
- 27 September 2026: the link answers (HTTP 200)
5 files
- Code/
analyse_population.m , MATLAB, 2,330 lines, 1 match - Code/
model_choice_under_press , MATLAB, 859 linesure.m - Code/
model_choice_under_press , MATLAB, 895 linesure_crossval.m - Code/
model_population.m , MATLAB, 711 lines - Code/
parameter_recovery.m , MATLAB, 249 lines
Code availability
The code to generate the results and the figure, and the experimental paradigm, of this study is available in an Open Science Framework project (https://
Reproduced under the paper's license (CC BY), from the paper cited above.
Tracing map
Proposed by the machine: these links were found in the paper and verified at the source, without human review. The map will receive a Zenodo DOI once one of the paper's authors has validated it with their ORCID.
What the map holds:
- 1 repository of the authors' code, each at its verified commit, with its license and how the link was found in the paper;
- 5 scripts, each with its path and the digest of its content;
- 1 match between paragraphs of the paper and lines of the code (method lexical-v1);
- neither the text of the paper nor the code itself.
Its JSON (tracing-map.json) is deposited on Zenodo with its DOI once the map is validated.
Data
No dataset and no data link were found in the paper.
Data availability
The behavioural data and the fMRI statistical maps from all analyses have been deposited in an Open Science Framework project (https://
Reproduced under the paper's license (CC BY), from the paper cited above.
Versions
The history of this record: each version stored by the harvester or made by a correction of its authors or of the maintainers of its code, and what changed in its facts. The texts of the paper (its abstract, its availability statements) are not part of it; versions that changed only those are not listed.
Version 1, 27 September 2026: the first record
Recorded: type, language, journal, volume, issue, pages, dates, 4 authors, 3 keywords, 11 MeSH terms, 1 funder, 67 references.
Cite
This paper
Pisauro, M. A., Pollicino, D., Fisher, L., & Apps, M. A. J. (2026). Neural and computational mechanisms of effort under the pressure of a deadline. Nature communications, 17(1), 9169. https://
BibTeX
@article{pisauro2026neur
author = {Pisauro, M Andrea and Pollicino, Daniele and Fisher, Lucy and Apps, Matthew A J},
title = {{Neural and computational mechanisms of effort under the pressure of a deadline}},
journal = {Nature communications},
year = {2026},
month = jul,
volume = {17},
number = {1},
pages = {9169},
publisher = {Nature Publishing Group},
issn = {2041-1723},
doi = {10.1038/
url = {https://
pmid = {42660916},
pmcid = {PMC13522516}
}
RIS
TY - JOUR
AU - Pisauro, M Andrea
AU - Pollicino, Daniele
AU - Fisher, Lucy
AU - Apps, Matthew A J
TI - Neural and computational mechanisms of effort under the pressure of a deadline
T2 - Nature communications
J2 - Nat Commun
PY - 2026
DA - 2026/
VL - 17
IS - 1
SP - 9169
SN - 2041-1723
PB - Nature Publishing Group
DO - 10.1038/
UR - https://
LA - en
ER -
CSL-JSON
{
"id": "10.1038/
"type": "article-journal",
"title": "Neural and computational mechanisms of effort under the pressure of a deadline",
"container-title": "Nature communications",
"author": [
{
"family": "Pisauro",
"given": "M Andrea"
},
{
"family": "Pollicino",
"given": "Daniele"
},
{
"family": "Fisher",
"given": "Lucy"
},
{
"family": "Apps",
"given": "Matthew A J"
}
],
"container-title-short":
"volume": "17",
"issue": "1",
"page": "9169",
"DOI": "10.1038/
"PMID": "42660916",
"PMCID": "PMC13522516",
"ISSN": "2041-1723",
"publisher": "Nature Publishing Group",
"URL": "https://
"language": "en",
"issued": {
"date-parts": [
[
2026,
7,
28
]
]
}
}
The tracing map gets a citation of its own once an author has validated it and it has a DOI.
Similar papers
The papers with a page that share the most with this one: the tools found in their code, their categories, datasets, cited references and authors, the rarest counting most.
- [1] doi:10.3758/s13415-026-01417-1 [code]
- Computational signatures of exertion and rest underlie moment-to-moment dynamics of subjective perceptions of effort and fatigue.Journal: Cognitive, affective & behavioral neuroscienceIn common: 4 references, author Matthew A J Apps
- [2] doi:10.1073/pnas.2601231123
- Contributions of the basolateral amygdala and nucleus accumbens to sustaining not just initiating cognitive effort.Journal: Proceedings of the National Academy of Sciences of the United States of AmericaIn common: cognitive, 6 references
- [3] doi:10.1162/imag.a.1332 [code]
- Decision processes underlying effort avoidance and their relationship with metacognition.Journal: Imaging neuroscience (Cambridge, Mass.)In common: Statistics and Machine Learning Toolbox, cognitive, 5 references
- [4] doi:10.1371/journal.pbio.3003767 [code]
- Ultrasound neuromodulation reveals distinct roles of the dorsal anterior cingulate cortex and anterior insula in learning.Journal: PLoS biologyIn common: boundedline, Statistics and Machine Learning Toolbox, cognitive, 2 references
- [5] doi:10.7554/elife.105774 [code]
- Anterior cingulate cortex monitors action state and action content in complex associative learning.Journal: eLifeIn common: cognitive, 4 references
- [6] doi:10.7554/elife.103566 [code]
- Effort produces after-effects costly for others but valued for self.Journal: eLifeIn common: 4 references
- [7] doi:10.1093/schbul/sbaf078
- Orbitofrontal Thickness and Network Associations as Transdiagnostic Signature of Amotivation Along the Bipolar-Schizophrenia Spectrum.Journal: Schizophrenia bulletinIn common: 4 references
- [8] doi:10.1093/brain/awag074 [code]
- Empathy motivation is preserved following amygdala damage.Journal: Brain : a journal of neurologyIn common: cognitive, 3 references
- [9] doi:10.1017/s0033291726103249 [code]
- Inefficient integration between effort and reward in anhedonia.Journal: Psychological medicineIn common: cognitive, 3 references
- [10] doi:10.7554/elife.103846 [code]
- Overt visual attention modulates decision-related signals in the frontal cortex.Journal: eLifeIn common: Statistics and Machine Learning Toolbox, cognitive, 2 references
Contribute
The authors of this paper can claim it, correct its record and validate its tracing map, and the maintainers of its code (its owner, or a public member of its organization) correct what it says of their repository; anyone signed in can ask for its removal. Every request goes to OSCR's own machine, which answers it; your account page follows them.
Sign in with ORCID to claim this paper as one of its authors, correct its record or validate its tracing map: when the paper's metadata lists your ORCID iD, you are recognized at once. Maintainers of its code: sign in with GitHub, then claim the repository on your account page.
Claim this paper
Correct its record
Say what each link of this record is, remove the ones that are not the paper's, add the ones that are missing. The correction becomes a new version of the record, in its Versions section.
Validate its tracing map
You validate the map as this page shows it: 1 repository of the authors' code, each at its verified commit and with its license, 5 scripts, and 1 match between paragraphs and code (see the Code and Map sections). It then receives a DOI on Zenodo, with you (your ORCID iD) and OSCR as its creators; the code itself is not deposited.
The map's fingerprint: sha256:81feda5a5294ff1d…
Add the badge to its README
The badge links the code to this page. Copy one of these into the README of the paper's code: only you decide where it goes, and nothing is changed for you.
Markdown
[.
Discussion, reproductions, activity
Discussion: questions and error reports about this paper and its code, from signed-in readers and its authors. It opens with sign-in.
Reproductions: reports from readers who ran the authors' code: what they reproduced, with which environment, commit and data. It opens with sign-in.
Activity: what happens around this paper: new versions of its record, its map's validation, discussions and reproductions. It opens with sign-in.
