-
Notifications
You must be signed in to change notification settings - Fork 5
/
mpsy_plot_feedback.m
95 lines (80 loc) · 3.77 KB
/
mpsy_plot_feedback.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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
% Usage: mpsy_plot_feedback
% ----------------------------------------------------------------------
% to be called from mpsy_afc_main or similar scripts
%
% all data/values of M.VAR during the current adaptive afc run
% are plotted as a function of their trial number
%
%
% input: (none), works on global variables
% output: (none), a plot figure
%
% Copyright (C) 2003, 2004 Martin Hansen, FH OOW
% Author : Martin Hansen, <psylab AT jade-hs.de>
% Date : 27 Jun 2003
% Updated: <14 Jan 2004 11:30, hansen>
%% This file is part of PSYLAB, a collection of scripts for
%% designing and controlling interactive psychoacoustical listening
%% experiments.
%% This file is free software; you can redistribute it and/or modify
%% it under the terms of the GNU General Public License as published
%% by the Free Software Foundation; either version 2 of the License,
%% or (at your option) any later version. See the GNU General
%% Public License for more details: http://www.gnu.org/licenses/gpl
%% This file is distributed in the hope that it will be useful,
%% but WITHOUT ANY WARRANTY; without even the implied warranty of
%% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
%figure(111);
idx_plus = find(M.ANSWERS ==1); % correct answers
idx_minus = find(M.ANSWERS ==0); % wrong answers
% In case that threshold has not yet been reached, a preliminary plot
% is shown. Whether threshold has been reached, can be checked by the
% content of M.med_thres, which is only set via mpsy_proto_adapt
if isempty(M.med_thres),
% simple plot
plot(1:length(M.VARS), M.VARS,'b.-', idx_plus, M.VARS(idx_plus), 'r+', idx_minus, M.VARS(idx_minus), 'ro');
else
% A somewhat nicer plot. Careful: The field M.familiarization_fidx
% has been calculated by mpsy_proto_adapt. Then these are the 2 indices at
% transition between familiarization phase and measurement phase:
idx_trans = [M.familiarization_fidx(end) M.measurement_fidx(1)]; %
hp = plot(M.measurement_fidx, M.VARS(M.measurement_fidx), 'k.-', ...
M.familiarization_fidx, M.VARS(M.familiarization_fidx), 'k.-', ...
idx_trans, M.VARS(idx_trans), 'k--', ...
idx_plus, M.VARS(idx_plus), 'r+', ...
idx_minus, M.VARS(idx_minus), 'ro');
set(hp([2 3]), 'Color', 0.5*[1 1 1]);
end
xlabel('trial number')
yl = [ M.VARNAME ' [' M.VARUNIT ']'];
ylabel(strrep(yl, '_','\_'));
tit = ['Exp.: ' M.EXPNAME ', Parameter: ' char(M.PARAMNAME(1)) ' = ' num2str(M.PARAM(1)) ' ' char(M.PARAMUNIT(1))];
for k=2:M.NUM_PARAMS,
tit = [tit ' Par.' num2str(k) ': ' char(M.PARAMNAME(k)) ' = ' num2str(M.PARAM(k)) ' ' char(M.PARAMUNIT(k))];
end
title(strrep(tit,'_','\_'));
% add a legend with subject name and date
legend( sprintf('%s: %s',M.SNAME,datestr(now)), 'location', 'Best');
% and add text information about median and std.dev.,
% but only if run is finished, i.e. threshold is reached. This can
% be checked via the variable M.med_thres that is set to a value
% only after a call to mpsy_proto_adapt
if ~isempty(M.med_thres),
text(M.measurement_fidx(1), 0.5*(M.VARS(M.measurement_fidx(1))+max(M.VARS)), ...
sprintf('med:%g, mean:%g, std:%g ', M.med_thres, M.mean_thres, M.std_thres));
end
% save the plot figure containing all M.VARS of current run into eps-file
if M.DEBUG>3 | M.FEEDBACK>1,
m_plotfilename = ['plot_run_' M.SNAME];
if M.FEEDBACK>2,
% add date and time information to plot-filename
tmp = datestr(now, 30);
tmp = tmp(3:end-2); tmp(7)='-';
m_plotfilename = [m_plotfilename tmp '_'];
end
print('-dpsc','-append', m_plotfilename)
end
% End of file: mpsy_plot_feedback.m
% Local Variables:
% time-stamp-pattern: "40/Updated: <%2d %3b %:y %02H:%02M, %u>"
% End: