Evaluating EEG-to-text models through noise-based performance analysis
The 5 matches
- [1] § Materials and methods › EEG-to-text decoding evaluation › EEG-to-text decoding ↔ model_sentiment.py, lines 170–209 · score 0.67 · cross entropy loss, transformer encoder, heads, decoder, layered, module
- [2] § Materials and methods › EEG-to-text decoding evaluation › EEG-to-text decoding ↔ model_sentiment.py, lines 170–209 · score 0.62 · cross entropy loss, transformer encoder, heads, layer, pretrained, modeling
- [3] § Materials and methods › EEG-to-text decoding evaluation › EEG-to-text decoding ↔ train_decoding.py, lines 20–124 · score 0.56 · cross entropy loss, language modeling, weights, decoding
- [4] § Materials and methods › EEG-to-text decoding evaluation › EEG-to-text decoding ↔ eval_sentiment.py, lines 306–370 · score 0.52 · cross entropy loss, decoder, encoder, layered, sequences, embeddings
- [5] § Materials and methods › EEG-to-text decoding evaluation › Evaluation ↔ eval_decoding.py, lines 77–115 · score 0.50 · repetition penalty, beam, sequences
Paper
Loaded from Europe PMC by your browser, not stored by OSCR: doi.org · Europe PMC
The paper is loaded when this pane is shown.
The authors' code
Python · 249 lines · 12 KB · no license · 2 matches
- import torch.nn as nn
- import torch.nn.functional as F
- import torch.utils.data
- from transformers import BartTokenizer, BartForConditionalGeneration, BartConfig, BertForSequenceClassification
- import math
- import numpy as np
- from torch.nn.utils.rnn import pack_padded_sequence, pad_packed_sequence
- """MLP baseline using sentence level eeg"""
- # using sent level EEG, MLP baseline for sentiment
- class BaselineMLPSentence(nn.Module):
- def __init__(self, input_dim = 840, hidden_dim = 128, output_dim = 3):
- super(BaselineMLPSentence, self).__init__()
- self.fc1 = nn.Linear(input_dim, hidden_dim)
- self.relu1 = nn.ReLU()
- self.fc2 = nn.Linear(hidden_dim, hidden_dim)
- self.relu2 = nn.ReLU()
- self.fc3 = nn.Linear(hidden_dim, output_dim) # positive, negative, neutral
- self.dropout = nn.Dropout(0.25)
- def forward(self, x):
- out = self.fc1(x)
- out = self.relu1(out)
- out = self.fc2(out)
- out = self.relu2(out)
- out = self.dropout(out)
- out = self.fc3(out)
- return out
- """bidirectional LSTM baseline using word level eeg"""
- class BaselineLSTM(nn.Module):
- def __init__(self, input_dim = 840, hidden_dim = 256, output_dim = 3, num_layers = 1):
- super(BaselineLSTM, self).__init__()
- self.hidden_dim = hidden_dim
- self.lstm = nn.LSTM(input_dim, hidden_dim, num_layers = 1, batch_first = True, bidirectional = True)
- self.hidden2sentiment = nn.Linear(hidden_dim*2, output_dim)
- def forward(self, x_packed):
- # input: (N,seq_len,input_dim)
- # print(x_packed.data.size())
- lstm_out, _ = self.lstm(x_packed)
- last_hidden_state = pad_packed_sequence(lstm_out, batch_first = True)[0][:,-1,:]
- # print(last_hidden_state.size())
- out = self.hidden2sentiment(last_hidden_state)
- return out
- """ Bert Baseline: Finetuning from a pretrained language model Bert"""
- class NaiveFineTunePretrainedBert(nn.Module):
- def __init__(self, input_dim = 840, hidden_dim = 768, output_dim = 3, pretrained_checkpoint = None):
- super(NaiveFineTunePretrainedBert, self).__init__()
- # mapping hidden states dimensioin
- self.fc1 = nn.Linear(input_dim, hidden_dim)
- self.pretrained_Bert = BertForSequenceClassification.from_pretrained('bert-base-cased',num_labels=3)
- if pretrained_checkpoint is not None:
- self.pretrained_Bert.load_state_dict(torch.load(pretrained_checkpoint))
- def forward(self, input_embeddings_batch, input_masks_batch, labels):
- embedding = F.relu(self.fc1(input_embeddings_batch))
- out = self.pretrained_Bert(inputs_embeds = embedding, attention_mask = input_masks_batch, labels = labels, return_dict = True)
- return out
- """ Finetuning from a pretrained language model BART, two step training"""
- class FineTunePretrainedTwoStep(nn.Module):
- def __init__(self, pretrained_layers, in_feature = 840, d_model = 1024, additional_encoder_nhead=8, additional_encoder_dim_feedforward = 2048):
- super(FineTunePretrainedTwoStep, self).__init__()
- self.pretrained_layers = pretrained_layers
- # additional transformer encoder, following BART paper about
- self.additional_encoder_layer = nn.TransformerEncoderLayer(d_model=in_feature, nhead=additional_encoder_nhead, dim_feedforward = additional_encoder_dim_feedforward, batch_first=True)
- self.additional_encoder = nn.TransformerEncoder(self.additional_encoder_layer, num_layers=6)
- # NOTE: add positional embedding?
- # print('[INFO]adding positional embedding')
- # self.positional_embedding = PositionalEncoding(in_feature)
- self.fc1 = nn.Linear(in_feature, d_model)
- def forward(self, input_embeddings_batch, input_masks_batch, input_masks_invert, labels):
- """input_embeddings_batch: batch_size*Seq_len*840"""
- """input_mask: 1 is not masked, 0 is masked"""
- """input_masks_invert: 1 is masked, 0 is not masked"""
- """labels: sentitment labels 0,1,2"""
- # NOTE: add positional embedding?
- # input_embeddings_batch = self.positional_embedding(input_embeddings_batch)
- # use src_key_padding_masks
- encoded_embedding = self.additional_encoder(input_embeddings_batch, src_key_padding_mask = input_masks_invert)
- # encoded_embedding = self.additional_encoder(input_embeddings_batch)
- encoded_embedding = F.relu(self.fc1(encoded_embedding))
- out = self.pretrained_layers(inputs_embeds = encoded_embedding, attention_mask = input_masks_batch, return_dict = True, labels = labels)
- return out
- """ Zero-shot sentiment discovery using a finetuned generation model and a sentiment model pretrained on text """
- class ZeroShotSentimentDiscovery(nn.Module):
- def __init__(self, brain2text_translator, sentiment_classifier, translation_tokenizer, sentiment_tokenizer, device = 'cpu'):
- # only for inference
- super(ZeroShotSentimentDiscovery, self).__init__()
- self.brain2text_translator = brain2text_translator
- self.sentiment_classifier = sentiment_classifier
- self.translation_tokenizer = translation_tokenizer
- self.sentiment_tokenizer = sentiment_tokenizer
- self.device = device
- def forward(self, input_embeddings_batch, input_masks_batch, input_masks_invert, target_ids_batch_converted, sentiment_labels):
- """input_embeddings_batch: batch_size*Seq_len*840"""
- """input_mask: 1 is not masked, 0 is masked"""
- """input_masks_invert: 1 is masked, 0 is not masked"""
- """labels: sentitment labels 0,1,2"""
- def logits2PredString(logits):
- probs = logits[0].softmax(dim = 1)
- # print('probs size:', probs.size())
- values, predictions = probs.topk(1)
- # print('predictions before squeeze:',predictions.size())
- predictions = torch.squeeze(predictions)
- predict_string = self.translation_tokenizer.decode(predictions)
- return predict_string
- # only works on batch is one
- assert input_embeddings_batch.size()[0] == 1
- seq2seqLMoutput = self.brain2text_translator(input_embeddings_batch, input_masks_batch, input_masks_invert, target_ids_batch_converted)
- predict_string = logits2PredString(seq2seqLMoutput.logits)
- predict_string = predict_string.split('</s></s>')[0]
- predict_string = predict_string.replace('<s>','')
- print('predict string:', predict_string)
- re_tokenized = self.sentiment_tokenizer(predict_string, return_tensors='pt', return_attention_mask = True)
- input_ids = re_tokenized['input_ids'].to(self.device) # batch = 1
- attn_mask = re_tokenized['attention_mask'].to(self.device) # batch = 1
- out = self.sentiment_classifier(input_ids = input_ids, attention_mask = attn_mask, return_dict = True, labels = sentiment_labels)
- return out
- """ Miscellaneous: jointly learn generation and classification (not working well) """
- class BartClassificationHead(nn.Module):
- # from transformers: https://huggingface.co/transformers/_modules/transformers/models/bart/modeling_bart.html
- """Head for sentence-level classification tasks."""
- def __init__(
- self,
- input_dim: int,
- inner_dim: int,
- num_classes: int,
- pooler_dropout: float,
- ):
- super().__init__()
- self.dense = nn.Linear(input_dim, inner_dim)
- self.dropout = nn.Dropout(p=pooler_dropout)
- self.out_proj = nn.Linear(inner_dim, num_classes)
- def forward(self, hidden_states: torch.Tensor):
- hidden_states = self.dropout(hidden_states)
- hidden_states = self.dense(hidden_states)
- hidden_states = torch.tanh(hidden_states)
- hidden_states = self.dropout(hidden_states)
- hidden_states = self.out_proj(hidden_states)
- return hidden_states
- class JointBrainTranslatorSentimentClassifier(nn.Module):
- def __init__(self, pretrained_layers, in_feature = 840, d_model = 1024, additional_encoder_nhead=8, additional_encoder_dim_feedforward = 2048, num_labels = 3):
- super(JointBrainTranslatorSentimentClassifier, self).__init__()
- self.pretrained_generator = pretrained_layers
- # additional transformer encoder, following BART paper about
- self.additional_encoder_layer = nn.TransformerEncoderLayer(d_model=in_feature, nhead=additional_encoder_nhead, dim_feedforward = additional_encoder_dim_feedforward, batch_first=True)
- self.additional_encoder = nn.TransformerEncoder(self.additional_encoder_layer, num_layers=6)
- self.fc1 = nn.Linear(in_feature, d_model)
- self.num_labels = num_labels
- self.pooler = Pooler(d_model)
- self.classifier = BartClassificationHead(input_dim = d_model, inner_dim = d_model, num_classes = num_labels, pooler_dropout = pretrained_layers.config.classifier_dropout)
- def forward(self, input_embeddings_batch, input_masks_batch, input_masks_invert, target_ids_batch_converted, sentiment_labels):
- """input_embeddings_batch: batch_size*Seq_len*840"""
- """input_mask: 1 is not masked, 0 is masked"""
- """input_masks_invert: 1 is masked, 0 is not masked"""
- # NOTE: add positional embedding?
- # input_embeddings_batch = self.positional_embedding(input_embeddings_batch)
- # use src_key_padding_masks
- encoded_embedding = self.additional_encoder(input_embeddings_batch, src_key_padding_mask = input_masks_invert)
- # encoded_embedding = self.additional_encoder(input_embeddings_batch)
- encoded_embedding = F.relu(self.fc1(encoded_embedding))
- LMoutput = self.pretrained_generator(inputs_embeds = encoded_embedding, attention_mask = input_masks_batch, return_dict = True, labels = target_ids_batch_converted, output_hidden_states = True)
- hidden_states = LMoutput.decoder_hidden_states # N, seq_len, hidden_dim
- # print('hidden states len:', len(hidden_states))
- last_hidden_states = hidden_states[-1]
- # print('last hidden states size:', last_hidden_states.size())
- sentence_representation = self.pooler(last_hidden_states)
- classification_logits = self.classifier(sentence_representation)
- loss_fct = nn.CrossEntropyLoss()
- classification_loss = loss_fct(classification_logits.view(-1, self.num_labels), sentiment_labels.view(-1))
- classification_output = {'loss':classification_loss,'logits':classification_logits}
- # print('successful one forward!!!!')
- return LMoutput, classification_output
- """ helper modules """
- # modified from BertPooler
- class Pooler(nn.Module):
- def __init__(self, hidden_size):
- super().__init__()
- self.dense = nn.Linear(hidden_size, hidden_size)
- self.activation = nn.Tanh()
- def forward(self, hidden_states):
- # We "pool" the model by simply taking the hidden state corresponding
- # to the first token.
- first_token_tensor = hidden_states[:, 0]
- pooled_output = self.dense(first_token_tensor)
- pooled_output = self.activation(pooled_output)
- return pooled_output
- # from https://pytorch.org/tutorials/beginner/transformer_tutorial.html
- class PositionalEncoding(nn.Module):
- def __init__(self, d_model, dropout=0.1, max_len=5000):
- super(PositionalEncoding, self).__init__()
- self.dropout = nn.Dropout(p=dropout)
- pe = torch.zeros(max_len, d_model)
- position = torch.arange(0, max_len, dtype=torch.float).unsqueeze(1)
- div_term = torch.exp(torch.arange(0, d_model, 2).float() * (-math.log(10000.0) / d_model))
- pe[:, 0::2] = torch.sin(position * div_term)
- pe[:, 1::2] = torch.cos(position * div_term)
- pe = pe.unsqueeze(0).transpose(0, 1)
- self.register_buffer('pe', pe)
- def forward(self, x):
- # print('[DEBUG] input size:', x.size())
- # print('[DEBUG] positional embedding size:', self.pe.size())
- x = x + self.pe[:x.size(0), :]
- # print('[DEBUG] output x with pe size:', x.size())
- return self.dropout(x)
model_sentiment.py at commit 00a50d0, no license · at the source
Overview
- Department of Software Convergence, Kyung Hee University, Yongin-si, 17104 Republic of Korea
- HKUST(GZ), Guangzhou, 511453 People’s Republic of China
- GrapheneX-UTS HAI Centre, Australian Artificial Intelligence Institute, Faculty of Engineering and Information Technology, University of Technology Sydney, Sydney, 2007 Australia
Abstract
The abstract is not reproduced here: the paper's license (none stated) does not allow it. Read it in the paper, at the publisher or on Europe PMC.
Repository
Its files are read in the Code ↔ Paper reader above, with 5 matches between paragraphs and lines of code.
khu-aims/EEG-To-Text
00a50d002d24ef999609fb3e9e344a8b3ba42066, 26 November 2025Availability: 1 check, the latest on 26 September 2026: the link answers
- 26 September 2026: the link answers
26 files
- config.py, Python, 102 lines
- data.py, Python, 346 lines
- eval_decoding.py, Python, 366 lines, 1 match
- eval_sentiment.py, Python, 370 lines, 1 match
- model_decoding.py, Python, 291 lines
- model_sentiment.py, Python, 249 lines, 2 matches
- scripts/
eval_decoding_1.sh , Shell, 14 lines - scripts/
eval_decoding_2.sh , Shell, 14 lines - scripts/
eval_decoding_3.sh , Shell, 14 lines - scripts/
eval_decoding_4.sh , Shell, 14 lines - scripts/
eval_sentiment_zeroshot_ , Shell, 6 linespipeline.sh - scripts/
prepare_dataset.sh , Shell, 12 lines - scripts/
train_decoding.sh , Shell, 25 lines - scripts/
train_decoding_1.sh , Shell, 25 lines - scripts/
train_eeg_sentiment_base , Shell, 1 lineline.sh - scripts/
train_eval_zeroshot_pipe , Shell, 41 linesline.sh - scripts/
train_text_sentiment_cla , Shell, 8 linesssifier.sh - train_decoding.py, Python, 379 lines, 1 match
- train_sentiment_baseline
.py , Python, 262 lines - train_sentiment_textbase
d.py , Python, 368 lines - util/
construct_dataset_mat_to , Python, 135 lines_pickle_v1.py - util/
construct_dataset_mat_to , Python, 138 lines_pickle_v2.py - util/
data_loading_helpers_mod , Python, 231 linesified.py - util/
get_SST_ternary_dataset. , Python, 143 linespy - util/
get_sentiment_labels.py , Python, 33 lines - README.md, Text, 109 lines
Code availability statement
The paper has a code availability statement. Its license (none stated) does not allow reproducing it here; in short, from what the harvester recognized in it:
- it points to the authors' code: khu-aims/
EEG-To-Text - it says that the code is available on request
Read it in the paper: doi.org/10.1038/s41598-025-29587-x.
Tracing map
Proposed by the machine: these links were found in the paper and verified at the source, without human review. The map will receive a Zenodo DOI once one of the paper's authors has validated it with their ORCID.
What the map holds:
- 1 repository of the authors' code, each at its verified commit, with its license and how the link was found in the paper;
- 25 scripts, each with its path and the digest of its content;
- 5 matches between paragraphs of the paper and lines of the code (method lexical-v1);
- neither the text of the paper nor the code itself.
Its JSON (tracing-map.json) is deposited on Zenodo with its DOI once the map is validated.
Data
No dataset and no data link were found in the paper.
Data availability statement
The paper has a data availability statement. Its license (none stated) does not allow reproducing it here; in short, from what the harvester recognized in it:
- it says that the data are available on request
Read it in the paper: doi.org/10.1038/s41598-025-29587-x.
Versions
The history of this record: each version stored by the harvester or made by a correction of its authors or of the maintainers of its code, and what changed in its facts. The texts of the paper (its abstract, its availability statements) are not part of it; versions that changed only those are not listed.
Version 1, 27 September 2026: the first record
Recorded: type, language, journal, volume, issue, pages, dates, 6 authors, 2 keywords, 7 MeSH terms, 2 funders, 10 references.
Cite
This paper
Jo, H., Yang, Y., Han, J., Duan, Y., Xiong, H., & Lee, W. H. (2025). Evaluating EEG-to-text models through noise-based performance analysis. Scientific Reports, 16(1), 350. https://
BibTeX
@article{jo2025evaluatin
author = {Jo, Hyejeong and Yang, Yiqian and Han, Juhyeok and Duan, Yiqun and Xiong, Hui and Lee, Won Hee},
title = {{Evaluating EEG-to-text models through noise-based performance analysis}},
journal = {Scientific Reports},
year = {2025},
volume = {16},
number = {1},
pages = {350},
publisher = {Nature Publishing Group},
issn = {2045-2322},
doi = {10.1038/
url = {https://
pmcid = {PMC12770527}
}
RIS
TY - JOUR
AU - Jo, Hyejeong
AU - Yang, Yiqian
AU - Han, Juhyeok
AU - Duan, Yiqun
AU - Xiong, Hui
AU - Lee, Won Hee
TI - Evaluating EEG-to-text models through noise-based performance analysis
T2 - Scientific Reports
J2 - Sci Rep
PY - 2025
DA - 2025
VL - 16
IS - 1
SP - 350
SN - 2045-2322
PB - Nature Publishing Group
DO - 10.1038/
UR - https://
LA - en
ER -
CSL-JSON
{
"id": "10.1038/
"type": "article-journal",
"title": "Evaluating EEG-to-text models through noise-based performance analysis",
"container-title": "Scientific Reports",
"author": [
{
"family": "Jo",
"given": "Hyejeong"
},
{
"family": "Yang",
"given": "Yiqian"
},
{
"family": "Han",
"given": "Juhyeok"
},
{
"family": "Duan",
"given": "Yiqun"
},
{
"family": "Xiong",
"given": "Hui"
},
{
"family": "Lee",
"given": "Won Hee"
}
],
"container-title-short":
"volume": "16",
"issue": "1",
"page": "350",
"DOI": "10.1038/
"PMCID": "PMC12770527",
"ISSN": "2045-2322",
"publisher": "Nature Publishing Group",
"URL": "https://
"language": "en",
"issued": {
"date-parts": [
[
2025
]
]
}
}
The tracing map gets a citation of its own once an author has validated it and it has a DOI.
Similar papers
The papers with a page that share the most with this one: the tools found in their code, their categories, datasets, cited references and authors, the rarest counting most.
- [1] doi:10.1038/s41467-026-75455-1 [code]
- Shared latent representations of speech production for cross-patient speech decoding.Journal: Nature communicationsIn common: h5py, PyTorch, scikit-learn, 3 other tools, 3 references
- [2] doi:10.1038/s41586-026-10658-6 [code]
- An AI system to help scientists write expert-level empirical software.Journal: NatureIn common: Hugging Face Transformers, h5py, PyTorch, 4 other tools, methods / tools
- [3] doi:10.1038/s41467-026-72253-7 [code]
- Spurious alignment between large language models and brains can emerge from non-robust methods and overlooked confounds.Journal: Nature communicationsIn common: Hugging Face Transformers, h5py, PyTorch, 4 other tools, methods / tools
- [4] doi:10.1162/imag.a.1299 [code]
- A modular semantic-structural pipeline for visual decoding from primate spiking data via selective temporal integration.Journal: Imaging neuroscience (Cambridge, Mass.)In common: Hugging Face Transformers, h5py, PyTorch, 4 other tools, methods / tools
- [5] doi:10.1016/j.isci.2026.117180 [code]
- Developmental changes in similarity between neural representations of mental arithmetic and artificial neural networks.Journal: iScienceIn common: Hugging Face Transformers, h5py, PyTorch, 4 other tools
- [6] doi:10.1038/s41467-026-76098-y [code]
- A single computational objective can produce specialization of streams in visual cortex.Journal: Nature communicationsIn common: Hugging Face Transformers, h5py, PyTorch, 4 other tools
- [7] doi:10.1186/s12864-026-12965-8 [code]
- Systematic evaluation of single-cell foundation model interpretability: attention-derived edge scores add no incremental value over gene-level features for perturbation-target prediction.Journal: BMC genomicsIn common: Hugging Face Transformers, h5py, PyTorch, 4 other tools
- [8] doi:10.1038/s41467-026-74358-5 [code]
- Brain-inspired spatial intelligence for embodied agents.Journal: Nature communicationsIn common: Hugging Face Transformers, h5py, PyTorch, 4 other tools
- [9] doi:10.1371/journal.pcbi.1014263 [code]
- MIRAGE: Robust multi-modal architectures translate fMRI-to-image models from vision to mental imagery.Journal: PLoS computational biologyIn common: Hugging Face Transformers, h5py, PyTorch, 4 other tools
- [10] doi:10.1038/s42003-026-10169-0 [code]
- Shared representations in brains and models reveal a two-route cortical organization during scene perception.Journal: Communications biologyIn common: Hugging Face Transformers, h5py, PyTorch, 4 other tools
Contribute
The authors of this paper can claim it, correct its record and validate its tracing map, and the maintainers of its code (its owner, or a public member of its organization) correct what it says of their repository; anyone signed in can ask for its removal. Every request goes to OSCR's own machine, which answers it; your account page follows them.
Sign in with ORCID to claim this paper as one of its authors, correct its record or validate its tracing map: when the paper's metadata lists your ORCID iD, you are recognized at once. Maintainers of its code: sign in with GitHub, then claim the repository on your account page.
Claim this paper
Correct its record
Say what each link of this record is, remove the ones that are not the paper's, add the ones that are missing. The correction becomes a new version of the record, in its Versions section.
Validate its tracing map
You validate the map as this page shows it: 1 repository of the authors' code, each at its verified commit and with its license, 25 scripts, and 5 matches between paragraphs and code (see the Code and Map sections). It then receives a DOI on Zenodo, with you (your ORCID iD) and OSCR as its creators; the code itself is not deposited.
The map's fingerprint: sha256:ea8f104c8a3b232a…
Add the badge to its README
The badge links the code to this page. Copy one of these into the README of the paper's code: only you decide where it goes, and nothing is changed for you.
Markdown
[, paste the snippet at the top, then “Commit changes…” and, to review it first, “Create a new branch and start a pull request”. You open the pull request; OSCR asks for no permission.
Request its removal
To ask OSCR to remove this record, the copies of its authors' scripts or its tracing map, use the removal request page: signed in, you say who you are, what to remove and why, then review and confirm the request. Published rules decide every request (how).
Discussion, reproductions, activity
Discussion: questions and error reports about this paper and its code, from signed-in readers and its authors. It opens with sign-in.
Reproductions: reports from readers who ran the authors' code: what they reproduced, with which environment, commit and data. It opens with sign-in.
Activity: what happens around this paper: new versions of its record, its map's validation, discussions and reproductions. It opens with sign-in.
