mne.
SourceEstimate
(data, vertices=None, tmin=None, tstep=None, subject=None, verbose=None)¶Container for surface source estimates
Parameters:  data : array of shape (n_dipoles, n_times)  2tuple (kernel, sens_data)
vertices : list of two arrays
tmin : scalar
tstep : scalar
subject : str  None
verbose : bool, str, int, or None


Attributes
data 
Numpy array of source estimate data 
shape 
Shape of the data 
subject  (str  None) The subject name. 
times  (array of shape (n_times,)) The time vector. 
vertices  (list of two arrays of shape (n_dipoles,)) The indices of the dipoles in the left and right source space. 
Methods
__add__ (a) 

__div__ (a) 

__hash__ () <==> hash(x) 

__mul__ (a) 

__neg__ () 

__sub__ (a) 

bin (width[, tstart, tstop, func]) 
Returns a SourceEstimate object with data summarized over time bins 
center_of_mass ([subject, hemi, ...]) 
Compute the center of mass of activity 
copy () 
Return copy of SourceEstimate instance 
crop ([tmin, tmax]) 
Restrict SourceEstimate to a time interval 
expand (vertices) 
Expand SourceEstimate to include more vertices 
extract_label_time_course (labels, src[, ...]) 
Extract label time courses for lists of labels 
get_peak ([hemi, tmin, tmax, mode, ...]) 
Get location and latency of peak amplitude 
in_label (label) 
Returns a SourceEstimate object restricted to a label 
mean () 
Make a summary stc file with mean power between tmin and tmax. 
morph (subject_to[, grade, smooth, ...]) 
Morph a source estimate from one subject to another 
morph_precomputed (subject_to, vertices_to, ...) 
Morph source estimate between subjects using a precomputed matrix 
plot ([subject, surface, hemi, colormap, ...]) 
Plot SourceEstimates with PySurfer 
resample (sfreq[, npad, window, n_jobs, verbose]) 
Resample data 
save (fname[, ftype, verbose]) 
Save the source estimates to a file 
sqrt () 
Take the square root 
time_as_index (times[, use_rounding]) 
Convert time to indices 
to_data_frame ([picks, index, scale_time, ...]) 
Export data in tabular structure as a pandas DataFrame. 
to_original_src (src_orig[, subject_orig, ...]) 
Return a SourceEstimate from morphed source to the original subject 
transform (func[, idx, tmin, tmax, copy]) 
Apply linear transform 
transform_data (func[, idx, tmin_idx, tmax_idx]) 
Get data after a linear (time) transform has been applied 
__hash__
() <==> hash(x)¶bin
(width, tstart=None, tstop=None, func=<function mean>)¶Returns a SourceEstimate 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:  width : scalar
tstart : scalar  None
tstop : scalar  None
func : callable


Returns:  stc : instance of SourceEstimate

center_of_mass
(subject=None, hemi=None, restrict_vertices=False, subjects_dir=None, surf='sphere')¶Compute the center of mass of activity
This function computes the spatial center of mass on the surface as well as the temporal center of mass as in [R15].
Note
All activity must occur in a single hemisphere, otherwise
an error is raised. The “mass” of each point in space for
computing the spatial center of mass is computed by summing
across time, and viceversa for each point in time in
computing the temporal center of mass. This is useful for
quantifying spatiotemporal cluster locations, especially
when combined with mne.source_space.vertex_to_mni()
.
Parameters:  subject : string  None
hemi : int, or None
restrict_vertices : bool  array of int  instance of SourceSpaces
subjects_dir : str, or None
surf : str


Returns:  vertex : int
hemi : int
t : float

See also
References
[R15]  (1, 2) Larson and Lee, “The cortical dynamics underlying effective switching of auditory spatial attention”, NeuroImage 2012. 
copy
()¶Return copy of SourceEstimate instance
crop
(tmin=None, tmax=None)¶Restrict SourceEstimate to a time interval
Parameters:  tmin : float  None
tmax : float  None


data
¶Numpy array of source estimate data
expand
(vertices)¶Expand SourceEstimate to include more vertices
This will add rows to stc.data (zerofilled) and modify stc.vertices to include all vertices in stc.vertices and the input vertices.
Parameters:  vertices : list of array


Returns:  stc : instance of SourceEstimate

extract_label_time_course
(labels, src, mode='mean_flip', allow_empty=False, verbose=None)¶Extract label time courses for lists of labels
This function will extract one time course for each label. The way the time courses are extracted depends on the mode parameter.
Valid values for mode are:
 ‘mean’: Average within each label.
 ‘mean_flip’: Average within each label with sign flip depending on source orientation.
 ‘pca_flip’: Apply an SVD to the time courses within each label and use the scaled and signflipped first rightsingular vector as the label time course. The scaling is performed such that the power of the label time course is the same as the average pervertex time course power within the label. The sign of the resulting time course is adjusted by multiplying it with “sign(dot(u, flip))” where u is the first leftsingular vector, and flip is a singflip vector based on the vertex normals. This procedure assures that the phase does not randomly change by 180 degrees from one stc to the next.
 ‘max’: Max value within each label.
Parameters:  labels : Label  list of Label
src : list
mode : str
allow_empty : bool
verbose : bool, str, int, or None


Returns:  label_tc : array, shape=(len(labels), n_times)

See also
extract_label_time_course
get_peak
(hemi=None, tmin=None, tmax=None, mode='abs', vert_as_index=False, time_as_index=False)¶Get location and latency of peak amplitude
Parameters:  hemi : {‘lh’, ‘rh’, None}
tmin : float  None
tmax : float  None
mode : {‘pos’, ‘neg’, ‘abs’}
vert_as_index : bool
time_as_index : bool


Returns:  pos : int
latency : float  int

in_label
(label)¶Returns a SourceEstimate object restricted to a label
SourceEstimate contains the time course of activation of all sources inside the label.
Parameters:  label : Label  BiHemiLabel


mean
()¶Make a summary stc file with mean power between tmin and tmax.
Returns:  stc : instance of SourceEstimate


morph
(subject_to, grade=5, smooth=None, subjects_dir=None, buffer_size=64, n_jobs=1, subject_from=None, sparse=False, verbose=None)¶Morph a source estimate from one subject to another
Parameters:  subject_to : string
grade : int, list (of two arrays), or None
smooth : int or None
subjects_dir : string, or None
buffer_size : int
n_jobs : int
subject_from : string
sparse : bool
verbose : bool, str, int, or None


Returns:  stc_to : SourceEstimate

morph_precomputed
(subject_to, vertices_to, morph_mat, subject_from=None)¶Morph source estimate between subjects using a precomputed matrix
Parameters:  subject_to : string
vertices_to : list of array of int
morph_mat : sparse matrix
subject_from : string  None


Returns:  stc_to : SourceEstimate

plot
(subject=None, surface='inflated', hemi='lh', colormap='auto', time_label='auto', smoothing_steps=10, transparent=None, alpha=1.0, time_viewer=False, config_opts=None, subjects_dir=None, figure=None, views='lat', colorbar=True, clim='auto', cortex='classic', size=800, background='black', foreground='white', initial_time=None, time_unit=None)¶Plot SourceEstimates 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:  subject : str  None
surface : str
hemi : str, ‘lh’  ‘rh’  ‘split’  ‘both’
colormap : str  np.ndarray of float, shape(n_colors, 3  4)
time_label : str  callable  None
smoothing_steps : int
transparent : bool  None
alpha : float
time_viewer : bool
config_opts : dict
subjects_dir : str
figure : instance of mayavi.core.scene.Scene  list  int  None
views : str  list
colorbar : bool
clim : str  dict
cortex : str or tuple
size : float or pair of floats
background : matplotlib color
foreground : matplotlib color
initial_time : float  None
time_unit : ‘s’  ‘ms’


Returns:  brain : Brain

resample
(sfreq, npad='auto', window='boxcar', n_jobs=1, verbose=None)¶Resample data
Parameters:  sfreq : float
npad : int  str
window : string or tuple
n_jobs : int
verbose : bool, str, int, or None


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
(fname, ftype='stc', verbose=None)¶Save the source estimates to a file
Parameters:  fname : string
ftype : string
verbose : bool, str, int, or None


sfreq
¶Sample rate of the data
shape
¶Shape of the data
sqrt
()¶Take the square root
Returns:  stc : instance of SourceEstimate


time_as_index
(times, use_rounding=False)¶Convert time to indices
Parameters:  times : listlike  float  int
use_rounding : boolean


Returns:  index : ndarray

to_data_frame
(picks=None, index=None, scale_time=1000.0, scalings=None, copy=True, start=None, stop=None)¶Export data in tabular structure as a pandas DataFrame.
Columns and indices will depend on the object being converted. Generally this will include as much relevant information as possible for the data type being converted. This makes it easy to convert data for use in packages that utilize dataframes, such as statsmodels or seaborn.
Parameters:  picks : arraylike of int  None
index : tuple of str  None
scale_time : float
scalings : dict  None
copy : bool
start : int  None
stop : int  None


Returns:  df : instance of pandas.core.DataFrame

to_original_src
(src_orig, subject_orig=None, subjects_dir=None, verbose=None)¶Return a SourceEstimate from morphed source to the original subject
Parameters:  src_orig : instance of SourceSpaces
subject_orig : str  None
subjects_dir : string, or None
verbose : bool, str, int, or None


See also
Notes
New in version 0.10.0.
transform
(func, idx=None, tmin=None, tmax=None, copy=False)¶Apply linear transform
The transform is applied to each source time course independently.
Parameters:  func : callable
idx : array  None
tmin : float  int  None
tmax : float  int  None
copy : bool


Returns:  stcs : instance of SourceEstimate  list

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 “lcmv_epochs” do this automatically (if possible).
transform_data
(func, idx=None, tmin_idx=None, tmax_idx=None)¶Get data after a linear (time) transform has been applied
The transorm is applied to each source time course independently.
Parameters:  func : callable
idx : array  None
tmin_idx : int  None
tmax_idx : int  None


Returns:  data_t : ndarray

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 “lcmv_epochs” do this automatically (if possible).