mne-plsc#

mne-plsc is a library for partial least squares correlation (PLSC) analysis of M/EEG data in Python, integrated with the MNE-Python library. The basic computations are performed by the pyplsc library, and the documentation of that library contains some background on the PLSC technique.

Installation#

mne-plsc can be installed from PyPI via:

pip install mne-plsc

Quickstart#

The main functions for model fitting are fit_mc, fit_beh, and fit_within_beh. These return objects whose methods can be used for permutation testing, cluster analysis, and visualization. The typical workflow would be:

1. Fit and visualize model#

Perform the initial decomposition and check the patterns of saliences.

from mne_plsc import fit_mc
mod = fit_mc(epochs, condition)
mod.plot_lv(0)

2. Permutation testing#

Evaluate which latent variables are significant.

mod.permute(1000)
print(model.summary())

3. Cluster analysis#

Perform bootstrap resampling to estimate brain salience z-scores, then cluster strong saliences (e.g., \(|z| > 2\)).

mod.bootstrap(1000)
mod.cluster(threshold=2)

4. Visualize cluster(s)#

Examine the temporal/spectral/spatial distribution of the major clusters for a given set of brain saliences.

mod.plot_cluster_sizes(lv_idx=0)
mod.plot_cluster(lv_idx=0, cluster_idx=0)

5. Extract and export data in cluster(s)#

For further analysis, we can extract data at cluster peaks (or averages within clusters) and export to a spreadsheet.

df = mod.get_cluster_data(lv_idx=[0, 1, 2], cluster_idx=[0, 1])
df.to_csv('cluster-data.csv')

See the examples for more details.