Volume (or Area) of a 2D Gaussian surface
Nasser
I'd like to calculate the area or the volume under the surface given by a 2D gaussian surface. Thanks to the "Gauss 2D" built-in fitting function, I think the most difficult has been done.
I don't want to integrate analytically, because it involves the "erf" function,and I'm sure a good approximation can be calculated numerically (e.g. Trapezes or Rectangles). Just for info, I've read that a good approximation of a 1D gaussian curve integral is :
a*sigma*sqrt(2*pi)
Where a is the amplitude of the gaussian curve. So what about a 2D curve ? Anyway...
The point is that IGOR enables us to integrate through the rows and the columns of a 2D wave, using /DIM.
However, I think that a double integral shall be performed, by caring about the bounds. Indeed, the bounds of the second integral might be expressed in function of the first integral. Moreover, I suppose that the coordinate system should be changed as well (cartesian --> cylindrical?)
Has anyone ever done such a thing please ? I mean, calculated the area or the volume of a Two-dimensionnal Gaussian?
Thanks in advance for your help !
Thank you
Edit --> NO ! It depends on the number of samples contained in the wave !!
June 17, 2010 at 05:47 am - Permalink
So this means you have already a wave with numbers representing the 2D gaussian?
So the sum should be ok, but you have to include the increment of the data points (i.e. the replacement for dx dy of the integral). Or what do you mean by the 'number of samples'?
June 17, 2010 at 07:18 am - Permalink
Yes sir !
The number of points.
I agree, for instance using the rectangular integration (Riemann sum):
Total Volume under the suface = SUM{z(x[i],y[j])*(x[i+1]-x[i])*(y[j+1]-y[j])}
Igor enables us to use INTEGRATE , e.g. :
Integrate /DIM=0 My2DWave /D=Integrated2DWaveThroughColumns
Integrate /DIM=1 Integrated2DWave /D=Integrated2DWaveThroughColsANDrows
It is supposed to be a double integral, which may return the volume under the surface, BUT I have a big doubt...
Any idea ? (I haven't practiced math for a while )
June 17, 2010 at 08:01 am - Permalink
From my understanding of the Integrate function, it's giving you the antiderivate of a 1D wave (or in your case, the antidreivate of a specific row or column).
To get a value out of the curve, the 'area' function is needed. So your procedure should do this:
For Column_i = 0 to last
TempWave[i] = Area(My2DWave[][Column_i])
Endfor
and then scaling the TempWave to the y scale of My2DWave and doing Area(TempWave) should give a (somewhat close) result.
I think this should do the job as a trapezoidal integration and is using the x and y scaling to do the increment.
If you want try the Riemann sum style, you can choose to write 2 nested for-loops with a summation, like:
Volume = 0
For...
For...
Volume += My2DWave[i][j] * DimDelta[My2DWave,0] * DimDelta[My2DWave,1]
Ok, and if you have no increment to work with, then you have to construct one, maybe from a available FWHM. But then this is actually getting close to obtaining the result from a gauss2D fit.
June 17, 2010 at 09:41 am - Permalink
If your surface is indeed Gaussian then integrating without using the analytic expression for the volume is unnecessarily painful. Can you explain what is wrong with using erf()?
A.G.
WaveMetrics, Inc.
June 17, 2010 at 10:33 am - Permalink
Thank you. I think your solution is equivalent to use the INTEGRATE functions across the rows and columns, provided we compute:
Antiderivative(x_max,y_max) - Antiderivative(x_min,y_min)
I will try your method tomorrow morning !
Hello A.G.,
Well, I haven't tried it yet. Actually, a numerical method could be generalized to any kind of function which can not be fitted ; Here is a concrete exemple : I would be interested in computing the volume under a surface consisting in several peaks z(x,y). Rather than detecting the peaks, fitting each of them, and integrate them analytically, it would be nice to integrate the whole volume at once.
To perform this, can we simply perform a double integrand as suggested above ?
Thank you very much
Best regards
June 17, 2010 at 12:17 pm - Permalink
If you are working with some arbitrary surface then the analytic description of the surface is irrelevant. In two-dimensions the Integrate operation is not going to help you much.
A simple and crude solution is to point you to Integrate1d() which has an example for handling 2D integration. The difficulty with this approach is that it is designed for integrating a user function. In your case the user function should simply sample your data set, using, for example, Interp2D().
HTH,
A.G.
WaveMetrics, Inc.
June 17, 2010 at 03:11 pm - Permalink
Since you have done a fit using the built-in Gauss2d fit function, the volume is easy to compute:
In terms of the W_coef wave, that's
Note that I have not included W_coef[0]. If it is non-zero, the volumn is infinite. Presumably you want the volumn above the baseline.
John Weeks
WaveMetrics, Inc.
support@wavemetrics.com
June 17, 2010 at 04:57 pm - Permalink
Indeed,
V = a*2*pi*sigma_x*sigma_y*sqrt(1-cov^2) is interesting for intergrating a 2Dgaussian because the volume under the baseline is not included in the calculation, contrary to the other methods.
I think the easiest way to quantify the volume under an arbitrary surface is to sum all the z(x,y) values, and multiply this by delta_x and delta_y, provided these steps are constant. Caution : One must care about the volume under the baseline.
Best Regards
June 18, 2010 at 05:33 am - Permalink
Is there a similar way in which to calculate the volume under a surface defined with the poly2D function? Specifically a three degree polynomial.
Regards
Jon
April 19, 2013 at 08:48 am - Permalink
John Weeks
WaveMetrics, Inc.
support@wavemetrics.com
April 19, 2013 at 08:59 am - Permalink