# mne.MixedSourceEstimate¶

class mne.MixedSourceEstimate(data, vertices=None, tmin=None, tstep=None, subject=None, verbose=None)[source]

Container for mixed surface and volume source estimates.

Parameters
dataarray of shape (n_dipoles, n_times) | tuple, shape (2,)

The data in source space. The data can either be a single array or a tuple with two arrays: “kernel” shape (n_vertices, n_sensors) and “sens_data” shape (n_sensors, n_times). In this case, the source space data corresponds to np.dot(kernel, sens_data).

vertices

Vertex numbers corresponding to the data. The list contains arrays with one array per source space.

tminscalar

Time point of the first sample in data.

tstepscalar

Time step between successive samples in data.

subject

The subject name. While not necessary, it is safer to set the subject parameter to avoid analysis errors.

verbose

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

SourceEstimate

A container for surface source estimates.

VectorSourceEstimate

A container for vector source estimates.

VolSourceEstimate

A container for volume source estimates.

VolVectorSourceEstimate

A container for Volume vector source estimates.

Notes

New in version 0.9.0.

Attributes
subject

The subject name.

timesarray of shape (n_times,)

A timestamp for each sample.

vertices

Vertex numbers corresponding to the data. The list contains arrays with one array per source space.

dataarray of shape (n_dipoles, n_times)

Numpy array of source estimate data.

shapetuple

Shape of the data.

Methods

 __add__(self, a) Add source estimates. __div__(self, a) Divide source estimates. __hash__(self, /) Return hash(self). __mul__(self, a) Multiply source estimates. __neg__(self) Negate the source estimate. __sub__(self, a) Subtract source estimates. bin(self, width[, tstart, tstop, func]) Return a source estimate object with data summarized over time bins. copy(self) Return copy of source estimate instance. crop(self[, tmin, tmax, include_tmax]) Restrict SourceEstimate to a time interval. mean(self) Make a summary stc file with mean over time points. plot_surface(self, src[, subject, surface, …]) Plot surface source estimates with PySurfer. resample(self, sfreq[, npad, window, …]) Resample data. save(self, fname[, ftype, verbose]) Save the full source estimate to an HDF5 file. sqrt(self) Take the square root. sum(self) Make a summary stc file with sum over time points. time_as_index(self, times[, use_rounding]) Convert time to indices. to_data_frame(self[, index, scaling_time, …]) Export data in tabular structure as a pandas DataFrame. transform(self, func[, idx, tmin, tmax, copy]) Apply linear transform. transform_data(self, func[, idx, tmin_idx, …]) Get data after a linear (time) transform has been applied.
__add__(self, a)[source]

__div__(self, a)[source]

Divide source estimates.

__hash__(self, /)

Return hash(self).

__mul__(self, a)[source]

Multiply source estimates.

__neg__(self)[source]

Negate the source estimate.

__sub__(self, a)[source]

Subtract source estimates.

bin(self, width, tstart=None, tstop=None, func=<function mean at 0x7fc29f14a290>)[source]

Return a source estimate object with data summarized over time bins.

Time bins of width seconds. This method is intended for visualization only. No filter is applied to the data before binning, making the method inappropriate as a tool for downsampling data.

Parameters
widthscalar

Width of the individual bins in seconds.

tstart

Time point where the first bin starts. The default is the first time point of the stc.

tstop

Last possible time point contained in a bin (if the last bin would be shorter than width it is dropped). The default is the last time point of the stc.

funccallable()

Function that is applied to summarize the data. Needs to accept a numpy.array as first input and an axis keyword argument.

Returns
stc

The binned source estimate.

copy(self)[source]

Return copy of source estimate instance.

Returns
stcinstance of SourceEstimate

A copy of the source estimate.

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

Restrict SourceEstimate to a time interval.

Parameters
tmin

The first time point in seconds. If None the first present is used.

tmax

The last time point in seconds. If None the last present is used.

include_tmaxbool

If True (default), include tmax. If False, exclude tmax (similar to how Python indexing typically works).

New in version 0.19.

Returns
stcinstance of SourceEstimate

The cropped source estimate.

property data

Numpy array of source estimate data.

mean(self)[source]

Make a summary stc file with mean over time points.

Returns
stc

The modified stc.

plot_surface(self, src, subject=None, surface='inflated', hemi='lh', colormap='auto', time_label='time=%02.f ms', smoothing_steps=10, transparent=None, alpha=1.0, time_viewer='auto', subjects_dir=None, figure=None, views='lat', colorbar=True, clim='auto')[source]

Plot surface source estimates with PySurfer.

Note: PySurfer currently needs the SUBJECTS_DIR environment variable, which will automatically be set by this function. Plotting multiple SourceEstimates with different values for subjects_dir will cause PySurfer to use the wrong FreeSurfer surfaces when using methods of the returned Brain object. It is therefore recommended to set the SUBJECTS_DIR environment variable or always use the same value for subjects_dir (within the same Python session).

Parameters
srcSourceSpaces

The source spaces to plot.

subject

The subject name corresponding to FreeSurfer environment variable SUBJECT. If None stc.subject will be used. If that is None, the environment will be used.

surfacestr

The type of surface (inflated, white etc.).

hemistr, ‘lh’ | ‘rh’ | ‘split’ | ‘both’

The hemisphere to display. Using ‘both’ or ‘split’ requires PySurfer version 0.4 or above.

colormapstr | np.ndarray of float, shape(n_colors, 3 | 4)

Name of colormap to use. See plot_source_estimates.

time_labelstr

How to print info about the time instant visualized.

smoothing_stepsint

The amount of smoothing.

transparent

If True, use a linear transparency between fmin and fmid. None will choose automatically based on colormap type.

alphafloat

Alpha value to apply globally to the overlay.

time_viewerbool

Display time viewer GUI.

subjects_dir

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

figureinstance of mayavi.mlab.Figure | None

If None, the last figure will be cleaned and a new figure will be created.

views

View to use. See surfer.Brain.

colorbarbool

If True, display colorbar on scene.

clim

Colorbar properties specification. See plot_source_estimates.

Returns
braininstance of surfer.Brain

A instance of surfer.Brain from PySurfer.

resample(self, sfreq, npad='auto', window='boxcar', n_jobs=1, verbose=None)[source]

Resample data.

Parameters
sfreqfloat

New sample rate to use.

Amount to pad the start and end of the data. Can also be “auto” to use a padding that will result in a power-of-two size (can be much faster).

window

Window to use in resampling. See scipy.signal.resample().

n_jobsint

The number of jobs to run in parallel (default 1). Requires the joblib package.

verbose

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

Returns
stcinstance of SourceEstimate

The resampled source estimate.

Notes

For some data, it may be more accurate to use npad=0 to reduce artifacts. This is dataset dependent – check your data!

Note that the sample rate of the original data is inferred from tstep.

save(self, fname, ftype='h5', verbose=None)[source]

Save the full source estimate to an HDF5 file.

Parameters
fnamestr

The file name to write the source estimate to, should end in ‘-stc.h5’.

ftypestr

File format to use. Currently, the only allowed values is “h5”.

verbose

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

property sfreq

Sample rate of the data.

property shape

Shape of the data.

sqrt(self)[source]

Take the square root.

Returns
stcinstance of SourceEstimate

A copy of the SourceEstimate with sqrt(data).

sum(self)[source]

Make a summary stc file with sum over time points.

Returns
stc

The modified stc.

time_as_index(self, times, use_rounding=False)[source]

Convert time to indices.

Parameters
timeslist-like | float | int

List of numbers or a number representing points in time.

use_roundingbool

If True, use rounding (instead of truncation) when converting times to indices. This can help avoid non-unique indices.

Returns
indexndarray

Indices corresponding to the times supplied.

property times

A timestamp for each sample.

property tmin

The first timestamp.

to_data_frame(self, index=None, scaling_time=None, scalings=None, long_format=False, time_format='ms')[source]

Export data in tabular structure as a pandas DataFrame.

Vertices are converted to columns in the DataFrame. By default, an additional column “time” is added, unless index='time' (in which case time values form the DataFrame’s index).

Parameters
index‘time’ | None

Kind of index to use for the DataFrame. If None, a sequential integer index (pandas.RangeIndex) will be used. If 'time', a pandas.Float64Index, pandas.Int64Index, or pandas.TimedeltaIndex will be used (depending on the value of time_format). Defaults to None.

scaling_timeNone

Deprecated; use time_format instead. If you need to scale time values by a factor other than 1000 (seconds → milliseconds), create the DataFrame first, then scale its time column afterwards.

scalings

Scaling factor applied to the channels picked. If None, defaults to dict(eeg=1e6, mag=1e15, grad=1e13) — i.e., converts EEG to µV, magnetometers to fT, and gradiometers to fT/cm.

long_formatbool

If True, the DataFrame is returned in long format where each row is one observation of the signal at a unique combination of time point and vertex. Defaults to False.

time_format

Desired time format. If None, no conversion is applied, and time values remain as float values in seconds. If 'ms', time values will be rounded to the nearest millisecond and converted to integers. If 'timedelta', time values will be converted to pandas.Timedelta values. Defaults to 'ms'.

New in version 0.20.

Returns
dfinstance of pandas.DataFrame

A dataframe suitable for usage with other statistical/plotting/analysis packages.

transform(self, func, idx=None, tmin=None, tmax=None, copy=False)[source]

Apply linear transform.

The transform is applied to each source time course independently.

Parameters
funccallable()

The transform to be applied, including parameters (see, e.g., functools.partial()). The first parameter of the function is the input data. The first two dimensions of the transformed data should be (i) vertices and (ii) time. See Notes for details.

idx

Indices of source time courses for which to compute transform. If None, all time courses are used.

tmin

First time point to include (ms). If None, self.tmin is used.

tmax

Last time point to include (ms). If None, self.tmax is used.

copybool

If True, return a new instance of SourceEstimate instead of modifying the input inplace.

Returns
stcs

The transformed stc or, in the case of transforms which yield N-dimensional output (where N > 2), a list of stcs. For a list, copy must be True.

Notes

Transforms which yield 3D output (e.g. time-frequency transforms) are valid, so long as the first two dimensions are vertices and time. In this case, the copy parameter must be True and a list of SourceEstimates, rather than a single instance of SourceEstimate, will be returned, one for each index of the 3rd dimension of the transformed data. In the case of transforms yielding 2D output (e.g. filtering), the user has the option of modifying the input inplace (copy = False) or returning a new instance of SourceEstimate (copy = True) with the transformed data.

Applying transforms can be significantly faster if the SourceEstimate object was created using “(kernel, sens_data)”, for the “data” parameter as the transform is applied in sensor space. Inverse methods, e.g., “apply_inverse_epochs”, or “apply_lcmv_epochs” do this automatically (if possible).

transform_data(self, func, idx=None, tmin_idx=None, tmax_idx=None)[source]

Get data after a linear (time) transform has been applied.

The transform is applied to each source time course independently.

Parameters
funccallable()

The transform to be applied, including parameters (see, e.g., functools.partial()). The first parameter of the function is the input data. The first return value is the transformed data, remaining outputs are ignored. The first dimension of the transformed data has to be the same as the first dimension of the input data.

idx

Indicices of source time courses for which to compute transform. If None, all time courses are used.

tmin_idx

Index of first time point to include. If None, the index of the first time point is used.

tmax_idx

Index of the first time point not to include. If None, time points up to (and including) the last time point are included.

Returns
data_tndarray

The transformed data.

Notes

Applying transforms can be significantly faster if the SourceEstimate object was created using “(kernel, sens_data)”, for the “data” parameter as the transform is applied in sensor space. Inverse methods, e.g., “apply_inverse_epochs”, or “apply_lcmv_epochs” do this automatically (if possible).

property tstep

The change in time between two consecutive samples (1 / sfreq).