forked from cortex-lab/Suite2P
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild_ops2.m
55 lines (46 loc) · 1.51 KB
/
build_ops2.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
function ops = build_ops2(db, ops)
% ops = db;
fieldNames = fieldnames(db);
for i = 1:size(fieldNames,1)
if ~isempty(db.(fieldNames{i}))
ops.(fieldNames{i}) = db.(fieldNames{i});
end
end
if ~(isfield(ops, 'planesToProcess') && ~isempty(ops.planesToProcess))
ops.planesToProcess = 1:ops.nplanes;
else
% planesToProcess is not working right now
ops.planesToProcess = 1:ops.nplanes;
end
for k = 1:length(db.expts)
ops.SubDirs{k} = num2str(db.expts(k));
end
ops.RootDir = fullfile(ops.RootStorage, ops.mouse_name, ops.date);
ops.TempDir = fullfile(ops.TempStorage, ops.mouse_name, ops.date);
% build file list
ops.fsroot = [];
for j = 1:length(ops.SubDirs)
ops.fsroot{j} = dir(fullfile(ops.RootDir, ops.SubDirs{j}, '*.tif'));
for k = 1:length(ops.fsroot{j})
ops.fsroot{j}(k).name = fullfile(ops.RootDir, ops.SubDirs{j}, ops.fsroot{j}(k).name);
end
end
% build file list
ops.fs = [];
for j = 1:length(ops.SubDirs)
ops.fs{j} = dir(fullfile(ops.TempDir, ops.SubDirs{j}, '*.tif'));
for k = 1:length(ops.fs{j})
if ops.CopyDataLocally
ops.fs{j}(k).name = fullfile(ops.TempDir, ops.SubDirs{j}, ops.fs{j}(k).name);
else
ops.fs{j}(k).name = ops.fsroot{j}(k).name;
end
end
end
CharSubDirs = '';
for i = 1:length(ops.SubDirs)
CharSubDirs = [CharSubDirs ops.SubDirs{i} '_'];
end
CharSubDirs = CharSubDirs(1:end-1);
ops.ResultsSavePath = sprintf('%s//%s//%s//%s//', ops.ResultsSavePath, ops.mouse_name, ops.date, ...
CharSubDirs);