gausscon.m

From Spinach Documentation Wiki
Jump to: navigation, search

Normalised Gaussian function in magnetic resonance notation and its convolution with a triangular function. The standard deviation is obtained from the full width at half-maximum as sigma=fwhm/(2*sqrt(2*log(2))), and the offsets are sorted in ascending order. Two offsets are treated as coincident when they differ by less than sqrt(eps) times the Euclidean norm of the offset vector, with eps used as the tolerance when that norm is zero.

A scalar offset, or three vertices that all coincide, give the plain Gaussian ampl*gaussfun(x-offs,fwhm). When the first two vertices coincide, or the last two do, the triangle is a right-angled one and the result is assembled from the Gaussian values at the two distinct vertices and the Gaussian integral between them, the latter written in terms of error functions. In the general case the triangle is split at its middle vertex, the first moment of the Gaussian is computed over each of the two segments, and the two contributions are weighted by the reciprocals of the products of the corresponding edge lengths. All branches return a curve of unit area at unit amplitude, and the arithmetic is elementwise in x.

Syntax

    y=gausscon(offs,ampl,fwhm,x)

Parameters

     offs - peak offset from zero - when this is a scalar,
            a Gaussian is returned; when this is a vector
            with three elements, a convolution with a tri-
            angular function is returned.

     ampl - amplitude multiplier, scalar

     fwhm - full width at half-maximum, scalar

        x - argument, array of any dimension

Outputs

        y - an array of values, same size as x

Notes

The three elements of offs are the vertices of the triangular function; they are sorted internally, and so their order in the input is immaterial.

A compiled implementation of the same function is supplied in kernel/line_shapes as gausscon.cpp with the corresponding MEX binaries; when those are on the path, Matlab calls the compiled version.

See also

gaussfun.m, lorentzcon.m, lorentzfun.m, fwhm2rlx.m, Kernel utilities

Version 2.13, authors: Ilya Kuprov