wolffd@0: function [clip_dict, X, Y, valididx] = get_data_compact(clips, featureVec, simdata) wolffd@0: % --- wolffd@0: % instead of creating a new three feature vectors wolffd@0: % for each constraint, this function links back to the wolffd@0: % FIRST occurrence of a distinct clip and its features wolffd@0: % wolffd@0: % TODO: try to always link ALL occurences of a feature wolffd@0: % / clip in the rankings wolffd@0: % --- wolffd@0: wolffd@0: global comparison_ids; wolffd@0: global comparison_invids; wolffd@0: wolffd@0: % --- wolffd@0: % build the clip dictionary wolffd@0: % --- wolffd@0: uniclip = unique(reshape( simdata, 1, [])); wolffd@0: last_clip_pos = zeros(1, numel(uniclip)); wolffd@0: wolffd@0: clip_dict = []; wolffd@0: Y = {}; wolffd@0: idx_newclip = 1; wolffd@0: valididx = logical([]); wolffd@0: wolffd@0: % cycle all constraints of one cv bin wolffd@0: for j = 1:size(simdata,1) wolffd@0: wolffd@0: wolffd@0: % save the first clip wolffd@0: constraint = simdata(j,:); wolffd@0: wolffd@0: % --- wolffd@0: % check where the clip is and if there wolffd@0: % is space to write cosntraint data wolffd@0: % wolffd@0: % If not, a position is created wolffd@0: a = find_clip(constraint(1), 1); wolffd@0: b = find_clip(constraint(2), 0); wolffd@0: c = find_clip(constraint(3), 0); wolffd@0: wolffd@0: % [a,b,c] -> clip a more similar to clip b than to clip c wolffd@0: wolffd@0: % adress weightings wolffd@0: if numel(constraint) == 4 wolffd@0: Y(a,:) = {b, c, (constraint(4))}; wolffd@0: else wolffd@0: Y(a,:) = {b, c}; wolffd@0: end wolffd@0: end wolffd@0: wolffd@0: % --- wolffd@0: % get feature data wolffd@0: % NOTE: this uses an index of the comparison clips wolffd@0: % --- wolffd@0: X = featureVec(:,(comparison_invids(clip_dict))); wolffd@0: wolffd@0: for i = find(~valididx) wolffd@0: if size(Y,2) == 3 wolffd@0: Y(i,:) = {[], [], 0}; wolffd@0: else wolffd@0: Y(i,:) = {[], []}; wolffd@0: end wolffd@0: end wolffd@0: wolffd@0: function clip_idx = find_clip(clip, write) wolffd@0: uc_idx = find(uniclip == clip); wolffd@0: wolffd@0: % --- wolffd@0: % do we have a place of this clip? wolffd@0: % wolffd@0: % NOTE: last_clip_pos has to be reset after every write wolffd@0: % --- wolffd@0: if (last_clip_pos(uc_idx) == 0) || ... wolffd@0: write && (numel(valididx) >= last_clip_pos(uc_idx)) &&... wolffd@0: (valididx(last_clip_pos(uc_idx)) == 1) wolffd@0: wolffd@0: % if not, create one wolffd@0: clip_idx = idx_newclip; wolffd@0: clip_dict(clip_idx) = clip; wolffd@0: valididx(clip_idx) = false; wolffd@0: wolffd@0: % and save into last pos wolffd@0: last_clip_pos(uc_idx) = clip_idx; wolffd@0: wolffd@0: idx_newclip = idx_newclip + 1; wolffd@0: else wolffd@0: clip_idx = last_clip_pos(uc_idx); wolffd@0: end wolffd@0: wolffd@0: if write wolffd@0: valididx(clip_idx) = true; wolffd@0: end wolffd@0: wolffd@0: end wolffd@0: wolffd@0: end