sesameeg.Particle

class sesameeg.Particle(n_verts, lam, dip_mom_std=None, prior_locs=None, fixed_ori=False, hyper_q=False)[source]

Particle class for SESAME, used to store a single particle of an empirical pdf.

Parameters:
n_vertsint

The number of the points in the given brain discretization.

lamfloat

The parameter of the prior Poisson pdf of the number of dipoles.

dip_mom_stdfloat

The standard deviation of the prior of the dipole moment.

hyper_qbool

If True use hyperprior in dipole strength

Attributes:
n_dipsint

The number of dipoles in the particle.

dipolesndarray of instances of Dipole, shape(n_dips,)

The particle’s dipoles.

loglikelihood_unitfloat

The logarithm of the marginal likelihood, evaluated in the particle.

priorfloat

The prior pdf, evaluated in the particle.

add_dipole(n_verts, num_dip=1)[source]

Add new dipole(s) to the particle.

Parameters:
n_vertsint

The number of the points in the given brain discretization.

num_dipint

The number of dipoles to add.

compute_loglikelihood_unit(r_data, lead_field, noise_std=None)[source]

Evaluates the logarithm of the marginal likelihood in the present particle.

Parameters:
r_datandarray of float, shape (n_sens, n_ist)

The real part of the data; n_sens is the number of sensors and n_ist is the number of time-points or of frequencies.

lead_fieldndarray of float, shape (n_sens x n_comp*n_verts)

The leadfield matrix. (n_comp = 1, if fixed orientation, 3, if free orientation)

noise_stdfloat

The standard deviation of the noise distribution.

Returns:
loglikelihood_unitfloat

The logarithm of the likelihood function in the present particle.

compute_prior(lam)[source]

Evaluate the prior pdf in the present particle.

Parameters:
lamfloat

Parameter of the Poisson probability distribution used for determining the number of dipoles in the particle.

Returns:
priorfloat

The prior pdf evaluated in the present particle.

evol_n_dips(n_verts, r_data, lead_field, max_n_dips, lklh_exp, noise_std, lam, q_birth=0.3333333333333333, q_death=0.05)[source]
Perform a Reversible Jump Markov Chain Monte Carlo step in order

to explore the “number of sources” component of the state space. Recall that we are working in a variable dimension model.

Parameters:
n_vertsint

The number of the points in the given brain discretization.

r_datandarray of float, shape (n_sens, n_ist)

The real part of the data; n_sens is the number of sensors and n_ist is the number of time-points or of frequencies.

lead_fieldndarray of float, shape (n_sens x n_comp*n_verts)

The leadfield matrix. (n_comp = 1, if fixed orientation, 3, if free orientation)

max_n_dipsint

The maximum number of dipoles allowed in a particle.

lklh_expfloat

This number represents a point in the sequence of artificial distributions used in SESAME.

noise_stdfloat

The standard deviation of the noise distribution.

lamfloat

Parameter of the Poisson probability distribution used for determining the number of dipoles in the particle.

q_birthfloat

Probability of proposing to add a dipole. We recommend to use the default value q_birth = 1/3.

q_deathfloat

Probability of proposing to remove a dipole. We recommend to use the default value q_death = 1/20.

Returns:
selfinstance of Particle

The possibly modified particle instance.

evol_single_loc(dip_idx, neigh, neigh_p, r_data, lead_field, lklh_exp, noise_std, lam)[source]
Perform a Markov Chain Monte Carlo step in order to explore the

dipole location component of the state space. The dipole is allowed to move only to a restricted set of brain points, called “neighbours”, with a probability that depends on the point.

Parameters:
dip_idxint

index of the Particle.dipoles array.

neighndarray of int

The neighbours of each point in the brain discretization.

neigh_pndarray of float

The neighbours’ probabilities.

r_datandarray of float, shape (n_sens, n_ist)

The real part of the data; n_sens is the number of sensors and n_ist is the number of time-points or of frequencies.

lead_fieldndarray of float, shape (n_sens x n_comp*n_verts)

The leadfield matrix. (n_comp = 1, if fixed orientation, 3, if free orientation)

lklh_expfloat

This number represents a point in the sequence of artificial distributions used in SESAME.

noise_stdfloat

The standard deviation of the noise distribution.

lamfloat

Parameter of the Poisson probability distribution used for determining the number of dipoles in the particle.

Returns:
selfinstance of Particle

The possibly modified particle instance.

remove_dipole(diprip)[source]

Remove a dipole from the particle.

Parameters:
dipripint

The index representing the dipoles array entry to be removed.