From: Royi Avital on 1 Apr 2010 12:55 "Matt J " <mattjacREMOVE(a)THISieee.spam> wrote in message <hp1ek5$cev$1(a)fred.mathworks.com>... > "Royi Avital" <RoyiREMOVEAvital(a)yahoo.com> wrote in message <hp18i5$eeh$1(a)fred.mathworks.com>... > > > > > I do have the Optimization Pack. > > I can run SLM, yet can't figure how to you use it properly to my case. > ==================== > > Well, as I've been saying, we can't know either, since you haven't explained what caused your LSF to be truncated and explained only partially what it has to look like when extrapolated. If there is no smoothness requirement on the extrapolation (you haven't mentioned any) then you don't need the SLM tool at all. Just extrapolate with zeros. > > If you need to extrapolate in a way that preserves slope at the boundary, you might do something like this for the right hand side extrapolation > > y=[LSF(end), zeros(1,N-1)]; > x=1:N > weights=logical(y); > > prescription=slmset('decreasing,'on','minvalue',0,... > 'leftvalue',y(1),'leftminslope',something, 'leftmaxslope',something,'weights',weights); > > model=slmfit(x,y,prescription); Here is what I want: 1. For 'r' within the range an Interpolation would take place. 2. For r outside the range (7<abs(r)) an Extrapolation would take place. The extrapolation must be "Decreasing" and have no negative values. Of course the smoother the better. Zeros aren't good, it has be somewhat smooth. I used the SLM as follows: I took the interpolation made by the 'spline' option (Lets call that PSF). Then operated on it: SLMExtPSF = slmengine(r, PSF , 'Decreasing', 'on', 'leftminvalue', 0, 'rightminvalue', 0); PSFExt = slmeval(r, SLMExtPSF); As at the end I need a matrix of values. The only problem I encountered is changing the values of the Matrix within the Interpolation Range. Is there an option to control it? Is there a better way to use this Pack? Thanks.
From: Matt J on 1 Apr 2010 16:06 "Royi Avital" <RoyiREMOVEAvital(a)yahoo.com> wrote in message <hp2j5q$bnf$1(a)fred.mathworks.com>... > Here is what I want: > 1. For 'r' within the range an Interpolation would take place. > 2. For r outside the range (7<abs(r)) an Extrapolation would take place. The extrapolation must be "Decreasing" and have no negative values. Of course the smoother the better. Zeros aren't good, it has be somewhat smooth. ================ Then why not just fit your 1-dimensional PSF data with an exponentially decaying tail of the form k*exp(-a*x) where k and a are fitting parameters. The code below performs this fitting, choosing k and a so that the extrapolated tail has the same value and slope as PSF at the boundary point PSF(end) function PSFExt=ExtrapPSF(PSF,Rmax) %PSF - input PSF %Rmax - maximum radius in number of samples (default=ceil(r0*sqrt(2))) % where r0 is the maximum radius of given PSF samples. r0=length(PSF); if nargin<2, Rmax=ceil(r0*sqrt(2)); end slope=PSF(end)-PSF(end-1); endval=PSF(end); %fit a model k*exp(-a*r0) a=-slope/endval; k=endval/exp(-a*r0); Tail=@(r) k.*exp(-a.*r) PSFExt=[PSF, Tail(r0+1:Rmax)];
From: Matt J on 1 Apr 2010 16:15 "Matt J " <mattjacREMOVE(a)THISieee.spam> wrote in message <hp2ubc$ebb$1(a)fred.mathworks.com>... > Then why not just fit your 1-dimensional PSF data with an exponentially decaying tail of the form k*exp(-a*x) where k and a are fitting parameters. The code below performs this fitting, choosing k and a so that the extrapolated tail has the same value and slope as PSF at the boundary point PSF(end) > > > function PSFExt=ExtrapPSF(PSF,Rmax) > %PSF - input PSF > %Rmax - maximum radius in number of samples (default=ceil(r0*sqrt(2))) > % where r0 is the maximum radius of given PSF samples. > > > r0=length(PSF); > > if nargin<2, Rmax=ceil(r0*sqrt(2)); end > > > slope=PSF(end)-PSF(end-1); > > endval=PSF(end); > > > %fit a model k*exp(-a*r0) > a=-slope/endval; > k=endval/exp(-a*r0); > > Tail=@(r) k.*exp(-a.*r) > > PSFExt=[PSF, Tail(r0+1:Rmax)]; I should probably have used the notation LSF instead of PSF above. The code is intended to perform a 1-dimensional extrapolation of your LSF. After the extrapolation, you can interpolate LSFExt freely to obtain PSFExt
From: Matt J on 1 Apr 2010 17:05 "Royi Avital" <RoyiREMOVEAvital(a)yahoo.com> wrote in message <hp2j5q$bnf$1(a)fred.mathworks.com>... > Here is what I want: > 1. For 'r' within the range an Interpolation would take place. > 2. For r outside the range (7<abs(r)) an Extrapolation would take place. ================ It does not sound like a logical approach to try to selectively interpolate/extrapolate the 2D PSF. A more logical approach would be to first take your 1D data LSF and extend it via extrapolation so that it covers a sufficiently large range of 'r'. Call this extension LSFExt and the enlarged radius Rmax. The samples of PSF would then be obtained entirely by interpolation of LSFExt. Something like. PSF=interp1(0:Rmax, LSFExt, r(:));
From: Royi Avital on 2 Apr 2010 16:58
"Matt J " <mattjacREMOVE(a)THISieee.spam> wrote in message <hp2ubc$ebb$1(a)fred.mathworks.com>... > "Royi Avital" <RoyiREMOVEAvital(a)yahoo.com> wrote in message <hp2j5q$bnf$1(a)fred.mathworks.com>... > > > Here is what I want: > > 1. For 'r' within the range an Interpolation would take place. > > 2. For r outside the range (7<abs(r)) an Extrapolation would take place. The extrapolation must be "Decreasing" and have no negative values. Of course the smoother the better. Zeros aren't good, it has be somewhat smooth. > ================ > > Then why not just fit your 1-dimensional PSF data with an exponentially decaying tail of the form k*exp(-a*x) where k and a are fitting parameters. The code below performs this fitting, choosing k and a so that the extrapolated tail has the same value and slope as PSF at the boundary point PSF(end) > > > function PSFExt=ExtrapPSF(PSF,Rmax) > %PSF - input PSF > %Rmax - maximum radius in number of samples (default=ceil(r0*sqrt(2))) > % where r0 is the maximum radius of given PSF samples. > > > r0=length(PSF); > > if nargin<2, Rmax=ceil(r0*sqrt(2)); end > > > slope=PSF(end)-PSF(end-1); > > endval=PSF(end); > > > %fit a model k*exp(-a*r0) > a=-slope/endval; > k=endval/exp(-a*r0); > > Tail=@(r) k.*exp(-a.*r) > > PSFExt=[PSF, Tail(r0+1:Rmax)]; Because it holds only for this example. Not always the LSF would be a 1D Gaussian function. It could be any arbitrary function. For the other idea, If you pay attention that's exactly what I did using SLM. Yet the result I got has changed the PSF at points which coincident with the LSF. Which I prefer not to happen. |