-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCl_GetClusterData.m
68 lines (53 loc) · 2.22 KB
/
Cl_GetClusterData.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
function [data, structure]=Cl_GetClusterData(path, file, c1, c2, se)
%CL_GETCLUSTERDATA will return all data from the saved S.mat's in the
% following folders: FOLDER/X/S.mat (content)
mainFolder = dir(path);
completeFile = strcat(file, se); %e.g. 'S.mat' (stored data)
for i=1:length(mainFolder) %iterate through the whole folder
if (strcmp(num2str(mainFolder(i).name), '.')~=1 ) % and then, only if it's a real folder
if (strcmp(num2str(mainFolder(i).name), '..')~=1 ) % and then, only if it's a real folder
if (strcmp(num2str(mainFolder(i).name), completeFile)==1 )%if we found a .mat file
%load the file
S = load(strcat(path,'/',completeFile));
% structure contains all fields of the stored struct
% e.g. Coordinates, Name, Picture, isEmpty, etc.
structure = getfield(S,'S');
%extract inner data
for x=1:length(S.S); % length(S) determines amount of pictures within the struct
if(isstr(c2) ==1 && findstr(c2, 'LBP')==1)
b = getfield(S.S(x), char(c1), char(c2));
data(x).values = b;
else
b = getfield(S.S(x), char(c1), char(c2(1)));
innerData(x,1) = b(1); %x1
if (length(b)==2)
innerData(x,2) = b(2); %x2
end
end
end
A = exist('innerData', 'var');
if(A)
da = innerData;
end
break
end
% end
%Added, because if we have already found our values, we don't need
%to proceed
% if isempty(values) == 0
% break;
% end
end
end
end
if(exist('data','var'))
else
n = str2double(1);
data(1).values = da;
end
%this was a nasty bug: da wasn't deleted afterwards, so for example
%after we dealt with 45 pictures and in the next run only 20,
%25 more were apended. FUCK.
da=[];
innerData=[];
end