File: MeasMonSpd.m

package info (click to toggle)
psychtoolbox-3 3.0.14.20170103%2Bgit6-g605ff5c.dfsg1-1
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 103,044 kB
  • ctags: 69,483
  • sloc: ansic: 167,371; cpp: 11,232; objc: 4,708; sh: 1,875; python: 383; php: 344; makefile: 207; java: 113
file content (108 lines) | stat: -rwxr-xr-x 3,675 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
function [spd,S] = MeasMonSpd(window, settings, S, syncMode, whichMeterType, bitsppClut)
% [spd,S] = MeasMonSpd(window, settings, [S], [syncMode], [whichMeterType], [bitsppClut])
%
% Measure the Spd of a series of monitor settings.
%
% This routine is specific to go with CalibrateMon,
% as it depends on the action of SetMon. 
%
% If whichMeterType is passed and set to 0, then the routine
% returns random spectra.  This is useful for testing when
% you don't have a meter.
%
% Other valid types:
%  1 - Use PR650 (default)
%  2 - Use CVI
%
% 10/26/93  dhb	  Wrote it based on ccc code.
% 11/12/93  dhb	  Modified to use SetColor.
% 8/11/94	dhb	  Sync mode.
% 8/15/94   dhb	  Sync mode as argument, allow S to be [] for default.
% 4/12/97   dhb   New toolbox compatibility, take window and bits args.
% 8/26/97   dhb   pbe Add noMeterAvail arg.
% 4/7/99    dhb   Add argument for radius board. Compact default arg code.
% 8/14/00   dhb   Call to CMETER('SetParams') conditional on OS9.
% 8/20/00   dhb   Remove bits arg to SetColor.
% 8/21/00   dhb   Remove dependence on RADIUS flag.  This is now handled inside of SetColor.
%	        dhb   Change calling conventions to remove unused args.
% 9/14/00   dhb   Sync mode is not actually used.  Arg still passed for backwards compat.
% 2/27/02   dhb   Change noMeterAvail to whichMeterType.
% 8/19/12   mk    Rewrite g_usebitspp path to use PTB imaging pipeline for higher robustness 
%                 and to support more display devices.

% Declare Bits++ box global
global g_usebitspp;

% If the global flag for using Bits++ is empty, then it hasn't been
% initialized and default it to 0.
if isempty(g_usebitspp)
    g_usebitspp = 0;
end

% Check args and make sure window is passed right.
usageStr = 'Usage: [spd,S] = MeasMonSpd(window, settings, [S], [syncMode], [whichMeterType])';
if nargin < 2 || nargin > 6 || nargout > 2
	error(usageStr);
end
if size(window,1) ~= 1 || size(window,2) ~= 1
	error(usageStr);
end

% Set defaults
defaultS = [380 5 81];
defaultSync = 0;
defaultWhichMeterType = 1;

% Get the current gamma table.
if g_usebitspp
    theClut = bitsppClut;
else
    theClut = Screen('ReadNormalizedGammaTable', window);
end

% Check args and set defaults
if nargin < 5 || isempty(whichMeterType)
	whichMeterType = defaultWhichMeterType;
end
if nargin < 4 || isempty(syncMode)
    % FIXME: Not used? MeasSpd() would accept it as argument.
	syncMode = defaultSync;
end
if nargin < 3 || isempty(S)
	S = defaultS;
end

[null, nMeas] = size(settings); %#ok<*ASGLU>
spd = zeros(S(3), nMeas);
for i = 1:nMeas
    % Set the color.
    
    % Measure spectrum
    switch whichMeterType
        case 0
            theClut(2,:) = settings(:, i)';
            if g_usebitspp
                Screen('LoadNormalizedGammaTable', window, theClut, 2);
                Screen('Flip', window, 0, 1);
            else
                Screen('LoadNormalizedGammaTable', window, theClut);
            end
            spd(:,i) = sum(settings(:, i)) * ones(S(3), 1);
            WaitSecs(.1);
        case 1
            theClut(2,:) = settings(:, i)';
            if g_usebitspp
                Screen('LoadNormalizedGammaTable', window, theClut, 2);
                Screen('Flip', window, 0, 1);
            else
                Screen('LoadNormalizedGammaTable',window, theClut);
            end
            spd(:,i) = MeasSpd(S);
        case 2
            error('CVI interface not yet ported to PTB-3.');
            % cviCal = LoadCVICalFile;
            % spd(:,i) =  CVICalibratedDarkMeasurement(cviCal, S, [], [], [], window, 1, settings(:,i));
        otherwise
            error('Invalid meter type set');
    end
end