To check out this repository please hg clone the following URL, or open the URL using EasyMercurial or your preferred Mercurial client.

The primary repository for this project is hosted at git://github.com/rmeddis/MAP.git .
This repository is a read-only copy which is updated automatically every hour.

Statistics Download as Zip
| Branch: | Revision:

root / multithreshold 1.46 / printReport.m @ 33:161913b595ae

History | View | Annotate | Download (9.71 KB)

1 0:f233164f4c86 rmeddis
function printReport(fileName, printTracks)
2
3
% End of run report (no args)
4
% *or*
5
% reprint previous report from file
6
7 32:82fb37eb430e rmeddis
global experiment stimulusParameters betweenRuns withinRuns statsModel
8 0:f233164f4c86 rmeddis
global LevittControl expGUIhandles
9 29:b51bf546ca3f rmeddis
global paramChanges
10 0:f233164f4c86 rmeddis
11 32:82fb37eb430e rmeddis
% NB all globals are used even though this is not obvious
12 0:f233164f4c86 rmeddis
global inputStimulusParams OMEParams DRNLParams
13
global IHC_VResp_VivoParams IHCpreSynapseParams  AN_IHCsynapseParams
14
global MacGregorParams MacGregorMultiParams  filteredSACFParams
15
global experiment % used by calls from multiThreshold only
16
global IHC_cilia_RPParams
17
18
printReportGuide.structures=1;
19
printReportGuide.showPsychometric=0;
20
printReportGuide.HorizontalTracks=1;
21
22
if nargin==0
23
    % print new report
24
    printReportGuide.showTracks=experiment.printTracks;
25
    printReportGuide.fileName=[];
26 33:161913b595ae rmeddis
    % save this data (just in case)
27
    saveFileName=['savedData/mostRecentResults'];
28 0:f233164f4c86 rmeddis
    experiment.minElapsed=etime(clock, betweenRuns.timeNow)/60;
29 20:fafe69c43108 rmeddis
    save(saveFileName, 'experiment', 'stimulusParameters',...
30
        'betweenRuns', 'withinRuns', 'statsModel', 'expGUIhandles')
31 0:f233164f4c86 rmeddis
    disp(['data saved as: ' saveFileName]);
32 32:82fb37eb430e rmeddis
33 0:f233164f4c86 rmeddis
else
34 20:fafe69c43108 rmeddis
    % reprint request (i.e print out old data)
35 0:f233164f4c86 rmeddis
    printReportGuide.fileName=fileName;
36
    load(printReportGuide.fileName)
37
    saveFileName=printReportGuide.fileName;
38
    if nargin>1
39
        printReportGuide.showTracks=printTracks;
40
    else
41
        printReportGuide.showTracks=experiment.printTracks;
42
    end
43
end
44
45
fprintf('******** multithreshold ')
46 20:fafe69c43108 rmeddis
47 0:f233164f4c86 rmeddis
x=pwd; disp(['version ' x(end-3:end)])
48
fprintf('\nName:\t%s ', experiment.name)
49
fprintf('\nparadigm:\t%s ', experiment.paradigm)
50
fprintf('\nEar:\t%s ', experiment.ear)
51 20:fafe69c43108 rmeddis
52 0:f233164f4c86 rmeddis
method=experiment.threshEstMethod;
53
if stimulusParameters.includeCue && ~strcmp(method(1:6),'2I2AFC')
54
    method=[method '/ withCue'];
55
end
56
fprintf('\nmethod:\t%s ', method)
57
fprintf('\ndate:\t%s ', experiment.date)
58
fprintf('\n\n')
59
60
if isempty(betweenRuns.thresholds)
61
    disp('no thresholds found')
62
end
63
64
% prepare results as matrices ready to print
65 20:fafe69c43108 rmeddis
%  first sort the actual sequence into a more readable sequence
66 0:f233164f4c86 rmeddis
[idx1, idx2, var1values, var2values]=...
67 20:fafe69c43108 rmeddis
    sortVariables(betweenRuns.variableList1, betweenRuns.variableList2,...
68
    betweenRuns.var1Sequence, betweenRuns.var2Sequence);
69 0:f233164f4c86 rmeddis
70
header1=betweenRuns.variableName1;
71
header2=betweenRuns.variableName2;
72
header1 = strrep(header1, 'none', ' '); % none is not a useful header
73
header2 = strrep(header2, 'none', ' '); % none is not a useful header
74
headers=strvcat([header1 '/'], header2);
75
76
disp('thresholds')
77 28:02aa9826efe0 rmeddis
global resultsTable
78
resultsTable= sortTablesForPrinting(idx1,idx2,...
79
    var1values,var2values, betweenRuns.thresholds);
80
msg=printTabTable(resultsTable,  headers);
81 0:f233164f4c86 rmeddis
addToMsg(msg,0)
82 32:82fb37eb430e rmeddis
if ~isempty(paramChanges)
83
    fprintf('\n')
84 33:161913b595ae rmeddis
    fprintf('%s\n', char(paramChanges))
85 32:82fb37eb430e rmeddis
end
86 0:f233164f4c86 rmeddis
87
% sort tracks into the same order
88
betweenRuns.levelTracks=betweenRuns.levelTracks(idx1);
89
betweenRuns.responseTracks=betweenRuns.responseTracks(idx1);
90
betweenRuns.bestThresholdTracks=betweenRuns.bestThresholdTracks(idx1);
91
betweenRuns.levelTracks=betweenRuns.levelTracks(idx2);
92
betweenRuns.responseTracks=betweenRuns.responseTracks(idx2);
93
betweenRuns.bestThresholdTracks=betweenRuns.bestThresholdTracks(idx2);
94
95
if printReportGuide.structures
96
    maxNoArrayValues=30;
97 32:82fb37eb430e rmeddis
    showStructureSummary(stimulusParameters, 'stimulusParameters', ...
98
        maxNoArrayValues)
99 0:f233164f4c86 rmeddis
    showStructureSummary(experiment, 'experiment',maxNoArrayValues)
100
    showStructureSummary(betweenRuns, 'betweenRuns',maxNoArrayValues)
101
    showStructureSummary(withinRuns, 'withinRuns')
102 32:82fb37eb430e rmeddis
103 0:f233164f4c86 rmeddis
    switch experiment.threshEstMethod
104
        case {'2I2AFC++', '2I2AFC+++'}
105 32:82fb37eb430e rmeddis
            showStructureSummary(LevittControl, 'LevittControl', ...
106
                maxNoArrayValues)
107 0:f233164f4c86 rmeddis
    end
108 32:82fb37eb430e rmeddis
109 0:f233164f4c86 rmeddis
    switch experiment.ear
110
        case {'statsModelLogistic','statsModelRareEvent'}
111 32:82fb37eb430e rmeddis
            showStructureSummary(statsModel, 'statsModel', ...
112
                maxNoArrayValues)
113 0:f233164f4c86 rmeddis
    end
114
end
115
116
if printReportGuide.showTracks
117
    % NB this procedure can only be used if all the tracks are present and
118
    % of equal length
119
    bigTable=[]; header=[];
120 32:82fb37eb430e rmeddis
    disp(' ');
121
    disp('Leveltracks starting from 1 response before the first reversal')
122 0:f233164f4c86 rmeddis
    for i=1:length(betweenRuns.levelTracks)
123
        if printReportGuide.HorizontalTracks
124
            printTabTable(betweenRuns.levelTracks{i});
125
        end
126
        header=strvcat(header, 'level');
127
    end
128 32:82fb37eb430e rmeddis
129
    disp(' ');
130
    disp('Response tracks  from 1 response before the first reversal')
131 0:f233164f4c86 rmeddis
    for i=1:length(betweenRuns.responseTracks)
132
        if printReportGuide.HorizontalTracks
133
            printTabTable(betweenRuns.responseTracks{i});
134
        end
135
        header=strvcat(header, 'resp');
136
    end
137 32:82fb37eb430e rmeddis
138 0:f233164f4c86 rmeddis
    disp(' '); disp('threshold tracks starting from the first reversal')
139
    for i=1:length(betweenRuns.bestThresholdTracks)
140
        if printReportGuide.HorizontalTracks
141
        end
142
        printTabTable(betweenRuns.bestThresholdTracks{i});
143
        header=strvcat(header, 'mean');
144
    end
145 32:82fb37eb430e rmeddis
146 0:f233164f4c86 rmeddis
end
147
148
switch experiment.ear
149
    case  {'MAPmodelMultiCh', 'MAPmodelSingleCh'}
150
        % show all parameters but do not compute the model
151
        nm=UTIL_paramsList(whos);
152
        for i=1:length(nm)
153
            try
154
                eval(['UTIL_showStruct(' nm{i} ', ''' nm{i} ''')'])
155
            catch
156
            end
157
        end
158
end
159
160
if experiment.saveData
161
    fprintf('\n')
162
    disp('To reprint this report with tracks use:')
163
    disp([ 'printReport(''' saveFileName ''',1)'])
164
end
165
166
% print final summary (repeat of above)
167
fprintf('\n')
168
fprintf('\n')
169
disp('thresholds')
170 32:82fb37eb430e rmeddis
msg=printTabTable(sortTablesForPrinting...
171
    (idx1,idx2,var1values,var2values, betweenRuns.thresholds),  headers);
172 0:f233164f4c86 rmeddis
addToMsg(msg,0)
173
fprintf('\n')
174
175 32:82fb37eb430e rmeddis
if length(var1values)==1 && length(var2values)==1 ...
176
        && experiment.maxTrials>49
177
    [psy, levelsBinVector, binFrequencies]= ...
178
        psychometricFunction(withinRuns.levelsPhaseTwo,...
179
        withinRuns.responsesPhaseTwo, experiment.psyBinWidth);
180 0:f233164f4c86 rmeddis
    disp('Psychometric function')
181
    fprintf(' level  \tfreq\tprob\n')
182 32:82fb37eb430e rmeddis
    fprintf('%6.0f\t%6.2f\t%6.0f\n',[levelsBinVector; binFrequencies; psy])
183 0:f233164f4c86 rmeddis
    fprintf('\n')
184
    fprintf('k \t %6.2f\n',logistic.bestK)
185
    fprintf('g  \t%7.5f\n',rareEvent.bestGain)
186
    fprintf('\n')
187 32:82fb37eb430e rmeddis
188 0:f233164f4c86 rmeddis
end
189 9:ecad0ea62b43 rmeddis
190
fprintf('\nparadigm:\t%s\n ', experiment.paradigm)
191 32:82fb37eb430e rmeddis
if ~isempty(paramChanges)
192 33:161913b595ae rmeddis
    fprintf('%s\n', char(paramChanges))
193 32:82fb37eb430e rmeddis
end
194 0:f233164f4c86 rmeddis
195 32:82fb37eb430e rmeddis
% ------------------------------------------------- sortTablesForPrinting
196 0:f233164f4c86 rmeddis
function table= sortTablesForPrinting(idx1,idx2, var1values,var2values, x)
197
% table converts a vector to a table
198
% after sorting according to idx1 and idx2
199
% the table is completed by adding row and column values
200
x=x(idx1);
201
x=x(idx2);
202
xMatrix=reshape(x,length(var1values),length(var2values));
203
204
table=[[-1000 var2values]; [var1values' xMatrix]];
205
206 32:82fb37eb430e rmeddis
% --------------------------------------------------- showStructureSummary
207 0:f233164f4c86 rmeddis
function showStructureSummary(structure, name, maxNoArrayValues)
208
% showStructureSummary prints out the values of a single structure
209
% The header is the structure name and each row is a field
210
% e.g. showStructureSummary(params,'params')
211
% This not the same as 'UTIL_showstruct'
212
213
214
if nargin<3
215
    maxNoArrayValues=20;
216
end
217
218
fprintf('\n%s:', name)
219
220
fields=fieldnames(eval('structure'));
221
% for each field in the structure
222
for i=1:length(fields)
223
    y=eval([ 'structure.' fields{i}]);
224
    if isstr(y),
225
        % strings
226
        fprintf('\n%s=\t''%s''',  fields{i},y)
227
    elseif isnumeric(y)
228
        % arrays
229
        if length(y)>1
230
            % vectors
231
            [r c]=size(y);
232
            if r>c, y=y'; end
233 32:82fb37eb430e rmeddis
234 0:f233164f4c86 rmeddis
            [r c]=size(y);
235
            if r>1
236 32:82fb37eb430e rmeddis
                % fprintf('\n%s.%s=\t%g x %g matrix',name, fields{i}, r, c)
237 0:f233164f4c86 rmeddis
                fprintf('\n%s=\t%g x %g matrix',fields{i}, r, c)
238 32:82fb37eb430e rmeddis
239 0:f233164f4c86 rmeddis
            elseif c<maxNoArrayValues
240 32:82fb37eb430e rmeddis
                %  fprintf('\n%s=\t[%s]',  fields{i},num2str(y))
241 0:f233164f4c86 rmeddis
                fprintf('\n%s=',  fields{i})
242
                fprintf('\t%g',y)
243 32:82fb37eb430e rmeddis
244 0:f233164f4c86 rmeddis
            else
245 32:82fb37eb430e rmeddis
                fprintf('\n%s=\t %g...   [%g element array]', ...
246
                    fields{i}, y(1),c)
247 0:f233164f4c86 rmeddis
            end
248
        else
249
            % single valued arrays
250 32:82fb37eb430e rmeddis
            % fprintf('\n%s.%s=\t%s;', name, fields{i},num2str(y))
251 0:f233164f4c86 rmeddis
            fprintf('\n%s=\t%s', fields{i},num2str(y))
252
        end
253
    elseif iscell(y)
254
        fprintf('\n%s=\t cell array', fields{i})
255 32:82fb37eb430e rmeddis
256 0:f233164f4c86 rmeddis
    elseif isstruct(y)
257
        fprintf('\n%s=\t structure', fields{i})
258
    end,
259 32:82fb37eb430e rmeddis
260 0:f233164f4c86 rmeddis
end,
261
fprintf('\n')
262
263
264
% ------------------------------------------------------- printTabTable
265
function strings= printTabTable(M, headers)
266
% printTabTable prints a matrix as a table with tabs
267
%headers are optional
268
%headers=strvcat('firstname', 'secondname')
269
%  printTabTable([1 2; 3 4],strvcat('a1','a2'));
270
stringCount=1; strings{stringCount}=[];
271
272
if nargin>1
273
    [r c]=size(headers);
274
    for no=1:r
275
        % print all headers in a row
276
        fprintf('%s\t',headers(no,:))
277 32:82fb37eb430e rmeddis
        strings{stringCount}=...
278
            sprintf('%s\t',headers(no,:)); stringCount=stringCount+1;
279 0:f233164f4c86 rmeddis
    end
280
    fprintf('\n')
281
end
282
283
[r c]=size(M);
284
285
for row=1:r
286
    string=[];
287
    for col=1:c
288 32:82fb37eb430e rmeddis
        if row==1 && col==1 && M(1,1)==-1000
289 0:f233164f4c86 rmeddis
            %   Print nothing (tab follows below)
290
        else
291
            fprintf('%s',num2str(M(row,col)))
292
            string=[string ' ' sprintf('%s',num2str(M(row,col)))];
293
        end
294
        if col<c
295
            fprintf('\t')
296 32:82fb37eb430e rmeddis
            %strings{stringCount}=sprintf('\t'); stringCount=stringCount+1;
297 0:f233164f4c86 rmeddis
        end
298
    end % col
299
    strings{stringCount}=string; stringCount=stringCount+1;
300
    fprintf('\n')
301
end % row
302
303
% ------------------------------------------------------- sortVariables
304
function [idx1, idx2, var1values, var2values]= ...
305
    sortVariables(var1values, var2values, var1Sequence, var2Sequence)
306
307
[x idx1]= sort(var1Sequence);
308
var1Sequence= x;
309
var2Sequence= var2Sequence(idx1);
310
depVarName= 'th';
311
312
[x idx2]=sort(var2Sequence);
313
var2Sequence=x;
314
var1Sequence=var1Sequence(idx2);
315
316
var1values=sort(var1values);
317
var2values=sort(var2values);