Request access
The MRL model is gated. Request access, then log in:
From raw EEG to embeddings to insights
Request access
huggingface-cli login
Embed your EEG (one call)
import mne
from neuroencoder import MRL
raw = mne.io.read_raw_edf("recording.edf", preload=True)
model = MRL.from_pretrained()
embeddings = model.embed(
raw.get_data(),
sfreq=raw.info["sfreq"],
channel_names=raw.ch_names,
dim=192,
)
# -> numpy array, shape [N, 192], L2-normalized
# embeddings are L2-normalized, so cosine similarity is just a dot product
import numpy as np
sim = embeddings @ embeddings.T
top5 = np.argpartition(-sim, 5, axis=1)[:, :5] # 5 nearest for each epoch
# Compute once at the highest dim and slice later
full = model.embed(eeg, sfreq=256, channel_names=ch_names, dim=768)
compact = full[:, :48] / np.linalg.norm(full[:, :48], axis=1, keepdims=True)
# Default is a 1s sliding window. For one embedding per 30s window:
embeddings = model.embed(eeg, sfreq=256, channel_names=ch_names,
dim=192, stride_seconds=30.0)
images = ne.preprocess(epochs, sfreq=250, filter=False) # [N, 8, 7500] -> images
embeddings = model.predict(images, dim=192)