Formulas used by fit_gaussian_2D

Overview

This document will provide specific details of 2D-Gaussian equations used by the different method options within gaussplotR::fit_gaussian_2D().

method = "elliptical"

Using method = "elliptical" fits a two-dimensional, elliptical Gaussian equation to gridded data.

G(x, y) = Ao + A * eU/2

where G is the value of the 2D-Gaussian at each (x, y) point, Ao is a constant term, and A is the amplitude (i.e. scale factor).

The elliptical function, U, is:

U = (x′/a)2 + (y′/b)2

where a is the spread of Gaussian along the x-axis and b is the spread of Gaussian along the y-axis.

x and y are defined as:

x′ = (x − x0)cos(θ) − (y − y0)sin(θ) y′ = (x − x0)sin(θ) + (y − y0)cos(θ) where x0 is the center (peak) of the Gaussian along the x-axis, y0 is the center (peak) of the Gaussian along the y-axis, and θ is the rotation of the ellipse from the x-axis in radians, counter-clockwise.

Therefore, all together:

G(x, y) = Ao + A * e−((((x − x0)cos(θ) − (y − y0)sin(θ))/a)2 + (((x − x0)sin(θ) + (y − y0)cos(θ))/b)2)/2

Setting the constrain_orientation argument to a numeric will optionally constrain the value of θ to a user-specified value. If a numeric is supplied here, please note that the value will be interpreted as a value in radians. Constraining θ to a user-supplied value can lead to considerably poorer-fitting Gaussians and/or trouble with converging on a stable solution; in most cases constrain_orientation should remain its default: "unconstrained".

method = "elliptical_log"

The formula used in method = "elliptical_log" uses the modification of a 2D Gaussian fit used by Priebe et al. 20031.

G(x, y) = A * e(−(x − x0)2)/σx2 * e(−(y − y′(x)))/σy2

and

y′(x) = 2(Q + 1) * (x − x0) + y0 where A is the amplitude (i.e. scale factor), x0 is the center (peak) of the Gaussian along the x-axis, y0 is the center (peak) of the Gaussian along the y-axis, σx is the spread along the x-axis, σy is the spread along the y-axis and Q is an orientation parameter.

Therefore, all together:

G(x, y) = A * e(−(x − x0)2)/σx2 * e(−(y − (2(Q + 1) * (x − x0) + y0)))/σy2

This formula is intended for use with log2-transformed data.

Setting the constrain_orientation argument to a numeric will optionally constrain the value of Q to a user-specified value, which can be useful for certain kinds of analyses (see Priebe et al. 2003 for more). Keep in mind that constraining Q to a user-supplied value can lead to considerably poorer-fitting Gaussians and/or trouble with converging on a stable solution; in most cases constrain_orientation should remain its default: "unconstrained".

method = "circular"

This method uses a relatively simple formula:

G(x, y) = A * e(−(((x − x0)2/2σx2) + ((y − y0)2/2σy2)))

where A is the amplitude (i.e. scale factor), x0 is the center (peak) of the Gaussian along the x-axis, y0 is the center (peak) of the Gaussian along the y-axis, σx is the spread along the x-axis, and σy is the spread along the y-axis.

That’s all!

🐢


  1. Priebe NJ, Cassanello CR, Lisberger SG. The neural representation of speed in macaque area MT/V5. J Neurosci. 2003 Jul 2;23(13):5650-61. doi: 10.1523/JNEUROSCI.23-13-05650.2003.↩︎