-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPreProcess3pRecording.m
More file actions
74 lines (58 loc) · 1.89 KB
/
Copy pathPreProcess3pRecording.m
File metadata and controls
74 lines (58 loc) · 1.89 KB
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
%% Pre-process 3p single plane and volumetric movies.
%
% See github wiki for documentation.
%
% Dependencies:
% LoadTifSI.m
% SamplingCorrection.m
% GetMetaDataNumber.m
% deinterleave.m
%
% Input
% files: List of *.tif files of 3p recordings to be pre-processed.
%
% Output
% Writes *.mat files containing pre-processed 3p datasets.
%
%
% --SW, last modified: 12/14/2018.
function [] = PreProcess3pRecording(files)
if ~exist('files','var') || isempty(files)
% Load all files in the current directory and process
files = dir('*.tif');
end
for file = files'
[~,name,~] = fileparts(file.name);
disp(['Processing ',name,'..']);
% Load ScanImage produced TIF file:
[frames,meta,~] = LoadTifSI(file.name);
frames = SamplingCorrection(frames);
% Assess plane vs volumetric from meta data:
z = GetMetaDataNumber(meta,'SI.hFastZ.numFramesPerVolume',2);
if z>1
type = '3p-volumetric';
else
type = '3p-plane';
end
switch type
%% =========================================================================
case '3p-plane'
% Convert to single
Y = single(frames);
% Save data in .m format
save([name,'.mat'],'Y','z','meta','-v7.3');
%% =========================================================================
case '3p-volumetric'
% Convert to single
Y = single(frames);
% Deinterleave planes and time points
Y = deinterleave(Y,z);
% Remove flyback frames
FlybackFrames = GetMetaDataNumber(meta,'SI.hFastZ.numDiscardFlybackFrames',1);
Y = Y(:,:,:,1:z-FlybackFrames);
% Save data in .m format
z = z-FlybackFrames;
save([name,'.mat'],'Y','z','meta','-v7.3');
end
end
end