OSCR

Opioid-specific brain connectivity dynamics distinguish analgesia from secondary effects: Studies in male mice.

Code ↔ Paper

The paper beside its authors' code: matches between them have not been computed for this paper yet.

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 · 277 lines · 9.8 KB · CC-BY-4.0

  1. from collections import ChainMap
  2. from operator import itemgetter
  3. from pathlib import Path
  4. from typing import cast
  5. import h5py as h5
  6. import numpy as np
  7. from bids import BIDSLayout
  8. from joblib import Parallel, delayed
  9. from nibabel.nifti1 import Nifti1Image
  10. from rich.console import Console
  11. from rich.progress import track
  12. from opioids_analysis.pearson import (
  13. SessionSubjectLevelPearson,
  14. SubjectLevelPearson,
  15. compute_group_level_pearson,
  16. compute_group_level_pearson_anova,
  17. compute_subject_level_pearson,
  18. read_session_sample_masks,
  19. read_session_subject_level_pearson,
  20. write_group_level_pearson_anova,
  21. write_session_group_level_pearson,
  22. write_session_subject_level_pearson,
  23. )
  24. from opioids_analysis.plotting import (
  25. plot_group_level_pearson,
  26. plot_group_level_pearson_anova,
  27. )
  28. console = Console()
  29. ########################################################################################
  30. # Parameters
  31. ########################################################################################
  32. # Path to the preprocessed fUS-BIDS dataset.
  33. registered_data_path = Path(
  34. "/mnt/feanor/datasets/opioids/derivatives/registration/derivatives/preprocessed/"
  35. )
  36. layout = BIDSLayout(registered_data_path, validate=False)
  37. # Session labels present in the dataset.
  38. sessions = layout.get_sessions()
  39. # Path to the parameters directory.
  40. params_path = Path("params/")
  41. # Analysis results root path.
  42. opioids_results_root = Path("/mnt/feanor/home/sdiebolt/opioids-paper-results/")
  43. # Sample masks path.
  44. sample_masks_path = opioids_results_root / "sample_masks.h5"
  45. # Saline sessions used for the control group.
  46. saline_sessions = ["saline", "saline2", "WTFS1", "WTMS1"]
  47. # Label of the session used as control in statistical comparisons.
  48. control_session = "salineControl"
  49. # Labels of the treatment sessions used in the analysis.
  50. treatment_sessions = ["WTM10", "WTM20", "WTM30", "WTM70"]
  51. # Threshold for significance after FDR correction.
  52. fdr_threshold = 0.05
  53. # Output HDF5 file for subject-level and group-level results.
  54. subject_level_path = opioids_results_root / "subject_level_pearson.h5"
  55. group_level_path = opioids_results_root / "group_level_pearson.h5"
  56. group_level_anova_path = opioids_results_root / "group_level_pearson_anova.h5"
  57. # Folder where figures will be saved.
  58. figures_path = group_level_path.parent / "figures"
  59. # ROI ordering and labels for circular graphs
  60. graph_roi_order = (8, 9, 5, 4, 3, 2, 1, 0, 6, 7, 10, 11, 12, 16, 17, 13, 14, 15)
  61. graph_roi_labels = {k: v + 1 for k, v in enumerate(graph_roi_order)}
  62. # The maximum number of concurrently running jobs. If -1 all CPUs are used.
  63. n_jobs = -1
  64. # Whether to overwrite existing results in HDF5 files.
  65. overwrite_results = False
  66. ########################################################################################
  67. # Initializations
  68. ########################################################################################
  69. with console.status("[bold cyan]Loading template and ROIs..."):
  70. template_path = params_path / "opioids_template.nii.gz"
  71. template_img = Nifti1Image.from_filename(template_path)
  72. # Set the sform code to 0 so that Nilearn uses qform.
  73. template_img.set_sform(None, code=0)
  74. rois_name = params_path / "Mask-autoROIs18-slim.nii.gz"
  75. rois_img = Nifti1Image.from_filename(rois_name)
  76. if template_img.shape != rois_img.shape:
  77. raise ValueError("Template and ROIs image shapes do not match!")
  78. brain_mask_img = Nifti1Image(
  79. (template_img.get_fdata() > 0).astype(int),
  80. affine=template_img.affine,
  81. header=template_img.header,
  82. )
  83. ########################################################################################
  84. # Subject-level Pearson correlation computation
  85. ########################################################################################
  86. with Parallel(n_jobs=n_jobs) as parallel:
  87. for session in track(
  88. sessions,
  89. description="[bold cyan]Computing subject-level Pearson correlation",
  90. transient=True,
  91. ):
  92. if subject_level_path.is_file():
  93. with h5.File(subject_level_path, "r") as f:
  94. if "seed_maps" in f and session in f["seed_maps"]:
  95. continue
  96. sample_masks = read_session_sample_masks(sample_masks_path, session)
  97. # Paths are sorted to order them by run index.
  98. subjects = cast(list[str], layout.get_subjects(session=session))
  99. subject_level_pearson = cast(
  100. list[SubjectLevelPearson],
  101. parallel(
  102. delayed(compute_subject_level_pearson)(
  103. nii_paths=sorted(
  104. layout.get(subject=subject, session=session, return_type="file")
  105. ),
  106. brain_mask_img=brain_mask_img,
  107. rois_img=rois_img,
  108. sample_masks=sample_masks[subject],
  109. )
  110. for subject in subjects
  111. ),
  112. )
  113. # Matrices and maps are saved as numpy arrays for easier operations during the
  114. # group-level analysis.
  115. correlation_matrices = np.array(
  116. [res["correlation_matrices"] for res in subject_level_pearson]
  117. )
  118. seed_maps = [res["seed_maps"] for res in subject_level_pearson]
  119. subject_level_pearson = cast(
  120. SessionSubjectLevelPearson,
  121. {
  122. "correlation_matrices": dict(
  123. zip(subjects, np.array(correlation_matrices))
  124. ),
  125. "seed_maps": dict(zip(subjects, np.array(seed_maps))),
  126. },
  127. )
  128. write_session_subject_level_pearson(
  129. subject_level_path,
  130. session,
  131. subject_level_pearson,
  132. overwrite=overwrite_results,
  133. )
  134. ########################################################################################
  135. # Create the saline control session
  136. ########################################################################################
  137. with console.status("[bold cyan]Creating saline control session..."):
  138. with h5.File(subject_level_path, "r") as f:
  139. missing_pearson = [s for s in saline_sessions if s not in f["seed_maps"]]
  140. if missing_pearson:
  141. raise RuntimeError(
  142. "The following saline pearson are missing from the HDF5 file: "
  143. f"{missing_pearson}."
  144. )
  145. saline_pearson = [
  146. read_session_subject_level_pearson(subject_level_path, s)
  147. for s in saline_sessions
  148. ]
  149. correlation_matrices = map(itemgetter("correlation_matrices"), saline_pearson)
  150. seed_maps = map(itemgetter("seed_maps"), saline_pearson)
  151. saline_control_pearson = cast(
  152. SessionSubjectLevelPearson,
  153. {
  154. "correlation_matrices": dict(ChainMap(*correlation_matrices)),
  155. "seed_maps": dict(ChainMap(*seed_maps)),
  156. },
  157. )
  158. write_session_subject_level_pearson(
  159. subject_level_path,
  160. control_session,
  161. saline_control_pearson,
  162. overwrite=overwrite_results,
  163. )
  164. ########################################################################################
  165. # Group-level Pearson correlation computation (individual sessions)
  166. ########################################################################################
  167. brain_mask = brain_mask_img.get_fdata().squeeze().astype(bool)
  168. # Compute group-level results for each treatment session individually
  169. for session in track(
  170. treatment_sessions,
  171. description="[bold cyan]Computing group-level Pearson correlation",
  172. transient=True,
  173. ):
  174. group_level_pearson = compute_group_level_pearson(
  175. subject_level_path=subject_level_path,
  176. session_treatment=session,
  177. session_control=control_session,
  178. brain_mask=brain_mask,
  179. fdr_threshold=fdr_threshold,
  180. n_jobs=n_jobs,
  181. )
  182. write_session_group_level_pearson(
  183. group_level_path, session, group_level_pearson, overwrite=overwrite_results
  184. )
  185. ########################################################################################
  186. # Group-level Pearson correlation computation (ANOVA across sessions)
  187. ########################################################################################
  188. with console.status("[bold cyan]Computing group-level Pearson ANOVA..."):
  189. group_level_pearson_anova = compute_group_level_pearson_anova(
  190. subject_level_path=subject_level_path,
  191. treatment_sessions=treatment_sessions,
  192. control_session=control_session,
  193. brain_mask=brain_mask,
  194. fdr_threshold=fdr_threshold,
  195. n_jobs=n_jobs,
  196. )
  197. write_group_level_pearson_anova(
  198. group_level_anova_path, group_level_pearson_anova, overwrite=overwrite_results
  199. )
  200. ########################################################################################
  201. # Plotting group-level Pearson correlation results (individual sessions)
  202. ########################################################################################
  203. for session in track(
  204. treatment_sessions,
  205. description="[bold cyan]Plotting group-level Pearson correlation results",
  206. transient=True,
  207. ):
  208. plot_group_level_pearson(
  209. group_level_path=group_level_path,
  210. session=session,
  211. template_img=template_img,
  212. rois_img=rois_img,
  213. graph_roi_order=graph_roi_order,
  214. graph_roi_labels=graph_roi_labels,
  215. output_path=figures_path,
  216. )
  217. ########################################################################################
  218. # Plotting group-level Pearson ANOVA results (across sessions)
  219. ########################################################################################
  220. with console.status("[bold cyan]Plotting group-level Pearson ANOVA results..."):
  221. plot_group_level_pearson_anova(
  222. group_level_path=group_level_anova_path,
  223. template_img=template_img,
  224. rois_img=rois_img,
  225. graph_roi_order=graph_roi_order,
  226. graph_roi_labels=graph_roi_labels,
  227. output_path=figures_path,
  228. )

01_figure_pearson.py, under CC-BY-4.0 · at the source

Overview

Authors: Jean-Charles Mariani1, Samuel Le Meur-Diebolt1,2,3, Laurianne Beynac1, Renata Santos1,4, Stefan Schulz5,6, Thomas Deffieux2, Mickael Tanter2, Zsolt Lenkei1, Andrea Kliewer1,5
  1. Team Dynamics of Neuronal Structure in Health and Disease, Institute of Psychiatry and Neuroscience of Paris, Inserm U1266, Université Paris Cité, Paris 75014, France
  2. Institute Physics for Medicine Paris, École Supérieure de Physique et de Chimie Industrielles de la Ville de Paris, Inserm U1273, CNRS U8631, Paris Sciences et Lettres – Université PSL, Paris 75015, France
  3. Iconeus, Paris 75014, France
  4. Institut des Sciences Biologiques, CNRS, Paris 75005, France
  5. Institute of Pharmacology and Toxicology, Jena University Hospital, Friedrich Schiller University, Jena 07747, Germany
  6. 7TM Antibodies GmbH, Jena 07745, Germany
Dates: received 11 March 2025; accepted 9 January 2026; published online 9 March 2026; in print 17 March 2026
Type: Research article · Language: English
License: CC BY-NC-ND
Identifiers: DOI 10.1073/pnas.2505464123 · PMID 41802052 · PMCID PMC12994188 · OpenAlex W7134850877
Open access: hybrid, a free copy (OpenAlex)
Status: code verified
Categories: mouse (organism), pain (population), systems (subfield)
Methods: Spectral & time-frequency, Smoothing, state filtering, decompositions, Machine learning, Preprocessing, Statistics, fMRI & imaging
Keywords: opioids, pain, brain imaging, functional connectivity
MeSH: Analgesia*, Analgesics, Opioid*, Brain*, Receptors, Opioid, mu*, Animals, Buprenorphine, Male, Mice, Mice, Inbred C57BL, Morphine, Somatosensory Cortex (* major topic)
Journal subjects: Biological Sciences, Neuroscience
Topic: Functional Brain Connectivity Studies (Cognitive Neuroscience, Neuroscience), according to OpenAlex
Funding: Else Kröner-Fresenius-Stiftung (2019_A68); Interdisciplinary center for clinical research Jena (AMSP 03); EMBO Short-term Fellowship (n{degree sign} 8439); PhD scholarship from Boehringer Ingelheim (No number); DAAD short-term research grant (57507442); Inserm Biomedical Ultrasound ART project (No number)
Citations: cited by 1 paper (Europe PMC); 62 references in the paper

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.

Repositories

Its files are read in the Code ↔ Paper reader above.

Zenodo 10286698

License: CC-BY-4.0
State: the link answers, verified on 30 September 2026
Evidence: files inventoried
Size: 1 file
Software Heritage: not checked
Found in: “Data, Materials, and Software Availability”
Not found: README, license file, CITATION.cff, environment file, tests, continuous integration, documentation
Availability: 1 check, the latest on 30 September 2026: the link answers (HTTP 200)
  • 30 September 2026: the link answers (HTTP 200)
At the source:

Zenodo 10401165

License: CC-BY-4.0
State: the link answers, verified on 30 September 2026
Evidence: files inventoried
Size: 1 file
Software Heritage: not checked
Found in: “Data, Materials, and Software Availability”
Not found: README, license file, CITATION.cff, environment file, tests, continuous integration, documentation
Tools: NumPy (8 files), NiBabel (7 files), h5py (5 files), Nilearn (5 files), Matplotlib (4 files), PyBIDS (4 files), pandas (3 files), SciPy (3 files), seaborn (3 files), NetworkX (1 file), scikit-learn (1 file), scikit-posthocs (1 file), statsmodels (1 file)
Availability: 1 check, the latest on 30 September 2026: the link answers (HTTP 200)
  • 30 September 2026: the link answers (HTTP 200)
11 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:

  • 2 repositories of the authors' code, each at its verified commit, with its license and how the link was found in the paper;
  • 10 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.

Code and data availability statement

The paper has a code and data availability statement. Its license (CC BY-NC-ND) does not allow reproducing it here; in short, from what the harvester recognized in it:

Read it in the paper: doi.org/10.1073/pnas.2505464123.

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, 30 September 2026: the first record

Recorded: type, language, journal, volume, issue, pages, dates, 9 authors, 4 keywords, 11 MeSH terms, 6 funders, 60 references.

Cite

This paper

Mariani, J.-C., Le Meur-Diebolt, S., Beynac, L., Santos, R., Schulz, S., Deffieux, T., Tanter, M., Lenkei, Z., & Kliewer, A. (2026). Opioid-specific brain connectivity dynamics distinguish analgesia from secondary effects: Studies in male mice. Proceedings of the National Academy of Sciences of the United States of America, 123(11), e2505464123. https://doi.org/10.1073/pnas.2505464123

BibTeX

@article{mariani2026opioid,
author = {Mariani, Jean-Charles and Le Meur-Diebolt, Samuel and Beynac, Laurianne and Santos, Renata and Schulz, Stefan and Deffieux, Thomas and Tanter, Mickael and Lenkei, Zsolt and Kliewer, Andrea},
title = {{Opioid-specific brain connectivity dynamics distinguish analgesia from secondary effects: Studies in male mice}},
journal = {Proceedings of the National Academy of Sciences of the United States of America},
year = {2026},
month = mar,
volume = {123},
number = {11},
pages = {e2505464123},
publisher = {National Academy of Sciences},
issn = {0027-8424},
doi = {10.1073/pnas.2505464123},
url = {https://doi.org/10.1073/pnas.2505464123},
pmid = {41802052},
pmcid = {PMC12994188}
}

RIS

TY - JOUR
AU - Mariani, Jean-Charles
AU - Le Meur-Diebolt, Samuel
AU - Beynac, Laurianne
AU - Santos, Renata
AU - Schulz, Stefan
AU - Deffieux, Thomas
AU - Tanter, Mickael
AU - Lenkei, Zsolt
AU - Kliewer, Andrea
TI - Opioid-specific brain connectivity dynamics distinguish analgesia from secondary effects: Studies in male mice
T2 - Proceedings of the National Academy of Sciences of the United States of America
J2 - Proc Natl Acad Sci U S A
PY - 2026
DA - 2026/03/09
VL - 123
IS - 11
SP - e2505464123
SN - 0027-8424
PB - National Academy of Sciences
DO - 10.1073/pnas.2505464123
UR - https://doi.org/10.1073/pnas.2505464123
LA - en
ER -

CSL-JSON

{
"id": "10.1073/pnas.2505464123",
"type": "article-journal",
"title": "Opioid-specific brain connectivity dynamics distinguish analgesia from secondary effects: Studies in male mice",
"container-title": "Proceedings of the National Academy of Sciences of the United States of America",
"author": [
{
"family": "Mariani",
"given": "Jean-Charles"
},
{
"family": "Le Meur-Diebolt",
"given": "Samuel"
},
{
"family": "Beynac",
"given": "Laurianne"
},
{
"family": "Santos",
"given": "Renata"
},
{
"family": "Schulz",
"given": "Stefan"
},
{
"family": "Deffieux",
"given": "Thomas"
},
{
"family": "Tanter",
"given": "Mickael"
},
{
"family": "Lenkei",
"given": "Zsolt"
},
{
"family": "Kliewer",
"given": "Andrea"
}
],
"container-title-short": "Proc Natl Acad Sci U S A",
"volume": "123",
"issue": "11",
"page": "e2505464123",
"DOI": "10.1073/pnas.2505464123",
"PMID": "41802052",
"PMCID": "PMC12994188",
"ISSN": "0027-8424",
"publisher": "National Academy of Sciences",
"URL": "https://doi.org/10.1073/pnas.2505464123",
"language": "en",
"issued": {
"date-parts": [
[
2026,
3,
9
]
]
}
}

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.1162/imag.a.1191
Robust functional ultrasound imaging in the awake and behaving brain: A systematic framework for motion artifact removal.
Journal: Imaging neuroscience (Cambridge, Mass.)
In common: mouse, 7 references, 4 authors
[2] doi:10.1038/s41467-026-71270-w [code]
Spatiotemporal dynamics of the human cortical functional hierarchy across the lifespan.
Journal: Nature communications
In common: PyBIDS, Nilearn, NetworkX, 8 other tools
[3] doi:10.1038/s41467-026-75959-w [code]
Charting higher-order models of brain function beyond pairwise interactions.
Journal: Nature communications
In common: Nilearn, NetworkX, h5py, 8 other tools, 1 reference
[4] doi:10.64898/2026.08.18.26360725 [code]
Temporal pole blurring in hippocampal sclerosis reflects seizure-disrupted myelination
Journal: medRxiv (preprint)
In common: PyBIDS, Nilearn, h5py, 8 other tools
[5] doi:10.1016/j.isci.2026.117180 [code]
Developmental changes in similarity between neural representations of mental arithmetic and artificial neural networks.
Journal: iScience
In common: PyBIDS, Nilearn, h5py, 8 other tools
[6] doi:10.1007/s00234-026-04103-8 [code]
Enhanced detection of subtle cortical abnormalities in focal epilepsy using 7 T MRI surface-based models and graph neural networks.
Journal: Neuroradiology
In common: PyBIDS, Nilearn, h5py, 8 other tools
[7] doi:10.64898/2026.03.12.710517 [code]
Cortical excitability inversely modulates fMRI connectivity via low-frequency neuronal coupling
Journal: bioRxiv (preprint)
In common: h5py, seaborn, pandas, 3 other tools, systems, 1 reference, author Jean-Charles Mariani
[8] doi:10.1186/s13293-026-00891-z [code]
Sex differences in dynamic and static measures of brain integration derived from resting-state functional magnetic resonance imaging.
Journal: Biology of sex differences
In common: PyBIDS, Nilearn, NetworkX, 7 other tools
[9] doi:10.1016/j.isci.2026.117375 [code]
Motor priming is associated with widespread recruitment into neural ensembles and more rapid ensemble transitions.
Journal: iScience
In common: scikit-posthocs, NetworkX, h5py, 7 other tools, systems
[10] doi:10.1038/s42003-026-09794-6 [code]
The role of dorsal anterior cingulate cortex in dynamic attitude changes in naturalistic settings.
Journal: Communications biology
In common: Nilearn, NetworkX, NiBabel, 7 other tools, systems, 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.

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.