-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathlsm_read_mod.m~
executable file
·75 lines (57 loc) · 2.24 KB
/
lsm_read_mod.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
% Alistair Boettiger
% Levine lab
% UC Berkeley
function stack = lsm_read_mod(name,N,nmax)
%%
% clear all;
% name = '/Volumes/Data/Lab Data/Raw_Data/02-08-11/MP10_22C_sna_y.mat';
% N =9;
% nmax = 1.4E4;
global TIF;
load(name)
filetemp= fopen(Datas.filename,'r','l');
Zs = Datas.LSM_info.DimensionZ;
filetemp= fopen(Datas.filename,'r','l');
stack= cell(1,Zs);
for i=1:Zs % i = 21
TIF = Datas.([ 'Stack' num2str(N)]).(['Image' num2str(i)]).TIF;
IMG = Datas.([ 'Stack' num2str(N)]).(['Image' num2str(i)]).IMG;
TIF.file=filetemp;
offset = 0;
%read the image channels
for c = 1:TIF.SamplesPerPixel % c=3
TIF.StripCnt = c;
IMG.data{c} = read_planeT(offset, IMG.width, IMG.height, c,TIF);
% check for screwed up offset
[h,w] = size(IMG.data{c});
% look in middle of data set and see if it's noise or
% signal
sdata = IMG.data{c}( floor(h/2*.9):floor(h/2*1.1), floor(w/2*.9):floor(w/2*1.1) );
isnoise = std(double(sdata(:)));
if isnoise> nmax
offset = 1;
IMG.data{c} = read_planeT(offset, IMG.width, IMG.height,c,TIF);
sdata = IMG.data{c}( floor(h/2*.9):floor(h/2*1.1), floor(w/2*.9):floor(w/2*1.1) );
fixed = std(double(sdata(:)));
disp(['offset error found in chn ', num2str(c), ' layer ',num2str(i),...
' std=',num2str(isnoise,5), ' now=',num2str(fixed,5)] );
if fixed > 1.5nmax
if TIF.BitsPerSample(1) == 16
IMG.data{c} = uint16(zeros(h,w));
else
IMG.data{c} = uint8(zeros(h,w));
end
disp(['Fix failed for in chn ', num2str(c),...
' layer ',num2str(i),' skipping this image...'] );
end
end
end
stack{1,i} = IMG.data;
end
% Just for troubleshooting
%
% for z = 1:Zs
% figure(1); clf; imshow(stack{1,21}{3});
% pause(.01);
% end
% clear all;