-
Notifications
You must be signed in to change notification settings - Fork 0
/
build_xyl_trackdat.m
executable file
·57 lines (40 loc) · 2.71 KB
/
build_xyl_trackdat.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
function [ trackdat_xyl ] = build_xyl_trackdat ( tracks_input, px_spacing, Nframes )
% Create a data structure with a more streamlined reference for the
% positions, luminations, and changes in position of the various tracks.
Num_comp_tracks = length( tracks_input);
% Loop through each independent track (of length T frames) and figure
% out how many sub-tracks need to be considered for each case:
for ti = 1:Num_comp_tracks
Nsubtracks(ti) = size( tracks_input(ti).tracksCoordAmpCG, 1);
% get the offset from which this composite track starts and finishes.
comptrack_birth = min( tracks_input(ti).seqOfEvents(:,1) );
comptrack_death_lag = Nframes - max( tracks_input(ti).seqOfEvents(:,1) );
% the number of frames that should be appended to the end of this comptrack to make it to the end of the movie.
for sti = 1:Nsubtracks( ti )
% Within each sub-track, extract the position and change values
% segment in which the particle could not be located on either side
% of the window
% get birth and death time points for each subtrack _within_ the composite window
obituary = tracks_input(ti).seqOfEvents( tracks_input(ti).seqOfEvents(:,3)==sti, 1 );
xdat_compwindow = px_spacing * tracks_input(ti).tracksCoordAmpCG(sti,1:8:end);
ydat_compwindow = px_spacing * tracks_input(ti).tracksCoordAmpCG(sti,2:8:end);
% the above sets the raw *COORDINATES* in units of micrometers. All
% diffs are carried out accordingly.
Adat_compwindow = tracks_input(ti).tracksCoordAmpCG(sti,4:8:end);
trackdat_xyl(ti).xpos(sti,:) = [ repmat(NaN,[1 , (comptrack_birth-1)]), xdat_compwindow, repmat(NaN,[1 , comptrack_death_lag]) ];
trackdat_xyl(ti).ypos(sti,:) = [ repmat(NaN,[1 , (comptrack_birth-1)]), ydat_compwindow, repmat(NaN,[1 , comptrack_death_lag]) ];
trackdat_xyl(ti).Lamp(sti,:) = [ repmat(NaN,[1 , (comptrack_birth-1)]), Adat_compwindow, repmat(NaN,[1 , comptrack_death_lag]) ];
end % terminate forloop through subtracks
% Sanity check: is this track data the right dimensions:
if( ~all( size( trackdat_xyl(ti).xpos ) == [ Nsubtracks(ti), Nframes] ) || ~all( size( trackdat_xyl(ti).ypos ) == [ Nsubtracks(ti), Nframes] ) )
disp("FATAL ERROR: unexpected dimension in trackdat_xyl.")
return
end
trackdat_xyl(ti).dx = diff ( trackdat_xyl(ti).xpos, 1, 2 );
trackdat_xyl(ti).dy = diff ( trackdat_xyl(ti).ypos, 1, 2 );
if( ~all ( size( trackdat_xyl(ti).Lamp ) == [ Nsubtracks(ti), Nframes] ) )
disp("FATAL ERROR: unexpected dimension in trackdat_xyl.Lamp.")
return
end
end % terminate forloop through comptracks
end