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 @ 31:c54a34161e4a

History | View | Annotate | Download (9.76 KB)

1
function printReport(fileName, printTracks)
2

    
3
% End of run report (no args)
4
% *or*
5
% reprint previous report from file
6

    
7
global experiment stimulusParameters betweenRuns withinRuns statsModel   audio
8
global LevittControl expGUIhandles
9
global paramChanges
10

    
11
global inputStimulusParams OMEParams DRNLParams
12
global IHC_VResp_VivoParams IHCpreSynapseParams  AN_IHCsynapseParams
13
global MacGregorParams MacGregorMultiParams  filteredSACFParams
14
global experiment % used by calls from multiThreshold only
15
global IHC_cilia_RPParams
16

    
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
    if experiment.saveData
27
        saveFileName=...
28
            ['savedData/' experiment.name '_' ...
29
            experiment.date '_' experiment.paradigm];
30
    else
31
        % save this data (just in case)
32
        saveFileName=['savedData/mostRecentResults'];
33
    end
34
    experiment.minElapsed=etime(clock, betweenRuns.timeNow)/60;
35
    save(saveFileName, 'experiment', 'stimulusParameters',...
36
        'betweenRuns', 'withinRuns', 'statsModel', 'expGUIhandles')
37
    disp(['data saved as: ' saveFileName]);
38
    
39
else
40
    % reprint request (i.e print out old data)
41
    printReportGuide.fileName=fileName;
42
    load(printReportGuide.fileName)
43
    saveFileName=printReportGuide.fileName;
44
    if nargin>1
45
        printReportGuide.showTracks=printTracks;
46
    else
47
        printReportGuide.showTracks=experiment.printTracks;
48
    end
49
end
50

    
51
fprintf('******** multithreshold ')
52

    
53
x=pwd; disp(['version ' x(end-3:end)])
54
fprintf('\nName:\t%s ', experiment.name)
55
fprintf('\nparadigm:\t%s ', experiment.paradigm)
56
fprintf('\nEar:\t%s ', experiment.ear)
57

    
58
method=experiment.threshEstMethod;
59
if stimulusParameters.includeCue && ~strcmp(method(1:6),'2I2AFC')
60
    method=[method '/ withCue'];
61
end
62
fprintf('\nmethod:\t%s ', method)
63
fprintf('\ndate:\t%s ', experiment.date)
64
fprintf('\n\n')
65

    
66
if isempty(betweenRuns.thresholds)
67
    disp('no thresholds found')
68
end
69

    
70
% prepare results as matrices ready to print
71
%  first sort the actual sequence into a more readable sequence
72
[idx1, idx2, var1values, var2values]=...
73
    sortVariables(betweenRuns.variableList1, betweenRuns.variableList2,...
74
    betweenRuns.var1Sequence, betweenRuns.var2Sequence);
75

    
76
header1=betweenRuns.variableName1;
77
header2=betweenRuns.variableName2;
78
header1 = strrep(header1, 'none', ' '); % none is not a useful header
79
header2 = strrep(header2, 'none', ' '); % none is not a useful header
80
headers=strvcat([header1 '/'], header2);
81

    
82
disp('thresholds')
83
global resultsTable
84
resultsTable= sortTablesForPrinting(idx1,idx2,...
85
    var1values,var2values, betweenRuns.thresholds);
86
msg=printTabTable(resultsTable,  headers);
87
addToMsg(msg,0)
88
fprintf('\n')
89
disp(paramChanges)
90

    
91
% sort tracks into the same order
92
betweenRuns.levelTracks=betweenRuns.levelTracks(idx1);
93
betweenRuns.responseTracks=betweenRuns.responseTracks(idx1);
94
betweenRuns.bestThresholdTracks=betweenRuns.bestThresholdTracks(idx1);
95
betweenRuns.levelTracks=betweenRuns.levelTracks(idx2);
96
betweenRuns.responseTracks=betweenRuns.responseTracks(idx2);
97
betweenRuns.bestThresholdTracks=betweenRuns.bestThresholdTracks(idx2);
98

    
99
if printReportGuide.structures
100
    maxNoArrayValues=30;
101
    showStructureSummary(stimulusParameters, 'stimulusParameters', maxNoArrayValues)
102
    showStructureSummary(experiment, 'experiment',maxNoArrayValues)
103
    showStructureSummary(betweenRuns, 'betweenRuns',maxNoArrayValues)
104
    showStructureSummary(withinRuns, 'withinRuns')
105
    
106
    switch experiment.threshEstMethod
107
        case {'2I2AFC++', '2I2AFC+++'}
108
            showStructureSummary(LevittControl, 'LevittControl', maxNoArrayValues)
109
    end
110
    
111
    switch experiment.ear
112
        case {'statsModelLogistic','statsModelRareEvent'}
113
            showStructureSummary(statsModel, 'statsModel', maxNoArrayValues)
114
    end
115
end
116

    
117
if printReportGuide.showTracks
118
    % NB this procedure can only be used if all the tracks are present and
119
    % of equal length
120
    bigTable=[]; header=[];
121
    disp(' '); disp('Leveltracks starting from 1 response before the first reversal')
122
    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
    
129
    disp(' '); disp('Response tracks starting from 1 response before the first reversal')
130
    for i=1:length(betweenRuns.responseTracks)
131
        if printReportGuide.HorizontalTracks
132
            printTabTable(betweenRuns.responseTracks{i});
133
        end
134
        header=strvcat(header, 'resp');
135
    end
136
    
137
    disp(' '); disp('threshold tracks starting from the first reversal')
138
    for i=1:length(betweenRuns.bestThresholdTracks)
139
        if printReportGuide.HorizontalTracks
140
        end
141
        printTabTable(betweenRuns.bestThresholdTracks{i});
142
        header=strvcat(header, 'mean');
143
    end
144
    
145
end
146

    
147
switch experiment.ear
148
    case  {'MAPmodelMultiCh', 'MAPmodelSingleCh'}
149
        % show all parameters but do not compute the model
150
        nm=UTIL_paramsList(whos);
151
        for i=1:length(nm)
152
            try
153
                eval(['UTIL_showStruct(' nm{i} ', ''' nm{i} ''')'])
154
            catch
155
            end
156
        end
157
end
158

    
159
if experiment.saveData
160
    fprintf('\n')
161
    disp('To reprint this report with tracks use:')
162
    disp([ 'printReport(''' saveFileName ''',1)'])
163
end
164

    
165
% print final summary (repeat of above)
166
fprintf('\n')
167
fprintf('\n')
168
disp('thresholds')
169
msg=printTabTable(sortTablesForPrinting(idx1,idx2,var1values,var2values, betweenRuns.thresholds),  headers);
170
addToMsg(msg,0)
171
fprintf('\n')
172

    
173
if length(var1values)==1 && length(var2values)==1 && experiment.maxTrials>49
174
    [psy, levelsBinVector, binFrequencies, nNo, nYes]= ...
175
        psychometricFunction(withinRuns.levelsPhaseTwo,withinRuns.responsesPhaseTwo, experiment.psyBinWidth);
176
    disp('Psychometric function')
177
    fprintf(' level  \tfreq\tprob\n')
178
    fprintf('%6.0f\t%6.2f\t%6.0f\n', [levelsBinVector; binFrequencies; psy])
179
    fprintf('\n')
180
    fprintf('k \t %6.2f\n',logistic.bestK)
181
    fprintf('g  \t%7.5f\n',rareEvent.bestGain)
182
    fprintf('\n')
183
    
184
end
185

    
186
fprintf('\nparadigm:\t%s\n ', experiment.paradigm)
187
disp(paramChanges)
188

    
189
% ------------------------------------------------------- sortTablesForPrinting
190
function table= sortTablesForPrinting(idx1,idx2, var1values,var2values, x)
191
% table converts a vector to a table
192
% after sorting according to idx1 and idx2
193
% the table is completed by adding row and column values
194
x=x(idx1);
195
x=x(idx2);
196
xMatrix=reshape(x,length(var1values),length(var2values));
197

    
198
table=[[-1000 var2values]; [var1values' xMatrix]];
199

    
200
% ------------------------------------------------------- showStructureSummary
201
function showStructureSummary(structure, name, maxNoArrayValues)
202
% showStructureSummary prints out the values of a single structure
203
% The header is the structure name and each row is a field
204
% e.g. showStructureSummary(params,'params')
205
% This not the same as 'UTIL_showstruct'
206

    
207

    
208
if nargin<3
209
    maxNoArrayValues=20;
210
end
211

    
212
fprintf('\n%s:', name)
213

    
214
fields=fieldnames(eval('structure'));
215
% for each field in the structure
216
for i=1:length(fields)
217
    y=eval([ 'structure.' fields{i}]);
218
    if isstr(y),
219
        % strings
220
        fprintf('\n%s=\t''%s''',  fields{i},y)
221
    elseif isnumeric(y)
222
        % arrays
223
        if length(y)>1
224
            % vectors
225
            [r c]=size(y);
226
            if r>c, y=y'; end
227
            
228
            [r c]=size(y);
229
            if r>1
230
                %                 fprintf('\n%s.%s=\t%g x %g matrix',name, fields{i}, r, c)
231
                fprintf('\n%s=\t%g x %g matrix',fields{i}, r, c)
232
                
233
            elseif c<maxNoArrayValues
234
                %                     fprintf('\n%s=\t[%s]',  fields{i},num2str(y))
235
                fprintf('\n%s=',  fields{i})
236
                fprintf('\t%g',y)
237
                
238
            else
239
                fprintf('\n%s=\t %g...   [%g element array]', fields{i}, y(1),c)
240
            end
241
        else
242
            % single valued arrays
243
            %             fprintf('\n%s.%s=\t%s;', name, fields{i},num2str(y))
244
            fprintf('\n%s=\t%s', fields{i},num2str(y))
245
        end
246
    elseif iscell(y)
247
        fprintf('\n%s=\t cell array', fields{i})
248
        
249
    elseif isstruct(y)
250
        fprintf('\n%s=\t structure', fields{i})
251
    end,
252
    
253
end,
254
fprintf('\n')
255

    
256

    
257
% ------------------------------------------------------- printTabTable
258
function strings= printTabTable(M, headers)
259
% printTabTable prints a matrix as a table with tabs
260
%headers are optional
261
%headers=strvcat('firstname', 'secondname')
262
%  printTabTable([1 2; 3 4],strvcat('a1','a2'));
263
stringCount=1; strings{stringCount}=[];
264

    
265
if nargin>1
266
    [r c]=size(headers);
267
    for no=1:r
268
        % print all headers in a row
269
        fprintf('%s\t',headers(no,:))
270
        strings{stringCount}=sprintf('%s\t',headers(no,:)); stringCount=stringCount+1;
271
    end
272
    fprintf('\n')
273
end
274

    
275
[r c]=size(M);
276

    
277
for row=1:r
278
    string=[];
279
    for col=1:c
280
        if row==1 & col==1 & M(1,1)==-1000
281
            %   Print nothing (tab follows below)
282
        else
283
            fprintf('%s',num2str(M(row,col)))
284
            string=[string ' ' sprintf('%s',num2str(M(row,col)))];
285
        end
286
        if col<c
287
            fprintf('\t')
288
            % 			strings{stringCount}=sprintf('\t'); stringCount=stringCount+1;
289
        end
290
    end % col
291
    strings{stringCount}=string; stringCount=stringCount+1;
292
    fprintf('\n')
293
end % row
294

    
295
% ------------------------------------------------------- sortVariables
296
function [idx1, idx2, var1values, var2values]= ...
297
    sortVariables(var1values, var2values, var1Sequence, var2Sequence)
298

    
299
[x idx1]= sort(var1Sequence);
300
var1Sequence= x;
301
var2Sequence= var2Sequence(idx1);
302
depVarName= 'th';
303

    
304
[x idx2]=sort(var2Sequence);
305
var2Sequence=x;
306
var1Sequence=var1Sequence(idx2);
307

    
308
var1values=sort(var1values);
309
var2values=sort(var2values);