-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathsg_motl_plot_class_changes.m
85 lines (50 loc) · 1.66 KB
/
sg_motl_plot_class_changes.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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
function sg_motl_plot_class_changes(motl_root,iteration_range)
%% sg_motl_plot_class_changes
% Calculate the percentage of subtomograms that have changed class through
% the range.
%
% WW 06-2019
%% Intitialize
% Read first motivelist
motl = sg_motl_read2([motl_root,'_',num2str(iteration_range(1)),'.star']);
n_motls = numel(unique(motl.motl_idx));
% Number of iterations
n_iter = numel(iteration_range);
% Class cell
class_array = zeros(n_motls,n_iter);
%% Parse classes
% Loop through iterations
for i = 1:n_iter
% Read motivelist
motl = sg_motl_read2([motl_root,'_',num2str(iteration_range(i)),'.star']);
% Check type
motl_type = sg_motl_check_type(motl);
% Parse classes
switch motl_type
case {1,2}
class_array(:,i) = motl.class;
case 3
% Parse classes
classes = unique(motl.class);
n_classes = numel(classes);
% Parse top scores
[~,top_scores] = max(reshape(motl.scores,n_classes,[]),[],1);
% Store classes
class_array(:,i) = classes(top_scores);
end
end
%% Determine class changes
% Class changes
class_changes = zeros(n_motls,1);
% Determine number of changes
for i = 2:n_iter
change_idx = class_array(:,i-1) ~= class_array(:,i);
class_changes = class_changes + change_idx;
end
% Unchanged
no_changes = sum(class_changes == 0);
disp(['Subtomos with unchanged classes: ',num2str(no_changes)]);
% Plot bar graph
[N,~] = histcounts(class_changes,0:max(class_changes)+1);
figure
bar(0:max(class_changes),N);