supereeg.Model

class supereeg.Model(data=None, locs=None, template=None, numerator=None, denominator=None, n_subs=None, meta=None, date_created=None, rbf_width=20, save=None)[source]

Model data object for the supereeg package

This class holds your supereeg model. To create an instance, pass a list of brain objects and the model will be generated from those brain objects. You can also add your own model by passing a numpy array as your matrix and the corresponding locations. Alternatively, you can bypass creating a new model by passing numerator, denominator, locations, and n_subs (see parameters for details). Additionally, you can include a meta dictionary with any other information that you want to save with the model.

Parameters:
data : supereeg.Brain or list supereeg.Brain, supereeg.Nifti or list supereeg.Nifti, or Numpy.ndarray

A supereeg.Brain object or supereeg.Nifti object, list of objects, or a Numpy.ndarray of your model.

locs : pandas.DataFrame or np.ndarray

MNI coordinate (x,y,z) by number of electrode df containing electrode locations

template : filepath

Path to a template nifti file used to set model locations

numerator : Numpy.ndarray

(Optional) A locations x locations matrix comprising the sum of the log z-transformed correlation matrices over subjects. If used, must also pass denominator, locs and n_subs. Otherwise, numerator will be computed from the brain object data.

denominator : Numpy.ndarray

(Optional) A locations x locations matrix comprising the sum of the log (weighted) number of subjects contributing to each matrix cell. If used, must also pass numerator, locs and n_subs. Otherwise, denominator will be computed from the brain object data.

n_subs : int

The number of subjects used to create the model. Required if you pass numerator/denominator. Otherwise computed automatically from the data.

rbf_width : positive scalar

The width of the radial basis function (RBF) used as a spatial prior for smoothing estimates at nearby locations. (Default: 20)

meta : dict

Dict containing whatever you want: Initialized with a stability field {‘stable’:True}. This is changed to {‘stable’:False} after subtraction performed.

date created : str

Time created

save : None

Optional filename to save created model

Returns:
model : supereeg.Model instance

A model that can be used to infer timeseries from unknown locations

Attributes:
numerator : Numpy.ndarray

A locations x locations matrix comprising the sum of the log z-transformed correlation matrices over subjects

denominator : Numpy.ndarray

A locations x locations matrix comprising the log sum of the (weighted) number of subjects contributing to each matrix cell

n_subs : int

Number of subject used to create the model

Methods

get_locs() Returns the locations in the model
get_model([z_transform]) Returns a copy of the model in the form of a correlation matrix
get_slice(loc_inds[, inplace]) Indexes brain object data
info() Print info about the model object Prints the number of electrodes, number of subjects, date created, and any optional meta data.
plot_data([savefile, show]) Plot the supereeg model as a correlation matrix This function wraps seaborn’s heatmap and accepts any inputs that seaborn supports for models less than 2000x2000.
plot_locs([pdfpath]) Plots electrode locations from brain object
predict(bo[, nearest_neighbor, ...]) Takes a brain object and a ‘full’ covariance model, fills in all
save(fname[, compression]) Save method for the model object The data will be saved as a ‘mo’ file, which is a dictionary containing the elements of a model object saved in the hd5 format using deepdish.
set_locs(new_locs[, force_include_bo_locs]) update self.locs to a new set of locations (and blur the correlation matrix accordingly). if
update(data[, inplace]) Update a model with new data.
__init__(data=None, locs=None, template=None, numerator=None, denominator=None, n_subs=None, meta=None, date_created=None, rbf_width=20, save=None)[source]

Methods

__init__([data, locs, template, numerator, ...])
get_locs() Returns the locations in the model
get_model([z_transform]) Returns a copy of the model in the form of a correlation matrix
get_slice(loc_inds[, inplace]) Indexes brain object data
info() Print info about the model object Prints the number of electrodes, number of subjects, date created, and any optional meta data.
plot_data([savefile, show]) Plot the supereeg model as a correlation matrix This function wraps seaborn’s heatmap and accepts any inputs that seaborn supports for models less than 2000x2000.
plot_locs([pdfpath]) Plots electrode locations from brain object
predict(bo[, nearest_neighbor, ...]) Takes a brain object and a ‘full’ covariance model, fills in all
save(fname[, compression]) Save method for the model object The data will be saved as a ‘mo’ file, which is a dictionary containing the elements of a model object saved in the hd5 format using deepdish.
set_locs(new_locs[, force_include_bo_locs]) update self.locs to a new set of locations (and blur the correlation matrix accordingly). if
update(data[, inplace]) Update a model with new data.