forked from cortex-lab/Suite2P
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathbuild_ops_RunOnly.m
92 lines (77 loc) · 3.22 KB
/
build_ops_RunOnly.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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
function ops = build_ops_RunOnly(db, ops)
ops.nplanes = getOr(ops, 'nplanes', 1);
ops.nchannels = getOr(ops, 'nchannels', 1);
ops = addfields(ops, db);
for k = 1:length(db.expts)
ops.SubDirs{k} = num2str(db.expts(k));
end
if ops.doRegistration
ops.RootDir = fullfile(ops.RootStorage, ops.mouse_name, ops.date);
else
ops.RootDir = fullfile(ops.RootStorage, ops.mouse_name, ops.date,'Corrected');
ops.RootDirRaw = fullfile(ops.RootStorage, ops.mouse_name, ops.date);
end
disp(ops.RootDir);
% build file list
ops.fsroot = [];
overview_ind = [];
for j = 1:ops.nplanes %length(ops.SubDirs) % changed on 16/11/25 by SK
ops.fsroot{j} = dir(fullfile(ops.RootDir,sprintf('*Slice%02d*.tif',j)));
if j==1
ops.rawMovies = dir(fullfile(ops.RootDirRaw,'FOV1_0*.tif'));
for k = 1:length(ops.rawMovies)
% Do not include overview image
if isfinite(strfind(ops.rawMovies(k).name,'overview'));
overview_ind = k;
end
end
if ~isempty(overview_ind)
pick_ind = (1:length(ops.rawMovies))~=overview_ind;
ops.rawMovies = ops.rawMovies(pick_ind);
end
end
% ops.fsroot{j} = dir(fullfile(ops.RootDir,sprintf('*Slice%02d*_File001.tif',j)));
for k = 1:length(ops.fsroot{j})
% Do not include overview image
if isempty(strfind(ops.fsroot{j}(k).name,'overview'));
ops.fsroot{j}(k).name = fullfile(ops.RootDir, ops.fsroot{j}(k).name);
else
ops.fsroot{j}(k).name = [];
end
end
% ops.fsroot{j} = ops.fsroot{j}(1:20); % select some fraction of files
end
try
% MK code for automatically determining number of planes and channels
[~, header] = loadFramesBuff(fullfile(ops.RootDirRaw,ops.rawMovies(1).name), 1, 1, 1);
% [~, header] = loadFramesBuff(ops.fsroot{1}(1).name, 1, 1, 1);
[~, scanImageMetadata] = bigTiffRead(fullfile(ops.RootDirRaw,ops.rawMovies(1).name));
% [mov, scanImageMetadata] = obj.readRaw(movNum,'single');
hh=header{1};
assert(strcmp(scanImageMetadata.VERSION_MAJOR, '2017b')) % For scanimage 2017b
ops.nchannels = scanImageMetadata.hChannels.channelSave;
fastZEnable = scanImageMetadata.hFastZ.enable;
fastZDiscardFlybackFrames = scanImageMetadata.hFastZ.discardFlybackFrames;
stackNumSlices = scanImageMetadata.hStackManager.numSlices;
ops.nplanes = 1;
ops.zoomMicro = scanImageMetadata.hRoiManager.scanZoomFactor;
ops.imageRate = scanImageMetadata.hRoiManager.scanVolumeRate;
catch
error('Error in parsing scanImageMetadata.')
end
if ~(isfield(ops, 'planesToProcess') && ~isempty(ops.planesToProcess))
% ops.planesToProcess = 1:ops.nplanes;
ops.planesToProcess = 1:stackNumSlices; % changed by SK 16/12/14
else
% planesToProcess is not working right now
ops.planesToProcess = 1:ops.nplanes;
end
CharSubDirs = '';
for i = 1:length(ops.SubDirs)
CharSubDirs = [CharSubDirs ops.SubDirs{i} '_'];
end
CharSubDirs = CharSubDirs(1:end-1);
ops.CharSubDirs = CharSubDirs;
ops.ResultsSavePath = sprintf('%s\\%s\\%s\\%s\\', ops.ResultsSavePath, ops.mouse_name, ops.date);
% ops.ResultsSavePath = sprintf('%s\\%s\\%s\\%s\\', ops.ResultsSavePath, ops.mouse_name, ops.date, CharSubDirs);
end