Deconvolution gives Inf results - MATLAB precision error?
Afficher commentaires plus anciens
Hi everyone,
I am trying to deconvolve a signal with a template:
Template=[2 5 6 3];
Events=[0 0 0 0 0 0 1 0 1 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0];
Signal=conv(Template, Events);
[RestoredEvents,Remainder]=deconv(Signal, Template);
The upper code works fine and RestoredEvents== Events.
If I increase the size of Template (1x600) and Events (1x5000), the deconvolution results in a RestoredEvents vector of zeros, at some point linearly increasing to inf and then NaNs. And I have no clue why. Interestingly, if the Events are spaced far enough from each other (not overlapping), it works fine again. As soon as there is one overlapping data point, the deconvolution results in nonsense.
In the MATLAB help for deconv it says:
[q,r] = deconv(v,u) deconvolves vector u out of vector v, using long division.
The quotient is returned in vector q and the remainder in vector r such that v = conv(u,q)+r
But the last equation does not hold true in my case. Could it be a precision problem? Or a MATLAB bug?
A note why I am doing this: In real life, "Signal" is real data from patch clamp experiments, "Template" is the form of a unitary postsynaptic potential, and "RestoredEvents" would be the result I want to have in order to know at which times postsynaptice potentials did occur.
Thanks for your help!
Maximilian
3 commentaires
Maitreyee Mordekar
le 2 Nov 2017
Hi Maximilian,
I was trying to reproduce the issue that you observe on my end. The following is the code that I am using:
Template=[2 5 6 3];
Events=[0 0 0 0 0 0 1 0 1 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0];
NewTemplate = repmat(Template,1,150);
NewEvents = repmat(Events,1,179);
NewSignal=conv(NewTemplate, NewEvents);
[NewRestoredEvents,NewRemainder]=deconv(NewSignal, NewTemplate);
The NewTemplate has dimension 1x600 whereas NewEvents has 1x5012 dimension. I used R2017a to execute this code. However, I could not observe this issue. I do obtain the expected result.
Can you share your code along with the large data so that I can check the output that you observe?
Maximilian Rüppell
le 3 Nov 2017
David Goodmanson
le 7 Nov 2017
Hi Maximilian,
After trying a few cases I believe that this is due to the limited precision of double precision arithmetic, as you suggested.
Réponse acceptée
Plus de réponses (1)
Bjorn Gustavsson
le 8 Nov 2017
0 votes
In the case where deconv is failing and you have access to the image processing toolbox you have the image deconvolution functions to try: deconvreg, deconvwnr and deconvlucy, all have (slightly different) means to regularize the deconvolution, if you have Gonzales (sp?) Woods (and Eddins) book on image processing it is "rather straightforward" to implement the two first.
HTH
Catégories
En savoir plus sur Logical dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!