mne.Dipole

class mne.Dipole(times, pos, amplitude, ori, gof, name=None)

Dipole class for sequential dipole fits

Note

This class should usually not be instantiated directly, instead mne.read_dipole() should be used.

Used to store positions, orientations, amplitudes, times, goodness of fit of dipoles, typically obtained with Neuromag/xfit, mne_dipole_fit or certain inverse solvers. Note that dipole position vectors are given in the head coordinate frame.

Parameters:

times : array, shape (n_dipoles,)

The time instants at which each dipole was fitted (sec).

pos : array, shape (n_dipoles, 3)

The dipoles positions (m) in head coordinates.

amplitude : array, shape (n_dipoles,)

The amplitude of the dipoles (nAm).

ori : array, shape (n_dipoles, 3)

The dipole orientations (normalized to unit length).

gof : array, shape (n_dipoles,)

The goodness of fit.

name : str | None

Name of the dipole.

Notes

This class is for sequential dipole fits, where the position changes as a function of time. For fixed dipole fits, where the position is fixed as a function of time, use mne.DipoleFixed.

Methods

__getitem__(item) Get a time slice
__hash__() <==> hash(x)
__len__() The number of dipoles
copy() Copy the Dipoles object
crop([tmin, tmax]) Crop data to a given time interval
plot_amplitudes([color, show]) Plot the dipole amplitudes as a function of time
plot_locations(trans, subject[, ...]) Plot dipole locations as arrows
save(fname) Save dipole in a .dip file
__getitem__(item)

Get a time slice

Parameters:

item : array-like or slice

The slice of time points to use.

Returns:

dip : instance of Dipole

The sliced dipole.

__hash__() <==> hash(x)
__len__()

The number of dipoles

Returns:

len : int

The number of dipoles.

Examples

This can be used as:

>>> len(dipoles)  
10
copy()

Copy the Dipoles object

Returns:

dip : instance of Dipole

The copied dipole instance.

crop(tmin=None, tmax=None)

Crop data to a given time interval

Parameters:

tmin : float | None

Start time of selection in seconds.

tmax : float | None

End time of selection in seconds.

plot_amplitudes(color='k', show=True)

Plot the dipole amplitudes as a function of time

Parameters:

color: matplotlib Color

Color to use for the trace.

show : bool

Show figure if True.

Returns:

fig : matplotlib.figure.Figure

The figure object containing the plot.

plot_locations(trans, subject, subjects_dir=None, bgcolor=(1, 1, 1), opacity=0.3, brain_color=(1, 1, 0), fig_name=None, fig_size=(600, 600), mode='cone', scale_factor=0.01, colors=None, verbose=None)

Plot dipole locations as arrows

Parameters:

trans : dict

The mri to head trans.

subject : str

The subject name corresponding to FreeSurfer environment variable SUBJECT.

subjects_dir : None | str

The path to the freesurfer subjects reconstructions. It corresponds to Freesurfer environment variable SUBJECTS_DIR. The default is None.

bgcolor : tuple of length 3

Background color in 3D.

opacity : float in [0, 1]

Opacity of brain mesh.

brain_color : tuple of length 3

Brain color.

fig_name : tuple of length 2

Mayavi figure name.

fig_size : tuple of length 2

Mayavi figure size.

mode : str

Should be 'cone' or 'sphere' to specify how the dipoles should be shown.

scale_factor : float

The scaling applied to amplitudes for the plot.

colors: list of colors | None

Color to plot with each dipole. If None defaults colors are used.

verbose : bool, str, int, or None

If not None, override default verbose level (see mne.verbose).

Returns:

fig : instance of mlab.Figure

The mayavi figure.

save(fname)

Save dipole in a .dip file

Parameters:

fname : str

The name of the .dip file.