mne.Dipole

class mne.Dipole(times, pos, amplitude, ori, gof, name=None, conf=None, khi2=None, nfree=None, verbose=None)[source]

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
timesarray, shape (n_dipoles,)

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

posarray, shape (n_dipoles, 3)

The dipoles positions (m) in head coordinates.

amplitudearray, shape (n_dipoles,)

The amplitude of the dipoles (Am).

oriarray, shape (n_dipoles, 3)

The dipole orientations (normalized to unit length).

gofarray, shape (n_dipoles,)

The goodness of fit.

namestr | None

Name of the dipole.

confdict

Confidence limits in dipole orientation for “vol” in m^3 (volume), “depth” in m (along the depth axis), “long” in m (longitudinal axis), “trans” in m (transverse axis), “qlong” in Am, and “qtrans” in Am (currents). The current confidence limit in the depth direction is assumed to be zero (although it can be non-zero when a BEM is used).

New in version 0.15.

khi2array, shape (n_dipoles,)

The χ^2 values for the fits.

New in version 0.15.

nfreearray, shape (n_dipoles,)

The number of free parameters for each fit.

New in version 0.15.

verbosebool, str, int, or None

If not None, override default verbose level (see mne.verbose() and Logging documentation for more).

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__(self, item)

Get a time slice.

__hash__(self, /)

Return hash(self).

__len__(self)

Return the number of dipoles.

copy(self)

Copy the Dipoles object.

crop(self[, tmin, tmax])

Crop data to a given time interval.

plot_amplitudes(self[, color, show])

Plot the dipole amplitudes as a function of time.

plot_locations(self, trans, subject[, …])

Plot dipole locations in 3d.

save(self, fname)

Save dipole in a .dip file.

__getitem__(self, item)[source]

Get a time slice.

Parameters
itemarray_like or slice

The slice of time points to use.

Returns
dipinstance of Dipole

The sliced dipole.

__hash__(self, /)

Return hash(self).

__len__(self)[source]

Return the number of dipoles.

Returns
lenint

The number of dipoles.

Examples

This can be used as:

>>> len(dipoles)  
10
copy(self)[source]

Copy the Dipoles object.

Returns
dipinstance of Dipole

The copied dipole instance.

crop(self, tmin=None, tmax=None)[source]

Crop data to a given time interval.

Parameters
tminfloat | None

Start time of selection in seconds.

tmaxfloat | None

End time of selection in seconds.

Returns
selfinstance of Dipole

The cropped instance.

plot_amplitudes(self, color='k', show=True)[source]

Plot the dipole amplitudes as a function of time.

Parameters
color: matplotlib Color

Color to use for the trace.

showbool

Show figure if True.

Returns
figmatplotlib.figure.Figure

The figure object containing the plot.

plot_locations(self, trans, subject, subjects_dir=None, mode='orthoview', coord_frame='mri', idx='gof', show_all=True, ax=None, block=False, show=True, verbose=None)[source]

Plot dipole locations in 3d.

Parameters
transdict

The mri to head trans.

subjectstr

The subject name corresponding to FreeSurfer environment variable SUBJECT.

subjects_dirNone | str

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

modestr

Currently only 'orthoview' is supported.

New in version 0.14.0.

coord_framestr

Coordinate frame to use, ‘head’ or ‘mri’. Defaults to ‘mri’.

New in version 0.14.0.

idxint | ‘gof’ | ‘amplitude’

Index of the initially plotted dipole. Can also be ‘gof’ to plot the dipole with highest goodness of fit value or ‘amplitude’ to plot the dipole with the highest amplitude. The dipoles can also be browsed through using up/down arrow keys or mouse scroll. Defaults to ‘gof’. Only used if mode equals ‘orthoview’.

New in version 0.14.0.

show_allbool

Whether to always plot all the dipoles. If True (default), the active dipole is plotted as a red dot and it’s location determines the shown MRI slices. The the non-active dipoles are plotted as small blue dots. If False, only the active dipole is plotted. Only used if mode equals ‘orthoview’.

New in version 0.14.0.

axinstance of matplotlib Axes3D | None

Axes to plot into. If None (default), axes will be created. Only used if mode equals ‘orthoview’.

New in version 0.14.0.

blockbool

Whether to halt program execution until the figure is closed. Defaults to False. Only used if mode equals ‘orthoview’.

New in version 0.14.0.

showbool

Show figure if True. Defaults to True. Only used if mode equals ‘orthoview’.

New in version 0.14.0.

verbosebool, str, int, or None

If not None, override default verbose level (see mne.verbose() and Logging documentation for more). Defaults to self.verbose.

Returns
figinstance of mayavi.mlab.Figure or matplotlib.figure.Figure

The mayavi figure or matplotlib Figure.

Notes

New in version 0.9.0.

save(self, fname)[source]

Save dipole in a .dip file.

Parameters
fnamestr

The name of the .dip file.