-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathTracking.m
More file actions
86 lines (73 loc) · 2.77 KB
/
Tracking.m
File metadata and controls
86 lines (73 loc) · 2.77 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
function tracks = Tracking(fits_fname,fits,trackparams,savetracks)
%% Tracking
% written BPI 6/7/16
% This function is just a wrapper for Track_3D2 to interface with the fit
% fits used in the SMALL-LABS fitting protocol
%%%% Inputs %%%%
% fits_fname is the name of the fits .mat file, importantly containing an
% array called fits with the fit information with column 9 being the
% goodfit boolean
% trackparams are the tracking parameters, definitions and defaults below
%%%% Outputs %%%%
% tracks is an array with the track information.
%%%% Dependencies %%%%
% Track_3D2
% hungarian
% Copyright (C) 2018 Benjamin P Isaacoff
%
% This program is free software: you can redistribute it and/or modify
% it under the terms of the GNU General Public License as published by
% the Free Software Foundation, either version 3 of the License, or
% (at your option) any later version.
%
% This program is distributed in the hope that it will be useful,
% but WITHOUT ANY WARRANTY; without even the implied warranty of
% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
% GNU General Public License for more details.
%
% You should have received a copy of the GNU General Public License
% along with this program. If not, see <http://www.gnu.org/licenses/>.
%
%% Default tracking parameters
if nargin<2
% TRACKING PARAMETERS
% minimum merit
trackparams(1)=0.01;
% Integration time (ms)
trackparams(2)=200;
% gamma
trackparams(3)=1;
% maximum step size
trackparams(4)=3;
% minimum track length
trackparams(5)=3;
% speed estimation window halfsize
trackparams(6)=1;
% time delay between consecutive frames (ms)
trackparams(7)=0;
end
alpha=-log(trackparams(1))/trackparams(4);
%% Tracking
%filling the goodfit for the tracking function array
goodfits=zeros(sum(fits.goodfit),23);
goodfits(:,1)=fits.frame(fits.goodfit);%frame number
goodfits(:,9)=fits.row(fits.goodfit);%x position
goodfits(:,11)=fits.col(fits.goodfit);%y position
goodfits(:,14)=fits.sum(fits.goodfit);%intensity
goodfits(:,21)=fits.roinum(fits.goodfit);% Cell# or ROI#
goodfits(:,22)=fits.molid(fits.goodfit);% Molecule ID#
trfile=Track_3D2(goodfits,trackparams(1),alpha,trackparams(3),trackparams(5),trackparams(6),...
1,trackparams(7),trackparams(2));
if savetracks
save(strrep(fits_fname,'.mat','_tracks.mat'),'trfile','trackparams','-v7.3')
end
if ~isempty(trfile)
%get rid of useless fits from the tracking program
% tracks is made of 1: frame #, 2: x (px), 3: y (px), 4: track #, 5:
% Cell or ROI #, 6: Molecule ID#
tracks=trfile(:,[2,4,5,1,13,9]);
else
warning('Not enough goodfits to contruct tracks')
tracks=[];
end
end