osl_ephys.glm.glm_base#
Classes#
A class for GLM-Epochs fitted to MNE-Python Raw objects. |
|
A class for group level GLM-Epochs fitted across mmultiple first-level |
|
A base class for sensor x frequency and sensor x time permutation tests computed from a |
|
A class holding the result for sensor x frequency or sensor x time max-stat permutation test computed |
|
A class holding the result for sensor x frequency or sensor x time cluster stats computed |
Functions#
|
Plot a GLM-Epochs contrast from cluster objects, with spatial line colouring and topograpies. |
|
Plot a GLM-Spectrum contrast with spatial line colouring. |
|
|
|
Plot sensor data with spatial line colouring. |
|
Get sensor colours from MNE info object. |
|
Decorate a spectrum plot. |
|
|
|
Plot sensor layout. |
|
Plot data with spatial line colouring. |
|
Plot a data map on a cortical surface. Wrapper for nilearn.plotting.plot_glass_brain. |
Module Contents#
- class osl_ephys.glm.glm_base.GLMBaseResult(model, design, info, data=None)[source]#
A class for GLM-Epochs fitted to MNE-Python Raw objects.
- compute_cohens_f2(reg_ind)[source]#
Compute a Cohens F-squared effect size associated with a specific regressor.
- Parameters:
reg_ind (int) – regressor of interest
- Returns:
Cohen’s F-squared values
- Return type:
array
- 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 epoch data in pickle? This is omitted by default to save disk space (Default value = False)
- class osl_ephys.glm.glm_base.GroupGLMBaseResult(model, design, info, config, fl_contrast_names=None, data=None)[source]#
A class for group level GLM-Epochs fitted across mmultiple first-level GLM-Epochs computed from MNE-Python Raw objects
- get_channel_adjacency(dist=40)[source]#
Return adjacency matrix of channels.
- Parameters:
dist (float) – Distance in mm between parcel centroids to consider neighbours. Only used if data is parcellated.
- Returns:
adjacency (scipy.sparse.csr_matrix) – The adjacency matrix.
ch_names (list of str) – The channel names.
- class osl_ephys.glm.glm_base.BaseSensorPerm[source]#
A base class for sensor x frequency and sensor x time permutation tests computed from a group level GLM-Spectrum.
- 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 epoch data in pickle? This is omitted by default to save disk space (Default value = False)
- class osl_ephys.glm.glm_base.SensorMaxStatPerm(glmsp, gl_con, fl_con=0, nperms=1000, tstat_args=None, metric='tstats', nprocesses=1, pooled_dims=(1, 2), tmin=None, tmax=None, fmin=None, fmax=None, picks=None)[source]#
Bases:
BaseSensorPermA class holding the result for sensor x frequency or sensor x time max-stat permutation test computed from a group level GLM-Spectrum or GLM-Epochs
- get_sig_clusters(thresh)[source]#
Return the significant clusters at a given threshold.
- Parameters:
thresh (float) – The threshold to consider a cluster significant eg 95 or 99
- Returns:
clusters – A list containing the significant clusters. Each list item contains a tuple of three items - the cluster statistic, the cluster percentile relative to the null and the spatial/spectral indices of the cluster.
obs_stat – The observed statistic.
- class osl_ephys.glm.glm_base.SensorClusterPerm(glmsp, gl_con, fl_con=0, nperms=1000, cluster_forming_threshold=3, tstat_args=None, metric='tstats', tmin=None, tmax=None, fmin=None, fmax=None, picks=None, nprocesses=1)[source]#
Bases:
BaseSensorPermA class holding the result for sensor x frequency or sensor x time cluster stats computed from a group level GLM-Spectrum or GLM-Epochs
- get_sig_clusters(thresh)[source]#
Return the significant clusters at a given threshold.
- Parameters:
thresh (float) – The threshold to consider a cluster significant eg 95 or 99
- Returns:
clusters – A list containing the significant clusters. Each list item contains a tuple of three items - the cluster statistic, the cluster percentile relative to the null and the spatial/spectral indices of the cluster.
obs_stat – The observed statistic.
- osl_ephys.glm.glm_base.plot_joint_clusters(xvect, erp, clusters, info, ax=None, times='auto', topo_scale='joint', lw=0.5, ylabel='Power', title='', ylim=None, xtick_skip=1, topo_prop=1 / 5, topo_cmap=None, topomap_args=None)[source]#
Plot a GLM-Epochs contrast from cluster objects, with spatial line colouring and topograpies.
- Parameters:
xvect (array_like) – Time vector
erp (array_like) – epochs values
clusters (list) – List of cluster objects
info (dict) – MNE-Python info object
ax ({None or axis handle}) – Axis to plot into (Default value = None)
times ({list, tuple or 'auto'}) – Which times to plot topos for (Default value = ‘auto’)
topo_scale ({'joint' or None}) – Whether to fix topomap colour scales across all topos (‘joint’) or leave them individual (Default value = ‘joint’)
lw (float) – Line width(Default value = 0.5)
ylabel (str) – Y-axis label(Default value = ‘Power’)
title (str) – Plot title(Default value = None)
ylim ({tuple or list}) – min and max values for y-axis (Default value = None)
xtick_skip (int) – Number of xaxis ticks to skip, useful for tight plots (Default value = 1)
topo_prop (float) – Proportion of plot dedicted to topomaps(Default value = 1/3)
topo_cmap ({None or matplotlib colormap}) – Colormap to use for plotting (Default is ‘RdBu_r’ if pooled topo data range is positive and negative, otherwise ‘Reds’ or ‘Blues’ depending on sign of pooled data range)
- osl_ephys.glm.glm_base.plot_sensor_erp(xvect, erp, info, ax=None, sensor_proj=False, xticks=None, xticklabels=None, lw=0.5, title=None, sensor_cols=True, ylabel=None, xtick_skip=1)[source]#
Plot a GLM-Spectrum contrast with spatial line colouring.
- Parameters:
xvect (array_like) – Vector of time values for x-axis
psd (array_like) – Array of spectrum values to plot
info (MNE Raw info) – Sensor info for spatial map
ax ({None or axis handle}) – Axis to plot into (Default value = None)
sensor_proj (bool) – Whether to plot a topomap inset (Default value = False)
xticks (array_like) – xtick positions (Default value = None)
xticklabels (array_like of str) – xtick labels (Default value = None)
lw (flot) – Line width(Default value = 0.5)
title (str) – Plot title(Default value = None)
sensor_cols (bool) – Whether to colour lines by sensor (Default value = True)
ylabel (str) – Y-axis label(Default value = None)
xtick_skip (int) – Number of xaxis ticks to skip, useful for tight plots (Default value = 1)
- osl_ephys.glm.glm_base.plot_sensor_data(xvect, data, info, ax=None, lw=0.5, xticks=None, xticklabels=None, sensor_cols=True, xtick_skip=1)[source]#
Plot sensor data with spatial line colouring.
- osl_ephys.glm.glm_base.get_mne_sensor_cols(info)[source]#
Get sensor colours from MNE info object.
- Parameters:
info (
mne.Info) – MNE-Python info object- Returns:
colors (array_like) – Array of RGB values for each sensor
pos (array_like) – Sensor positions
outlines (array_like) – Sensor outlines
- osl_ephys.glm.glm_base.decorate_spectrum(ax, ylabel='Amplitude')[source]#
Decorate a spectrum plot.
- Parameters:
ax (
matplotlib.axes) – Axis to plot intoylabel (str) – Y-axis label(Default value = ‘Power’)
- osl_ephys.glm.glm_base.plot_channel_layout(ax, info, size=30, marker='o')[source]#
Plot sensor layout.
- Parameters:
ax (
matplotlib.axes) – Axis to plot intoinfo (
mne.Info) – MNE-Python info objectsize (int) – Size of sensor § (Default value = 30)
marker (str) – Marker type (Default value = ‘o’)
- osl_ephys.glm.glm_base.plot_with_cols(ax, data, xvect, cols=None, lw=0.5)[source]#
Plot data with spatial line colouring.
- Parameters:
ax (
matplotlib.axes) – Axis to plot intodata (array_like) – Data to plot
xvect (array_like) – Vector of time values for x-axis
cols (array_like) – Array of RGB values for each sensor (Default value = None)
lw (flot) – Line width(Default value = 0.5)
- osl_ephys.glm.glm_base.plot_source_topo(data_map, parcellation_file=None, mask_file='MNI152_T1_8mm_brain.nii.gz', axis=None, cmap=None, vmin=None, vmax=None, alpha=0.7)[source]#
Plot a data map on a cortical surface. Wrapper for nilearn.plotting.plot_glass_brain.
- Parameters:
data_map (array_like) – Vector of data values to plot (nparc,)
parcellation_file (str) – Filepath of parcellation file to plot data on
mask_file (str) – Filepath of mask file to plot data on (Default value = ‘MNI152_T1_8mm_brain.nii.gz’)
axis ({None or axis handle}) – Axis to plot into (Default value = None)
cmap ({None or matplotlib colormap}) – Colormap to use for plotting (Default value = None)
vmin ({None or float}) – Minimum value for colormap (Default value = None)
vmax ({None or float}) – Maximum value for colormap (Default value = None)
alpha ({None or float}) – Alpha value for colormap (Default value = None)
- Returns:
image – AxesImage object
- Return type: