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