> ## Documentation Index
> Fetch the complete documentation index at: https://docs.neuroencoder.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Quickstart

> From raw EEG to embeddings to insights

<Steps>
  <Step title="Install">
    ```bash theme={null}
    pip install neuroencoder
    ```
  </Step>

  <Step title="Request access">
    The MRL model is gated. [Request access](https://huggingface.co/Neuroencoder/epi-embedding), then log in:

    ```bash theme={null}
    huggingface-cli login
    ```
  </Step>

  <Step title="Embed your EEG (one call)">
    Any number of channels, any sampling rate. Returns a numpy array.

    ```python theme={null}
    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
    ```
  </Step>

  <Step title="Use the embeddings">
    ```python theme={null}
    import neuroencoder as ne
    ne.explore(embeddings)   # interactive Atlas
    ne.plot(embeddings)      # static UMAP
    ```
  </Step>
</Steps>

## Common patterns

### Find similar epochs

```python theme={null}
# 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
```

### Truncate without re-running the model

```python theme={null}
# 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)
```

### Non-overlapping epochs (for classification with epoch-level labels)

```python theme={null}
# 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)
```

### Skip preprocessing for already-clean data

```python theme={null}
images = ne.preprocess(epochs, sfreq=250, filter=False)   # [N, 8, 7500] -> images
embeddings = model.predict(images, dim=192)
```

See [Embeddings](/embeddings) for the model class details and [Visualization](/visualization) for the Atlas.
