SYNTOLOGY HomeExplorerAtlasCodeMethodologyAboutDevelopersFeedPricing
Paper · 2403.07721 · 2024

Visual Decoding and Reconstruction via EEG Embeddings with Guided Diffusion

arXiv · PDF · Open in the Atlas

Code that ran

5 of 6 samples (functions and classes) lifted from this paper's linked repositories executed on a synthesized input in Syntology's jail (0 of them constructed an object rather than computing a result; 1 honoured the contract we drafted, 0 violated it and 0 have no contract verdict; 4 failures of our instrument; 1 no recorded run), measured 2026-11-23; repository links from the Papers with Code archive attributed under CC BY-SA, no affiliation; bodies inline only under a permissive licence as GitHub detects it. Not a reproduction of the paper's results.

"Ran" means the function executed on a synthesized input and returned a value. It is not a reproduction of the paper's results. This record, dated, as JSON: /api/ran/2403.07721.json · badge: /api/ran/2403.07721.svg

Each repository's role is a label: a classifier's output recorded on the link, or, where no role is recorded, what the Papers with Code archive marked. The line under it names its basis. Neither says who wrote the code.

RepositoryRoleRan
dongyangli-del/eeg_image_decode canonical (classifier label)
classifier basis: classifier_2025
5 ran · 0 no recorded run
nzwang/neural-mcrl reimplementation (classifier label)
classifier basis: classifier_2025
0 ran · 1 no recorded run
FunctionStatusWhere it lives
evaluate_model Ran
ran; our contract draft was wrong, not the code
dongyangli-del/eeg_image_decode/Generation/ATMS_reconstruction.py
code served (permissive licence) · get_code("dde08c57d862ec73")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API) and returned tuple, ndim 1, dtype family float; no output shape is stated. The image it ran in was not recorded. If your copy returns the same type and ndim on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import torch
from torch import nn
import random

torch.manual_seed(0)

# Create a minimal EEG model that satisfies the function's usage
class MinimalEEGModel(nn.Module):
    def __init__(self, eeg_input_dim=4, feature_dim=8, num_subjects=5):
        super().__init__()
        self.eeg_encoder = nn.Linear(eeg_input_dim, feature_dim)
        self.subject_embedding = nn.Embedding(num_subjects, feature_dim)
        self.logit_scale = nn.Parameter(torch.tensor(1.0))
        
    def forward(self, eeg_data, subject_ids):
        # eeg_data: (batch_size, eeg_input_dim)
        # subject_ids: (batch_size,)
        eeg_features = self.eeg_encoder(eeg_data)
        subject_features = self.subject_embedding(subject_ids)
        return eeg_features + subject_features
    
    def loss_func(self, eeg_features, other_features, logit_scale):
        # Simple contrastive loss
        logits = logit_scale * torch.mm(eeg_features, other_features.T)
        labels = torch.arange(logits.size(0), device=logits.device)
        loss = nn.functional.cross_entropy(logits, labels)
        return loss

# Create tiny tensors for text and image features (200 classes, 8 dim each)
num_classes = 200
feature_dim = 8
text_features_all = torch.randn(num_classes, feature_dim)
img_features_all = torch.randn(num_classes, feature_dim)

# Create a dataloader with 2 batches
batch_size = 2
eeg_dim = 4

def create_batch():
    eeg_data = torch.randn(batch_size, eeg_dim)
    labels = torch.randint(0, num_classes, (batch_size,))
    text = ["sample_text"] * batch_size
    text_features = torch.randn(batch_size, feature_dim)
    img = ["sample_img"] * batch_size
    img_features = torch.randn(batch_size, feature_dim)
    return (eeg_data, labels, text, text_features, img, img_features)

dataloader = [create_batch(), create_batch()]

# Create model
eeg_model = MinimalEEGModel(eeg_input_dim=eeg_dim, feature_dim=feature_dim, num_subjects=5)

# Build ARGS dict
ARGS = {
    "sub": "subject_1",
    "eeg_model": eeg_model,
    "dataloader": dataloader,
    "device": torch.device("cpu"),
    "text_features_all": text_features_all,
    "img_features_all": img_features_all,
    "k": 50,
    "config": {}
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
torch — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type tuple, ndim 1, dtype family float — a tuple output has no array shape of its own; none is stated
dtype family
int means an integer dtype; float means any other dtype the instrument saw, bool and complex included (fixture_check.py records only these two families)
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
evaluate_model Ran
ran; our contract draft was wrong, not the code
dongyangli-del/eeg_image_decode/Retrieval/ATMS_retrieval.py
code served (permissive licence) · get_code("a8f9f460931bbeb6")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API) and returned tuple, ndim 1, dtype family float; no output shape is stated. The image it ran in was not recorded. If your copy returns the same type and ndim on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import torch
import torch.nn as nn
import random

torch.manual_seed(0)
random.seed(0)

# Create a small mock EEG model
class MockEEGModel(nn.Module):
    def __init__(self):
        super().__init__()
        self.linear = nn.Linear(8, 4)  # 8 input features -> 4 output features
        self.logit_scale = nn.Parameter(torch.tensor(1.0))
        
    def forward(self, eeg_data, subject_ids):
        # eeg_data shape: (batch_size, 8)
        # Returns shape: (batch_size, 4)
        return self.linear(eeg_data)
    
    def loss_func(self, eeg_features, ref_features, logit_scale):
        # Simple contrastive loss mock
        logits = logit_scale * eeg_features @ ref_features.T
        labels = torch.arange(logits.size(0), device=logits.device)
        loss = nn.functional.cross_entropy(logits, labels)
        return loss

# Create mock dataloader
# Each batch: (eeg_data, labels, text, text_features, img, img_features)
def create_mock_batch():
    batch_size = 2
    eeg_data = torch.randn(batch_size, 8)  # 8-dim EEG data
    labels = torch.tensor([0, 1], dtype=torch.long)  # 2 different labels
    text = ["sample_text_0", "sample_text_1"]
    text_features = torch.randn(batch_size, 4)  # 4-dim text features
    img = ["sample_img_0", "sample_img_1"]
    img_features = torch.randn(batch_size, 4)  # 4-dim image features
    return (eeg_data, labels, text, text_features, img, img_features)

# Create dataloader with 2 batches
dataloader = [create_mock_batch() for _ in range(2)]

# Create all features for the entire dataset (must have at least k classes)
num_classes = 10
text_features_all = torch.randn(num_classes, 4)  # 10 classes, 4-dim features
img_features_all = torch.randn(num_classes, 4)   # 10 classes, 4-dim features

ARGS = {
    'sub': 'subject_1',
    'eeg_model': MockEEGModel(),
    'dataloader': dataloader,
    'device': torch.device('cpu'),
    'text_features_all': text_features_all,
    'img_features_all': img_features_all,
    'k': 10,
    'config': {}
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
torch — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type tuple, ndim 1, dtype family float — a tuple output has no array shape of its own; none is stated
dtype family
int means an integer dtype; float means any other dtype the instrument saw, bool and complex included (fixture_check.py records only these two families)
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
extract_id_from_string Ran
ran, honoured the contract we drafted
dongyangli-del/eeg_image_decode/Generation/ATMS_reconstruction.py
code served (permissive licence) · get_code("df2981298d15124f")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API) and returned int, ndim 0, dtype family int, shape () as a later run recorded it. The image it ran in was not recorded. If your copy returns the same type, ndim and shape on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import re

def extract_id_from_string(s):
    match = re.search('\\d+$', s)
    if match:
        return int(match.group())
    return None

ARGS = {
    's': 'model_v42'
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
none outside the standard library — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type int, ndim 0, dtype family int, shape () — shape () as a later run recorded it
dtype family
int means an integer dtype; float means any other dtype the instrument saw, bool and complex included (fixture_check.py records only these two families)
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
train_model Ran
ran; our contract draft was wrong, not the code
dongyangli-del/eeg_image_decode/Generation/ATMS_reconstruction.py
code served (permissive licence) · get_code("747fbfe5fbb06b48")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API) and returned tuple. The image it ran in was not recorded. If your copy returns the same type on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import torch
from torch import nn

torch.manual_seed(0)

# Build a minimal EEG model that satisfies the function's usage
class MinimalEEGModel(nn.Module):
    def __init__(self):
        super().__init__()
        self.linear = nn.Linear(4, 5)  # eeg_data dim 4 -> features dim 5
        self.logit_scale = nn.Parameter(torch.tensor(1.0))
        
    def forward(self, eeg_data, subject_ids):
        # eeg_data: (batch, 4), subject_ids: (batch,)
        return self.linear(eeg_data)
    
    def loss_func(self, features, target_features, logit_scale):
        # Contrastive loss - simple cosine similarity based
        logits = logit_scale * features @ target_features.T
        labels = torch.arange(logits.shape[0])
        loss_i = torch.nn.functional.cross_entropy(logits, labels)
        loss_t = torch.nn.functional.cross_entropy(logits.T, labels)
        return (loss_i + loss_t) / 2

# Create a minimal dataloader
# Each batch: (eeg_data, labels, text, text_features, img, img_features)
eeg_data_batch = torch.randn(2, 4)  # 2 samples, 4 EEG channels
labels_batch = torch.tensor([0, 1])
text_batch = ["text1", "text2"]
text_features_batch = torch.randn(2, 5)  # 2 samples, 5 feature dims
img_batch = ["img1", "img2"]
img_features_batch = torch.randn(2, 5)  # 2 samples, 5 feature dims

dataloader = [
    (eeg_data_batch, labels_batch, text_batch, text_features_batch, img_batch, img_features_batch),
    (eeg_data_batch, labels_batch, text_batch, text_features_batch, img_batch, img_features_batch),
]

# Create subject string with ID
sub = "subject_1"

# Create model
eeg_model = MinimalEEGModel()

# Create optimizer
optimizer = torch.optim.Adam(eeg_model.parameters(), lr=0.001)

# Device (CPU only)
device = "cpu"

# Global text and image features
text_features_all = torch.randn(10, 5)  # 10 samples, 5 feature dims
img_features_all = torch.randn(100, 5)  # 100 samples, 5 feature dims (will be downsampled by ::10)

# Config dict
config = {"lr": 0.001, "batch_size": 2}

ARGS = {
    "sub": sub,
    "eeg_model": eeg_model,
    "dataloader": dataloader,
    "optimizer": optimizer,
    "device": device,
    "text_features_all": text_features_all,
    "img_features_all": img_features_all,
    "config": config,
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
torch — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type tuple — a tuple output has no array shape of its own; none is stated
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
train_model Ran
ran; our contract draft was wrong, not the code
dongyangli-del/eeg_image_decode/Retrieval/ATMS_retrieval.py
code served (permissive licence) · get_code("8fae4949de13669a")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API) and returned tuple. The image it ran in was not recorded. If your copy returns the same type on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import torch
import torch.nn as nn

torch.manual_seed(0)

# Build a minimal EEG model that satisfies the function's usage
class MinimalEEGModel(nn.Module):
    def __init__(self):
        super().__init__()
        self.linear = nn.Linear(8, 5)  # input 8, output 5 features
        self.logit_scale = nn.Parameter(torch.tensor(1.0))
        
    def forward(self, eeg_data, subject_ids):
        # eeg_data: (batch, 8), subject_ids: (batch,)
        # Return features of size (batch, 5)
        return self.linear(eeg_data)
    
    def loss_func(self, eeg_features, other_features, logit_scale):
        # Simple contrastive-style loss
        logits = logit_scale * eeg_features @ other_features.T
        labels = torch.arange(logits.shape[0])
        loss = nn.functional.cross_entropy(logits, labels)
        return loss

# Create dataloader with tiny batches
def create_dataloader():
    batches = []
    for _ in range(2):
        eeg_data = torch.randn(2, 8)  # batch_size=2, eeg_dim=8
        labels = torch.tensor([0, 1])  # class labels
        text = ["text_sample_1", "text_sample_2"]
        text_features = torch.randn(2, 5)  # batch_size=2, feature_dim=5
        img = ["img_sample_1", "img_sample_2"]
        img_features = torch.randn(2, 5)  # batch_size=2, feature_dim=5
        batches.append((eeg_data, labels, text, text_features, img, img_features))
    return batches

eeg_model = MinimalEEGModel()
optimizer = torch.optim.Adam(eeg_model.parameters(), lr=0.001)
device = "cpu"
dataloader = create_dataloader()

# Create text and image features (pre-computed for all classes)
text_features_all = torch.randn(10, 5)  # 10 classes, 5 features
img_features_all = torch.randn(100, 5)  # 100 images, 5 features (will be downsampled by ::10)

config = {
    "alpha": 0.99,
    "batch_size": 2,
    "feature_dim": 5
}

ARGS = {
    "sub": "subject_001",
    "eeg_model": eeg_model,
    "dataloader": dataloader,
    "optimizer": optimizer,
    "device": device,
    "text_features_all": text_features_all,
    "img_features_all": img_features_all,
    "config": config
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
torch — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type tuple — a tuple output has no array shape of its own; none is stated
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
evaluate_model Not yet run
unverified (harvested, no recorded run)
nzwang/neural-mcrl/EEGToVisual/NeuralMCRL.py
pointer only (licence: NONE) · get_code("1979eed793bbbbf9")
How it ran

The body of this sample is withheld: GitHub detected no licence in this paper's repository, nzwang/neural-mcrl when it was checked. The setup block that called it is withheld with it, because it is written against that body. source_path and origin say where the code lives, to read under the repository's own terms. No invocation recorded.

Also present in other papers' code

Of 6 samples lifted from this paper's linked repositories, 6 carry a function identity and 0 do not. Of the 6 distinct functions with an identity, 0 are also present in other papers whose code we hold (0 with at least one paper dated earlier, 0 the same month, 0 later) and 6 are only here among the 52,977 papers whose code Syntology holds (as of 2026-09-26).

Only here means: among the 52,977 papers whose code Syntology holds (51,887 with lifted samples, 1,090 through their assemblies only), as of 2026-09-26, no other paper's lifted samples or current assembly bricks contain an identical function body after normalisation.

Presence, not direction: an identical function body in two papers' repositories does not say who wrote it, which came from which, or that either paper's method rests on it. Matching is exact after normalisation, so a renamed or edited function is not matched. Dates are when papers appeared, not when code was written. Only .py files the harvester lifted are covered; notebooks are not read. A new-style arXiv id YYMM.NNNN dates a paper to the month 20YY-MM; otherwise Paper.year dates it to the year; otherwise it is undated. Dates are when the paper appeared, not when the code was written. Read 2026-11-23.

Repositories linked to this paper

Some links come from the archived Papers with Code dataset (CC BY-SA 4.0): attribution and licence.

Abstract

How to decode human vision through neural signals has attracted a long-standing interest in neuroscience and machine learning. Modern contrastive learning and generative models improved the performance of visual decoding and reconstruction based on functional Magnetic Resonance Imaging (fMRI). However, the high cost and low temporal resolution of fMRI limit their applications in brain-computer interfaces (BCIs), prompting a high need for visual decoding based on electroencephalography (EEG). In this study, we present an end-to-end EEG-based visual reconstruction zero-shot framework, consisting of a tailored brain encoder, called the Adaptive Thinking Mapper (ATM), which projects neural signals from different sources into the shared subspace as the clip embedding, and a two-stage multi-pipe EEG-to-image generation strategy. In stage one, EEG is embedded to align the high-level clip embedding, and then the prior diffusion model refines EEG embedding into image priors. A blurry image also decoded from EEG for maintaining the low-level feature. In stage two, we input both the high-level clip embedding, the blurry image and caption from EEG latent to a pre-trained diffusion model. Furthermore, we analyzed the impacts of different time windows and brain regions on decoding and reconstruction. The versatility of our framework is demonstrated in the magnetoencephalogram (MEG) data modality. The experimental results indicate that our EEG-based visual zero-shot framework achieves SOTA performance in classification, retrieval and reconstruction, highlighting the portability, low cost, and high temporal resolution of EEG, enabling a wide range of BCI applications. Our code is available at https://github.com/ncclab-sustech/EEG_Image_decode.

For agents

The same record, over MCP at https://syntology.ai/mcp:

get_harvested_code_for_paper("2403.07721")
get_code_for_paper("2403.07721")
have("2403.07721")

The run record, dated, one paper per request, free:

curl https://syntology.ai/api/ran/2403.07721.json

A badge for a README (the split and the date, never a ratio):

[![Syntology run record](https://syntology.ai/api/ran/2403.07721.svg)](https://syntology.ai/paper/2403.07721)

Connect an agent — have() is free.