clear all mainfolder='' addpath(genpath(['subfunctions/'])) addpath(genpath(['subfunctions/rm_anova2'])) load('good_partis.mat') %list of participant with a good performance partis_sub=good_partis' %% Empty variables accrot_cu_uncue_all{1,1}=nan(512,length(partis_sub)); accrot_cu_uncue_all{1,2}=nan(512,length(partis_sub)); accrot_cu_uncue_all{2,1}=nan(512,length(partis_sub)); accrot_cu_uncue_all{2,2}=nan(512,length(partis_sub)); %% for ppp=1:length(partis_sub) %Per participant % Loading dataset if strcmp( partis_sub{ppp,:},'p11') load([mainfolder 'logfiles/resultfile_p11_table_repaired.mat']) else subtable=[]; sub = tdfread([mainfolder 'logfiles/resultfile_' partis_sub{ppp,:} '.txt'],'tab'); %Logfile for this participant subtable=struct2table(sub); end for item=1:2 % Cue (first test) toi=subtable.retro_cue==item&subtable.type_of_task==1 ... &subtable.acc_trial_concrete_cued~=2&subtable.acc_trial_concrete_cued~=NaN; toi2=subtable.retro_cue==item&subtable.type_of_task==1 ... &subtable.acc_trial_concrete_cued~=2; %to keep all trials it is fine if the value is NaN accrot_cu_uncue{item,1}(ppp)= nanmean(subtable.acc_trial_concrete_cued(toi)); accrot_cu_uncue_all{item,1}(toi2,ppp)= (subtable.acc_trial_concrete_cued(toi2)); % Uncue (second test) toi=subtable.retro_cue_uncued==item&subtable.type_of_task==1 ... &subtable.acc_trial_concrete_uncued~=2&subtable.acc_trial_concrete_uncued~=NaN; toi2=subtable.retro_cue_uncued==item&subtable.type_of_task==1 ... &subtable.acc_trial_concrete_uncued~=2; %to keep all trials it is fine if the value is NaN accrot_cu_uncue{item,2}(ppp)= nanmean(subtable.acc_trial_concrete_uncued(toi)); accrot_cu_uncue_all{item,2}(toi2,ppp)=(subtable.acc_trial_concrete_uncued(toi2)); end end %% Plot all{1}= cat(2,accrot_cu_uncue{1,1}',accrot_cu_uncue{2,1}',accrot_cu_uncue{1,2}',accrot_cu_uncue{2,2}') %All data together avg=nanmean(all{1},1); sem=std(all{1})/sqrt(size(all{1},1)); figure; er=errorbar([],avg,sem,sem,'o'); er.Color = [0 0 0]; er.LineStyle = 'none'; ylim([0.475 0.8]) xlim([0 5]) line([0,5],[0.5 0.5], 'Color', 'k','LineStyle','--');hold on; xticks([1:4]) xticklabels({'ori 1 1st test','ori 2 1st test','ori 1 2nd test','ori 2 2nd test'}) ylabel('accuracy') title(['General accuracy']) %% Anova a1= cat(1,accrot_cu_uncue{1,1}',accrot_cu_uncue{2,1}',accrot_cu_uncue{1,2}',accrot_cu_uncue{2,2}') p=size(accrot_cu_uncue{1,1},2); S=[1:p,1:p,1:p,1:p]; F1=[ones(p,1);ones(p,1)*2;ones(p,1);ones(p,1)*2]' F2=[ones(p*2,1);ones(p*2,1)*2]' FACTNAMES={'stim order', 'test order'} stats = rm_anova2(a1,S,F1,F2,FACTNAMES) totalSS=sum([stats{2,2},stats{3,2},stats{4,2},stats{5,2},stats{6,2},stats{7,2}]); etaS=[stats{2,2}/totalSS,stats{3,2}/totalSS,stats{4,2}/totalSS] %% Just to see means and sds testone= cat(1,accrot_cu_uncue{1,1}',accrot_cu_uncue{2,1}'); testtwo= cat(1,accrot_cu_uncue{1,2}',accrot_cu_uncue{2,2}'); itemone= cat(1,accrot_cu_uncue{1,1}',accrot_cu_uncue{1,2}'); itemtwo= cat(1,accrot_cu_uncue{2,1}',accrot_cu_uncue{2,2}'); mean(testone) std(testone) mean(testtwo) std(testtwo) mean(itemone) std(itemone) mean(itemtwo) std(itemtwo); %% Linear trend regarding distance %from closest to longest disntace distances(:,1)=all{1}(:,2) %stim 2 cued 1st distances(:,2)=all{1}(:,1) %stim 1 cued 1st distances(:,3)=all{1}(:,4)%stim 2 cued 2nd distances(:,4)=all{1}(:,3) %stim 1 cued 2nd %% Check linear trend ball=[]; yfit = []; for ppp = 1:size(distances,1) tof=[]; for c=1:size(distances,2); tof=[tof; distances(ppp,c)]; end [b,dev,stats] = glmfit(1:size(distances,2),tof,'normal'); yfit(ppp,:) = polyval([b(2,1),b(1,1)],[1,2,3,4]); ball(ppp) = b(2); end [h,p,ci,stats] = ttest(ball,0) [p,h,stats] = signrank(ball,0) %% Plotting accuracies + linear trends all{1}= distances; avg=nanmean(all{1},1); sem=std(all{1})/sqrt(size(all{1},1)); figure; er=errorbar([],avg,sem,sem,'o'); er.Color = [0 0 0]; er.LineStyle = 'none'; % ylim([0.475 0.8]) xlim([0 5]) line([0,5],[0.5 0.5], 'Color', 'k','LineStyle','--');hold on; xticks([1:4]) xticklabels({'ori 2 1st test','ori 1 1st test','ori 2 2nd test','ori 1 2nd test'}); hold on; plot(yfit') ylabel('accuracy') title(['General accuracy based on distance'])