Zyphra Releases ZUNA1.1: An Apache 2.0 EEG Foundation Model With Variable-Length Inputs From 0.5 To 30 Seconds
This week, Zyphra launched ZUNA1.1 under the Apache 2.0 license. The EEG basis mannequin reconstructs, denoises, and upsamples information throughout arbitrary channel layouts. It builds on ZUNA1, the Zyphra’s earlier open EEG basis mannequin.
The important change is flexibility, not a soar in uncooked accuracy. Real EEG recordings are messy. Sessions range in size, and channels go noisy or drop out mid-session. Montages vary from four-electrode headbands to 256-channel analysis caps. ZUNA1 processed solely fastened five-second segments. ZUNA1.1 accepts variable-length inputs from 0.5 to 30 seconds.
What is ZUNA1.1?
To perceive that flexibility, begin with what the mannequin does.
ZUNA1.1 is a 380M-parameter masked diffusion autoencoder for scalp-EEG alerts. Given a subset of channels, it denoises current EEG segments and channels. It reconstructs lacking ones. It additionally predicts novel channel alerts given bodily coordinates on the scalp.
The parameter depend is unchanged from ZUNA1. It runs on a client GPU and works acceptably on CPU for a lot of workloads. Weights sit on Hugging Face; inference and preprocessing code sit on GitHub. Install with pip set up zuna. Zyphra additionally hosts a free browser EEG Playground, and ships all of this for analysis use solely.
How The Architecture Works
That flexibility rests on tokenization.
ZUNA is a transformer encoder–decoder diffusion autoencoder. It slices every channel into 0.125 second segments, which is 32 samples at 256 Hz. Each phase turns into a continuous-valued token. Tokens are serialized in channel × time order.
The positional encoding is the important thing thought. Each token carries a 4D rotary positional encoding over (x, y, z, t). That is the electrode’s 3D scalp coordinate together with its coarse-time index. Because place, not array index, tells the mannequin the place a channel sits, ZUNA is channel-agnostic. It accepts any electrode structure, and might generate alerts at positions by no means recorded. That functionality allows arbitrary channel upsampling by location.
The encoder compresses the sign right into a latent. That latent circumstances the decoder by way of adaptive-RMS norm. The decoder is skilled with a rectified-flow goal. ZUNA1.1’s architectural modifications focused coaching stability, corresponding to added normalization layers.
What Changed From ZUNA1
Since the structure stayed shut, the variations come from coaching.
1. Variable-length inputs (0.5–30 seconds): ZUNA1.1 samples a phase size per coaching instance, snapped to the 0.125 s token grid. Lengths are drawn throughout 4 bins, from very quick to lengthy. The center 1.5–10 s vary is oversampled, since it’s the most typical working level. Because token counts range, Zyphra packs a number of segments per batch as much as a set finances. Flex consideration with a sample-aware masks stops tokens attending throughout samples. One mannequin subsequently serves a 0.5 s snippet and a 30 s stretch with out reconfiguration.
2. A richer combination of reconstruction duties: ZUNA1 skilled on one dropout sample: uniformly random complete channels. ZUNA1.1 trains on 4. The first is whole-channel dropout, protecting sparse montages and useless electrodes. The second removes quick time stretches throughout each channel. The third removes these stretches from just some channels, clustering gaps in house and time. The fourth scatters lacking values throughout particular person factors.
3. Quality-aware preprocessing and a much bigger corpus: ZUNA1 made channel-quality calls on the whole-recording stage, discarding usable sign. ZUNA1.1 as a substitute computes a per-channel, per-second high quality rating, thresholded at load time. That grew the corpus from roughly 2M to roughly 3.5M channel-hours of public EEG information. Zyphra crew additionally precomputes two filter variants per recording: a 0.1–45 Hz bandpass, and a 0.01 Hz highpass together with notch. Generalizing throughout preprocessing methods is a acknowledged aim, not a benchmarked consequence.
The Results
Consequently, the query is whether or not flexibility value accuracy.
On held-out duties, ZUNA1.1 reaches higher or primarily the identical reconstruction NMSE as ZUNA1. Both clearly outperform classical spherical-spline interpolation from MNE. For honest comparability, these analysis units used precisely five-second samples.
Zyphra additionally ran a region-based check. Electrodes from one mind area are deleted, then reconstructed from the remaining seven. That setup is extra real looking than random channel dropping. ZUNA1.1 outperforms each spherical-spline and ZUNA1 there.
Interactive Explainer
To make these mechanics concrete, the demo beneath animates the pipeline finish to finish.
ZUNA1 vs ZUNA1.1
Taken collectively, the releases differ largely in coaching, not structure.
| Attribute | ZUNA1 | ZUNA1.1 |
|---|---|---|
| Parameters | 380M | 380M |
| Architecture | Transformer encoder–decoder diffusion autoencoder | Same, plus further normalization layers |
| Input size | Fixed 5 s | 0.5–30 s, snapped to 0.125 s grid |
| Token | 0.125 s / 32 samples at 256 Hz | Same |
| Positional encoding | 4D RoPE over (x, y, z, t) | Same |
| Decoder goal | Rectified movement | Rectified movement |
| Dropout schemes in coaching | 1 (uniform random whole-channel) | 4 (channel, time, channel×time, scattered) |
| Training corpus | ~2M channel-hours | ~3.5M channel-hours |
| Quality filtering | Whole-recording stage | Per-channel, per-second rating at load time |
| Preprocessing variants | Single | Two (0.1–45 Hz bandpass; 0.01 Hz highpass + notch) |
| License | Apache 2.0 | Apache 2.0 |
| Reconstruction NMSE | Baseline | Equal or higher |
Running It
Turning to apply, reconstruct_fif runs instantly on .fif recordsdata with no .pt round-trip. The older four-step pipeline nonetheless ships alongside it.
from zuna import reconstruct_fif
reconstruct_fif(
input_dir="fif_in",
output_dir="fif_out",
figures_dir="figures",
gpu_device=0, # GPU id, or "" for CPU
segment_sec=5.0, # window size; default is 5.0, not the complete 30 s
montage="standard_1020", # fallback, used provided that the file has no positions
repair_channels=["Cz"], # channel(s) to completely reconstruct
target_channel_count=["Fz", "Pz"], # add/upsample new channels by identify (or an int for auto)
bad_segments=[(5, 6), (10, 11, "C3")], # mark time spans dangerous (all channels, or one)
sample_steps=50, # diffusion steps; observe: not "diffusion_sample_steps"
)
Note the defaults. segment_sec is 5.0, so the 0.5–30 s vary wants setting explicitly. Electrode positions are learn from the file itself. The montage argument is simply a fallback when positions are absent, and channels with out 3D coordinates are dropped.
The reconstruction goal is a union. It combines the file’s personal MNE dangerous channels and BAD_ annotations with something requested above. Two directories are written. full_reconstruction/ holds mannequin output all over the place. hybrid/ retains the unique and infills solely inferred cells, plus a _mask.npz.
Use Cases With Examples
Because masking is now versatile, a number of sensible patterns open up.
- Dead electrode: Mark
repair_channels=["Cz"]to rebuild the channel from its neighbours. - Motion artifact in a trial: Pass
bad_segments=[(10, 11, "C3")]to scrub one span on one channel. - Headband upsampling: Feed 4 electrodes, then request further
standard_1005positions. - UI-driven cleansing: Supply per-file masks by way of
mask_dir, unioned into the goal.
(*30*)
Check out the Model weight, GitHub Repo and Technical details. Also, be at liberty to observe us on Twitter and don’t neglect to hitch our 150k+ML SubReddit and Subscribe to our Newsletter. Wait! are you on telegram? now you can join us on telegram as well.
Need to associate with us for selling your GitHub Repo OR Hugging Face Page OR Product Release OR Webinar and so on.? Connect with us
The publish Zyphra Releases ZUNA1.1: An Apache 2.0 EEG Foundation Model With Variable-Length Inputs From 0.5 To 30 Seconds appeared first on MarkTechPost.
