-
Notifications
You must be signed in to change notification settings - Fork 0
/
jkfovmatch_mean.m
69 lines (57 loc) · 1.71 KB
/
jkfovmatch_mean.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
% pwd
num_iter = 100;
mouse_num = '030';
layer = 2;
% ref_fn_list = {'648_000_006';'650_000_001';'651_000_004';'652_000_004';'653_000_004'};
ref_fn_list1 = {'030_5555_001';'027_5555_001';'025_5555_001'};
ref_fn_list2 = {'030_5554_001';'027_5554_001';'025_5554_001'};
if layer == 1
for i = 1 : length(ref_fn_list1)
if strfind(ref_fn_list1{i},mouse_num) == 1
ref_fn = ref_fn_list1{i};
break
end
end
elseif layer == 2
for i = 1 : length(ref_fn_list2)
if strfind(ref_fn_list2{i},mouse_num) == 1
ref_fn = ref_fn_list2{i};
break
end
end
else
error('No filename list')
end
cd(['d:\2p\JK\',ref_fn(1:3)])
load([ref_fn,'.align'], '-mat')
if iscell(m)
ref = mat2gray(m{end});
else
ref = mat2gray(m);
end
figure, imagesc(ref), axis image
mmfile = memmapfile('scanbox.mmap','Writable',true, ...
'Format', { 'int16' [1 16] 'header' } , 'Repeat', 1);
fh = figure;
WinOnTop(fh);
while(true)
while(mmfile.Data.header(1)<0) % wait for a new frame...
if(mmfile.Data.header(1) == -2) % exit if Scanbox stopped
return;
end
end
mchA = [];
for i = 1 : num_iter
mmfile.Format = {'int16' [1 16] 'header' ; ...
'uint16' double([mmfile.Data.header(2) mmfile.Data.header(3)]) 'chA'};
% aaa = mmfile.Data;
if i == 1
mchA = double(intmax('uint16')-mmfile.Data.chA)/num_iter;
else
mchA = mchA + double(intmax('uint16')-mmfile.Data.chA)/num_iter;
end
mmfile.Data.header(1) = -1; % signal Scanbox that frame has been consumed!
end
imshowpair(mchA,ref)
drawnow limitrate;
end