-
Notifications
You must be signed in to change notification settings - Fork 0
/
batchDMxToTiff.m
38 lines (30 loc) · 933 Bytes
/
batchDMxToTiff.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
function indError = batchDMxToTiff(directory)
dirs = dir(fullfile(directory,'*.dm*'));
mkdir( fullfile( directory, 'tiffs' ) )
numFile = length(dirs);
indError = [];
for ind = 1:numFile
fname = dirs(ind).name;
if fname(1) ~= '.'
disp(fname)
try
DMtotiff( directory, fname );
catch
indError = [indError, ind];
end
end
end
end
function DMtotiff( directory, fname )
im_stack = DMReader( fullfile( directory,fname) );
writeBigTiff( im_stack, fullfile( directory, 'tiffs', [fname(1:end-4),'.tif']),'overwrite' );
end
function im_stack = DMReader(fname)
bfObject = bfopen(fname);
numIm = size(bfObject{1,1},1);
[nr,nc] = size(bfObject{1,1}{1,1});
im_stack = zeros(nr,nc,numIm);
for ind = 1:numIm
im_stack(:,:,ind) = bfObject{1,1}{ind,1};
end
end