-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathpreprocess.m
More file actions
34 lines (29 loc) · 819 Bytes
/
preprocess.m
File metadata and controls
34 lines (29 loc) · 819 Bytes
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
function preprocess(fname, force)
%function preprocess(fname, force)
%
% preprocess tiff image stack
%
% - median filter each image in stack
% - do simple motion correction
%
if ~exist('force', 'var')
force = 0;
end
%out = [dirname(fname) '/_' basename(fname)];
out = strrep(fname, '.tif', '.mat');
if exist(out, 'file') && ~force
fprintf('skipped %s\n', fname);
else
fprintf('loading %s\n', fname);
s = loadstack(fname);
fprintf(' %d frames\n', size(s.g, 3));
fprintf(' median filtering\n');
s = mfstack(s);
fprintf(' motion correcting to mean - pass 1\n');
s = mcorrect2(s, mean(s.g, 3));
fprintf(' motion correcting to first - pass 2\n');
s = mcorrect2(s, s.g(:,:,1));
fprintf(' saving to: %s\n', out);
%saveastiff(uint16([s.g; s.r] .* bitshift(1,16)), out);
save(out, 's');
end