-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathcheck_folder.m
40 lines (30 loc) · 1.36 KB
/
check_folder.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
function folder_content = check_folder (savepath, add_info)
% This function lists all folders and files in a specific stimulus analysis
% folder and puts them into a table which is displayed on the gui to see
% which data has been produces so far for each stimulus.
M = matfile(savepath,'Writable',false);
pathname = M.pathname;
%Check whats in the folder
folder_content = dir(strcat(pathname,"Stimulus_",num2str(add_info.stim_idx)));
if size(folder_content,1) == 0 %If folder is empty return empty table
folder_content = array2table(zeros(0,3));
folder_content.Properties.VariableNames = {'Name','Date','Folder'};
return
end
%if not empty, make cell with contents
folder_content = rmfield(folder_content,'datenum');
folder_content = rmfield(folder_content,'bytes');
folder_content = rmfield(folder_content,'folder');
%Remove first two entries (meaningless in the context)
folder_content(1:2) = [];
%Remove the time information from data field (because its unnecessary info)
for ii = 1:length(folder_content)
date_before = folder_content(ii).date;
split_idx = strfind(date_before,' ');
folder_content(ii).date = date_before(1:split_idx-1);
end
%make a table
folder_content = struct2table(folder_content);
%Give the right names for the columns
folder_content.Properties.VariableNames = {'Name','Date','Folder'};
end