-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathtemporal_SID_update.m
53 lines (44 loc) · 1.51 KB
/
temporal_SID_update.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
function [forward_model, timeseries, template, indices_in_orig] = ...
temporal_SID_update(Y, forward_model, timeseries, template, indices_in_orig, opts)
if nargin < 6
opts = struct;
end
if ~isfield(opts, 'tolerance')
opts.tolerance = 1e-12;
end
if ~isfield(opts, 'display')
opts.display = true;
end
if opts.display
disp([datestr(now, 'YYYY-mm-dd HH:MM:SS') ': ' 'Pruning neuron candidates with neglibible values in spatial component']);
end
id2=[];
for k=1:size(forward_model,1)
trace = forward_model(k, opts.microlenses(opts.idx)>0) > opts.tolerance;
if sum(trace) > 0 % (opts.Nnum^2)/3
id2 = [id2 k]; %#ok<AGROW>
elseif opts.display
disp([datestr(now, 'YYYY-mm-dd HH:MM:SS') ': Discarding neuron candidate ' num2str(k)]);
end
end
indices_in_orig = indices_in_orig(id2);
timeseries = timeseries(id2, :);
forward_model = forward_model(id2, :);
template = template(id2(1:end-opts.bg_sub), :);
if opts.display
disp([datestr(now, 'YYYY-mm-dd HH:MM:SS') ': ' 'Pruning completed']);
end
if opts.display
disp([datestr(now, 'YYYY-mm-dd HH:MM:SS') ': ' 'Starting temporal update']);
end
tic
forward_model = (1./ sqrt(sum(forward_model .^ 2, 2))) .* forward_model;
opts.warm_start = timeseries;
timeseries = fast_nnls(forward_model(:, opts.microlenses(opts.idx) > 0)', ...
Y(opts.microlenses(opts.idx) > 0, :), ...
opts);
if opts.display
disp([datestr(now, 'YYYY-mm-dd HH:MM:SS') ': ' 'Temporal update completed']);
toc
end
end