OSCR

Spec-RWKV: A Spectrum-Guided Multi-Scale Recurrent Modeling Framework for Multi-Center Resting-State fMRI-Assisted Diagnosis.

Code ↔ Paper

8 matches between paragraphs of the paper and lines of its authors' code, computed by the harvester (lexical-v1). Click a colored paragraph or line to see its counterpart.

5 blocks of code here have a permanent identifier (oscr:b:…), listed with the matches below: citable for good, with a page of its own. Select a match and press Cite to copy it. What a block identifier is.

The 8 matches · 2 of them tie a paragraph to a whole file without given lines: weak matches, whose lines are not tinted
  1. [1] § 2. Materials and Methods › 2.1. Datasets › 2.1.1. ABIDE-I ↔ Dataset/Prep/prep_abide.py, lines 107 to 179 · score 0.92 · global signal regression, band pass filtering, CPAC pipeline, fMRI, PCP, quality · block oscr:b:R6D7K1B2JZCJB-3 · Report a mismatch
  2. [2] § 2. Materials and Methods › 2.3. Spec-RWKV Framework › 2.3.4. Training Objectives and Optimization Strategy ↔ Models/spec_rwkv/model.py, lines 49 to 143 · score 0.74 · Asymmetric Focal Loss, learning rate scheduling, Adam, Optimization, classification, training · block oscr:b:HH6HWZTZ3TEV6-1 · Report a mismatch
  3. [3] § 2. Materials and Methods › 2.3. Spec-RWKV Framework › 2.3.2. Temporal Backbone: RWKV Recurrent Attention and PrismTimeMix ↔ Models/spec_rwkv/rwkv_block.py, lines 141 to 267 · score 0.66 · step decay rates, physical half, PrismTimeMix, heads, RWKV, TR · block oscr:b:KRAKX1Q3BMWD2-K · Report a mismatch
  4. [4] § 2. Materials and Methods › 2.3. Spec-RWKV Framework › 2.3.4. Training Objectives and Optimization Strategy ↔ Models/spec_rwkv/hyperparams.py, the whole file · a weak match · score 0.65 · Asymmetric Focal Loss, diversity, auxiliary, Optimization, resampling, classification · block oscr:b:X212QJCGTT7Y3-L · Report a mismatch
  5. [5] § 3. Results › 3.1. Experimental Settings and Evaluation Metrics › 3.1.2. Evaluation Metrics ↔ Models/spec_rwkv/model.py, lines 613 to 666 · score 0.59 · binary classification, ACC, TN, TP, FN, FP · block oscr:b:1PSX2HGWAHS9A-G · Report a mismatch
  6. [6] § 2. Materials and Methods › 2.3. Spec-RWKV Framework › 2.3.3. Spectral Branch and Spectrum-Guided Temporal Aggregation ↔ Models/spec_rwkv/hyperparams.py, the whole file · a weak match · score 0.57 · Gated Fusion, spectral contributions, GFU, dimension, weight, Branch · block oscr:b:X212QJCGTT7Y3-L · Report a mismatch
  7. [7] § 2. Materials and Methods › 2.1. Datasets › 2.1.2. ADHD-200 ↔ Dataset/Prep/prep_abide.py, lines 107 to 179 · score 0.56 · phenotypic information, fMRI, quality, Global · block oscr:b:R6D7K1B2JZCJB-3 · Report a mismatch
  8. [8] § 3. Results › 3.1. Experimental Settings and Evaluation Metrics › 3.1.1. Experimental Settings ↔ Models/spec_rwkv/rwkv_block.py, lines 141 to 267 · score 0.55 · physical half lives, PrismTimeMix, learnable, modulation, zero, heads · block oscr:b:KRAKX1Q3BMWD2-K · Report a mismatch

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 · 181 lines · 6.7 KB · no license · 2 matches

  1. import os
  2. from concurrent.futures import ProcessPoolExecutor
  3. from functools import partial
  4. import nilearn as nil
  5. import nilearn.datasets
  6. import nilearn.image
  7. from glob import glob
  8. import pandas
  9. import torch
  10. from tqdm import tqdm
  11. try:
  12. from .prep_atlas import prep_atlas
  13. except ImportError:
  14. from prep_atlas import prep_atlas
  15. from nilearn.input_data import NiftiLabelsMasker
  16. datadir = "./Dataset/Data"
  17. def parse_schaefer_labels_to_roi2net(labels, merge_7net=True):
  18. """
  19. labels: list of strings length N (1-based or 0-based names)
  20. returns: roi2net list of ints length N, mapping dict network->id, network_names list
  21. """
  22. if labels is None:
  23. raise ValueError("labels is None; cannot parse roi->network mapping")
  24. # ensure list of str
  25. lab_list = [str(l) for l in labels]
  26. canonical7 = ['Vis', 'SomMot', 'DorsAttn', 'SalVentAttn', 'Limbic', 'Cont', 'Default']
  27. mapping = {}
  28. roi2net = []
  29. for lab in lab_list:
  30. # typical label like "7Networks_LH_Vis_1" or "17Networks_LH_ContA_1"
  31. parts = lab.split('_')
  32. token = parts[2] if len(parts) >= 3 else lab
  33. if merge_7net and parts[0].startswith('7Networks'):
  34. matched = None
  35. for name in canonical7:
  36. if token.startswith(name):
  37. matched = name
  38. break
  39. token = matched if matched is not None else token
  40. # assign id
  41. if token not in mapping:
  42. mapping[token] = len(mapping)
  43. roi2net.append(mapping[token])
  44. network_names = [k for k, v in sorted(mapping.items(), key=lambda kv: kv[1])]
  45. # If atlas labels included a 'Background' token (common: labels length == n_rois + 1),
  46. # normalize by removing the background entry so roi2net length matches expected ROI count.
  47. if len(roi2net) > 0 and (network_names and network_names[0].lower().startswith("background") or (len(roi2net) % (len(network_names) if len(network_names)>0 else 1) == 1)):
  48. # heuristic: if first label is Background, drop it
  49. if lab_list[0].lower().startswith("background") or lab_list[0].lower().startswith("bg"):
  50. roi2net = roi2net[1:]
  51. # no change to mapping ids, but ensure network_names reflect mapping keys order
  52. network_names = [k for k, v in sorted(mapping.items(), key=lambda kv: kv[1])]
  53. return roi2net, mapping, network_names
  54. def _extract_subject(scan_path, atlas_map_path, phenoInfos):
  55. """
  56. Extract ROI time series and phenotypic information for one subject.
  57. This helper is designed for parallel preprocessing.
  58. """
  59. if ".gz" not in scan_path:
  60. return None
  61. try:
  62. # 1. Load the image and extract ROI signals.
  63. scanImage = nil.image.load_img(scan_path)
  64. masker = NiftiLabelsMasker(atlas_map_path)
  65. roiTimeseries = masker.fit_transform(scanImage)
  66. # 2. Extract acquisition metadata.
  67. header_zooms = scanImage.header.get_zooms()
  68. # TR is usually stored in the 4th zoom entry (index 3).
  69. tr = float(header_zooms[3]) if len(header_zooms) > 3 else None
  70. n_volumes = scanImage.shape[-1]
  71. # Compute total scan duration: Duration = TR × N.
  72. duration = tr * n_volumes if tr is not None else None
  73. # 3. Match phenotypic information.
  74. subjectId = scan_path.split("_")[-3][2:]
  75. pheno = phenoInfos.get(subjectId, {})
  76. return {
  77. "roiTimeseries": roiTimeseries,
  78. "pheno": {
  79. "subjectId": subjectId,
  80. "tr": tr,
  81. "n_volumes": n_volumes,
  82. "duration": duration,
  83. **pheno,
  84. },
  85. }
  86. except Exception as e:
  87. import traceback
  88. error_msg = f"Error processing {scan_path}: {type(e).__name__}: {e}"
  89. print(error_msg)
  90. # Print a short traceback for debugging.
  91. print(f" Traceback: {traceback.format_exc().splitlines()[-1]}")
  92. return None
  93. def prep_abide(atlas, num_workers=None):
  94. """
  95. Prepare the ABIDE-I dataset.
  96. Steps:
  97. 1) Download or load the requested atlas and build the ROI mask.
  98. 2) Download ABIDE PCP functional images if they are not already cached
  99. locally (CPAC pipeline, no filtering, no global signal regression).
  100. 3) Traverse 4D fMRI scans, extract ROI time series with the atlas, and
  101. save them together with phenotypic information.
  102. Args:
  103. atlas (str): Atlas identifier. Currently supports "schaefer7_400".
  104. Returns:
  105. None. Processed data files are written under Dataset/Data.
  106. """
  107. bulkDataDir = "{}/Bulk/ABIDE".format(datadir)
  108. atlasImage, atlas_map_path, labels = prep_atlas(atlas)
  109. # Always call fetch_abide_pcp: nilearn uses its cache and downloads only
  110. # missing files, so interrupted downloads can resume cleanly.
  111. nil.datasets.fetch_abide_pcp(
  112. data_dir=bulkDataDir,
  113. pipeline="cpac",
  114. band_pass_filtering=False,
  115. global_signal_regression=False,
  116. derivatives="func_preproc",
  117. quality_checked=True,
  118. )
  119. dataset = []
  120. temp = pandas.read_csv(bulkDataDir + "/ABIDE_pcp/Phenotypic_V1_0b_preprocessed1.csv").to_numpy()
  121. phenoInfos = {}
  122. for row in temp:
  123. phenoInfos[str(row[2])] = {"site": row[5], "age" : row[9], "disease" : row[7], "gender" : row[10]}
  124. print("\n\nStarting Parallel ROI Extraction...\n\n")
  125. scan_files = sorted(glob(bulkDataDir + "/ABIDE_pcp/cpac/nofilt_noglobal/*"))
  126. # Choose the number of worker processes: prefer the user-provided value,
  127. # otherwise use a fraction of the available CPU cores.
  128. workers = num_workers if num_workers is not None else max(1, (os.cpu_count() or 1) // 8)
  129. if workers == 1:
  130. # Single-process mode is easier to debug.
  131. iterator = map(lambda f: _extract_subject(f, atlas_map_path, phenoInfos), scan_files)
  132. for sample in tqdm(iterator, total=len(scan_files), ncols=60):
  133. if sample is not None:
  134. dataset.append(sample)
  135. else:
  136. # Multi-process mode speeds up preprocessing substantially.
  137. print(f"Using {workers} workers for parallel processing")
  138. from functools import partial
  139. process_fn = partial(_extract_subject, atlas_map_path=atlas_map_path, phenoInfos=phenoInfos)
  140. with ProcessPoolExecutor(max_workers=workers) as executor:
  141. # Distribute jobs with map.
  142. iterator = executor.map(process_fn, scan_files)
  143. for sample in tqdm(iterator, total=len(scan_files), ncols=60):
  144. if sample is not None:
  145. dataset.append(sample)
  146. # Save the fully processed dataset.
  147. save_path = datadir + "/dataset_abide_{}.save".format(atlas)
  148. torch.save(dataset, save_path)
  149. print(f"\nSuccessfully saved preprocessed dataset to: {save_path}")

prep_abide.py at commit 8e371b4, no license · at the source

Overview

Authors: Sihang Peng1, Qi Xu1
  1. College of Information Engineering, Shanghai Maritime University, Shanghai 201306, China
Institutions: Shanghai Maritime University (China)
Journal: Brain sciences, volume 16, issue 5, article 455
Dates: received 23 March 2026; accepted 22 April 2026; published online 24 April 2026
Type: Research article · Language: English
License: CC BY
Identifiers: DOI 10.3390/brainsci16050455 · PMID 42192768 · PMCID PMC13204946 · OpenAlex W7160296181
Open access: gold, a free copy (OpenAlex)
Status: code verified (how the code is found and verified)
Categories: fMRI (modality), autism (population), ADHD (population), clinical / translational (subfield)
Methods: Spectral & time-frequency, Connectivity, Preprocessing, fMRI & imaging, Machine learning
Keywords: resting-state fMRI, autism spectrum disorder, ADHD, multi-center data, recurrent neural network, spectral analysis
Topic: Functional Brain Connectivity Studies (Cognitive Neuroscience, Neuroscience), according to OpenAlex
Citations: not cited yet (Europe PMC); 38 references in the paper

Abstract

Highlights: What are the main findings? Spec-RWKV showed competitive diagnostic performance on ABIDE-I and ADHD-200, with relatively consistent results under leave-one-site-out evaluation and simulated TR perturbations. Model-derived importance maps were concentrated in the default mode and frontoparietal networks, and ASD-related spectral differences were more evident in slower frequency bands.

What are the implications of the main findings? Defining temporal dynamics in physical time may help make multi-site rs-fMRI modeling less sensitive to acquisition differences in TR. Joint temporal–spectral modeling could provide cross-site analyses with intermediate patterns that remain easier to inspect and interpret.

Abstract: Background: Multi-center resting-state functional magnetic resonance imaging (rs-fMRI) is important for neurodevelopmental disorder diagnosis, but cross-site differences in repetition time (TR) can cause temporal feature misalignment. In addition, blood-oxygenlevel-dependent (BOLD) signals are non-stationary, so disease-related information may be distributed across multiple time scales. Existing methods usually do not explicitly model physical sampling intervals or coordinate temporal and spectral information across scales, which may limit cross-site generalization in heterogeneous multi-center settings. Methods: We propose Spec-RWKV, a spectrum-guided linear recurrent framework for multi-site rs-fMRI diagnosis. It includes three components: PrismTimeMix, which models temporal dynamics using decay rates derived from physical half-lives and converts them adaptively across TRs; a TR-adaptive continuous wavelet transform, which aligns spectral representations across sites by adjusting frequency coverage; and spectrum-guided adaptive temporal aggregation, which uses spectral context to weight temporal features. Results: On ABIDE-I and ADHD-200, Spec-RWKV achieved AUCs of 75.86% and 76.31%, respectively. Under leave-one-site-out validation, it achieved the best mean AUC on ABIDE-I and the best mean accuracy and AUC on ADHD-200. Conclusions: Spec-RWKV explicitly models sampling-rate differences and multi-scale spectral structure, with results supporting strong cross-site generalizability.

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 8 matches between paragraphs and lines of code.

arisaris28/spec-rwkv

License: none: the authors keep all their rights
State: the link answers, verified on 29 September 2026
Evidence: files inventoried
Commit: 8e371b4551de922973e99c66f7280c2833cedaaa, 26 March 2026
Languages: Python (25), CUDA (1), C++ (1)
Size: 30 files, 27 scripts
Software Heritage: not archived
Found in: “Data Availability Statement”
Holds: README, environment (requirements.txt)
Not found: license file, CITATION.cff, tests, continuous integration, documentation
Tools: PyTorch (17 files), NumPy (8 files), Nilearn (3 files), pandas (3 files), scikit-learn (3 files), Matplotlib (2 files), PyWavelets (1 file), seaborn (1 file)
Availability: 1 check, the latest on 29 September 2026: the link answers
  • 29 September 2026: the link answers
28 files

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;
  • 27 scripts, each with its path and the digest of its content;
  • 8 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 data presented in this study are openly available in ABIDE Preprocessed Connectomes Project at http://preprocessed-connectomes-project.org/abide/ (accessed on 21 April 2026) and ADHD-200 Preprocessed Connectomes Project at http://preprocessed-connectomes-project.org/adhd200/ (accessed on 21 April 2026). The code for Spec-RWKV is available at https://github.com/arisaris28/spec-rwkv (accessed on 26 March 2026).

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, 37 references.

Cite

This paper

Peng, S., & Xu, Q. (2026). Spec-RWKV: A Spectrum-Guided Multi-Scale Recurrent Modeling Framework for Multi-Center Resting-State fMRI-Assisted Diagnosis. Brain sciences, 16(5), 455. https://doi.org/10.3390/brainsci16050455

BibTeX

@article{peng2026spec,
author = {Peng, Sihang and Xu, Qi},
title = {{Spec-RWKV: A Spectrum-Guided Multi-Scale Recurrent Modeling Framework for Multi-Center Resting-State fMRI-Assisted Diagnosis}},
journal = {Brain sciences},
year = {2026},
month = apr,
volume = {16},
number = {5},
pages = {455},
publisher = {Multidisciplinary Digital Publishing Institute},
issn = {2076-3425},
doi = {10.3390/brainsci16050455},
url = {https://doi.org/10.3390/brainsci16050455},
pmid = {42192768},
pmcid = {PMC13204946}
}

RIS

TY - JOUR
AU - Peng, Sihang
AU - Xu, Qi
TI - Spec-RWKV: A Spectrum-Guided Multi-Scale Recurrent Modeling Framework for Multi-Center Resting-State fMRI-Assisted Diagnosis
T2 - Brain sciences
J2 - Brain Sci
PY - 2026
DA - 2026/04/24
VL - 16
IS - 5
SP - 455
SN - 2076-3425
PB - Multidisciplinary Digital Publishing Institute
DO - 10.3390/brainsci16050455
UR - https://doi.org/10.3390/brainsci16050455
LA - en
ER -

CSL-JSON

{
"id": "10.3390/brainsci16050455",
"type": "article-journal",
"title": "Spec-RWKV: A Spectrum-Guided Multi-Scale Recurrent Modeling Framework for Multi-Center Resting-State fMRI-Assisted Diagnosis",
"container-title": "Brain sciences",
"author": [
{
"family": "Peng",
"given": "Sihang"
},
{
"family": "Xu",
"given": "Qi"
}
],
"container-title-short": "Brain Sci",
"volume": "16",
"issue": "5",
"page": "455",
"DOI": "10.3390/brainsci16050455",
"PMID": "42192768",
"PMCID": "PMC13204946",
"ISSN": "2076-3425",
"publisher": "Multidisciplinary Digital Publishing Institute",
"URL": "https://doi.org/10.3390/brainsci16050455",
"language": "en",
"issued": {
"date-parts": [
[
2026,
4,
24
]
]
}
}

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/s42003-026-10011-7 [code]
Learning brain dynamics across distinct scaling regimes reveals psychiatric signatures.
Journal: Communications biology
In common: PyWavelets, Nilearn, PyTorch, 4 other tools, ADHD, autism, 4 references
[2] doi:10.1007/s10278-025-01399-5 [code]
MHNet: Multi-view High-Order Network for Diagnosing Neurodevelopmental Disorders Using Resting-State fMRI.
Journal: Journal of imaging informatics in medicine
In common: Nilearn, PyTorch, scikit-learn, 3 other tools, fMRI, 4 references
[3] doi:10.1016/j.neuroimage.2024.120909 [code]
A simple but tough-to-beat baseline for fMRI time-series classification.
Journal: NeuroImage
In common: PyTorch, seaborn, scikit-learn, 3 other tools, fMRI, 5 references
[4] doi:10.1002/hbm.70469 [code]
VarCoNet: A Variability-Aware Self-Supervised Framework for Functional Connectome Extraction From Resting-State fMRI.
Journal: Human brain mapping
In common: Nilearn, PyTorch, seaborn, 4 other tools, autism, fMRI, 3 references
[5] doi:10.1016/j.isci.2023.108244 [code]
A common spectrum underlying brain disorders across lifespan revealed by deep learning on brain networks.
Journal: iScience
In common: Nilearn, PyTorch, scikit-learn, 3 other tools, 5 references
[6] doi:10.1186/s40708-026-00312-2 [code]
Synergistic and redundant information dynamics exhibit dissociable alterations across schizophrenia and neurodevelopmental conditions.
Journal: Brain informatics
In common: seaborn, scikit-learn, pandas, 2 other tools, ADHD, autism, fMRI, 5 references
[7] doi:10.1038/s41467-023-38972-x [code]
Hierarchical fluctuation shapes a dynamic flow linked to states of consciousness.
Journal: Nature communications
In common: Nilearn, PyTorch, seaborn, 4 other tools, fMRI, 4 references
[8] doi:10.1016/j.cell.2025.11.039 [code]
Stimulant medications affect arousal and reward, not attention networks.
Journal: Cell
In common: Nilearn, seaborn, scikit-learn, 3 other tools, ADHD, fMRI, 3 references
[9] doi:10.1093/gigascience/giaf091 [code]
High-precision machine learning identifies a reproducible functional connectivity signature of autism spectrum diagnosis in a subset of individuals.
Journal: GigaScience
In common: Nilearn, seaborn, scikit-learn, 3 other tools, autism, fMRI, clinical / translational, 2 references
[10] doi:10.1016/j.isci.2025.114100 [code]
Toward neuroimaging-based diagnostic support: a deep learning approach with a closed-loop system for psychiatric classification.
Journal: iScience
In common: PyWavelets, PyTorch, seaborn, 4 other tools, clinical / translational, 2 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.

Add the badge to the code's README

OSCR: the badge of this paper

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 -->
[![OSCR](https://openscicode.org/badge/doi/10.3390/brainsci16050455.svg)](https://openscicode.org/badge/doi/10.3390/brainsci16050455)
<!-- oscr-badge:end -->
reStructuredText
.. oscr-badge:start

.. image:: https://openscicode.org/badge/doi/10.3390/brainsci16050455.svg
   :target: https://openscicode.org/badge/doi/10.3390/brainsci16050455
   :alt: OSCR

.. oscr-badge:end
HTML
<!-- oscr-badge:start -->
<a href="https://openscicode.org/badge/doi/10.3390/brainsci16050455"><img src="https://openscicode.org/badge/doi/10.3390/brainsci16050455.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".

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.