Opioid-specific brain connectivity dynamics distinguish analgesia from secondary effects: Studies in male mice.
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
- from collections import ChainMap
- from operator import itemgetter
- from pathlib import Path
- from typing import cast
- import h5py as h5
- import numpy as np
- from bids import BIDSLayout
- from joblib import Parallel, delayed
- from nibabel.nifti1 import Nifti1Image
- from rich.console import Console
- from rich.progress import track
- from opioids_analysis.pearson import (
- SessionSubjectLevelPearson,
- SubjectLevelPearson,
- compute_group_level_pearson,
- compute_group_level_pearson_anova,
- compute_subject_level_pearson,
- read_session_sample_masks,
- read_session_subject_level_pearson,
- write_group_level_pearson_anova,
- write_session_group_level_pearson,
- write_session_subject_level_pearson,
- )
- from opioids_analysis.plotting import (
- plot_group_level_pearson,
- plot_group_level_pearson_anova,
- )
- console = Console()
- ########################################################################################
- # Parameters
- ########################################################################################
- # Path to the preprocessed fUS-BIDS dataset.
- registered_data_path = Path(
- "/mnt/feanor/datasets/opioids/derivatives/registration/derivatives/preprocessed/"
- )
- layout = BIDSLayout(registered_data_path, validate=False)
- # Session labels present in the dataset.
- sessions = layout.get_sessions()
- # Path to the parameters directory.
- params_path = Path("params/")
- # Analysis results root path.
- opioids_results_root = Path("/mnt/feanor/home/sdiebolt/opioids-paper-results/")
- # Sample masks path.
- sample_masks_path = opioids_results_root / "sample_masks.h5"
- # Saline sessions used for the control group.
- saline_sessions = ["saline", "saline2", "WTFS1", "WTMS1"]
- # Label of the session used as control in statistical comparisons.
- control_session = "salineControl"
- # Labels of the treatment sessions used in the analysis.
- treatment_sessions = ["WTM10", "WTM20", "WTM30", "WTM70"]
- # Threshold for significance after FDR correction.
- fdr_threshold = 0.05
- # Output HDF5 file for subject-level and group-level results.
- subject_level_path = opioids_results_root / "subject_level_pearson.h5"
- group_level_path = opioids_results_root / "group_level_pearson.h5"
- group_level_anova_path = opioids_results_root / "group_level_pearson_anova.h5"
- # Folder where figures will be saved.
- figures_path = group_level_path.parent / "figures"
- # ROI ordering and labels for circular graphs
- graph_roi_order = (8, 9, 5, 4, 3, 2, 1, 0, 6, 7, 10, 11, 12, 16, 17, 13, 14, 15)
- graph_roi_labels = {k: v + 1 for k, v in enumerate(graph_roi_order)}
- # The maximum number of concurrently running jobs. If -1 all CPUs are used.
- n_jobs = -1
- # Whether to overwrite existing results in HDF5 files.
- overwrite_results = False
- ########################################################################################
- # Initializations
- ########################################################################################
- with console.status("[bold cyan]Loading template and ROIs..."):
- template_path = params_path / "opioids_template.nii.gz"
- template_img = Nifti1Image.from_filename(template_path)
- # Set the sform code to 0 so that Nilearn uses qform.
- template_img.set_sform(None, code=0)
- rois_name = params_path / "Mask-autoROIs18-slim.nii.gz"
- rois_img = Nifti1Image.from_filename(rois_name)
- if template_img.shape != rois_img.shape:
- raise ValueError("Template and ROIs image shapes do not match!")
- brain_mask_img = Nifti1Image(
- (template_img.get_fdata() > 0).astype(int),
- affine=template_img.affine,
- header=template_img.header,
- )
- ########################################################################################
- # Subject-level Pearson correlation computation
- ########################################################################################
- with Parallel(n_jobs=n_jobs) as parallel:
- for session in track(
- sessions,
- description="[bold cyan]Computing subject-level Pearson correlation",
- transient=True,
- ):
- if subject_level_path.is_file():
- with h5.File(subject_level_path, "r") as f:
- if "seed_maps" in f and session in f["seed_maps"]:
- continue
- sample_masks = read_session_sample_masks(sample_masks_path, session)
- # Paths are sorted to order them by run index.
- subjects = cast(list[str], layout.get_subjects(session=session))
- subject_level_pearson = cast(
- list[SubjectLevelPearson],
- parallel(
- delayed(compute_subject_level_pearson)(
- nii_paths=sorted(
- layout.get(subject=subject, session=session, return_type="file")
- ),
- brain_mask_img=brain_mask_img,
- rois_img=rois_img,
- sample_masks=sample_masks[subject],
- )
- for subject in subjects
- ),
- )
- # Matrices and maps are saved as numpy arrays for easier operations during the
- # group-level analysis.
- correlation_matrices = np.array(
- [res["correlation_matrices"] for res in subject_level_pearson]
- )
- seed_maps = [res["seed_maps"] for res in subject_level_pearson]
- subject_level_pearson = cast(
- SessionSubjectLevelPearson,
- {
- "correlation_matrices": dict(
- zip(subjects, np.array(correlation_matrices))
- ),
- "seed_maps": dict(zip(subjects, np.array(seed_maps))),
- },
- )
- write_session_subject_level_pearson(
- subject_level_path,
- session,
- subject_level_pearson,
- overwrite=overwrite_results,
- )
- ########################################################################################
- # Create the saline control session
- ########################################################################################
- with console.status("[bold cyan]Creating saline control session..."):
- with h5.File(subject_level_path, "r") as f:
- missing_pearson = [s for s in saline_sessions if s not in f["seed_maps"]]
- if missing_pearson:
- raise RuntimeError(
- "The following saline pearson are missing from the HDF5 file: "
- f"{missing_pearson}."
- )
- saline_pearson = [
- read_session_subject_level_pearson(subject_level_path, s)
- for s in saline_sessions
- ]
- correlation_matrices = map(itemgetter("correlation_matrices"), saline_pearson)
- seed_maps = map(itemgetter("seed_maps"), saline_pearson)
- saline_control_pearson = cast(
- SessionSubjectLevelPearson,
- {
- "correlation_matrices": dict(ChainMap(*correlation_matrices)),
- "seed_maps": dict(ChainMap(*seed_maps)),
- },
- )
- write_session_subject_level_pearson(
- subject_level_path,
- control_session,
- saline_control_pearson,
- overwrite=overwrite_results,
- )
- ########################################################################################
- # Group-level Pearson correlation computation (individual sessions)
- ########################################################################################
- brain_mask = brain_mask_img.get_fdata().squeeze().astype(bool)
- # Compute group-level results for each treatment session individually
- for session in track(
- treatment_sessions,
- description="[bold cyan]Computing group-level Pearson correlation",
- transient=True,
- ):
- group_level_pearson = compute_group_level_pearson(
- subject_level_path=subject_level_path,
- session_treatment=session,
- session_control=control_session,
- brain_mask=brain_mask,
- fdr_threshold=fdr_threshold,
- n_jobs=n_jobs,
- )
- write_session_group_level_pearson(
- group_level_path, session, group_level_pearson, overwrite=overwrite_results
- )
- ########################################################################################
- # Group-level Pearson correlation computation (ANOVA across sessions)
- ########################################################################################
- with console.status("[bold cyan]Computing group-level Pearson ANOVA..."):
- group_level_pearson_anova = compute_group_level_pearson_anova(
- subject_level_path=subject_level_path,
- treatment_sessions=treatment_sessions,
- control_session=control_session,
- brain_mask=brain_mask,
- fdr_threshold=fdr_threshold,
- n_jobs=n_jobs,
- )
- write_group_level_pearson_anova(
- group_level_anova_path, group_level_pearson_anova, overwrite=overwrite_results
- )
- ########################################################################################
- # Plotting group-level Pearson correlation results (individual sessions)
- ########################################################################################
- for session in track(
- treatment_sessions,
- description="[bold cyan]Plotting group-level Pearson correlation results",
- transient=True,
- ):
- plot_group_level_pearson(
- group_level_path=group_level_path,
- session=session,
- template_img=template_img,
- rois_img=rois_img,
- graph_roi_order=graph_roi_order,
- graph_roi_labels=graph_roi_labels,
- output_path=figures_path,
- )
- ########################################################################################
- # Plotting group-level Pearson ANOVA results (across sessions)
- ########################################################################################
- with console.status("[bold cyan]Plotting group-level Pearson ANOVA results..."):
- plot_group_level_pearson_anova(
- group_level_path=group_level_anova_path,
- template_img=template_img,
- rois_img=rois_img,
- graph_roi_order=graph_roi_order,
- graph_roi_labels=graph_roi_labels,
- output_path=figures_path,
- )
01_figure_pearson.py, under CC-BY-4.0 · at the source
Overview
- Team Dynamics of Neuronal Structure in Health and Disease, Institute of Psychiatry and Neuroscience of Paris, Inserm U1266, Université Paris Cité, Paris 75014, France
- 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
- Iconeus, Paris 75014, France
- Institut des Sciences Biologiques, CNRS, Paris 75005, France
- Institute of Pharmacology and Toxicology, Jena University Hospital, Friedrich Schiller University, Jena 07747, Germany
- 7TM Antibodies GmbH, Jena 07745, Germany
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
Availability: 1 check, the latest on 30 September 2026: the link answers (HTTP 200)
- 30 September 2026: the link answers (HTTP 200)
Zenodo 10401165
Availability: 1 check, the latest on 30 September 2026: the link answers (HTTP 200)
- 30 September 2026: the link answers (HTTP 200)
11 files
- article-figures/
01_figure_pearson.py , Python, 277 lines - article-figures/
02_figure_fc_vs_analgesi , Python, 215 linesa.py - article-figures/
03_figure_multimodal.py , Python, 1,170 lines - article-figures/
04_figure_rcbv_rasterplo , Python, 255 linests.py - article-figures/
05_figure_xcorr.py , Python, 228 lines - src/
opioids_analysis/ , Python, 1 line__init__.py - src/
opioids_analysis/ , Python, 368 linescross_correlation.py - src/
opioids_analysis/ , Python, 95 linesmultimodal.py - src/
opioids_analysis/ , Python, 1,113 linespearson.py - src/
opioids_analysis/ , Python, 945 linesplotting.py - README.md, Text, 75 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:
- 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:
- it points to the authors' code: Zenodo 10286698, Zenodo 10401165
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://
BibTeX
@article{mariani2026opio
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/
url = {https://
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/
VL - 123
IS - 11
SP - e2505464123
SN - 0027-8424
PB - National Academy of Sciences
DO - 10.1073/
UR - https://
LA - en
ER -
CSL-JSON
{
"id": "10.1073/
"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":
"volume": "123",
"issue": "11",
"page": "e2505464123",
"DOI": "10.1073/
"PMID": "41802052",
"PMCID": "PMC12994188",
"ISSN": "0027-8424",
"publisher": "National Academy of Sciences",
"URL": "https://
"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 communicationsIn 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 communicationsIn 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 myelinationJournal: 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: iScienceIn 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: NeuroradiologyIn 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 couplingJournal: 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 differencesIn 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: iScienceIn 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 biologyIn 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.
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: 2 repositories of the authors' code, each at its verified commit and with its license, 10 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:3b0ac292461ba824…
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.
