Reconstruction of Imagined Melody with Relative Pitch Decoding in Electrocorticography.
The 3 matches
- [1] § Materials and Methods › Feature extraction ↔ code/Dec5_Major_Feature_Increment.py, lines 52–58 · score 0.80 · 12–30 Hz, 30–59 Hz, 8–12 Hz, 61–150 Hz, 1–4 Hz, HG
- [2] § Materials and Methods › Feature extraction ↔ code/Intersub_0_Major_Feature_selection.py, lines 51–57 · score 0.80 · 12–30 Hz, 30–59 Hz, 8–12 Hz, 61–150 Hz, 1–4 Hz, HG
- [3] § Materials and Methods › Classification and decoding models ↔ code/utils_ml_model.py, lines 51–78 · score 0.66 · nearest centroid, random forest, LDA, classification, Model
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 · 262 lines · 9.3 KB · no license · 1 match
- """
- Author: Jii Kwon <[email hidden]>
- Seoul National University
- Human Brain Function Laboratory
- ECoG_Music : Wrapper method
- """
- #%% Go to root
- import os.path
- import os
- serv = input("Window:0 Linux:1 -")
- if serv == '0':
- serv_name = 'E:\\'
- else:
- serv_name = '/mnt/e'
- folder_std = os.path.join(serv_name, 'ECoG_Music', '2304_Music_Imagery', '2304_Music_Imagery_Decoding_v1')
- folder_scripts = os.path.join(folder_std, '00_scripts')
- os.chdir(folder_scripts)
- os.getcwd()
- #%% import library
- from utils_basic_music import np, plt, sio, pd, sns
- from utils_basic_music import basic
- from utils_etc_function import Utils
- from utils_ml_model import ml_models
- from tqdm import trange
- from collections import Counter
- import pickle
- import glob
- utils = Utils()
- ml_models = ml_models()
- basic = basic()
- #%% Setting Analysis Parameter [adjusting param]
- # Decoding param
- BASE = 'norm_sd1'
- mean_max = 'mean'
- kfold = 7
- random_state = 1209
- aug_val = 1.5 #1.2 # None or number
- param_set = None #Boolean : getting the gridsearch result
- scaling = 'min-max'
- adj_fold = 'v231108_sess1-8[aug_1.5_FI]_min_max_train'
- #%% Setting Analysis Basic Parameter [not necessaries of adjusting param]
- # Basic Param
- Sub_Nums = np.arange(1,11)
- bands = ['D', 'T', 'A', 'B', 'G', 'HG']
- band_frqs = [(1,4), (4,7), (8,12), (12,30), (30,59), (61,150)]
- file_inform = os.path.join(serv_name, 'ECoG_Music', 'Subject_info.mat')
- # Set folder name
- fold_select = os.path.join(folder_std, '01_select_electrode', 'case2_P1orP2')
- fold_class_FW = os.path.join(folder_std, '04_Clf_FW', adj_fold)
- fold_acc = basic.set_folder(os.path.join(folder_std, '05_Resul_accuracy'))
- fold_major = basic.set_folder(os.path.join(folder_std, '07_Major_Feature_Distribution_v240723','Increment_Value', adj_fold))
- if serv == 1: plt.rcParams['font.family'] = 'DejaVu Serif'
- else: plt.rcParams['font.family'] = 'Times New Roman'
- #%% Analysis
- # 1st stage: 각 영역당 몇개의 channel이 있는지
- total_elec = pd.DataFrame([])
- for sub_idx in trange(len(Sub_Nums)):
- sub_fname, SubName, NumCh, Ch_list, Bad_Ch = basic.info_sub(SubNum = Sub_Nums[sub_idx], file_inform=file_inform)
- info_elec = pd.read_csv(os.path.join(fold_select, sub_fname+'.csv'), index_col=0)
- info_elec = pd.DataFrame(info_elec['Name (aparc)'])
- total_elec = pd.concat((total_elec,info_elec), axis = 0, ignore_index=True)
- electrode_count = pd.DataFrame(total_elec['Name (aparc)'].value_counts())
- electrode_count.to_excel(os.path.join(fold_major, 'total_implanted_elec.xlsx'))
- #%%
- major_feature = pd.DataFrame([])
- for sub_idx in trange(len(Sub_Nums)):
- sub_fname, SubName, NumCh, Ch_list, Bad_Ch = basic.info_sub(SubNum = Sub_Nums[sub_idx], file_inform=file_inform)
- clf_result = os.path.join(fold_acc, adj_fold+'.xlsx')
- clf_result = pd.read_excel(clf_result, sheet_name=sub_fname, index_col=0)
- train_acc = max(clf_result['train.1'])
- idx_max = clf_result[scaling].idxmax()
- best_model_name = clf_result['model.1'].iloc[idx_max]
- subfolders = basic.find_names(fold_class_FW, pattern = 'scaled_'+ scaling +'_sess', type_='dir')
- clf_max = subfolders[idx_max]
- clf_max = basic.load_pkl(os.path.join(fold_class_FW, clf_max,sub_fname+'.pkl'))
- test_acc = clf_max['test_acc']
- cv_result = clf_max['cv_result']
- cv_result = cv_result[best_model_name]
- chance_level = 1/6
- abs_increment = []
- abs_increment.append(cv_result[0][0]-chance_level)
- for ii in range(1,len(cv_result)):
- iii = cv_result[ii][0]-cv_result[ii-1][0]
- abs_increment.append(iii)
- rel_increment = []
- for num, value in enumerate(abs_increment):
- rel_increment.extend([value/(num+1)])
- fin_increment = []
- for idx in range(clf_result.loc[idx_max, 'indx.1']+1):
- fin_increment.append(sum(rel_increment[idx:clf_result.loc[idx_max, 'indx.1']+1]))
- sub_major_feat = clf_max['sorted_feature_name']
- sub_major_feat = sub_major_feat[:clf_result.loc[idx_max, 'indx.1']+1]
- sub_major_feat = pd.DataFrame(sub_major_feat, columns = ['Feature'])
- sub_major_feat[['Band', 'ChNum']] = sub_major_feat['Feature'].str.extract(r'(.*)\_Ch(\d+)')
- info_elec = pd.read_csv(os.path.join(fold_select, sub_fname+'.csv'), index_col=0)
- info_elec = pd.DataFrame(info_elec['Name (aparc)'])
- extract_Ch = []
- extract_Ch = [info_elec.loc[np.where(Ch_list == int(i))[0][0]].values[0] for i in sub_major_feat['ChNum']]
- extract_Ch = pd.DataFrame(extract_Ch, columns=['Area'])
- extract_Ch = pd.concat((extract_Ch, sub_major_feat['Band']), axis = 1)
- extract_Ch['Merged'] = extract_Ch['Area'] + '-' + extract_Ch['Band']
- extract_Ch['increment'] = pd.DataFrame(fin_increment)
- major_feature = pd.concat((major_feature,extract_Ch), axis = 0, ignore_index=True)
- major_feature.to_excel(os.path.join(fold_major, 'Total_result.xlsx'), index=False)
- #%%
- # 사람들이
- #%%
- import matplotlib.colors as mcolors
- processed = pd.read_excel(os.path.join(fold_major, 'Final.xlsx'))
- processed['Feature'] = processed['Feature'].str.replace('-', ' ')
- sum_processed = processed.sort_values(by='Sum', ascending=False)
- threshold = sum_processed['Sum'].quantile(0.9)
- df_top = sum_processed[sum_processed['Sum'] >= threshold]
- norm = mcolors.Normalize(vmin=df_top['Implant Count'].min(), vmax=df_top['Implant Count'].max())
- tt = pd.DataFrame([' ', ' ',' ',' '])
- # Choose a colormap
- colormap = plt.cm.Blues
- colors = colormap(norm(df_top['Implant Count']))
- colors = np.concatenate((colors, np.full((len(tt), 4), [0.8, 0.8, 0.8, 1])))
- all_features = pd.concat([df_top['Feature'], tt[0]], axis=0, ignore_index=True)
- all_sums = pd.concat([df_top['Sum']*100, pd.Series([0, 0, 0, 0])], axis=0)
- fig, ax = plt.subplots(figsize=(20, 12))
- ax.barh(all_features, all_sums, color=colors, edgecolor='black')
- ax.set_xlabel('Increment value', fontsize=20)
- ax.set_ylabel('Feature', fontsize=20)
- #ax.set_title('Top 20% of Sum Values with Different Bar Colors')
- ax.invert_yaxis() # To display the highest values at the top
- ax.grid(axis='x', linestyle='--', alpha=0.6)
- ax.tick_params(axis='both', labelsize=22)
- # Add colorbar
- sm = plt.cm.ScalarMappable(cmap=colormap, norm=norm)
- sm.set_array([])
- cbar = fig.colorbar(sm, ax=ax, label='Implant Count')
- cbar.ax.tick_params(labelsize=18)
- cbar.set_label('# of Electrode Implant', fontsize=22)
- plt.tight_layout()
- plt.savefig(os.path.join(fold_major, 'Increment_Value.png'), dpi = 300)
- plt.show()
- #%%
- average = processed.sort_values(by='Average', ascending=False)
- threshold = average['Average'].quantile(0.8)
- df_top = average[average['Average'] >= threshold]
- norm = mcolors.Normalize(vmin=df_top['Implant Count'].min(), vmax=df_top['Implant Count'].max())
- # Choose a colormap
- colormap = plt.cm.Blues
- # Create a figure and axes
- fig, ax = plt.subplots(figsize=(10, 6))
- # Create a horizontal bar plot
- ax.barh(df_top['Feature'], df_top['Average'], color=colormap(norm(df_top['Implant Count'])), edgecolor='black')
- ax.set_xlabel('Average')
- ax.set_ylabel('Feature')
- ax.set_title('Top 20% of Sum Values with Different Bar Colors')
- ax.invert_yaxis() # To display the highest values at the top
- ax.grid(axis='x', linestyle='--', alpha=0.6)
- # Add colorbar
- sm = plt.cm.ScalarMappable(cmap=colormap, norm=norm)
- sm.set_array([])
- fig.colorbar(sm, ax=ax, label='Implant Count')
- plt.show()
- #%% All data
- import matplotlib.colors as mcolors
- processed = pd.read_excel(os.path.join(fold_major, 'Final.xlsx'))
- processed['Feature'] = processed['Feature'].str.replace('-', ' ')
- sum_processed = processed.sort_values(by='Sum', ascending=False)
- threshold = sum_processed['Sum'].quantile(0.9)
- df_top = sum_processed#[sum_processed['Sum']]
- norm = mcolors.Normalize(vmin=df_top['Implant Count'].min(), vmax=df_top['Implant Count'].max())
- #tt = pd.DataFrame([' ', ' ',' ',' '])
- # Choose a colormap
- colormap = plt.cm.Blues
- colors = colormap(norm(df_top['Implant Count']))
- colors = np.concatenate((colors, np.full((len(tt), 4), [0.8, 0.8, 0.8, 1])))
- all_features = df_top['Feature']
- #all_features = pd.concat([df_top['Feature'], tt[0]], axis=0, ignore_index=True)
- all_sums = df_top['Sum']*100
- #all_sums = pd.concat([df_top['Sum']*100, pd.Series([0, 0, 0, 0])], axis=0)
- for ii in range(int(138/23)):
- fig, ax = plt.subplots(figsize=(22, 25))
- ax.barh(all_features[ii*23:(1+ii)*23], all_sums[ii*23:(1+ii)*23], color=colors, edgecolor='black')
- ax.set_xlabel('Increment value', fontsize=24)
- ax.set_ylabel('Feature', fontsize=24)
- #ax.set_title('Top 20% of Sum Values with Different Bar Colors')
- ax.invert_yaxis() # To display the highest values at the top
- ax.grid(axis='x', linestyle='--', alpha=0.6)
- ax.tick_params(axis='both', labelsize=24)
- ax.tick_params(axis='y', labelsize=28)
- plt.xlim([0, 20])
- # Add colorbar
- sm = plt.cm.ScalarMappable(cmap=colormap, norm=norm)
- sm.set_array([])
- cbar = fig.colorbar(sm, ax=ax, label='Implant Count')
- cbar.ax.tick_params(labelsize=24)
- cbar.set_label('# of Electrode Implant', fontsize=24)
- plt.tight_layout()
- plt.savefig(os.path.join(fold_major, 'Increment_Value'+str(ii)+'.png'), dpi = 300)
- plt.show()
Dec5_Major_Feature_Increment.py at commit 9720d6a, no license · at the source
Overview
- Department of Brain & Cognitive Sciences, Seoul National University, Seoul 08826, Republic of Korea
- Seoul AI School, Seoul School of Integrated Sciences and Technologies (aSSIST) University, Seoul 03767, Republic of Korea
- Research Institute of Basic Sciences, Seoul National University, Seoul 08826, Republic of Korea
- Department of Music Therapy, Graduate School, Ewha Womans University, Seoul 03760, Republic of Korea
- Department of Biomedical Engineering, Ulsan National Institute of Science and Technology, Ulsan 44919, Republic of Korea
- Department of Neurosurgery, Seoul National University Hospital, Seoul National University College of Medicine, Seoul 03080, Republic of Korea
- Neuroscience Research Institute, Seoul National University College of Medicine, Seoul 03080, Republic of Korea
Abstract
Music imagery involves internally generated auditory experiences, yet decoding imagined melodic content from neural activity remains challenging. Here, we examined whether imagined melodies can be decoded from human electrocorticography (ECoG) recordings using a relative pitch framework. Ten epilepsy patients performed a music imagery task involving familiar melodies presented in multiple tonalities (3 males and 7 females; mean age, 27.3 ± 4.69 years). Neural features from imagery-responsive cortical sites were used to train intrasubject models to decode relative pitch classes at the single-note level. Although single-note decoding accuracy was modest, it reliably exceeded chance. Sequential integration of decoded pitch classes enabled reconstruction of melodic contours that preserved the relative structure of imagined melodies. These results provide a proof-of-concept that imagined melodic structure can be accessed from intracranial neural recordings when framed in terms of relative pitch, underscoring the importance of sequence-level approaches for decoding internally generated auditory content.
Reproduced under the paper's license (CC BY), from the paper cited above.
Repository
Its files are read in the Code ↔ Paper reader above, with 3 matches between paragraphs and lines of code.
JII-Kwon/ECoG_Music_Imagined_Classification
9720d6ad23b97737c5da3a83d381986371aa6af6, 31 January 2026Availability: 1 check, the latest on 27 September 2026: the link answers
- 27 September 2026: the link answers
15 files
- code/
Dec1_Epoching_for_Classi , Python, 537 linesfication.py - code/
Dec2_Feature_extraction. , Python, 393 linespy - code/
Dec3_Feature_concat_n_sa , Python, 239 linesve_each_session_last.py - code/
Dec4_Decoding_FW_aug_ses , Python, 159 linession_v2_minmax.py - code/
Dec5_Major_Feature_Incre , Python, 262 lines, 1 matchment.py - code/
Dec6_make_answer_Time_fl , Python, 343 linesow_Decoding.py - code/
Dec7_Time_Flow_Decoding_ , Python, 484 linesv1108.py - code/
Intersub_0_Major_Feature , Python, 63 lines, 1 match_selection.py - code/
Intersub_1_Feature_extra , Python, 62 linesction.py - code/
pre1_cortex_basic.m , MATLAB, 65 lines - code/
pre2_cortex_filtered.m , MATLAB, 61 lines - code/
utils_basic_music.py , Python, 75 lines - code/
utils_etc_function.py , Python, 56 lines - code/
utils_ml_model.py , Python, 250 lines, 1 match - README.md, Text, 11 lines
Code accessibility
The code described in the paper is freely available online at https://
Reproduced under the paper's license (CC BY), from the paper cited above.
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;
- 14 scripts, each with its path and the digest of its content;
- 3 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
The data that support the findings of this study are available from the corresponding authors upon request.
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, 27 September 2026: the first record
Recorded: type, language, journal, volume, issue, pages, dates, 7 authors, 5 keywords, 11 MeSH terms, 2 funders, 44 references.
Cite
This paper
Kwon, J., Shin, Y., Kim, J. S., Jeong, E., Kim, S.-P., Lee, E. J., & Chung, C. K. (2026). Reconstruction of Imagined Melody with Relative Pitch Decoding in Electrocorticography. eNeuro, 13(8), ENEURO.0289-25.2026. https://
BibTeX
@article{kwon2026reconst
author = {Kwon, Jii and Shin, Youmin and Kim, June Sic and Jeong, Eunju and Kim, Sung-Phil and Lee, Eun Jung and Chung, Chun Kee},
title = {{Reconstruction of Imagined Melody with Relative Pitch Decoding in Electrocorticography}},
journal = {eNeuro},
year = {2026},
month = aug,
volume = {13},
number = {8},
pages = {ENEURO.0289--25.2026},
publisher = {Society for Neuroscience},
issn = {2373-2822},
doi = {10.1523/
url = {https://
pmid = {42547451},
pmcid = {PMC13456956}
}
RIS
TY - JOUR
AU - Kwon, Jii
AU - Shin, Youmin
AU - Kim, June Sic
AU - Jeong, Eunju
AU - Kim, Sung-Phil
AU - Lee, Eun Jung
AU - Chung, Chun Kee
TI - Reconstruction of Imagined Melody with Relative Pitch Decoding in Electrocorticography
T2 - eNeuro
J2 - eNeuro
PY - 2026
DA - 2026/
VL - 13
IS - 8
SP - ENEURO.0289
EP - 25.2026
SN - 2373-2822
PB - Society for Neuroscience
DO - 10.1523/
UR - https://
LA - en
ER -
CSL-JSON
{
"id": "10.1523/
"type": "article-journal",
"title": "Reconstruction of Imagined Melody with Relative Pitch Decoding in Electrocorticography",
"container-title": "eNeuro",
"author": [
{
"family": "Kwon",
"given": "Jii"
},
{
"family": "Shin",
"given": "Youmin"
},
{
"family": "Kim",
"given": "June Sic"
},
{
"family": "Jeong",
"given": "Eunju"
},
{
"family": "Kim",
"given": "Sung-Phil"
},
{
"family": "Lee",
"given": "Eun Jung"
},
{
"family": "Chung",
"given": "Chun Kee"
}
],
"container-title-short":
"volume": "13",
"issue": "8",
"page": "ENEURO.0289-25.2026",
"DOI": "10.1523/
"PMID": "42547451",
"PMCID": "PMC13456956",
"ISSN": "2373-2822",
"publisher": "Society for Neuroscience",
"URL": "https://
"language": "en",
"issued": {
"date-parts": [
[
2026,
8,
7
]
]
}
}
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.1523/eneuro.0254-25.2026 [code]
- Spatiotemporal Dynamics in Prespeech Semantic Category Decoding: An Intracranial EEG Study.Journal: eNeuroIn common: EEGLAB, seaborn, scikit-learn, 4 other tools, intracranial EEG (iEEG / ECoG / SEEG), cognitive, 1 reference, 2 authors
- [2] doi:10.1162/imag.a.1348 [code]
- The role of high-amplitude bursts of high-gamma activity in naturalistic speech and music listening.Journal: Imaging neuroscience (Cambridge, Mass.)In common: seaborn, pandas, SciPy, 2 other tools, intracranial EEG (iEEG / ECoG / SEEG), cognitive, 2 references
- [3] doi:10.3390/s26175327 [code]
- Subject Identity Confounds qEEG Emotion Recognition on DEAP and DREAMER.Journal: Sensors (Basel, Switzerland)In common: imbalanced-learn, seaborn, scikit-learn, 4 other tools, cognitive
- [4] doi:10.1002/advs.202519479 [code]
- Diminished Signal-to-Noise Ratio Disrupts Somatosensory Population Encoding and Drives Tactile Hyposensitivity in the Fmr1&
lt;sup& gt;-/ y& lt;/ sup& gt; Autism Model. Journal: Advanced science (Weinheim, Baden-Wurttemberg, Germany)In common: imbalanced-learn, seaborn, scikit-learn, 4 other tools, cognitive - [5] doi:10.1162/imag.a.1269 [code]
- From early to contemporary normative modeling: Mapping individual differences in neurophysiological signals.Journal: Imaging neuroscience (Cambridge, Mass.)In common: seaborn, scikit-learn, pandas, 3 other tools, 3 references
- [6] doi:10.1016/j.isci.2026.116586 [code]
- Condition-specific neural signatures of reactivation during post-retrieval rest: An EEG study.Journal: iScienceIn common: EEGLAB, seaborn, scikit-learn, 4 other tools, cognitive, 1 reference
- [7] doi:10.7554/elife.107088 [code]
- Development of auditory and spontaneous movement responses to music over the first postnatal year.Journal: eLifeIn common: EEGLAB, seaborn, scikit-learn, 4 other tools, 1 reference
- [8] doi:10.1093/cercor/bhag077 [code]
- The longitudinal development of intrinsic timescales in infancy and their relation to alpha brain rhythm.Journal: Cerebral cortex (New York, N.Y. : 1991)In common: EEGLAB, seaborn, scikit-learn, 4 other tools, 1 reference
- [9] doi:10.1002/mds.70348 [code]
- Electroencephalography-B
ased Clustering Reveals Robust Neurophysiological Subtypes in Parkinson's Disease. Journal: Movement disorders : official journal of the Movement Disorder SocietyIn common: EEGLAB, seaborn, scikit-learn, 4 other tools, 1 reference - [10] doi:10.1038/s41467-026-73878-4 [code]
- Neural Response to Familiar Names Predicts Outcome of Comatose ICU Patients: A Prospective Observational Cohort Study.Journal: Nature communicationsIn common: imbalanced-learn, EEGLAB, scikit-learn, 2 other tools, 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: 1 repository of the authors' code, each at its verified commit and with its license, 14 scripts, and 3 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:449624a7196aefc4…
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.
