-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathPAS_validate_EMG_responses.m
68 lines (53 loc) · 2.09 KB
/
PAS_validate_EMG_responses.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
function [all_evoked_EMGs, breakflag] = PAS_validate_EMG_responses(all_evoked_EMGs, time_axis, ch, baseline_mean)
%Plots individual trials of EMG responses and presents a space for user to enter a vector, indicating which trial to take out
figure;
%trialvect = true([size(all_evoked_EMGs,1),ch]);
%Calculate the baseline standard deviation from the 16 values of
%baseline_mean prior to stimulation. Stays the same regardless of
%whether baseline was removed or not.
% baseline_m2SD = mean(baseline_mean) + 2*(std(baseline_mean,0,1));
breakflag = 0;
med2sd= median(baseline_mean)+2*std(baseline_mean);
trialvect = baseline_mean < med2sd;
%For trials from 1 to 16,
for tr = 1:size(all_evoked_EMGs,1)
if trialvect(tr)
plot(time_axis,all_evoked_EMGs(tr,:),'b');
else
plot(time_axis,all_evoked_EMGs(tr,:),'r');
end
title(['stim number: ' num2str(tr)]);
BLSD = (baseline_mean(tr)-median(baseline_mean))/std(baseline_mean);
ChannelLabel = ['Ch ' sprintf('%d, %.2f SD',ch,BLSD)];
% dim = [.62 .5 .3 .3];
%annotation('textbox',dim,'String',ChannelLabel,'FitBoxToText','on');
legend(ChannelLabel);
% Construct a questdlg with three options
choice = questdlg('Would you like to keep this trial?', ...
'Trial Validation', ...
'KEEP','DISCARD','AUTO/Break','AUTO/Break');
% Handle response
%'Position',[.5 .2 .2 .15]);
switch choice
case 'KEEP'
sprintf('Trial %d KEPT', tr)
trialvect(tr) = true;
case 'DISCARD'
sprintf('Trial %d DISCARDED', tr)
trialvect(tr) = false;
case 'AUTO/Break'
breakflag = 1;
break;
end
if breakflag == 1
break;
end
% prompt = {'Exclude this Trial?'};
% dlg_title = 'Trial Exclusion';
% num_lines = 1;
% defaultans = {''};
% params = inputdlg(prompt,dlg_title,num_lines,defaultans);
% excludethistrial = params{1};
end
all_evoked_EMGs = all_evoked_EMGs(trialvect,:);
end