osl_ephys.glm.glm_epochs#

Classes#

GLMEpochsResult

A class for first-level GLM-Spectra fitted to MNE-Python Epochs objects

GroupGLMEpochs

A class for group level GLM-Spectra fitted across mmultiple first-level

Functions#

glm_epochs(config, epochs)

Compute a GLM-Epochs from an MNE-Python Epochs object.

group_glm_epochs(inspectra[, design_config, datainfo, ...])

Compute a group GLM-Epochs from a set of first-level GLM-Epochs.

read_mne_epochs(X[, picks])

Read in an MNE-Python Epochs object and convert it to a GLM data object.

read_glm_epochs(infile)

Read in a GLMEpochs object that has been saved as as a pickle.

Module Contents#

class osl_ephys.glm.glm_epochs.GLMEpochsResult(model, design, info, tmin=0, data=None, times=None)[source]#

Bases: osl_ephys.glm.glm_base.GLMBaseResult

A class for first-level GLM-Spectra fitted to MNE-Python Epochs objects

tmin = 0[source]#
times = None[source]#
save_pkl(outname, overwrite=True, save_data=False)[source]#

Save GLM-Epochs result to a pickle file.

Parameters:
  • outname (str) – Filename or full file path to write pickle to

  • overwrite (bool) – Overwrite previous file if one exists? (Default value = True)

  • save_data (bool) – Save epochs data in pickle? This is omitted by default to save disk space (Default value = False)

get_evoked_contrast(contrast=0, metric='copes')[source]#

Get the evoked response for a given contrast.

Parameters:
  • contrast (int) – Contrast index to return

  • metric ({'copes', or 'tsats'}) – Which metric to plot (Default value = ‘copes’)

Returns:

The evoked response for the contrast.

Return type:

mne.Evoked

plot_joint_contrast(contrast=0, metric='copes', title=None)[source]#

Plot the evoked response for a given contrast.

Parameters:
  • contrast (int) – Contrast index to return

  • metric ({'copes', or 'tsats'}) – Which metric to plot (Default value = ‘copes’)

  • title (str) – Title for the plot

class osl_ephys.glm.glm_epochs.GroupGLMEpochs(model, design, info, config, fl_contrast_names=None, data=None, tmin=0, times=None)[source]#

Bases: osl_ephys.glm.glm_base.GroupGLMBaseResult

A class for group level GLM-Spectra fitted across mmultiple first-level GLM-Spectra computed from MNE-Python Raw objects

tmin = 0[source]#
times = None[source]#
get_evoked_contrast(gcontrast=0, fcontrast=0, metric='copes')[source]#

Get the evoked response for a given contrast.

Parameters:
  • contrast (int) – Contrast index to return

  • metric ({'copes', or 'tsats'}) – Which metric to plot (Default value = ‘copes’)

Returns:

The evoked response for the contrast.

Return type:

mne.Evoked

plot_joint_contrast(gcontrast=0, fcontrast=0, metric='copes', title=None, joint_args=None)[source]#

Plot the evoked response for a given contrast.

Parameters:
  • contrast (int) – Contrast index to return

  • metric ({'copes', or 'tsats'}) – Which metric to plot (Default value = ‘copes’)

  • title (str) – Title for the plot

get_fl_contrast(fl_con)[source]#

Get the data from a single first level contrast.

Parameters:

fl_con (int) – First level contrast data index to return

Return type:

GLMEpochsResult instance containing a single first level contrast.

save_pkl(outname, overwrite=True, save_data=False)[source]#

Save GLM-Epochs result to a pickle file.

Parameters:
  • outname (str) – Filename or full file path to write pickle to

  • overwrite (bool) – Overwrite previous file if one exists? (Default value = True)

  • save_data (bool) – Save epochs data in pickle? This is omitted by default to save disk space (Default value = False)

osl_ephys.glm.glm_epochs.glm_epochs(config, epochs)[source]#

Compute a GLM-Epochs from an MNE-Python Epochs object.

Parameters:
  • config (glmtools.design.DesignConfig) – The design specification for the model

  • epochs (str, mne.Epochs) – The epochs object to use for the model

Return type:

GLMEpochsResult

osl_ephys.glm.glm_epochs.group_glm_epochs(inspectra, design_config=None, datainfo=None, metric='copes', baseline=None)[source]#

Compute a group GLM-Epochs from a set of first-level GLM-Epochs.

Parameters:
  • inspectra (list, tuple) – A list containing either the filepaths of a set of saved GLM-Epochs objects, or the GLM-Epochs objects themselves.

  • design_config (glmtools.design.DesignConfig) – The design specification for the group level model (Default value = None)

  • datainfo (dict) – Dictionary of data values to use as covariates. The length of each covariate must match the number of input GLM-Epochs (Default value = None)

  • metric ({'copes', or 'tsats'}) – Which metric to plot (Default value = ‘copes’)

Return type:

GroupGLMEpochs

osl_ephys.glm.glm_epochs.read_mne_epochs(X, picks=None)[source]#

Read in an MNE-Python Epochs object and convert it to a GLM data object.

Parameters:
  • X (str, mne.Epochs) – The epochs object to use for the model

  • picks (list) – List of channels to use for the model (Default value = None)

Returns:

The data object used to fit the model.

Return type:

glmtools.data.TrialGLMData

osl_ephys.glm.glm_epochs.read_glm_epochs(infile)[source]#

Read in a GLMEpochs object that has been saved as as a pickle.

Parameters:

infile (str) – Filepath of saved object

Return type:

GLMEpochsResult