Repository navigation
Expand file tree
/
Copy pathreformatGrouping.m
More file actions
128 lines (100 loc) · 4.54 KB
/
Copy pathreformatGrouping.m
File metadata and controls
128 lines (100 loc) · 4.54 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
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
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
function reformatGrouping
% I = imread(['X:\AlexData11\786Opar\786Opar_NaCl01_R3D\images\786Opar_NaCl01_T000.tif']);
% EDIT: hardcoded path below is specific to the original author's local machine -- update before running
load(['X:\AlexData11\786Opar\786Opar_NaCl02_R3D\point_files\config001_5p00_track_bidir.mat']);
% load(['Z:\AlexResults\EB1_Katsu_1s_1_600\point_files\EB1_poster_pooledData.mat']);
% find all the trajectories with lifetimes > 4
indx = find( [tracks.len] >= 4); %4
traj = tracks(indx);
leIndx = length(indx);
for i = 1:leIndx
traj(i).endID = traj(i).startID + traj(i).len - 1;
end
minFrB = min([traj.startID])
maxFrE = max([traj.endID])
aux = minFrB - 1; % Displacement of first track w a beginning
leIndBB = length(unique([traj.startID])) % FIND HOW MANY unique FRAMES HAVE START-ID
%--------------------------------------------------------------------------
for i = 1:leIndBB % Fill In Frame by Frame starting w the Beginnings
% Initialize 'feats' structure
feats=struct(...
'pos',[0 0],... % Centroid - [y x]
'ecc',0,... % Eccentricity
'ori',0,... % Orientation
'tip',0); % Beginning or End
s = 3;
strg=sprintf('%%.%dd',s);
indxStr=sprintf(strg,(i-1)); % NUMBER OF FRAME
indB = find([traj.startID]==(aux+i)); % Take into account the shift
indE = find([traj.endID]==(aux+i));
leIndB = length(indB);
leIndE = length(indE);
for j = 1:leIndB % Fill in feats beginning in frame 'i'
dY = traj(indB(j)).points(end,1) - traj(indB(j)).points(1,1);
dX = traj(indB(j)).points(end,2) - traj(indB(j)).points(1,2);
feats.pos(j,1) = traj(indB(j)).points(1,1); % Y of Begin point
feats.pos(j,2) = traj(indB(j)).points(1,2); % X of Begin point
feats.ecc(j,1) = sqrt(dY*dY + dX*dX);
if dX == 0
dX = dX + 0.0001;
end
feats.ori(j,1) = atan(dY/dX); % Xe-X1,Ye-Y1
feats.tip(j,1) = 1; % Beginning stamp
dY = [];
dX = [];
end
for j = 1:leIndE % Fill in feats ending in frame 'i'
dY = traj(indE(j)).points(end,1) - traj(indE(j)).points(1,1);
dX = traj(indE(j)).points(end,2) - traj(indE(j)).points(1,2);
feats.pos(j+leIndB,1) = traj(indE(j)).points(end,1); % Y of End point
feats.pos(j+leIndB,2) = traj(indE(j)).points(end,2); % X of End point
feats.ecc(j+leIndB,1) = sqrt(dY*dY + dX*dX);
if dX == 0
dX = dX + 0.0001;
end
feats.ori(j+leIndB,1) = atan(dY/dX); % Xe-X1,Ye-Y1
feats.tip(j+leIndB,1) = 2; % End stamp
dY = [];
dX = [];
end
fprintf('Total number of EB1 features is %d in frame %d\n', length(feats.pos), i); % CHECK
% EDIT: hardcoded path below is specific to the original author's local machine -- update before running
save(['H:\GROUPING_TEST\cands\feats',indxStr],'feats')
indB = [];
indE = [];
leIndB = [];
leIndE = [];
end
%--------------------------------------------------------------------------
for i = (leIndBB+1):maxFrE % Frame by Frame continuining for the rest of the Ends
% Initialize 'feats' structure
feats=struct(...
'pos',[0 0],... % Centroid - [y x]
'ecc',0,... % Eccentricity
'ori',0,... % Orientation
'tip',0); % Beginning or End
s = 3;
strg=sprintf('%%.%dd',s);
indxStr=sprintf(strg,(i-1)); % NUMBER OF FRAME
indEE = find([traj.endID]==(aux+i)); % Take into account the shift
leIndEE = length(indEE);
for j = 1:leIndEE % Fill in feats ending in frame 'i'
dY = traj(indEE(j)).points(end,1) - traj(indEE(j)).points(1,1);
dX = traj(indEE(j)).points(end,2) - traj(indEE(j)).points(1,2);
feats.pos(j,1) = traj(indEE(j)).points(end,1); % Y of End point
feats.pos(j,2) = traj(indEE(j)).points(end,2); % X of End point
feats.ecc(j,1) = sqrt(dY*dY + dX*dX);
if dX == 0
dX = dX + 0.0001;
end
feats.ori(j,1) = atan(dY/dX); % Xe-X1,Ye-Y1
feats.tip(j,1) = 2; % End stamp
dY = [];
dX = [];
end
fprintf('Total number of EB1 features is %d in frame %d\n', length(feats.pos), i); % CHECK
% EDIT: hardcoded path below is specific to the original author's local machine -- update before running
save(['H:\GROUPING_TEST\cands\feats',indxStr],'feats')
indEE = [];
leIndEE = [];
end