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 @ 28:02aa9826efe0

History | View | Annotate | Download (9.67 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

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

    
49
fprintf('******** multithreshold ')
50

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

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

    
64
if isempty(betweenRuns.thresholds)
65
    disp('no thresholds found')
66
end
67

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

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

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

    
88
% sort tracks into the same order
89
betweenRuns.levelTracks=betweenRuns.levelTracks(idx1);
90
betweenRuns.responseTracks=betweenRuns.responseTracks(idx1);
91
betweenRuns.bestThresholdTracks=betweenRuns.bestThresholdTracks(idx1);
92
betweenRuns.levelTracks=betweenRuns.levelTracks(idx2);
93
betweenRuns.responseTracks=betweenRuns.responseTracks(idx2);
94
betweenRuns.bestThresholdTracks=betweenRuns.bestThresholdTracks(idx2);
95

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

    
114
if printReportGuide.showTracks
115
    % NB this procedure can only be used if all the tracks are present and
116
    % of equal length
117
    bigTable=[]; header=[];
118
    disp(' '); disp('Leveltracks starting from 1 response before the first reversal')
119
    for i=1:length(betweenRuns.levelTracks)
120
        if printReportGuide.HorizontalTracks
121
            printTabTable(betweenRuns.levelTracks{i});
122
        end
123
        header=strvcat(header, 'level');
124
    end
125
    
126
    disp(' '); disp('Response tracks starting from 1 response before the first reversal')
127
    for i=1:length(betweenRuns.responseTracks)
128
        if printReportGuide.HorizontalTracks
129
            printTabTable(betweenRuns.responseTracks{i});
130
        end
131
        header=strvcat(header, 'resp');
132
    end
133
    
134
    disp(' '); disp('threshold tracks starting from the first reversal')
135
    for i=1:length(betweenRuns.bestThresholdTracks)
136
        if printReportGuide.HorizontalTracks
137
        end
138
        printTabTable(betweenRuns.bestThresholdTracks{i});
139
        header=strvcat(header, 'mean');
140
    end
141
    
142
end
143

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

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

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

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

    
183
fprintf('\nparadigm:\t%s\n ', experiment.paradigm)
184

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

    
194
table=[[-1000 var2values]; [var1values' xMatrix]];
195

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

    
203

    
204
if nargin<3
205
    maxNoArrayValues=20;
206
end
207

    
208
fprintf('\n%s:', name)
209

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

    
252

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

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

    
271
[r c]=size(M);
272

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

    
291
% ------------------------------------------------------- sortVariables
292
function [idx1, idx2, var1values, var2values]= ...
293
    sortVariables(var1values, var2values, var1Sequence, var2Sequence)
294

    
295
[x idx1]= sort(var1Sequence);
296
var1Sequence= x;
297
var2Sequence= var2Sequence(idx1);
298
depVarName= 'th';
299

    
300
[x idx2]=sort(var2Sequence);
301
var2Sequence=x;
302
var1Sequence=var1Sequence(idx2);
303

    
304
var1values=sort(var1values);
305
var2values=sort(var2values);