Decoding selective auditory attention to musical elements in ecologically valid music listening.
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 · 186 lines · 7 KB · no license
- import argparse
- from torch.utils.data import DataLoader
- import pytorch_lightning as pl
- from pytorch_lightning.callbacks import EarlyStopping
- from pytorch_lightning import Trainer
- from pytorch_lightning.loggers import TensorBoardLogger
- from audiomentations import AddGaussianNoise, Gain
- from datasets import get_dataset
- from models import SampleCNN2DEEG
- from modules import EEGContrastiveLearning
- from utils import yaml_config_hook, get_logger, file_writer
- from preprocessing import eeg_data_processing, experiment_data_processing
- import pandas as pd
- import datetime
- import random
- from pathlib import Path
- import torch
- if __name__ == "__main__":
- parser = argparse.ArgumentParser(description="PredANN")
- config = yaml_config_hook("/codes_attention/config/config.yaml")
- for k, v in config.items():
- parser.add_argument(f"--{k}", default=v, type=type(v))
- parser.add_argument('--mode', type=str)
- parser.add_argument('--start_position', type=int)
- parser.add_argument('--evaluation_length', type=int)
- parser.add_argument('--attention_values', type=int, nargs='+')
- parser.add_argument('--subject_id', type=int, default=None)
- parser.add_argument('--song_id', type=int, default=None)
- parser.add_argument('--key', type=str)
- parser.add_argument('--test_window_size', type=int)
- parser.add_argument('--test_stride', type=int)
- args = parser.parse_args()
- pl.seed_everything(args.seed, workers=True)
- train_transform = {}
- if args.openmiir_augmentation == "gaussiannoise":
- train_transform = [
- AddGaussianNoise(min_amplitude=args.min_amplitude,
- max_amplitude=args.max_amplitude, p=0.5),
- ]
- print("augematation is gaussiannoise")
- elif args.openmiir_augmentation == "gain":
- train_transform = [
- Gain(min_gain_in_db=-12, max_gain_in_db=12, p=0.5)
- ]
- print("augematation is gain")
- elif args.openmiir_augmentation == "gaussiannoise+gain":
- train_transform = [
- AddGaussianNoise(min_amplitude=args.min_amplitude,
- max_amplitude=args.max_amplitude, p=0.5),
- Gain(min_gain_in_db=-12, max_gain_in_db=12, p=0.5)
- ]
- print("augematation is gaussiannoise+gain")
- else:
- print("no augmentation")
- train_log = pd.DataFrame(
- columns=["Loss/train", "Accuracy/train_eeg", "Accuracy/train_audio"])
- valid_log = pd.DataFrame(
- columns=["Loss/valid", "Accuracy/valid_eeg", "Accuracy/valid_audio"])
- train_dataset = get_dataset(
- args.dataset, args.dataset_dir, subset="train", download=False)
- train_dataset.set_sliding_window_parameters(args.window_size, args.stride)
- train_dataset.set_eeg_normalization(
- args.eeg_normalization, args.clamp_value)
- train_dataset.set_other_parameters( args.eeg_length, args.audio_clip_length, args.shifting_time, args.start_position)
- random.seed(42)
- train_random_numbers = [random.randint(
- 0, args.eeg_sample_rate * 30 - args.eeg_length - 1) for _ in range(1200)]
- train_dataset.set_random_numbers(train_random_numbers)
- if args.openmiir_augmentation != "no_augmentation":
- train_dataset.set_transform(train_transform)
- train_loader = DataLoader(
- train_dataset,
- batch_size=args.batch_size,
- num_workers=args.workers,
- drop_last=True,
- shuffle=True,
- )
- valid_dataset = get_dataset(
- args.dataset, args.dataset_dir, subset="valid", download=False)
- valid_dataset.set_sliding_window_parameters(args.window_size, args.stride)
- valid_dataset.set_eeg_normalization(
- args.eeg_normalization, args.clamp_value)
- valid_dataset.set_other_parameters( args.eeg_length, args.audio_clip_length, args.shifting_time, args.start_position)
- random.seed(42)
- valid_random_numbers = [random.randint(
- 0, args.window_size - args.eeg_length - 1) for _ in range(1200)]
- valid_dataset.set_random_numbers(valid_random_numbers)
- valid_loader = DataLoader(
- valid_dataset,
- batch_size=args.batch_size,
- num_workers=args.workers,
- drop_last=True,
- shuffle=False,
- )
- test_dataset = get_dataset(
- args.test_dataset, args.dataset_dir, subset="test", download=False)
- test_dataset.set_test_data_length(args.test_data_length)
- test_dataset.set_sliding_window_parameters(args.test_window_size, args.test_stride)
- test_dataset.set_eeg_normalization(
- args.eeg_normalization, args.clamp_value)
- test_dataset.set_other_parameters(
- args.eeg_length, args.audio_clip_length, args.shifting_time, args.start_position)
- random.seed(42)
- test_random_numbers = [random.randint(
- 0, args.window_size - args.eeg_length - 1) for _ in range(1200)]
- test_dataset.set_random_numbers(test_random_numbers)
- test_loader = DataLoader(
- test_dataset,
- batch_size=args.batch_size,
- num_workers=args.workers,
- drop_last=True,
- shuffle=False,
- )
- print(f"Size of train dataset: {len(train_dataset)}")
- print(f"Size of valid dataset: {len(valid_dataset)}")
- print(f"Size of test dataset: {len(test_dataset)}")
- if args.dataset == "preprocessing_eegmusic":
- encoder_eeg = SampleCNN2DEEG(
- out_dim=train_dataset.labels(),
- kernal_size=3,
- )
- encoder_vocal = SampleCNN2DEEG(
- out_dim=train_dataset.labels(),
- kernal_size=3,
- )
- encoder_drum = SampleCNN2DEEG(
- out_dim=train_dataset.labels(),
- kernal_size=3,
- )
- encoder_bass = SampleCNN2DEEG(
- out_dim=train_dataset.labels(),
- kernal_size=3,
- )
- encoder_others = SampleCNN2DEEG(
- out_dim=train_dataset.labels(),
- kernal_size=3,
- )
- print('EEG Contrastive learning')
- module = EEGContrastiveLearning(
- valid_dataset, args, encoder_eeg, encoder_vocal, encoder_drum, encoder_bass, encoder_others,key=args.key)
- logger = TensorBoardLogger(
- "runs/{}".format(args.training_date), name="nmed-CL-{}".format(args.dataset))
- early_stop_callback = EarlyStopping(
- monitor="Valid/loss", patience=10
- )
- trainer = Trainer.from_argparse_args(
- args,
- logger=logger,
- sync_batchnorm=True,
- max_epochs=args.max_epochs,
- deterministic=True,
- log_every_n_steps=1,
- check_val_every_n_epoch=1,
- accelerator=args.accelerator,
- resume_from_checkpoint='/checkpoint_path',
- accumulate_grad_batches=6
- )
- print('[[[ START ]]]', datetime.datetime.now())
- checkpoint_path = "/checkpoint_path"
- checkpoint = torch.load(checkpoint_path)
- module.load_state_dict(checkpoint['state_dict'])
- trainer.test(module,dataloaders=test_loader)
- print('[[[ FINISH ]]]', datetime.datetime.now())
checkpoint_test.py at commit e82ea29, no license · at the source
Overview
Abstract
The abstract is not reproduced here: the paper's license (CC BY-NC-ND) 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.
JURIUENO11/Music_attention
e82ea29e3ecb6d7d87ee6b41c2fbcc79c3d42892, 20 April 2026Availability: 1 check, the latest on 28 September 2026: the link answers
- 28 September 2026: the link answers
24 files
- codes_attention/
attention/ , Python, 186 linescheckpoint_test.py - codes_attention/
attention/ , Python, 18 linesdatasets/ __init__.py - codes_attention/
attention/ , Python, 46 linesdatasets/ dataset.py - codes_attention/
attention/ , Python, 396 linesdatasets/ preprocessing_eegmusic_d ataset.py - codes_attention/
attention/ , Python, 240 linesmain.py - codes_attention/
attention/ , Python, 2 linesmodels/ __init__.py - codes_attention/
attention/ , Python, 11 linesmodels/ model.py - codes_attention/
attention/ , Python, 46 linesmodels/ sample_cnn2d_eeg.py - codes_attention/
attention/ , Python, 2 linesmodules/ __init__.py - codes_attention/
attention/ , Python, 306 linesmodules/ clip_loss.py - codes_attention/
attention/ , Python, 443 linesmodules/ contrastive_learning.py - codes_attention/
attention/ , Python, 1 linepreprocessing/ __init__.py - codes_attention/
attention/ , Python, 213 linespreprocessing/ transform.py - codes_attention/
attention/ , Python, 288 linesprevious_study_test.py - codes_attention/
attention/ , Python, 267 linesprevious_study_training. py - codes_attention/
attention/ , Shell, 1 linesequential.sh - codes_attention/
attention/ , Shell, 1 linesequential_test.sh - codes_attention/
attention/ , Python, 5 linesutils/ __init__.py - codes_attention/
attention/ , Python, 44 linesutils/ checkpoint.py - codes_attention/
attention/ , Python, 58 linesutils/ file_helpers.py - codes_attention/
attention/ , Python, 28 linesutils/ logger.py - codes_attention/
attention/ , Python, 15 linesutils/ time_helper.py - codes_attention/
attention/ , Python, 20 linesutils/ yaml_config_hook.py - Readme.md, Text, 166 lines
Code availability statement
The paper has a code availability statement. Its license (CC BY-NC-ND) does not allow reproducing it here; in short, from what the harvester recognized in it:
- it points to the authors' code: JURIUENO11/
Music_attention
Read it in the paper: doi.org/10.1038/s41598-026-55371-6.
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;
- 23 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
Datasets cited
- zenodo:1117371, at Zenodo; found in the references
- zenodo:18113092, at Zenodo; found in “Data availability”
Data availability statement
The paper has a data availability statement. Its license (CC BY-NC-ND) does not allow reproducing it here; in short, from what the harvester recognized in it:
- it points to a dataset: Zenodo 18113092
Read it in the paper: doi.org/10.1038/s41598-026-55371-6.
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, 28 September 2026: the first record
Recorded: type, language, journal, volume, issue, pages, dates, 6 authors, 2 keywords, 10 MeSH terms, 38 references.
Cite
This paper
Akama, T., Zhang, Z., Nagashima, T., Takagi, Y., Minamikawa, S., & Polouliakh, N. (2026). Decoding selective auditory attention to musical elements in ecologically valid music listening. Scientific reports, 16(1), 24486. https://
BibTeX
@article{akama2026decodi
author = {Akama, Taketo and Zhang, Zhuohao and Nagashima, Tsukasa and Takagi, Yutaka and Minamikawa, Shun and Polouliakh, Natalia},
title = {{Decoding selective auditory attention to musical elements in ecologically valid music listening}},
journal = {Scientific reports},
year = {2026},
month = may,
volume = {16},
number = {1},
pages = {24486},
publisher = {Nature Publishing Group},
issn = {2045-2322},
doi = {10.1038/
url = {https://
pmid = {42209637},
pmcid = {PMC13451197}
}
RIS
TY - JOUR
AU - Akama, Taketo
AU - Zhang, Zhuohao
AU - Nagashima, Tsukasa
AU - Takagi, Yutaka
AU - Minamikawa, Shun
AU - Polouliakh, Natalia
TI - Decoding selective auditory attention to musical elements in ecologically valid music listening
T2 - Scientific reports
J2 - Sci Rep
PY - 2026
DA - 2026/
VL - 16
IS - 1
SP - 24486
SN - 2045-2322
PB - Nature Publishing Group
DO - 10.1038/
UR - https://
LA - en
ER -
CSL-JSON
{
"id": "10.1038/
"type": "article-journal",
"title": "Decoding selective auditory attention to musical elements in ecologically valid music listening",
"container-title": "Scientific reports",
"author": [
{
"family": "Akama",
"given": "Taketo"
},
{
"family": "Zhang",
"given": "Zhuohao"
},
{
"family": "Nagashima",
"given": "Tsukasa"
},
{
"family": "Takagi",
"given": "Yutaka"
},
{
"family": "Minamikawa",
"given": "Shun"
},
{
"family": "Polouliakh",
"given": "Natalia"
}
],
"container-title-short":
"volume": "16",
"issue": "1",
"page": "24486",
"DOI": "10.1038/
"PMID": "42209637",
"PMCID": "PMC13451197",
"ISSN": "2045-2322",
"publisher": "Nature Publishing Group",
"URL": "https://
"language": "en",
"issued": {
"date-parts": [
[
2026,
5,
28
]
]
}
}
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.1111/ejn.70538 [code]
- Neural Tracking of Sustained Attention, Attention Switching, and Natural Conversation in Audiovisual Environments Using Wearable EEG.Journal: The European journal of neuroscienceIn common: MNE-Python, pandas, NumPy, EEG, cognitive, 4 references
- [2] doi:10.1162/imag.a.1207 [code]
- Investigating the temporal dynamics and modeling of mid-level feature representations in humans.Journal: Imaging neuroscience (Cambridge, Mass.)In common: PyTorch Lightning, MNE-Python, PyTorch, 3 other tools, EEG, cognitive
- [3] doi:10.1038/s41598-026-56070-y [code]
- SSDLabeler: realistic semi-synthetic data generation for multi-label artifact classification in EEG.Journal: Scientific reportsIn common: PyTorch Lightning, PyTorch, scikit-learn, 2 other tools, EEG, 1 reference
- [4] doi:10.1038/s41467-026-75455-1 [code]
- Shared latent representations of speech production for cross-patient speech decoding.Journal: Nature communicationsIn common: PyTorch Lightning, TensorFlow, PyTorch, 3 other tools, cognitive
- [5] doi:10.1038/s41562-026-02414-7 [code]
- Optimized feature gains explain and predict successes and failures of human selective listening.Journal: Nature human behaviourIn common: PyTorch Lightning, TensorFlow, PyTorch, 3 other tools, cognitive
- [6] doi:10.1093/bioinformatics/btag169 [code]
- Bidirectional Mamba-2 boosts EEG super-resolution via regression and diffusion.Journal: Bioinformatics (Oxford, England)In common: PyTorch Lightning, MNE-Python, PyTorch, 3 other tools, EEG
- [7] doi:10.1523/eneuro.0023-26.2026 [code]
- Real-Time Segmentation and Classification of Birdsong Syllables for Learning Experiments.Journal: eNeuroIn common: PyTorch Lightning, TensorFlow, PyTorch, 3 other tools, cognitive
- [8] doi:10.7554/elife.100056 [code]
- Multi-talker speech comprehension at different temporal scales in listeners with normal and impaired hearing.Journal: eLifeIn common: MNE-Python, PyTorch, scikit-learn, 2 other tools, EEG, cognitive, 1 reference
- [9] doi:10.3389/fpsyg.2026.1774068 [code]
- Analysis of cognitive mechanisms in phoneme perception and pronunciation errors among Korean language learners.Journal: Frontiers in psychologyIn common: TensorFlow, MNE-Python, PyTorch, 3 other tools, EEG, cognitive
- [10] doi:10.1038/s42003-026-10957-8 [code]
- Brain defence by the extracellular matrix protein Cochlin.Journal: Communications biologyIn common: PyTorch Lightning, TensorFlow, PyTorch, 3 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, 23 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:0664df0aeb3ad45a…
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.
