forked from LeventhalLab/LeventhalWorkflow
-
Notifications
You must be signed in to change notification settings - Fork 0
/
check_dataCollection.m
92 lines (80 loc) · 2.94 KB
/
check_dataCollection.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
87
88
89
90
91
92
function check_dataCollection(nasPath,subjectID,varargin)
% either enter start and end sessions, or just the single session to check
% usage: check_dataCollection('/Volumes/RecordingsLeventhal2/ChoiceTask','R0088','20151027a','20151102a');
%[] tally missing files
rawdata = fullfile(nasPath,subjectID,[subjectID,'-rawdata']);
folders = dir(rawdata);
sessionStart = varargin{1};
sessionEnd = '';
if length(varargin) == 2
sessionEnd = varargin{2};
end
display = false;
disp(char(repmat(46,1,20)));
clc;
for ii=1:length(folders)
if strcmp(folders(ii).name,[subjectID,'_',sessionStart])
display = true;
end
if ~display
continue;
end
foldersName = folders(ii).name;
disp(foldersName);
tab = 1;
searchFor('log',rawdata,foldersName,tab);
searchFor('tsq',rawdata,foldersName,tab);
searchFor('tev',rawdata,foldersName,tab);
searchFor('avi',rawdata,foldersName,tab);
sessionContents = dir(fullfile(rawdata,foldersName,foldersName));
if isempty(sessionContents)
formatDisp(false,'Ephys',0,tab);
else
formatDisp(true,'Ephys',sum([sessionContents(:).bytes]),tab);
end
tab = 2;
sessionContents = dir(fullfile(rawdata,foldersName,'sleep'));
if isempty(sessionContents)
formatDisp(false,'Sleep',0,tab);
else
disp([tabChars(tab-1),fullfile(foldersName,'sleep')]);
searchFor('log',rawdata,fullfile(foldersName,'sleep'),tab);
searchFor('tsq',rawdata,fullfile(foldersName,'sleep'),tab);
searchFor('tev',rawdata,fullfile(foldersName,'sleep'),tab);
searchFor('avi',rawdata,fullfile(foldersName,'sleep'),tab);
sessionContents = dir(fullfile(rawdata,foldersName,'sleep',[foldersName,'_sleep']));
if isempty(sessionContents)
formatDisp(false,'Sleep Ephys',0,tab);
else
formatDisp(true,'Sleep Ephys',sum([sessionContents(:).bytes]),tab);
end
end
fprintf('\n')
if ~isempty(sessionEnd)
if strcmp(folders(ii).name,[subjectID,'_',sessionEnd])
display = false;
end
else
display = false;
end
end
disp(char(repmat(46,1,20)));
end
function searchFor(searchTerm,rawdata,foldersName,tab)
sessionContents = dir(fullfile(rawdata,foldersName,['*.',searchTerm]));
if isempty(sessionContents)
formatDisp(false,searchTerm,0,tab);
else
formatDisp(true,searchTerm,sessionContents(1).bytes,tab);
end
end
function formatDisp(found,label,bytes,tab)
if found
disp([tabChars(tab),'[X] ',upper(label),' (',formatBytes(bytes),')']);
else
disp([tabChars(tab),'[ ] ',upper(label)]);
end
end
function t = tabChars(tab)
t = char(repmat(32,1,tab*4));
end