Human brain-wide activation of sleep rhythms.
The 2 matches
- [1] § Methods › fMRI GLM analysis ↔ First_level_SO_base.py, lines 77–104 · score 0.68 · drift model, fMRI GLM, FWHM, cosine, smoothed
- [2] § Methods › MRI data preprocessing › Functional data preprocessing ↔ First_level_SO_base.py, lines 120–154 · score 0.63 · preprocessed BOLD, brain mask, FreeSurfer, space, mri
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 · 165 lines · 6.6 KB · MIT · 2 matches
- import glob
- import os
- import time
- import numpy as np
- import argparse
- from datetime import date
- from os.path import join
- import pandas as pd
- from joblib import Parallel, delayed
- import nibabel as nib
- from nilearn import image, masking
- from nilearn.glm.first_level import FirstLevelModel
- def prepare_data(subj, configs):
- func_dir, event_dir = configs['func_dir'], configs['event_dir']
- # func_name = configs['func_name']
- func_path = configs['func_path']
- mask_path = configs['mask_path']
- # sub_func_path = func_dir + '/sub-{}/func/'.format(subj)
- run_list = glob.glob(event_dir + '/sub-{}/run*'.format(subj))
- functional_imgs = []
- design_matrices = []
- mask_imgs = []
- for f in run_list:
- run_num = f.split('-')[-1]
- # func_file = sub_func_path + func_name.format(subj, run_num)
- func_file = func_path.format(subj, subj, run_num)
- func_img = nib.load(func_file)
- mask_file = mask_path
- mask_img = nib.load(mask_file)
- DM_path = event_dir + '/sub-{}/run-{}/DM.pkl'.format(subj, run_num)
- need_tr_path = event_dir + '/sub-{}/run-{}/need_tr_list.npy'.format(subj, run_num)
- design_matrix = pd.read_pickle(DM_path)
- need_tr_list = np.load(need_tr_path, allow_pickle=True)
- func_data = np.asarray(func_img.dataobj)[..., need_tr_list]
- img_header = func_img.header.copy()
- img_header.set_data_shape(func_data.shape)
- func_img_new = nib.Nifti1Image(func_data, func_img.affine, header=img_header)
- mask_imgs.append(mask_img)
- functional_imgs.append(func_img_new)
- design_matrices.append(design_matrix)
- DM_max_len = max(design_matrices, key=lambda x: x.shape[1]).shape[1]
- for dm in design_matrices:
- dummy_count = 0
- while dm.shape[1] < DM_max_len:
- dm.insert(dm.shape[1], 'dummy{}'.format(dummy_count), np.zeros(dm.shape[0]))
- dummy_count += 1
- return functional_imgs, design_matrices, mask_imgs
- def set_contrasts_SOSP_inter(design_matrices):
- contrast_matrix = np.eye(design_matrices.shape[1])
- basic_contrasts = dict([(column, contrast_matrix[i]) for i, column in enumerate(design_matrices.columns)])
- contrasts = {
- 'SO_spindle': basic_contrasts['SO_spindle'],
- 'SP_main': basic_contrasts['SP_main'],
- 'SO_main': basic_contrasts['SO_main'],
- }
- return contrasts
- def set_contrasts_SOSP_inter_PPI(design_matrices):
- contrast_matrix = np.eye(design_matrices.shape[1])
- basic_contrasts = dict([(column, contrast_matrix[i]) for i, column in enumerate(design_matrices.columns)])
- contrasts = {
- 'SO_spindle': basic_contrasts['SO_spindle'],
- 'SP_main': basic_contrasts['SP_main'],
- 'SO_main': basic_contrasts['SO_main'],
- 'Hippo_FC': basic_contrasts['hippo_ts'],
- 'Hippo_PPI': basic_contrasts['SOSP*seed'],
- }
- return contrasts
- def first_level_glm(datasink, run_imgs, design_matrices, mask_img, PPI):
- T1 = time.perf_counter()
- fmri_glm = FirstLevelModel(t_r=2.0, slice_time_ref=0.5, hrf_model='spm',
- drift_model='cosine', high_pass=0.01,
- mask_img=mask_img[0], smoothing_fwhm=8,
- verbose=1, n_jobs=-1)
- fmri_glm = fmri_glm.fit(run_imgs, design_matrices=design_matrices)
- T2 = time.perf_counter()
- print('run_glm:%s\n' % (T2 - T1))
- # TODO
- if PPI == 1:
- contrasts = set_contrasts_SOSP_inter_PPI(design_matrices[0])
- else:
- contrasts = set_contrasts_SOSP_inter(design_matrices[0])
- run_path = datasink
- os.makedirs(run_path, exist_ok=True)
- print('Computing contrasts...')
- for index, (contrast_id, contrast_val) in enumerate(contrasts.items()):
- print('Contrast % 2i out of %i: %s' % (index + 1, len(contrasts), contrast_id))
- stats_map = fmri_glm.compute_contrast(contrast_val, output_type='all')
- c_map = stats_map['effect_size']
- z_map = stats_map['z_score']
- c_image_path = join(run_path, '%s_cmap.nii.gz' % contrast_id)
- c_map.to_filename(c_image_path)
- z_image_path = join(run_path, '%s_zmap.nii.gz' % contrast_id)
- z_map.to_filename(z_image_path)
- def run(subj, out, PPI):
- print("-------{} start!--------".format(subj))
- data_sink_path = out
- data_sink = data_sink_path + '{}/sub-{}'.format(configs['task'], subj)
- if os.path.exists(data_sink): return
- functional_imgs, design_matrices, mask_imgs = prepare_data(subj, configs)
- if functional_imgs is None or len(functional_imgs) == 0: return
- # try:
- first_level_glm(data_sink, functional_imgs, design_matrices, mask_imgs, PPI)
- # except:
- # raise 'sub{} error!'.format(subj)
- parser = argparse.ArgumentParser()
- parser.add_argument("--para", type=str, help="para_path")
- parser.add_argument("--PPI", type=int, help="is PPI?")
- args = parser.parse_args()
- para = args.para
- PPI = args.PPI
- mri_code_path = '/home/wht/data/PKU_all/code/2.3_mri_result/'
- contrasts_list_SOSP_inter = 'SO_spindle,SP_main,SO_main'
- contrasts_list_SOSP_inter_PPI = 'SO_spindle,SP_main,SO_main,Hippo_FC,Hippo_PPI' #,SO_PPI,SP_PPI'
- if PPI == 1:
- event_dir = '{}2.2.2_behavior_SO_base_PPI'.format(para)
- else:
- event_dir = '{}2.2.1_behavior_SO_base'.format(para)
- assert os.path.exists(event_dir)
- configs = {'task': 'rest',
- 'func_dir': '/home/wht/data/PKU_all/2/1.2_Sleep_PKU_part_all_bids_mri/1.2.3_mri_preproc_out',
- 'event_dir': event_dir,
- 'func_name': 'sub-{}_task-rest_run-{}_space-MNI152NLin2009cAsym_desc-preproc_bold.nii.gz',
- 'func_path': '/home/wht/data/PKU_all/2/1.2_Sleep_PKU_part_all_bids_mri/1.2.3_mri_preproc_out/sub-{}/func/sub-{}_task-rest_run-{}_space-MNI152NLin2009cAsym_desc-preproc_bold.nii.gz',
- 'mask_path': '/home/wht/data/PKU_all/4/bids_redo/1.2.2.2_bids_ICA_out/tpl-MNI152NLin2009cAsym_res-02_desc-brain_mask.nii.gz',
- 'events_name': 'result.npz'}
- sub_list = glob.glob(configs['event_dir'] + '/sub*')
- subjects = [s.split('-')[-1] for s in sub_list]
- if PPI == 1:
- out_path = '{}3.1_mri_result_SO_base_PPI/'.format(para)
- else:
- out_path = '{}3.1_mri_result_SO_base/'.format(para)
- os.makedirs(out_path, exist_ok=True)
- Parallel(n_jobs=4)(delayed(run)(sub, out_path, PPI) for sub in subjects)
- # TODO
- if PPI == 1:
- cmd = "python '{}Second_level.py' --data_path {} --contrasts {}".format(mri_code_path, out_path, contrasts_list_SOSP_inter_PPI)
- else:
- cmd = "python '{}Second_level.py' --data_path {} --contrasts {}".format(mri_code_path, out_path, contrasts_list_SOSP_inter)
- os.system(cmd)
- cmd = "python '{}Correction_resample.py' --data_path {}".format(mri_code_path, out_path)
- os.system(cmd)
First_level_SO_base.py at commit 1b16df6, under MIT · at the source
Overview
- State Key Laboratory of Cognitive Neuroscience and Learning, IDG/McGovern Institute for Brain Research, Beijing Normal University, Beijing, China
- Chinese Institute for Brain Research, Beijing, China
- Center for MRI Research, Academy for Advanced Interdisciplinary Studies, Peking University, Beijing, China
- Beijing City Key Lab for Medical Physics and Engineering, Institute of Heavy Ion Physics, School of Physics, Peking University, Beijing, China
- McGovern Institute for Brain Research, Peking University, Beijing, China
Abstract
During sleep, our brain undergoes highly synchronized activity, orchestrated by distinct neural rhythms. Little is known about the associated brain activation during these sleep rhythms, and even less about their functional implications. In this study, we investigated the brain-wide activation underlying human sleep rhythms by employing simultaneous electroencephalography and functional magnetic resonance imaging in 107 participants during nocturnal naps (first half of the night). We identified robust coupling between slow oscillations (SOs) and fast spindles during deep non-rapid eye movement sleep (N2/
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 2 matches between paragraphs and lines of code.
liu_lab/eeg-fmri-sleep
1b16df6943d77837bb07093f0b812d3f6f92c40e, 28 July 2026Availability: 1 check, the latest on 27 September 2026: the link answers
- 27 September 2026: the link answers
5 files
- Correction_resample.py, Python, 76 lines
- First_level_SO_base.py, Python, 165 lines, 2 matches
- Second_level.py, Python, 34 lines
- LICENSE, License, 21 lines
- README.md, Text, 8 lines
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:
- 1 repository of the authors' code, each at its verified commit, with its license and how the link was found in the paper;
- 3 scripts, each with its path and the digest of its content;
- 2 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
Datasets cited
- doi:10.5061/
dryad.2fqz612x0 , at Dryad; found in “Data availability” - github.com/
neuroanatomyandconnectiv , at github.com; found in the text, “Open-ended cognitive state functional decoding”ity/ gradient_analysis
Data availability
The processed data are publicly available at https://
The following dataset was generated:
Haiteng W, Qihong Z, Jinbo Z, Jia-Hong G, Yunzhe L. 2026. Data from: Human brain-wide activation of sleep rhythms. Dryad Digital Repository.
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, pages, dates, 5 authors, 1 keyword, 13 MeSH terms, 4 funders, 84 references, 2 RRIDs.
Cite
This paper
Wang, H., Zou, Q., Zhang, J., Gao, J.-H., & Liu, Y. (2026). Human brain-wide activation of sleep rhythms. eLife, 14, RP103956. https://
BibTeX
@article{wang2026human,
author = {Wang, Haiteng and Zou, Qihong and Zhang, Jinbo and Gao, Jia-Hong and Liu, Yunzhe},
title = {{Human brain-wide activation of sleep rhythms}},
journal = {eLife},
year = {2026},
month = aug,
volume = {14},
pages = {RP103956},
publisher = {eLife Sciences Publications, Ltd},
issn = {2050-084X},
doi = {10.7554/
url = {https://
pmid = {42583934},
pmcid = {PMC13466540}
}
RIS
TY - JOUR
AU - Wang, Haiteng
AU - Zou, Qihong
AU - Zhang, Jinbo
AU - Gao, Jia-Hong
AU - Liu, Yunzhe
TI - Human brain-wide activation of sleep rhythms
T2 - eLife
J2 - Elife
PY - 2026
DA - 2026/
VL - 14
SP - RP103956
SN - 2050-084X
PB - eLife Sciences Publications, Ltd
DO - 10.7554/
UR - https://
LA - en
ER -
CSL-JSON
{
"id": "10.7554/
"type": "article-journal",
"title": "Human brain-wide activation of sleep rhythms",
"container-title": "eLife",
"author": [
{
"family": "Wang",
"given": "Haiteng"
},
{
"family": "Zou",
"given": "Qihong"
},
{
"family": "Zhang",
"given": "Jinbo"
},
{
"family": "Gao",
"given": "Jia-Hong"
},
{
"family": "Liu",
"given": "Yunzhe"
}
],
"container-title-short":
"volume": "14",
"page": "RP103956",
"DOI": "10.7554/
"PMID": "42583934",
"PMCID": "PMC13466540",
"ISSN": "2050-084X",
"publisher": "eLife Sciences Publications, Ltd",
"URL": "https://
"language": "en",
"issued": {
"date-parts": [
[
2026,
8,
12
]
]
}
}
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.1371/journal.pbio.3003755 [code]
- Action information is integrated into entorhinal representations of conceptual space and is reflected in eye movements.Journal: PLoS biologyIn common: Nilearn, NiBabel, pandas, 1 other tool, 16 references
- [2] doi:10.1523/eneuro.0370-25.2026 [code]
- Pretraining for Large-Scale Functional Connectome Fingerprinting Supports Generalization and Transfer Learning in Functional Neuroimaging.Journal: eNeuroIn common: Nilearn, pandas, NumPy, 13 references
- [3] doi:10.1038/s41467-025-63281-w [code]
- Trait anxiety is associated with reduced reward-related replay at restJournal: n/aIn common: EEG, 3 references, 2 authors
- [4] doi:10.1371/journal.pbio.3003684 [code]
- The retrieval of previously learned motor memories is facilitated by the reinstatement of default mode network manifold structures.Journal: PLoS biologyIn common: Nilearn, NiBabel, pandas, 1 other tool, 11 references
- [5] doi:10.7554/elife.108023 [code]
- Challenges in replay detection by TDLM in post-encoding resting state.Journal: eLifeIn common: pandas, NumPy, 10 references
- [6] doi:10.1038/s41467-026-71428-6 [code]
- Binding items to contexts through conjunctive neural representations with the method of loci.Journal: Nature communicationsIn common: Nilearn, NiBabel, pandas, 1 other tool, systems, 10 references
- [7] doi:10.7554/elife.107955
- Multiple event segmentation mechanisms in the human brain.Journal: eLifeIn common: 14 references
- [8] doi:10.1162/imag.a.1272 [code]
- Building bridges between brain and behavior: An open-source toolbox for joint modeling with fMRI.Journal: Imaging neuroscience (Cambridge, Mass.)In common: 13 references
- [9] doi:10.1038/s42003-026-09988-y
- Thalamic involvement defines distinct slow-wave subtypes in NREM sleep.Journal: Communications biologyIn common: EEG, 9 references
- [10] doi:10.1038/s41467-026-71151-2 [code]
- Common and distinct neural correlates of social interaction processing and theory of mind in narratives.Journal: Nature communicationsIn common: Nilearn, NiBabel, pandas, 1 other tool, 8 references
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, 3 scripts, and 2 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:83fe391c791b5f6e…
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
[.
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.
