-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathjksbx2tif_forsuite2p.m
52 lines (43 loc) · 1010 Bytes
/
jksbx2tif_forsuite2p.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 jksbx2tif_forsuite2p(fn, varargin)
tic
if ~exist([fn,'.trials'],'file')
jksbxsplittrial(fn)
end
load([fn,'.trials'],'-mat') % loading 'frame_to_use'
ftu = frame_to_use;
if nargin > 1
ch = varargin{1};
else
ch = 1;
end
if nargin > 2
fnummax = varargin{2};
else
fnummax = 4000;
end
curr_dir = pwd;
global info
sbxread(fn,0,1);
if ~exist(fn,'dir')
mkdir(fn)
end
cd(fn)
for i = 1 : length(frame_to_use)
if ~exist(num2str(i),'dir')
mkdir(num2str(i))
end
end
cd(curr_dir)
for i = 1 : length(ftu)
for j = 1 : length(ftu{i})
a = sbxread(fn,ftu{i}(j),1);
a = squeeze(a(ch,101:end,101:end));
if ch == 1
temp_fn = sprintf('%s_%d_green_%02d.tif',fn,i,ceil(j/fnummax));
elseif ch == 2
temp_fn = sprintf('%s_%d_red_%02d.tif',fn,i,ceil(j/fnummax));
end
imwrite(a,[pwd,filesep,fn,filesep,num2str(i),filesep,temp_fn],'WriteMode', 'append');
end
end
toc