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

« back to all changes in this revision

Viewing changes to Psychtoolbox/PsychCal/SaveCalFile.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:
7
7
% If filespec is not passed, then it saves to default.mat
8
8
% in the CalData folder.  If filespec is an integer, saves
9
9
% to screenN.mat.  If filespec is a string, saves to string.mat.
10
 
 
 
10
% You can also pass the name with the training .mat already there.
 
11
%
 
12
% Saves to existing file if it is found, otherwise creates a
 
13
% new calibration file.
 
14
%
 
15
% See also LoadCalFile, CalDataFolder.
 
16
%
11
17
% 5/28/96  dgp  Wrote it.
12
18
% 6/6/96   dgp  Use CalibrationsFolder.
13
19
% 7/25/96  dgp  Use CalDataFolder.
14
20
% 8/4/96   dhb  More flexible filename interface.
15
 
% 8/21/97        dhb  Rewrite for cell array convention.
 
21
% 8/21/97  dhb  Rewrite for cell array convention.
16
22
% 8/25/97  dhb, pbe  Fix bug in cell array handling.
17
23
% 8/26/97  dhb  Make saving code parallel LoadCalFile.
18
24
% 5/18/99  dhb  Add optional directory arg.
20
26
% 7/9/02   dhb  Incorporate filespec/filename fix as suggested by Eiji Kimura.
21
27
% 3/27/12  dhb  Pass dir to LoadCalFile call, so that it does the right thing
22
28
%               in cases where cal file location is expilcitly passed.
 
29
% 4/2/13   dhb  Updated for subdir searching logic.
 
30
% 4/12/13  dhb  Make this save to cal file folder when file doesn't yet exist.
 
31
% 6/2/13   dhb  More robust about whether passed filespec contains the trailing '.mat'.
23
32
 
24
33
% Set the filename
25
 
if nargin < 3 || isempty(dir)
26
 
        dir = CalDataFolder;
27
 
end
28
34
if nargin < 2 || isempty(filespec)
29
35
        filespec = 'default';
30
 
        filename = [dir 'default.mat'];
 
36
        filename = ['default.mat'];
31
37
elseif ischar(filespec)
32
 
        filename = [dir filespec '.mat'];
 
38
        if (~strcmp(filespec(end-3:end),'.mat'))
 
39
        filename = [filespec '.mat'];
 
40
    else
 
41
        filename = filespec;
 
42
    end
33
43
else
34
 
        filename = [dir sprintf('screen%d.mat',filespec)];
 
44
        filename = [sprintf('screen%d.mat',filespec)];
 
45
end
 
46
 
 
47
if nargin < 3 || isempty(dir)
 
48
        dir = CalDataFolder(0,filename);
35
49
end
36
50
 
37
51
% Load the file to get older calibrations
38
 
[oldCal, oldCals] = LoadCalFile(filespec, [], dir);
 
52
[oldCal, oldCals, fullFilename] = LoadCalFile(filespec, [], dir);
39
53
if isempty(oldCals)
40
54
        cals = {cal}; %#ok<NASGU>
 
55
    eval(['save ' QuoteString(fullFilename) ' cals']);
41
56
else
42
57
        nOldCals = length(oldCals);
43
58
        cals = oldCals;
44
59
        cals{nOldCals+1} = cal; %#ok<NASGU>
 
60
    eval(['save ' QuoteString(fullFilename) ' cals']);
45
61
end
46
62
 
47
 
% Save the file
48
 
eval(['save ' QuoteString(filename) ' cals']);