Skip to content

Commit

Permalink
fix error messages in R2019b. these error messages were warnings in t…
Browse files Browse the repository at this point in the history
…he earlier versions.
  • Loading branch information
zhoupc committed Jan 23, 2020
1 parent 45641cf commit 173bace
Show file tree
Hide file tree
Showing 10 changed files with 30 additions and 16 deletions.
24 changes: 15 additions & 9 deletions OASIS_matlab/deconvolveCa.m
Original file line number Diff line number Diff line change
Expand Up @@ -108,28 +108,32 @@
%% run deconvolution
c = y;
s = y;
b0 = options.b;

switch lower(options.method)
case 'foopsi' %% use FOOPSI
if strcmpi(options.type, 'ar1') % AR 1
if options.smin<0
options.smin = abs(options.smin)*options.sn;
end
gmax = exp(-1/options.max_tau);
[c, s, options.b, options.pars] = foopsi_oasisAR1(y-options.b, options.pars, options.lambda, ...
[c, s, options.b, options.pars] = foopsi_oasisAR1(y-b0, options.pars, options.lambda, ...
options.smin, options.optimize_b, options.optimize_pars, [], options.maxIter, ...
options.tau_range, gmax);
options.b = options.b + b0;
elseif strcmpi(options.type, 'ar2') % AR 2
if options.smin<0
options.smin = abs(options.smin)*options.sn/max_ht(options.pars);
end
[c, s, options.b, options.pars] = foopsi_oasisAR2(y-options.b, options.pars, options.lambda, ...
[c, s, options.b, options.pars] = foopsi_oasisAR2(y-b0, options.pars, options.lambda, ...
options.smin);
options.b = options.b + b0;
elseif strcmpi(options.type, 'exp2') % difference of two exponential functions
kernel = exp2kernel(options.pars, options.window);
[c, s] = onnls(y-options.b, kernel, options.lambda, ...
[c, s] = onnls(y-b0, kernel, options.lambda, ...
options.shift, options.window);
elseif strcmpi(options.type, 'kernel') % convolution kernel itself
[c, s] = onnls(y-options.b, options.pars, options.lambda, ...
[c, s] = onnls(y-b0, options.pars, options.lambda, ...
options.shift, options.window);
else
disp('to be done');
Expand Down Expand Up @@ -158,7 +162,7 @@
% options.pars, options.sn, options.optimize_b, options.optimize_pars, ...
% [], options.maxIter, options.thresh_factor);
% else
% [c, s] = oasisAR1(y-options.b, options.pars, options.lambda, ...
% [c, s] = oasisAR1(y-b0, options.pars, options.lambda, ...
% options.smin);
% end
elseif strcmpi(options.type, 'ar2')
Expand All @@ -170,17 +174,17 @@
% options.pars, options.sn, options.optimize_b, options.optimize_pars, ...
% [], options.maxIter, options.thresh_factor);
% else
% [c, s] = oasisAR2(y-options.b, options.pars, options.lambda, ...
% [c, s] = oasisAR2(y-b0, options.pars, options.lambda, ...
% options.smin);
% end
elseif strcmpi(options.type, 'exp2') % difference of two exponential functions
d = options.pars(1);
r = options.pars(2);
options.pars = (exp(log(d)*(1:win)) - exp(log(r)*(1:win))) / (d-r); % convolution kernel
[c, s] = onnls(y-options.b, options.pars, options.lambda, ...
[c, s] = onnls(y-b0, options.pars, options.lambda, ...
options.shift, options.window, [], [], [], options.smin);
elseif strcmpi(options.type, 'kernel') % convolution kernel itself
[c, s] = onnls(y-options.b, options.pars, options.lambda, ...
[c, s] = onnls(y-b0, options.pars, options.lambda, ...
options.shift, options.window, [], [], [], options.smin);
else
disp('to be done');
Expand All @@ -194,10 +198,12 @@

% deal with large residual
if options.remove_large_residuals && strcmpi(options.method, 'foopsi')
ind = (abs(smooth(y-c, 3))>options.smin);
ind = (abs(fastsmooth(y-c, 3))>options.smin) & (c>options.smin*5);
c(ind) = max(0, y(ind));
end

% avoid nan output
c(isnan(c) | isinf(c)) = 0;

function options=parseinputs(varargin)
%% parse input variables
Expand Down
2 changes: 1 addition & 1 deletion OASIS_matlab/examples/Paper/fig3.m
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
set(gca, 'ytick', 0:2);
ylabel('Fluor.');
box off;
legend('Data', 'Truth', 'OASIS', 'CVX', 'location', 'northeast', 'orientation', 'horizental');
legend('Data', 'Truth', 'OASIS', 'CVX', 'location', 'northeast', 'orientation', 'horizontal');
% s
axes('position', [.05, .18, .95, .37]);
hold on;
Expand Down
4 changes: 2 additions & 2 deletions OASIS_matlab/examples/Paper/fig5.m
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
plot(trueC(1, :), 'color', col{3}/255, 'linewidth', 3);
plot(c, 'color', col{1}/255);
plot(c_t, 'color', col{2}/255);
legend('Data', 'Truth', 'Thresh', 'L1', 'orientation', 'horizental');
legend('Data', 'Truth', 'Thresh', 'L1', 'orientation', 'horizontal');
ylim([ymin, ymax]);
xlim([0, 452]);
set(gca, 'xtick', 0:150:500);
Expand Down Expand Up @@ -116,7 +116,7 @@
plot(trueC(1, :), 'color', col{3}/255, 'linewidth', 3);
plot(c, 'color', col{1}/255);
plot(c_t, 'color', col{2}/255);
legend('Data', 'Truth', 'Thresh', 'L1', 'orientation', 'horizental');
legend('Data', 'Truth', 'Thresh', 'L1', 'orientation', 'horizontal');
ylim([ymin, ymax]);
xlim([0, 452]);
set(gca, 'xtick', 0:150:500);
Expand Down
3 changes: 3 additions & 0 deletions OASIS_matlab/examples/Paper/test_all.m
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
if ~exist('fig', 'dir')
mkdir('fig');
end
fig1;
fig2;
fig3;
Expand Down
4 changes: 2 additions & 2 deletions OASIS_matlab/examples/show_results.m
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@
ylabel('Fluor.');
box off;
if plot_cvx
legend('Data', 'Truth', 'OASIS', 'CVX', 'location', 'northeast', 'orientation', 'horizental');
legend('Data', 'Truth', 'OASIS', 'CVX', 'location', 'northeast', 'orientation', 'horizontal');
else
legend('Data', 'Truth', 'OASIS', 'location', 'northeast', 'orientation', 'horizental');
legend('Data', 'Truth', 'OASIS', 'location', 'northeast', 'orientation', 'horizontal');
end
% s
axes('position', [.05, .18, .95, .37]);
Expand Down
3 changes: 3 additions & 0 deletions OASIS_matlab/packages/oasis/constrained_oasisAR1.m
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,8 @@

%% optimize parameters
tol = 1e-4;
dphi = 0;

% flag_lam = true;
if ~optimize_b %% don't optimize the baseline b
%% initialization
Expand Down Expand Up @@ -227,6 +229,7 @@ function update_lam_b() % estimate lambda & b
g_range = [0, 1];
end
%% find the optimal g and get the warm started active_set
h = [];
g = fminbnd(@rss_g, g_range(1), g_range(2));
yp = y - lam*(1-g);
for m=1:len_active_set
Expand Down
1 change: 1 addition & 0 deletions OASIS_matlab/packages/oasis/foopsi_oasisAR1.m
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,7 @@
c = zeros(size(y)); % the optimal denoised trace

%% find the optimal g and get the warm started active_set
h = [];
g = fminbnd(@rss_g, g_range(1), g_range(2));
yp = y - lam*(1-g);
for m=1:len_active_set
Expand Down
2 changes: 1 addition & 1 deletion OASIS_matlab/packages/oasis/oasisAR1.m
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@

%% backtrack until violations fixed
while (~isnan(ii_prev)) && (active_set(ii,1)/active_set(ii,2)<...
active_set(ii_prev,1)/active_set(ii_prev,2)*g^(active_set(ii_prev,4))+smin)
max(0, active_set(ii_prev,1)/active_set(ii_prev,2)*g^(active_set(ii_prev,4)))+smin)
ii_next = ii;
ii = ii_prev;
active_set(ii,1) = active_set(ii,1) + active_set(ii_next,1)* (g^(active_set(ii,4)));
Expand Down
1 change: 1 addition & 0 deletions OASIS_matlab/packages/oasis/thresholded_oasisAR1.m
Original file line number Diff line number Diff line change
Expand Up @@ -245,6 +245,7 @@
g_range = [0, 1];
end
%% find the optimal g and get the warm started active_set
h = [];
g = fminbnd(@rss_g, g_range(1), g_range(2));
yp = y;
for m=1:len_active_set
Expand Down
2 changes: 1 addition & 1 deletion OASIS_matlab/packages/oasis/thresholded_oasisAR2.m
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@
break;
end
% update g
if and(optimize_g, ~g_converged);
if and(optimize_g, ~g_converged)
g0 = g;
g = update_g(y-b, g, spks);
smin = choose_smin(g, sn, 0.9999);
Expand Down

0 comments on commit 173bace

Please sign in to comment.