33 lines
902 B
Matlab
33 lines
902 B
Matlab
function[obj] = deconvolve(obj, settings)
|
|
|
|
%% Perform pupil deconvolution based on the methods
|
|
% described in Wierda et al PNAS 2012
|
|
|
|
o=optimset;
|
|
o.MaxFunEvals = 10000;
|
|
o.MaxIter = 10000;
|
|
|
|
fs = 50; % Hz downsampling
|
|
|
|
y = obj.data.baseline_corrected.interpolated;
|
|
|
|
t_orig = obj.time;
|
|
|
|
nt = round((t_orig(end) - t_orig(1)) / (1000/fs));
|
|
t_ds = linspace(t_orig(1), t_orig(end), nt);
|
|
yq = interp1(t_orig, y, t_ds);
|
|
|
|
|
|
obj.deconvolution.time = t_ds;
|
|
obj.deconvolution.input = yq;
|
|
|
|
init_params = [ 1 zeros(1,length(obj.labels)-1) ];
|
|
init_slope = (obj.deconvolution.input(end) -obj.deconvolution.input(1)) / length(t_ds);
|
|
|
|
%% perform search with initial params : slope = 0; pulse weight 1
|
|
|
|
final_params = fminsearch(@obj.evaluate_model, [init_slope init_params], o);
|
|
|
|
obj.deconvolution.params = final_params;
|
|
obj.deconvolution.output = obj.prf_convolve(obj.stick_model(final_params(2:end)),final_params(1));
|