-
Notifications
You must be signed in to change notification settings - Fork 20
Expand file tree
/
Copy pathaddLogEntry.m
More file actions
36 lines (28 loc) · 1.01 KB
/
Copy pathaddLogEntry.m
File metadata and controls
36 lines (28 loc) · 1.01 KB
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
function e = addLogEntry(subject, timestamp, type, value, comments, AlyxInstance)
%DAT.ADDLOGENTRY Adds a new entry to the experiment log
% e = DAT.ADDLOGENTRY(subject, timestamp, type, value, comments) files a
% new log entry for 'subject' with the corresponding info.
%
% Part of Rigbox
% 2013-03 CB created
function s = entry(id)
dateStr = datestr(timestamp, 'ddd dd-mmm-yyyy HH:MM');
s = struct('date', timestamp, 'dateStr', dateStr,...
'type', type, 'value', value, 'comments', comments, 'id', id);
end
%% load existing log from central repos
log = loadVar(dat.logPath(subject, 'master'), 'log');
%% find next free id
if isempty(log)
nextidx = 1; %if log is empty, first id is 1
else
nextidx = max([log.id]) + 1;
end
%% create and store entry
e = entry(nextidx);
log(nextidx) = e;
% Store an instance of Alyx for narrative registration
if nargin > 5; e.AlyxInstance = AlyxInstance; end
%% store updated log to *all* repos locations
superSave(dat.logPath(subject, 'all'), struct('log', log));
end