comparison core/magnatagatune/tests_evals/get_data_compact.m @ 0:e9a9cd732c1e tip

first hg version after svn
author wolffd
date Tue, 10 Feb 2015 15:05:51 +0000
parents
children
comparison
equal deleted inserted replaced
-1:000000000000 0:e9a9cd732c1e
1 function [clip_dict, X, Y, valididx] = get_data_compact(clips, featureVec, simdata)
2 % ---
3 % instead of creating a new three feature vectors
4 % for each constraint, this function links back to the
5 % FIRST occurrence of a distinct clip and its features
6 %
7 % TODO: try to always link ALL occurences of a feature
8 % / clip in the rankings
9 % ---
10
11 global comparison_ids;
12 global comparison_invids;
13
14 % ---
15 % build the clip dictionary
16 % ---
17 uniclip = unique(reshape( simdata, 1, []));
18 last_clip_pos = zeros(1, numel(uniclip));
19
20 clip_dict = [];
21 Y = {};
22 idx_newclip = 1;
23 valididx = logical([]);
24
25 % cycle all constraints of one cv bin
26 for j = 1:size(simdata,1)
27
28
29 % save the first clip
30 constraint = simdata(j,:);
31
32 % ---
33 % check where the clip is and if there
34 % is space to write cosntraint data
35 %
36 % If not, a position is created
37 a = find_clip(constraint(1), 1);
38 b = find_clip(constraint(2), 0);
39 c = find_clip(constraint(3), 0);
40
41 % [a,b,c] -> clip a more similar to clip b than to clip c
42
43 % adress weightings
44 if numel(constraint) == 4
45 Y(a,:) = {b, c, (constraint(4))};
46 else
47 Y(a,:) = {b, c};
48 end
49 end
50
51 % ---
52 % get feature data
53 % NOTE: this uses an index of the comparison clips
54 % ---
55 X = featureVec(:,(comparison_invids(clip_dict)));
56
57 for i = find(~valididx)
58 if size(Y,2) == 3
59 Y(i,:) = {[], [], 0};
60 else
61 Y(i,:) = {[], []};
62 end
63 end
64
65 function clip_idx = find_clip(clip, write)
66 uc_idx = find(uniclip == clip);
67
68 % ---
69 % do we have a place of this clip?
70 %
71 % NOTE: last_clip_pos has to be reset after every write
72 % ---
73 if (last_clip_pos(uc_idx) == 0) || ...
74 write && (numel(valididx) >= last_clip_pos(uc_idx)) &&...
75 (valididx(last_clip_pos(uc_idx)) == 1)
76
77 % if not, create one
78 clip_idx = idx_newclip;
79 clip_dict(clip_idx) = clip;
80 valididx(clip_idx) = false;
81
82 % and save into last pos
83 last_clip_pos(uc_idx) = clip_idx;
84
85 idx_newclip = idx_newclip + 1;
86 else
87 clip_idx = last_clip_pos(uc_idx);
88 end
89
90 if write
91 valididx(clip_idx) = true;
92 end
93
94 end
95
96 end