-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsampleData.m
More file actions
25 lines (22 loc) · 799 Bytes
/
sampleData.m
File metadata and controls
25 lines (22 loc) · 799 Bytes
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
% Sample metadata into training and test sets
function [trainingSet,trainingLabels,testSet,testLabels] = sampleData(databank)
trainingRatio = 0.8;
trainingLabels = {};
testLabels = {};
trainingSet = struct('imfile',{},'annfile',{});
testSet = struct('imfile',{},'annfile',{});
for class_set=databank
label = class_set.label;
files = class_set.files;
n = length(files);
border = floor(trainingRatio*n);
testLabels = concatStructArrays(testLabels, repeatstr(label, n-border));
trainingLabels = concatStructArrays(trainingLabels, ...
repeatstr(label, border));
testSet = [testSet files(border+1:end)];
trainingSet = [trainingSet files(1:border)];
end
testLabels = testLabels;
trainingLabels = trainingLabels;
testSet = loadData(testSet);
trainingSet = loadData(trainingSet);