Commit 005acd0b authored by Julius Welzel's avatar Julius Welzel

Stats included

parent 44ccd89d
......@@ -46,14 +46,15 @@ n_trials = 96;
%ES params
t_emg = 1.5; % STD threshold EMG
t_BP_ms = 1000; % ms at end
max_ffe = 30; % max calculations
mu = 4;
lambda_ = 10;
t_BP_ms = 1000; % ms at beginning of ES
max_ffe = 50; % max calculations
mu = 2;
lambda_ = 4;
i_sigma = 0.9;
%rechenberg
T = 5; %Rechenberg success
tau = 0.75;
tau = 2;
......@@ -79,7 +80,7 @@ h_INPUT{2,end} = pop_x(1,2);
%initiate Rechenberg
s = 0;
sigma = 0.8; % stepsize
sigma = i_sigma; % stepsize
while ffe < max_ffe
......@@ -109,14 +110,15 @@ while ffe < max_ffe
s = 0;
end
% constraint for BP time
if sum(pop_x(:,1) > 1600)>=1
i = pop_x(1:mu,1) > 1600;
pop_x(i,1) = 1000;
elseif sum(pop_x(:,1) < 400)>=1
i = pop_x(1:mu,1) < 400;
pop_x(i,1) = 1000;
if ffe >1
% constraint for BP time
if sum(pop_x(:,1) > 1600)>=1
i = pop_x(1:mu,1) > 1600;
pop_x(i,1) = h_INPUT{1,end-1};
elseif sum(pop_x(:,1) < 600)>=1
i = pop_x(1:mu,1) < 600;
pop_x(i,1) = h_INPUT{1,end-1};
end
end
%save best offspring
......@@ -177,6 +179,8 @@ end
%% Accuracy overview
RTs = [nanmean(EMG_all(:,cfg.blck_idx{1,:}),2) nanmean(EMG_all(:,cfg.blck_idx{2,:}),2) nanmean(EMG_all(:,cfg.blck_idx{3,:}),2) nanmean(EMG_all(:,cfg.blck_idx{4,:}),2)];
ACCs = 100*[NaN_acc(EMG_all(:,cfg.blck_idx{1,:})) NaN_acc(EMG_all(:,cfg.blck_idx{2,:})) NaN_acc(EMG_all(:,cfg.blck_idx{3,:})) NaN_acc(EMG_all(:,cfg.blck_idx{4,:}))];
ACC_MI = [NaN_acc(EMG_all(:,cfg.blck_idx{2,:}))*40 NaN_acc(EMG_all(:,cfg.blck_idx{3,:}))*40];
% Scatter
Ind = figure;
CT=cbrewer('qual', 'Paired', size(RTs,1));
......@@ -187,20 +191,98 @@ for n = 1:size(RTs,1)
hold on
end
ylabel 'Epochs clean [%]'
xlim([0 size(RTs,2)+1])
xlabel 'Blocks'
xticks([1:4])
xticklabels({'ME1','MI1','MI2','ME2'})
title (['Clean epochs'])
set(findall(gcf,'-property','FontSize'),'FontSize',18)
legend ([SUBJ])
hline(70,'k')
set(gcf, 'Position', [0 0 1200 800]);
saveas(gcf,[PATHOUT_ES 'EMG_acc_overview.png']);
close;
boxplot(40-ACC_MI',double(old))
ylabel 'Movement epochs [n]'
recolor_box(gcf,[c_young;c_old]);
xlabel 'Group'
xticks([1:2])
xticklabels({'Young','Old'})
pic_r = 1/1.7;
save_fig(gcf,PATHOUT_ES,['Movement_epoch_n'],'fontsize',15,'figsize',[0 0 22.7/2 pic_r*22.7/2],'figtype','.png');
% xlim([0 size(RTs,2)+1])
% ylim ([0 min(min(ACC_MI))+2])
% xlabel 'Blocks'
% xticks([1:2])
% xticklabels({'MI1','MI2'})
% title (['Clean epochs // acc: ' num2str(mean(ACCs,'all'))])
% set(findall(gcf,'-property','FontSize'),'FontSize',24)
% legend ([SUBJ])
% hline(70,'k')
% set(gcf, 'Position', [0 0 1400 800]);
% saveas(gcf,[PATHOUT_ES 'final_sigma_' num2str(i_sigma) '_tau_' num2str(tau) '_EMG_acc_overview.png']);
% close;
for b = 1:size(ACCs,2)
score_EMG(1,b) = mean(ACCs(young,b));
score_EMG(2,b) = mean(ACCs(old,b));
end
all_b_EMG = mean(score_EMG);
all_g_EMG = mean(score_EMG,2);
save([PATHIN 'EMG_ES.mat'],'EMG_all','cfg')
%% Validity plots EMG
% CAVE: Run first part of ana08_rela first
% Boxplot Threshold & BP time
BP_times = [cfg.EMG.thresh_BP_ms];
thresh_SD = [cfg.EMG.thresh_STD];
boxplot([BP_times],double(old))
recolor_box(gcf,[c_young;c_old]);
ylabel 'BP time [ms]'
xlabel 'Group'
xticks([1:2])
xticklabels({'Young','Old'})
pic_r = 1/1.7;
save_fig(gcf,PATHOUT_ES,['BP_times'],'fontsize',35,'figsize',[0 0 22.7 pic_r*22.7]);
boxplot([thresh_SD],double(old))
recolor_box(gcf,[c_young;c_old]);
ylabel 'Threshold [SD]'
xlabel 'Group'
xticks([1:2])
xticklabels({'Young','Old'})
save_fig(gcf,PATHOUT_ES,['Thresh_SD'],'fontsize',35,'figsize',[0 0 22.7 pic_r*22.7]);
[t_BP] = ttest2_param(BP_times(old),BP_times(young));
[t_thresh] = ttest2_param(thresh_SD(old),thresh_SD(young));
%% Find EMG movement in MI
[r c] = find(isnan(EMG_all(:,MI_trials)));
% for i = 1:length(r)
% figure
% plot(emgdata{r(i),c(i)}(1,:))
% end
%
figure
subplot(2,1,1)
ep=13;
sub=11;
t_vec = linspace(0,length(emgdata{sub,ep})*(1000/cfg.EMG.srate),length(emgdata{sub,ep}));
plot(t_vec,emgdata{sub,ep}(1,:),'Color',[0.7 0.7 0.7])
% ylabel 'Amplitude [\muV]'
% xlabel 'Time [ms]'
axis tight
v = vline(length(emgdata{sub,ep})*(1000/cfg.EMG.srate)-cfg.EMG.thresh_BP_ms(sub)/1.8,'-k')
v.LineWidth = 2;
subplot(2,1,2)
t_vec = linspace(0,length(emgdata{11,55})*(1000/cfg.EMG.srate),length(emgdata{11,55}));
plot(t_vec,emgdata{11,55}(1,:),'Color',[0.7 0.7 0.7])
ylabel ' Amplitude [\muV]'
xlabel 'Time [ms]'
axis tight
v = vline(length(emgdata{11,55})*(1000/cfg.EMG.srate)-cfg.EMG.thresh_BP_ms(sub)/1.8,'-k');
v.LineWidth = 2;
pic_r = 1/1.7;
save_fig(gcf,PATHOUT_ES,['BP_emg_eg'],'fontsize',15,'figsize',[0 0 22.7/2 pic_r*22.7/2])
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment