~ubuntu-branches/ubuntu/trusty/psychtoolbox-3/trusty-proposed

« back to all changes in this revision

Viewing changes to Psychtoolbox/PsychCal/RefitCalGamma.m

  • Committer: Package Import Robot
  • Author(s): Yaroslav Halchenko
  • Date: 2013-11-19 23:34:50 UTC
  • mfrom: (3.1.4 experimental)
  • Revision ID: package-import@ubuntu.com-20131119233450-f7nf92vb8qavjmk8
Tags: 3.0.11.20131017.dfsg1-3
Upload to unsable since fresh glew has arrived to sid!

Show diffs side-by-side

added added

removed removed

Lines of Context:
2
2
%
3
3
% Refit the gamma data from a calibration.
4
4
%
 
5
% See also CalDemo, CalibrateFitGamma, SetGammaMethod, GamutToSettings
 
6
%
5
7
% 3/27/02  dhb  Wrote it.
6
8
% 8/26/03  dhb, jl  Allow changing dacsize of calibraiton.  Useful for dropping from 10 to 8.
7
9
% 2/2/05   dhb, dam Ask for filename to save to, rather than automatically overwrite.
17
19
% 5/28/10  dhb      Add yoked fitting routine to calls.  Should have no effect when yoked isn't set, but do the right thing when it is.
18
20
% 6/5/10   dhb      Update type list provided to user.
19
21
%          dhb      Better plots, using plot subroutines.
 
22
% 5/26/12  dhb      Added ability to use raw measured data as the fit gamma table.  See comment where that's done below.
20
23
 
21
24
% Enter load code
22
 
defaultFileName = 'monitor';
 
25
defaultFileName = 'PTB3TestCal';
23
26
thePrompt = sprintf('Enter calibration filename [%s]: ',defaultFileName);
24
27
newFileName = input(thePrompt,'s');
25
28
if (isempty(newFileName))
43
46
fprintf('Old gamma fit type was: %s\n',cal.describe.gamma.fitType);
44
47
oldType = cal.describe.gamma.fitType;
45
48
fprintf('Possible fit types are defined by routine CalibrateFitGamma\n');
46
 
fprintf('See "help CalibrateFitGamma for most up to date options\n');
47
 
fprintf('Current (June, 2010) options are:\n');
 
49
fprintf('See "help CalibrateFitGamma for most up to date options (except for rawdata)\n');
 
50
fprintf('Current (May 2012) options are:\n');
48
51
fprintf('\tsimplePower\n');
49
52
fprintf('\tcrtLinear\n');
50
53
fprintf('\tcrtPolyLinear\n');
53
56
fprintf('\tbetacdf\n');
54
57
fprintf('\tsigmoid\n');
55
58
fprintf('\tweibull\n');
 
59
fprintf('\trawdata\n');
56
60
 
57
61
gamma.fitType= GetWithDefault('Enter new fit type',oldType);
58
62
cal.describe.gamma = gamma;
76
80
% Now refit
77
81
cal = CalibrateFitLinMod(cal);
78
82
cal = CalibrateFitYoked(cal);
79
 
cal = CalibrateFitGamma(cal,2^cal.describe.dacsize);
 
83
 
 
84
% Switch about whether to call standard routine
 
85
switch (gamma.fitType)
 
86
    % Literally use the measured data as the fit data.
 
87
    % You only want to do this under very unusual circumstances.
 
88
    % The reason I'm putting it in is to deal with a DLP projector
 
89
    % whose filter wheel I ripped out, and for which the light output
 
90
    % is highly non-monotonic with input.  So, I'll measure at every
 
91
    % possible input settings and then use exhaustive search of the
 
92
    % gamma table to invert.  This is where the output of the standard
 
93
    % calibration program pushes the raw data into the typical field.
 
94
    % 
 
95
    % This is probably a fairly fragile bit of code and should only be used
 
96
    % with caution and knowledge aforethought.
 
97
    %
 
98
    % I put this here rather than in CalibrateFitGamma to avoid a lot of
 
99
    % massaging done by that routine, which we do not want.
 
100
    case 'rawdata'
 
101
        if (size(cal.rawdata.rawGammaTable,2) ~= cal.nDevices*cal.nPrimaryBases)
 
102
            error('Dimensions of raw data are not correct, given number of devices and linear model size')
 
103
        end
 
104
        cal.gammaInput = cal.rawdata.rawGammaInput;
 
105
        cal.gammaTable = cal.rawdata.rawGammaTable;
 
106
        cal.gammaTable(cal.gammaTable < 0) = 0;
 
107
        cal.gammaTable(cal.gammaTable > 1) = 1;
 
108
        
 
109
    % Fit the measured data using standard PTB methods
 
110
    otherwise 
 
111
        cal = CalibrateFitGamma(cal,2^cal.describe.dacsize);
 
112
end
80
113
 
81
114
% Put up a plot of the essential data
82
115
CalibratePlotSpectra(cal,figure(1));