/usr/share/psychtoolbox-3/PsychCal/LoadCalFile.m is in psychtoolbox-3-common 3.0.9+svn2579.dfsg1-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
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 | function [cal, cals] = LoadCalFile(filespec, whichCal, dir)
% [cal, cals] = LoadCalFile([filespec], [whichCal], [dir])
%
% Load calibration data from saved file in the CalData folder.
% If no argument is given, loads from file default.mat. If
% an integer N is passed, loads from file screenN.mat. If
% a string S is given, loads from S.mat.
%
% If whichCal is specified, the whichCal'th calibration
% in the file is returned. If whichCal > nCals, an
% empty calibration is returned. whichCal defaults
% to the most recent calibration.
%
% If the specified file cannot be found, returns empty matrix.
%
% The returned variable is a structure containing calibration
% information.
% 5/28/96 dgp Wrote it.
% 6/6/96 dgp Use CalibrationsFolder.
% 6/6/96 dgp Use whole path in filename so Matlab will only look there.
% 7/25/96 dgp Use CalDataFolder.
% 8/4/96 dhb More flexible filename interface.
% 8/21/97 dhb Rewrite for calibrations stored as cell array.
% Optional return of entire calibration history.
% 8/26/97 dhb Handle case of isempty(cals).
% Added whichCal argument.
% 5/18/99 dhb Added dir argument.
% 8/15/00 dhb Modify to handle local/demo cal directories.
% Get whichCal
if nargin < 2 || isempty(whichCal)
whichCal = Inf;
end
% Set the filename
if nargin < 3 || isempty(dir)
useDir = CalDataFolder;
else
useDir = dir;
end
if (nargin < 1 || isempty(filespec))
filename = [useDir 'default.mat'];
elseif (ischar(filespec))
filename = [useDir filespec '.mat'];
else
filename = [useDir sprintf('screen%d.mat', filespec)];
end
% If the file doesn't exist in the usual location, take a look in the
% secondary location.
if (~exist(filename, 'file') && (nargin < 3 || isempty(dir)))
useDir = CalDataFolder(1);
if (nargin < 1 || isempty(filespec))
filename = [useDir 'default.mat'];
elseif (ischar(filespec))
filename = [useDir filespec '.mat'];
else
filename = [useDir sprintf('screen%d.mat',filespec)];
end
end
% Now read the sucker if it is there.
if exist(filename, 'file')
eval(['load ' QuoteString(filename)]);
if isempty(cals) %#ok<NODEF>
cal = [];
else
% Get the number of calibrations.
nCals = length(cals);
% User the most recent calibration (the last one in the cals cell
% array) by default. If the user specified a particular cal file,
% try to retrieve it or return an empty matrix if the cal index is
% out of range.
if whichCal == Inf
cal = cals{nCals};
elseif whichCal > nCals || whichCal < 1
cal = [];
else
cal = cals{whichCal};
end
end
else
cal = [];
cals = {};
end
|