forked from ackman678/wholeBrainDX
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbatchFetchOptFlow.m
More file actions
78 lines (63 loc) · 2.27 KB
/
Copy pathbatchFetchOptFlow.m
File metadata and controls
78 lines (63 loc) · 2.27 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
75
76
77
78
function batchFetchOptFlow(filelist, region, varin)
%batchFetchOptFlow(filelist, region, varin)
% Fetches and makes movies of the optic flow calculation for each domain mask movie described by the region d2r file in filelist
% Examples
% filelist = readtext('files.txt',' ');
% batchFetchOptFlow(filelist);
% varin.makePlots=1; batchFetchOptFlow(filelist, region, varin);
%
% INPUTS
% filelist -- cell array of strings, full path names to the region domains2region, *d2r*.mat files
% region -- region formatted data structure (as from CalciumDX, domains2region, etc) that includes CC and STATS data structures returned from wholeBrain_segmentation.m and wholeBrain_detect.m
% varin -- optional additional arguments.
%
% See also wholeBrain_opticFlowByDomain.m, batchfetchDomainProps.m, wholeBrain_batch.m, optFlowLk.m
%
% James B. Ackman 2014-06-25 13:37:27
if nargin< 2 || isempty(region), region = []; end
if nargin< 3 || isempty(varin), varin = []; end
if ~isfield(varin,'makePlots'), varin.makePlots=0; end
mainfcnLoop(filelist, region, varin);
function results = mainfcnLoop(filelist, region, varin)
%start loop through files-----------------------------------------------------------------
if nargin< 2 || isempty(region);
region = []; loadfile = 1;
else
loadfile = 0;
end
fnms = filelist(:,1);
if size(filelist,1) > 1 && size(filelist,2) > 1
fnms2 = filelist(:,2);
end
for j=1:numel(fnms)
if loadfile > 0
matfile=load(fnms{j});
region=matfile.region;
end
sprintf(fnms{j})
varin.fnm = fnms{j};
disp('--------------------------------------------------------------------')
A3 = setupMovieArray(region);
[Vsum, ~, ~] = wholeBrain_opticFlowByDomain(A3,region,region.filename,varin.makePlots);
region.domainData.Vsum = Vsum;
save(fnms{j},'region','-v7.3')
% [pathstr, name, ext] = fileparts(fnms{j});
% region.matfilename = [name ext];
if ismac | ispc
h = waitbar(j/numel(fnms));
else
disp([num2str(j) '/' num2str(numel(fnms))])
end
end
%data=results;
if ismac | ispc
close(h)
end
function A3 = setupMovieArray(region)
sz=region.domainData.CC.ImageSize;
A3 = false(sz);
for i = 1:region.domainData.CC.NumObjects
if ~strcmp(region.domainData.STATS(i).descriptor, 'artifact')
A3(region.domainData.CC.PixelIdxList{i}) = 1;
end
end