-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathprocessAnnotationData.m
More file actions
54 lines (47 loc) · 1.63 KB
/
processAnnotationData.m
File metadata and controls
54 lines (47 loc) · 1.63 KB
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
% Failure identification Raw - preprocessing
% Compute the main indicators in moving window
% Autor - Petr Šopák (221022)
% 05.11.2025
function Awin = processAnnotationData(dataAnnot, valid_mask, fps)
% ---------------------------------------------------------------
% Aggregates subjective annotation features into 1 s windows
% using the same structure as processVideoData.
%
% INPUT:
% dataAnnot - numeric matrix with first column = time [s]
% valid_mask - logical vector (same length as samples)
% fps - sampling frequency (typically 30 Hz)
%
% OUTPUT:
% Awin.meanVals - [K × F] matrix of mean values per feature
% Awin.featureNames - cellstr of feature labels
%
% ---------------------------------------------------------------
% ---- Constants ----
min_valid_frac = 0.8;
W = max(1, round(fps * 1.0)); % 1 s window
H = max(1, round(fps * 0.5)); % 50% overlap
% ---- Extract ----
Time_s = dataAnnot(:,1);
Values = dataAnnot(:,2:end);
% Prepare feature names (if loaded via readtable)
% If readmatrix used, dummy labels
nFeat = size(Values,2);
featNames = "AnnotFeature_" + string(1:nFeat);
% ---- Prepare output ----
N = numel(Time_s);
starts = 1:H:(N - W);
K = numel(starts);
meanVals = nan(K, nFeat);
for k = 1:K
ii = starts(k):(starts(k)+W-1);
finiteMask = all(isfinite(Values(ii,:)),2) & valid_mask(ii);
if mean(finiteMask) < min_valid_frac
continue;
end
meanVals(k,:) = mean(Values(ii,:), 'omitnan');
end
% ---- Output ----
Awin.meanVals = meanVals;
Awin.featureNames = featNames;
end