-
Notifications
You must be signed in to change notification settings - Fork 5
/
kitExamplePlaneFitTest.m
52 lines (46 loc) · 1.84 KB
/
kitExamplePlaneFitTest.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
function job = kitExamplePlaneFitTest(job,makeMovie)
% Perform and test plane fitting
%
%take output from kitExampleDetectionTest.m and
%kitExampleRefinementTest.m rather than redoing
% Jonathan U Harrison 2019-02-12
%%%%%%%%%%
%%%%% can get output from metaphase example by rerunning previous test
if nargin <1
[spots, movie, job] = kitExampleDetectionTest();
job = kitExampleRefinementTest(spots,movie,job);
end
if nargin<2
makeMovie=0; %make a movie of the planes for each frame
end
%read in movie
if isfield(job,'metadata')
if iscell(job.metadata)
job.metadata = job.metadata{job.index};
end
[job.metadata, reader] = kitOpenMovie(fullfile(job.movieDirectory,job.ROI.movie),'valid',job.metadata);
else
[job.metadata, reader] = kitOpenMovie(fullfile(job.movieDirectory,job.ROI.movie));
end
% Fit plane in chosen channel.
planeChan = job.options.coordSystemChannel;
job.options.debug.showPlaneFit = 2;
job.options.debug.makePlaneFitMovie = makeMovie;
job.options.smoothPlaneOrigin = 1;
kitLog('Fitting plane in channel %d', planeChan);
if strcmp(job.options.coordMode{planeChan}, 'none')
% No spot tracking in plane channel so populate dataStruct.
job.dataStruct{planeChan} = kitMakeMakiDatastruct(job, planeChan);
end
if strcmp(job.options.coordSystem, 'register')
job.dataStruct{planeChan} = kitRegisterFrames(job,reader,job.dataStruct{planeChan});
else
job.dataStruct{planeChan} = kitFitPlane(job,reader,job.dataStruct{planeChan},planeChan,0);
end
%% Test1: check if reasonable number of spots
assert(~job.dataStruct{planeChan}.failed, 'Make sure fit has not failed');
assert(size(job.dataStruct{1}.planeFit(1).plane,2)==4, ...
'Check size of plane for first time slice');
assert(all(job.dataStruct{1}.planeFit(1).eigenValues>0), ...
'Check all eigenvalues positive for first plane');
end