File: DropCalBits.m

package info (click to toggle)
psychtoolbox-3 3.0.19.14.dfsg1-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 86,796 kB
  • sloc: ansic: 176,245; cpp: 20,103; objc: 5,393; sh: 2,753; python: 1,397; php: 384; makefile: 193; java: 113
file content (40 lines) | stat: -rw-r--r-- 1,410 bytes parent folder | download | duplicates (6)
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
function cal = DropCalBits(cal,whichScreen,forceBits)
% cal = DropCalBits(cal,whichScreen,[forceBit])
%
% Drops the bitdepth of a calibration file if
% necessary.  Useful for running programs
% transparently on 8 and 10 bit hardware.
%
% If arg forceBits is passed, it is used as
% the current hardware depth.  Otherwise the
% reported DACBits of whichScreen is used.
%
% This code assumes calibration was done at
% equally spaced levels in RGB settings, as is
% the case with our calibration routines.  May
% not generalize, and I haven't worried about
% the roundoff errors.  Certainly OK for basic
% use.
%
% 2/13/05		dhb		Wrote it.

% Get hardware dac level.  Note that the application
% code should use LoadClut, not SetClut, to access
% full bit depth.
if (nargin > 2 && ~isempty(forceBits))
	hardwareBits = forceBits;
else
	hardwareBits = Screen(whichScreen,'Preference','DACBits');
end

% Force calibration down to 8 bits, which is how we plan to use it.
% Simply refit raw data at correct number of input levels.  
if (cal.describe.dacsize > hardwareBits)
	cal.describe.dacsize = hardwareBits;
	nInputLevels = 2^cal.describe.dacsize;
	cal.rawdata.rawGammaInput = round(linspace(nInputLevels/cal.describe.nMeas,nInputLevels-1,cal.describe.nMeas))';
	cal = CalibrateFitGamma(cal);
elseif (cal.describe.dacsize < hardwareBits)
	error('Current hardware has greater bit depth than at calibration.');
end