-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathkitMakeMakiDatastruct.m
156 lines (139 loc) · 5.53 KB
/
kitMakeMakiDatastruct.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
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
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
function dataStruct = kitMakeMakiDatastruct(job, channel)
%KITMAKEMAKIDATASTRUCT Generates maki compatible datastruct from kit job
%
% SYNOPSIS: dataStruct = kitMakeMakiDatastruct(job)
%
% INPUT job: Struct containing tracking job setup options.
% Requires at least the following fields:
%
% .
%
% OUTPUT dataStruct: Maki compatible struct containing the following fields:
%
% .rawMovieName - may contain the actual movie
% .rawMoviePath
% .dataProperties - struct containing
%
% Copyright (c) 2012 Jonathan W. Armond
options = job.options;
% Default values for non-Kit fields.
dataProperties.LENSID=12003;
dataProperties.timeLapse=1;
dataProperties.expTime=NaN;
dataProperties.NDfilter=NaN;
dataProperties.cellCycle=NaN;
dataProperties.strains=NaN;
dataProperties.drugs=NaN;
dataProperties.temperature={'Nan'};
dataProperties.crop=[];
dataProperties.F_TEST_PROB=0.9990;
dataProperties.IDopt= [];
dataProperties.PATCHSIZE=7;
dataProperties.CH_MAXNUMINTERV=1000;
dataProperties.OVERLPSIZE=[15 15 15];
dataProperties.split=[];
dataProperties.MAXSPOTS=500;
dataProperties.T_TEST_PROB=0.0500;
dataProperties.maxSize = 100 * 2^20; % 100 Mb
dataProperties.amplitudeCutoff = 0; % undefined
dataProperties.fitNPlusOne = 1; % super-resolution fitting in detector
dataProperties.waveIdx = channel; % current wavelength
dataProperties.movieType = 'sorger'; % also: 'sedat', 'misteli', 'synth'
dataProperties.name = '';
dataProperties.sigmaCorrection=[1.5 1.5];
if isfield(options,'deconvolvedDataCorrection') && options.deconvolvedDataCorrection
% assume a smaller PSF by a factor 4 to correct for less dispersion of spots
dataProperties.sigmaCorrection=dataProperties.sigmaCorrection/2;
end
% linker properties
dataProperties.linker_relativeMaxDistance = -1; % don't use
dataProperties.linker_absoluteMaxDistance=-1; % don't use
dataProperties.linker_relAmpWeight=1/1.5; % weighs distance more
dataProperties.linker_useCOM = 1; % use center of mass to correct
dataProperties.linker_fuseRatio = 1.5; % fuse if less than 1.5 RL separated
% tracking settings
tracksParam.rotate = 1;
tracksParam.timeWindow = options.maxCloseGap;
tracksParam.minRadius = options.minSearchRadius;
tracksParam.maxRadius = options.maxSearchRadius;
% gap closing parameters.
gapCloseParam.timeWindow = tracksParam.timeWindow + 1;
gapCloseParam.mergeSplit = 0;
gapCloseParam.minTrackLen = 2;
gapCloseParam.diagnostics = options.debug.gapClosing;
%assign cost matrix parameters for linking spots between consecutive
%frames
costMatrices(1).funcName = 'trackCostMatLink';
parameters.linearMotion = 0;
parameters.minSearchRadius = tracksParam.minRadius;
parameters.maxSearchRadius = tracksParam.maxRadius;
parameters.brownStdMult = 3.5;
parameters.useLocalDensity = 1;
parameters.nnWindow = gapCloseParam.timeWindow;
costMatrices(1).parameters = parameters;
clear parameters
%assign cost matrix parameters for closing gaps and (in principle)
%merging and splitting
costMatrices(2).funcName = 'trackCostMatCloseGaps';
parameters.linearMotion = 0;
parameters.minSearchRadius = tracksParam.minRadius;
parameters.maxSearchRadius = tracksParam.maxRadius;
parameters.brownStdMult = 3.5*ones(gapCloseParam.timeWindow,1);
% parameters.timeReachConfB = min(2,gapCloseParam.timeWindow);
parameters.timeReachConfB = min(1,gapCloseParam.timeWindow);
parameters.lenForClassify = 10;
parameters.ampRatioLimit = [0.65 4];
parameters.useLocalDensity = 1;
parameters.nnWindow = gapCloseParam.timeWindow;
parameters.linStdMult = 3.5*ones(gapCloseParam.timeWindow,1);
parameters.timeReachConfL = 1;
parameters.maxAngleVV = 45;
costMatrices(2).parameters = parameters;
clear parameters
%assign Kalman filter function names
kalmanFunctions.reserveMem = 'kalmanResMemLM';
kalmanFunctions.initialize = 'kalmanInitLinearMotion';
kalmanFunctions.calcGain = 'kalmanGainLinearMotion';
kalmanFunctions.timeReverse = 'kalmanReverseLinearMotion';
%save tracking parameters in dataStruct
tracksParam.gapCloseParam = gapCloseParam;
tracksParam.costMatrices = costMatrices;
tracksParam.kalmanFunctions = kalmanFunctions;
dataProperties.tracksParam = tracksParam;
% Group sisters.
groupSisters.useAlignment = options.useSisterAlignment;
groupSisters.maxAngle = options.maxSisterAlignmentAngle;
groupSisters.maxDist = options.maxSisterSeparation;
groupSisters.minOverlap = options.minSisterTrackOverlap;
groupSisters.useAnaphase = options.oppositeAnaphaseDir;
groupSisters.robust = options.robustStats;
dataProperties.groupSisters = groupSisters;
% Translate metadata.
md = job.metadata;
dataProperties.PIXELSIZE_XY = md.pixelSize(1);
if md.pixelSize(1) ~= md.pixelSize(2)
error('unequal pixelsize x/y!')
end
dataProperties.PIXELSIZE_Z = md.pixelSize(3);
dataProperties.NA = md.na;
if isempty(job.ROI.crop)
dataProperties.movieSize(1:2) = md.frameSize(1:2);
else
dataProperties.movieSize(1:2) = job.ROI.cropSize(1:2);
end
dataProperties.movieSize(3) = md.frameSize(3);
dataProperties.movieSize(4) = md.nFrames;
dataProperties.WVL = md.wavelength;
% if there are multiple wavelengths: Make it a numZ x numT x
% numW array
dataProperties.frameTime = repmat(md.frameTime, [1, 1, length(md.wavelength)]);
% calculate filterparms
[FT_XY, FT_Z] = calcFilterParms(...
dataProperties.WVL(dataProperties.waveIdx),dataProperties.NA,[],'gauss',...
dataProperties.sigmaCorrection,...
[dataProperties.PIXELSIZE_XY dataProperties.PIXELSIZE_Z]);
patchXYZ=roundOddOrEven(4*[FT_XY FT_XY FT_Z],'odd','inf');
dataProperties.FILTERPRM = [FT_XY,FT_XY,FT_Z,patchXYZ];
dataProperties.FT_SIGMA = [FT_XY,FT_XY,FT_Z];
% Assign to dataStruct.
dataStruct.dataProperties = dataProperties;