Attention-Enhanced U-Net for Sensor-Efficient High-Density EEG Reconstruction in Wearable Brain Monitoring Systems.
Paper
Loaded from Europe PMC by your browser; OSCR does not store it: doi.org · Europe PMC
The paper is loaded when this pane is shown.
The authors' code
Python · 153 lines · 5 KB · MIT
- # -*- coding: utf-8 -*-
- import os
- import time
- from pathlib import Path
- import torch
- import numpy as np
- import scipy.io as sio
- import VEEG_A_U_Net as mm
- from dataload import loadData
- from modelTrainer import model_train
- from modelValidation import modelValidation
- def _to_nct(arr: np.ndarray, time_expected: int = 600) -> np.ndarray:
- a = np.asarray(arr)
- if a.ndim != 3:
- raise ValueError(f"Expected 3D array, got {a.shape}")
- # (C, T, N)
- if a.shape[1] == time_expected and a.shape[0] in (32, 60):
- return np.transpose(a, (2, 0, 1))
- # (N, C, T)
- if a.shape[2] == time_expected and a.shape[1] in (32, 60):
- return a
- raise ValueError(f"Unrecognized layout (expect T={time_expected}): {a.shape}")
- def main():
- mse_loss_list = []
- device = torch.device("cuda:0" if torch.cuda.is_available() else "cpu")
- start_time = time.time()
- # Base dirs (relative to this script file)
- CODE_DIR = Path(__file__).resolve().parent
- ROOT_DIR = CODE_DIR.parent
- folder_path = str(CODE_DIR)
- mats = sorted(CODE_DIR.glob("SEED_Sub*.mat"))
- if not mats:
- raise FileNotFoundError(
- "[PATH ERROR] No SEED_Sub*.mat found in the script folder.\n"
- f"Script folder: {CODE_DIR}\n\n"
- "Fix:\n"
- " Put SEED_Sub*.mat into the SAME folder as this .py file,\n"
- " or run the script from the folder that contains SEED_Sub*.mat."
- )
- # Model output path (keep your original structure; relative-safe)
- save_path = str((ROOT_DIR / "SEED" / "SREEG" / "VEEG_A_UNet" / "LOSO_LR35" / "iterp").resolve())
- os.makedirs(save_path, exist_ok=True)
- print(f"[INFO] Device: {device}")
- print(f"[INFO] Visible CUDA device count: {torch.cuda.device_count()}")
- print(f"[INFO] Input folder: {folder_path}")
- print(f"[INFO] Save folder : {save_path}")
- print(f"[INFO] Mat files found: {len(mats)}")
- # Load mats from script folder
- data_dict = loadData(folder_path)
- print("\n[CHECK] After loadData() -> normalize to (N, C, T), enforce 60ch:")
- for k in sorted(data_dict.keys()):
- X_raw = data_dict[k]["X"]
- y_raw = data_dict[k]["y"]
- print(f" {k} raw : X={np.asarray(X_raw).shape} y={np.asarray(y_raw).shape}")
- X_nct = _to_nct(X_raw).astype(np.float32, copy=False)
- y_nct = _to_nct(y_raw).astype(np.float32, copy=False)
- data_dict[k]["X"] = X_nct
- data_dict[k]["y"] = y_nct
- print(f" {k} nct : X={X_nct.shape} y={y_nct.shape} dtype={X_nct.dtype}")
- if X_nct.shape[1] != 60 or y_nct.shape[1] != 60:
- raise RuntimeError(
- f"[LOAD ERROR] {k} is not 60ch. Got X={X_nct.shape}, y={y_nct.shape}.\n"
- "Please verify your .mat contains 60-channel X and y."
- )
- print("[CHECK] OK: all subjects are 60ch in (N, C, T).\n")
- subjects = sorted(data_dict.keys())
- # LOSO training loop (keep logic unchanged)
- for i in range(len(subjects)):
- X_list, y_list, valid_X_list, valid_y_list = [], [], [], []
- sub_now = subjects[i]
- for j, sub in enumerate(subjects):
- if j == i:
- valid_X_list.append(data_dict[sub]["X"])
- valid_y_list.append(data_dict[sub]["y"])
- else:
- X_list.append(data_dict[sub]["X"])
- y_list.append(data_dict[sub]["y"])
- valid_X = np.concatenate(valid_X_list, axis=0).astype(np.float32, copy=False)
- valid_y = np.concatenate(valid_y_list, axis=0).astype(np.float32, copy=False)
- X = np.concatenate(X_list, axis=0).astype(np.float32, copy=False)
- y = np.concatenate(y_list, axis=0).astype(np.float32, copy=False)
- print(f"[LOSO] Valid data shape ({sub_now}): {valid_X.shape}")
- print(f"[LOSO] Train data shape: {X.shape}")
- if X.shape[1] != 60 or y.shape[1] != 60:
- raise RuntimeError(f"[DATA ERROR] Expect 60ch. Got X={X.shape}, y={y.shape}")
- ckpt = Path(save_path) / f"{sub_now}_model.pt"
- if ckpt.exists():
- try:
- ckpt.unlink()
- except Exception:
- pass
- model = model_train(
- X=X,
- y=y,
- use_model=mm.Attn_UNet_inter(),
- # For this journal, we set batch_size = 64 and epochs = 50, which can be adjusted based on your compute budget.
- batch_size=64,
- epochs=50,
- model_name=sub_now,
- savePath=save_path,
- device=device,
- )
- mse_loss = modelValidation(valid_X=valid_X, valid_y=valid_y, model=model, device=device)
- mse_loss_list.append(mse_loss)
- np.save(f"{save_path}/MSELoss_list.npy", mse_loss_list)
- end_time = time.time()
- print("[DONE] Total execution time:", round((end_time - start_time) / 3600, 3), "hours")
- if __name__ == "__main__":
- main()
DP_LOSO_Train.py at commit 7438484, under MIT · at the source
Overview
Abstract
High-channel-density (HCD) electroencephalography (EEG) enables fine-grained neural sensing but is constrained by high hardware costs, spatial complexity, and limited portability. This study developed a deep learning-based method to reconstruct high-density EEG signals from low-channel-density (LCD) inputs, enabling more practical and affordable brain-monitoring systems. This study introduces VEEG-A-U-Net, a lightweight U-Net architecture enhanced with attention gates and residual learning. The model combined spherical spline interpolation with a learnable correction signal to adaptively model spatial-temporal features. The framework was trained and evaluated on the SEED dataset, using normalized mean square error (NMSE), signal-to-noise ratio (SNR), and Pearson correlation coefficient (PCC) to assess reconstruction performance. Validation was conducted through leave-one-subject-out cross-validation (LOSO-CV) and cross-dataset experiments to examine generalizability. Under the same reconstruction setting (scale factor = 2), VEEG-A-U-Net achieved competitive reconstruction performance compared with state-of-the-art methods, while requiring substantially fewer parameters and computational operations. Cross-dataset evaluations confirmed stable performance across different EEG paradigms. Inference-time analysis showed low computational latency, indicating practical feasibility for deployment in resource-constrained and edge computing environments. A preliminary clinical EEG evaluation was also conducted to explore feasibility in clinical settings.The proposed framework offers an effective and lightweight solution for reconstructing high-density EEG from sparse measurements. These findings may support the development of sensor-efficient and portable EEG systems for practical neuroengineering and brain–computer interface applications.
Supplementary Information: The online version contains supplementary material available at 10.1007/
Reproduced under the paper's license (CC BY), from the paper cited above.
Repositories
Its files are read in the Code ↔ Paper reader above.
IASlab526/VEEG-A-U-Net
7438484714f50cb649458b213e1b9daa36146dff, 25 January 2026Availability: 1 check, the latest on 29 September 2026: the link answers
- 29 September 2026: the link answers
8 files
- code/
DP_LOSO_Train.py , Python, 153 lines - code/
VEEG_A_U_Net.py , Python, 691 lines - code/
calculateError.py , Python, 202 lines - code/
dataload.py , Python, 37 lines - code/
modelTrainer.py , Python, 129 lines - code/
modelValidation.py , Python, 63 lines - LICENSE, License, 21 lines
- README.md, Text, 78 lines
IASlab526/VEEG-A-U-NetAdditional
Availability: 1 check, the latest on 29 September 2026: the link is dead
- 29 September 2026: the link is dead
The paper's code and data availability statement is in the Data section.
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:
- 2 repositories of the authors' code, each at its verified commit, with its license and how the link was found in the paper;
- 6 scripts, each with its path and the digest of its content;
- no match between paragraphs and code yet;
- 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
The source code and model configurations of VEEG-A-U-Net are publicly available at https://
Reproduced under the paper's license (CC BY), from the paper cited above.
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, 29 September 2026: the first record
Recorded: type, language, journal, volume, issue, pages, dates, 2 authors, 6 keywords, 9 MeSH terms, 1 funder, 31 references.
Cite
This paper
Zhuang, J.-R., & Guo, P.-C. (2026). Attention-Enhanced U-Net for Sensor-Efficient High-Density EEG Reconstruction in Wearable Brain Monitoring Systems. Journal of medical systems, 50(1), 46. https://
BibTeX
@article{zhuang2026atten
author = {Zhuang, Jyun-Rong and Guo, Pin-Cheng},
title = {{Attention-Enhanced U-Net for Sensor-Efficient High-Density EEG Reconstruction in Wearable Brain Monitoring Systems}},
journal = {Journal of medical systems},
year = {2026},
month = apr,
volume = {50},
number = {1},
pages = {46},
publisher = {Springer Science+Business Media},
issn = {0148-5598},
doi = {10.1007/
url = {https://
pmid = {41936725},
pmcid = {PMC13050758}
}
RIS
TY - JOUR
AU - Zhuang, Jyun-Rong
AU - Guo, Pin-Cheng
TI - Attention-Enhanced U-Net for Sensor-Efficient High-Density EEG Reconstruction in Wearable Brain Monitoring Systems
T2 - Journal of medical systems
J2 - J Med Syst
PY - 2026
DA - 2026/
VL - 50
IS - 1
SP - 46
SN - 0148-5598
PB - Springer Science+Business Media
DO - 10.1007/
UR - https://
LA - en
ER -
CSL-JSON
{
"id": "10.1007/
"type": "article-journal",
"title": "Attention-Enhanced U-Net for Sensor-Efficient High-Density EEG Reconstruction in Wearable Brain Monitoring Systems",
"container-title": "Journal of medical systems",
"author": [
{
"family": "Zhuang",
"given": "Jyun-Rong"
},
{
"family": "Guo",
"given": "Pin-Cheng"
}
],
"container-title-short":
"volume": "50",
"issue": "1",
"page": "46",
"DOI": "10.1007/
"PMID": "41936725",
"PMCID": "PMC13050758",
"ISSN": "0148-5598",
"publisher": "Springer Science+Business Media",
"URL": "https://
"language": "en",
"issued": {
"date-parts": [
[
2026,
4,
6
]
]
}
}
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.1093/bioinformatics/btag169 [code]
- Bidirectional Mamba-2 boosts EEG super-resolution via regression and diffusion.Journal: Bioinformatics (Oxford, England)In common: MNE-Python, PyTorch, scikit-learn, 3 other tools, methods / tools, EEG, 5 references
- [2] doi:10.1186/s12967-025-06862-z
- Multi-stream feature fusion of vision transformer and CNN for precise epileptic seizure detection from EEG signals.Journal: Journal of translational medicineIn common: methods / tools, EEG, 5 references
- [3] doi:10.3389/frai.2025.1679218
- Improved attention-based PCNN with GhostNet for epilepsy seizure detection using EEG and fMRI modalities: extractive pattern and histogram feature set.Journal: Frontiers in artificial intelligenceIn common: EEG, 5 references
- [4] doi:10.1038/s41598-025-32207-3 [code]
- Multi-scale EEG feature decoding with Swin Transformers for subject independent motor imagery BCIs.Journal: Scientific reportsIn common: MNE-Python, PyTorch, scikit-learn, 3 other tools, methods / tools, EEG, 2 references
- [5] doi:10.3390/s26082431
- Missing Data Gap Imputation Methods in Electroencephalogram (EEG) Signals: A Systematic Scoping Review.Journal: Sensors (Basel, Switzerland)In common: methods / tools, EEG, 5 references
- [6] doi:10.3389/fnins.2023.1251677
- Assigning channel weights using an attention mechanism: an EEG interpolation algorithm.Journal: Frontiers in neuroscienceIn common: EEG, 5 references
- [7] doi:10.1371/journal.pone.0327791 [code]
- PyNoetic: A modular python framework for no-code development of EEG brain-computer interfaces.Journal: PloS oneIn common: MNE-Python, PyTorch, scikit-learn, 3 other tools, methods / tools, EEG, 2 references
- [8] doi:10.3389/fninf.2024.1459970 [code]
- hvEEGNet: a novel deep learning model for high-fidelity EEG reconstruction.Journal: Frontiers in neuroinformaticsIn common: MNE-Python, PyTorch, scikit-learn, 3 other tools, EEG, 2 references
- [9] doi:10.1371/journal.pone.0351872 [code]
- Decoding visual object recognition from EEG signals.Journal: PloS oneIn common: MNE-Python, PyTorch, scikit-learn, 3 other tools, EEG, 1 reference
- [10] doi:10.1038/s41597-026-07120-7 [code]
- PhysioMotion Artifact: A task-driven EEG dataset with point-wise motion artifact annotations.Journal: Scientific dataIn common: MNE-Python, PyTorch, scikit-learn, 2 other tools, methods / tools, EEG, 1 reference
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: 2 repositories of the authors' code, each at its verified commit and with its license, 6 scripts, and 0 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:e0b62ce2ce2a8c97…
Add the badge to the code's README
If you are an author or a maintainer of this paper's code, you can add this badge. It says what OSCR knows of the paper (its code, its validated tracing map) and links the code to this page. Paste one of these snippets under the README's title. Keep the two marks around it, so that the badge can be replaced in place and is never added twice. OSCR changes nothing in your repository.
Markdown
<!-- oscr-badge:start -->
[](https://openscicode.org/badge/doi/10.1007/s10916-026-02374-5)
<!-- oscr-badge:end -->reStructuredText
.. oscr-badge:start
.. image:: https://openscicode.org/badge/doi/10.1007/s10916-026-02374-5.svg
:target: https://openscicode.org/badge/doi/10.1007/s10916-026-02374-5
:alt: OSCR
.. oscr-badge:endHTML
<!-- oscr-badge:start -->
<a href="https://openscicode.org/badge/doi/10.1007/s10916-026-02374-5"><img src="https://openscicode.org/badge/doi/10.1007/s10916-026-02374-5.svg" alt="OSCR"></a>
<!-- oscr-badge:end -->On GitHub, open the README, choose Edit (the pencil), paste the snippet under the title, then "Commit changes".
- IASlab526/VEEG-A-U-Net: README.md on GitHub
- IASlab526/VEEG-A-U-NetAdditional on GitHub (add a README there)
If you choose to, you can have the badge kept up to date for you, with oscr badge --write from the command line or with the GitHub Action in your repository's workflows. Every other form and option (a card, AsciiDoc, LaTeX, shields.io) is on the badge page.
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: code errors and mismatches between the code and the paper about this paper and its code, from readers and its authors, beside the paper and its tracing map.
Report a mismatch between the code and the paper · Report a code error (signed in)
Reproductions: reports from readers who ran the authors' code and did not get the paper's result, what they ran, with which environment, commit and data.
Report a reproduction failure (signed in)
Versions of its code: the releases of its code tied to a version of this paper (the preprint, the accepted manuscript, the version of record…), each with the tracing map versioned with it.
Activity: what happens around this paper: new versions of its record, its map's validation, discussions and reproductions. It opens with sign-in.
