-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathsg_motl_av3_to_stopgap.m
70 lines (56 loc) · 1.6 KB
/
sg_motl_av3_to_stopgap.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
function sg_motl_av3_to_stopgap(input_name,output_name)
%% sg_motl_av3_to_stopgap
% Convert TOM/AV3 motivelist to stopgap motivelist.
%
% WW 07-2018
%% Check check
% Check output name
if nargin < 2
if nargin == 1
[path,name,~] = fileparts(input_name);
if ~isempty(path)
path = [path,'/'];
end
output_name = [path,name,'.star'];
end
end
%% Convert
% Read AV3 motl
av3_motl = sg_emread(input_name);
n_motls = size(av3_motl,2);
% Get motl fields
motl_fields = sg_get_motl_fields;
n_fields = size(motl_fields,1);
% AV3 Motl indices
motl_row = {'motl_idx', 4;...
'tomo_num', 5;...
'object', 6;...
'subtomo_num', 4;...
'halfset', [];...
'orig_x', 8;...
'orig_y', 9;...
'orig_z', 10;...
'score', 1;...
'x_shift', 11;...
'y_shift', 12;...
'z_shift', 13;...
'phi', 17;...
'psi', 18;...
'the', 19;...
'class', 20;...
};
% Initalize struct array
motl = struct();
% Fill fields
for i = 1:n_fields
switch motl_fields{i,3}
case 'int'
motl.(motl_fields{i,1}) = int32(av3_motl(:,motl_row{i,2}));
case 'float'
motl.(motl_fields{i,1}) = single(av3_motl(:,motl_row{i,2}));
case 'str'
motl.(motl_fields{i,1}) = repmat({'A'},n_motls,1);
end
end
% Write output
sg_motl_write2(output_name,motl);