gridcells.analysis.bumps
- bump tracking¶
Classes and functions for processing data related to bump attractors.
Classes¶
MLFit (mu, sigma2, ln_lh, err2) |
Maximum likelihood fit data holer. |
MLFitList ([mu, sigma2, ln_lh, err2, times]) |
A container for holding results of maximum likelihood fitting. |
MLGaussianFit (amplitude, mu_x, mu_y, sigma, ...) |
Gaussian fit performed by applying maximum likelihood estimator. |
MLGaussianFitList ([amplitude, mu_x, mu_y, ...]) |
A container for holding maximum likelihood Gaussian fits. |
SingleBumpPopulation (senders, times, sheet_size) |
A population of neurons that is supposed to form a bump on a twisted torus. |
SymmetricGaussianParams (amplitude, mu_x, ...) |
Parameters for the symmetric Gaussian function. |
Functions¶
fit_gaussian_tt (sig_f, i) |
Fit a 2D circular Gaussian function to a 2D signal using a maximum likelihood estimator. |
fit_gaussian_bump_tt (sig) |
Fit a 2D Gaussian onto a (potential) firing rate bump on the twisted torus. |
fit_maximum_lh (sig) |
Fit a maximum likelihood solution under Gaussian noise. |
-
class
gridcells.analysis.bumps.
MLFit
(mu, sigma2, ln_lh, err2)[source]¶ Bases:
object
Maximum likelihood fit data holer.
-
class
gridcells.analysis.bumps.
MLFitList
(mu=None, sigma2=None, ln_lh=None, err2=None, times=None)[source]¶ Bases:
gridcells.analysis.bumps.MLFit
,collections.abc.Sequence
A container for holding results of maximum likelihood fitting.
Can be accessed as a Sequence object.
-
class
gridcells.analysis.bumps.
MLGaussianFit
(amplitude, mu_x, mu_y, sigma, err2, ln_lh, lh_precision)[source]¶ Bases:
gridcells.analysis.bumps.SymmetricGaussianParams
Gaussian fit performed by applying maximum likelihood estimator.
-
class
gridcells.analysis.bumps.
MLGaussianFitList
(amplitude=None, mu_x=None, mu_y=None, sigma=None, err2=None, ln_lh=None, lh_precision=None, times=None)[source]¶ Bases:
gridcells.analysis.bumps.MLGaussianFit
,collections.abc.Sequence
A container for holding maximum likelihood Gaussian fits.
Can be accessed as a Sequence.
-
append_data
(d, t)[source]¶ d must be an instance of
MLGaussianFit
-
-
class
gridcells.analysis.bumps.
SingleBumpPopulation
(senders, times, sheet_size)[source]¶ Bases:
gridcells.analysis.spikes.TwistedTorusSpikes
A population of neurons that is supposed to form a bump on a twisted torus.
Parameters: senders : array_like
A an array of neurons’ IDs.
times : array_like
An array of spike times. Length must be the same as as <senders>.
sheet_size : A pair
A pair of X and Y dimensions of the torus.
-
bump_position
(tstart, tend, dt, win_len, full_err=True)[source]¶ Estimate bump positions during the simulation time:
- Estimates population firing rate for each bin.
- Apply the bump position estimation procedure to each of the population activity items.
Parameters: tstart, tend, dt, win_len : float
Start and end time, time step, and window length. See also
sliding_firing_rate()
.full_err : bool
If
True
, save the full error of fit. Otherwise a sum only.Returns: pos:list
MLGaussianFitList
A list of fitted Gaussian parameters
Notes
This method uses the Maximum likelihood estimator to fit the Gaussian function (
fit_gaussian_bump_tt()
)
-
uniform_fit
(tstart, tend, dt, win_len, full_err=True)[source]¶ Estimate the mean firing rate using maximum likelihood estimator (
fit_maximum_lh()
)- Uses
sliding_firing_rate()
. - Apply the estimator.
Parameters: tstart, tend, dt, win_len
As in
sliding_firing_rate()
.full_err : bool
If
True
, save the full error of fit. Otherwise a sum only.Returns: MLFitList
A list of fitted parameters.
- Uses
-
-
class
gridcells.analysis.bumps.
SymmetricGaussianParams
(amplitude, mu_x, mu_y, sigma, err2)[source]¶ Bases:
object
Parameters for the symmetric Gaussian function.
-
gridcells.analysis.bumps.
fit_gaussian_bump_tt
(sig)[source]¶ Fit a 2D Gaussian onto a (potential) firing rate bump on the twisted torus.
Parameters: sig : np.ndarray
2D firing rate map to fit. Axis 0 is the Y position. This will be passed directly to
fit_gaussian_tt()
.Returns: analysis.image.MLGaussianFit
Estimated values of the fit.
Notes
The function initialises the Gaussian fitting parameters to a position at the maximum of sig.
-
gridcells.analysis.bumps.
fit_gaussian_tt
(sig_f, i)[source]¶ Fit a 2D circular Gaussian function to a 2D signal using a maximum likelihood estimator.
The Gaussian is not generic: \(\sigma_x = \sigma_y = \sigma\), i.e. it is circular only.
The function fitted looks like this:
\[f(\mathbf{X}) = |A| \exp\left\{\frac{-|\mathbf{X} - \mathbf{\mu}|^2}{2\sigma^2}\right\}\]where \(|\cdot|\) is a distance metric on the twisted torus.
Parameters: sig_f : np.ndarray
A 2D array that specified the signal to fit the Gaussian onto. The dimensions of the torus will be inferred from the shape of sig_f: (dim.y, dim.x) = sig_f.shape.
i : SymmetricGaussianParams
Guassian initialisation parameters. The err2 field will be ignored.
Returns: Estimated values, together with maximum likelihood value and precision (inverse variance of noise: NOT of the fitted Gaussian).