-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathRenderedParams.m
88 lines (77 loc) · 2.89 KB
/
RenderedParams.m
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
classdef RenderedParams
%RENDEREDPARAMS A list of paramiters for an xfile. This is generated
%from a .pfile that is opened and variables are set. This class is
%immutable, hence it's not a handle class.
% Note although this looks similar to Params it's sematically different
% enough that it warrents a new class, and no subclassing. Rendered
% param files indicate an experiment is to be/has been run, quite
% different from a p file and I want to hilight the separation.
properties(SetAccess = private)
% name of pfile - not including extension
name;
xFile;
% numStim * numParam int64 matrix
stimuli;
numStim;
numParam;
% for matrix commands
numRow;
numCol;
% variable settings
variables;
values;
experimentType;
minimumWait;
deadTime;
expEndDelay;
end
methods
function self = RenderedParams(name, xFile, stimuli, numRow, numCol, ...
variables, values, experimentType, minimumWait, deadTime, ...
expEndDelay)
self.name = name;
self.xFile = xFile;
self.stimuli = stimuli;
self.numRow = numRow;
self.numCol = numCol;
self.variables = variables;
self.values = values;
self.experimentType = experimentType;
self.minimumWait = minimumWait;
self.deadTime = deadTime;
self.expEndDelay = expEndDelay;
[self.numStim self.numParam] = size(stimuli);
end
% Write this object to a .p file, this is used as a log of the
% experiment.
function writeToFile(self, path)
fid = fopen(path, 'wt');
[s, p] = size(self.stimuli);
fprintf(fid, [self.xFile.name '.x\n']);
fprintf(fid, [upper(self.experimentType) '\n']);
fprintf(fid, '%d %d %d\n', s, p, 0); % find out what 0 is
fprintf(fid, '%d %d %d\n', 0, self.numRow, self.numCol); % find out what 0 is
for i = 1:s
for j = 1:p
% write out rep num symbol, or actual number
if self.stimuli(i, j) == Params.repNumMagic
str = '#';
else
str = sprintf( '%d ', self.stimuli(i, j));
end
if j ~= p
fprintf(fid, '%s ', str);
else
fprintf(fid, '%s', str);
end
end
fprintf(fid, '\n');
end
fclose(fid);
end
function r = getDuration(self, index)
% assume duration is always first param
r = double(self.stimuli(index, 1));
end
end
end