Skip to main content

Minimal Python implementation of lmeEEG for random-intercept mass-univariate M/EEG analysis

Project description

LmeEEG

Minimal Python package implementing the core lmeEEG workflow for epoched M/EEG data with random intercepts:

  1. parse a mixed-model style formula at the API edge,
  2. fit a random-intercept mixed model at each channel × timepoint,
  3. subtract the fitted random effects to obtain marginal EEG,
  4. run fast mass-univariate OLS on the marginalized data,
  5. perform max-stat, cluster, or TFCE correction.

Current scope

  • One grouping factor in the public API
  • Random intercept only
  • Trial-wise epoched data shaped (n_observations, n_channels, n_times)
  • Cluster / TFCE correction via MNE-Python when installed
  • Tiny simulation utilities for recovery / null checks

Not yet included

  • Random slopes
  • Two grouping factors in the public API
  • Real-data validation workflows
  • Parallel / distributed optimization

Basic example

import numpy as np
import pandas as pd

from lmeeeg.api.fit import fit_lmm_mass_univariate
from lmeeeg.api.infer import permute_fixed_effect
from lmeeeg.simulation.generator import simulate_random_intercept_dataset

simulated = simulate_random_intercept_dataset(
    n_subjects=10,
    n_trials_per_subject=12,
    n_channels=4,
    n_times=25,
    effect_channels=[1, 2],
    effect_times=range(8, 14),
    beta=0.8,
    seed=13,
)

fit_result = fit_lmm_mass_univariate(
    eeg=simulated.eeg,
    metadata=simulated.metadata,
    formula="y ~ condition + latency + (1|subject)",
    variable_types={
        "condition": "categorical",
        "latency": "numeric",
        "subject": "group",
    },
)

inference = permute_fixed_effect(
    fit_result=fit_result,
    effect="condition[T.B]",
    correction="maxstat",
    n_permutations=200,
    seed=13,
)

print(inference.corrected_p_values.shape)

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

lmeeeg-0.1.0.tar.gz (18.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

lmeeeg-0.1.0-py3-none-any.whl (27.9 kB view details)

Uploaded Python 3

File details

Details for the file lmeeeg-0.1.0.tar.gz.

File metadata

  • Download URL: lmeeeg-0.1.0.tar.gz
  • Upload date:
  • Size: 18.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.0

File hashes

Hashes for lmeeeg-0.1.0.tar.gz
Algorithm Hash digest
SHA256 f63e1881e0999b15963cec8d896d694acc6d2a4748737ced8de18e59cccbe7ec
MD5 a00f6073d03be58705d4b17ae49c336c
BLAKE2b-256 01a636ff348f20068a05fed5c17ac7a8165d349286debfef08c666cf5d166c08

See more details on using hashes here.

File details

Details for the file lmeeeg-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: lmeeeg-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 27.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.0

File hashes

Hashes for lmeeeg-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 b7be5c1ade5ce23b117a45dc3ad9f4e3fd558d6365d83c97d975351e985af710
MD5 441146b8a4ecec7a9fc4b292faa9f038
BLAKE2b-256 c312505aa148118393107507043a05475906357ac98807d72f0360cdc33bca60

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page