Alterations in brain spatiotemporal autocorrelation and functional connectivity in lifelong premature ejaculation: A resting-state fMRI study.
The 1 match
- [1] § STAR★Methods › Method details › fMRI data processing ↔ spatiotemporal/models.py, lines 163 to 181 · score 0.51 · pass filtered, fMRI, minimize, 0.01 Hz · 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 · 214 lines · 10 KB · no license · 1 match
- # Part of the spatiotemporal package for python
- # Copyright 2022 Max Shinn <[email hidden]>
- # Available under the MIT license
- import numpy as np
- import scipy.signal
- import scipy.optimize
- from .tools import spatial_exponential_floor
- def spatiotemporal_model_timeseries(distance_matrix, sa_lambda, sa_inf, ta_delta1s, num_timepoints, sample_rate, highpass_freq, seed=None):
- """Simulate the spatiotemporal model from [Shinn et al (2022)](https://www.biorxiv.org/content/10.1101/2021.06.01.446561v1)
- Args:
- distance_matrix (NxN numpy array): the NxN distance matrix, representing the spatial distance
- between location of each of the timeseries. This should usually be the
- output of the `distance_matrix_euclidean` function.
- sa_lambda (float): the SA-λ parameter
- sa_inf (float): the SA-∞ parameter
- ta_delta1s (length-N list of floats): a list of TA-Δ₁ values, of length N, for generating the timeseries
- num_timepoints (int): length of timeseries to generate
- sample_rate (float): the spacing between timepoints (e.g. TR in fMRI)
- highpass_freq (float): if non-zero, apply a highpass filter above the
- given frequency. A good default is 0.01 for fMRI timeseries.
- seed (int, optional): the random seed. If not specified, it will use
- the current state of the numpy random number generator.
- Returns:
- NxT numpy array: For each of the N nodes, a timeseries of length T=`num_timepoints` according to the spatiotemporal model
- """
- assert num_timepoints % 2 == 0, "Must be even timeseries length"
- # Filtered brown noise spectrum
- spectrum = make_spectrum(tslen=num_timepoints, sample_rate=sample_rate, alpha=2, highpass_freq=highpass_freq)
- spectra = np.asarray([spectrum]*len(ta_delta1s))
- # Spatial autocorrelation matrix
- corr = spatial_exponential_floor(distance_matrix, sa_lambda, sa_inf)
- # Create spatially embedded timeseries with the given spectra
- tss = spatial_temporal_timeseries(corr, spectra, seed=seed)
- # Compute the standard deviation of nosie we need to add to get the desired TA-delta1
- noises = [how_much_noise(spectrum, max(.001, ta_delta1)) for ta_delta1 in ta_delta1s]
- # Add noise to the timeseries
- rng = np.random.RandomState(seed)
- tss += rng.randn(tss.shape[0], tss.shape[1]) * np.asarray(noises).reshape(-1,1)
- return tss
- def spatiotemporal_noiseless_model_timeseries(distance_matrix, sa_lambda, sa_inf, ta_delta1s, num_timepoints, sample_rate, highpass_freq, seed=0):
- """Simulate the noiseless spatiotemporal model from [Shinn et al (2022)](https://www.biorxiv.org/content/10.1101/2021.06.01.446561v1)
- Args:
- distance_matrix (NxN numpy array): the NxN distance matrix, representing the spatial distance
- between location of each of the timeseries. This should usually be the
- output of the `distance_matrix_euclidean` function.
- sa_lambda (float): the SA-λ parameter
- sa_inf (float): the SA-∞ parameter
- ta_delta1s (length-N list of floats): a list of TA-Δ₁ values, of length N, for generating the timeseries
- num_timepoints (int): length of timeseries to generate
- sample_rate (float): the spacing between timepoints (e.g. TR in fMRI)
- highpass_freq (float): if non-zero, apply a highpass filter above the
- given frequency. A good default is 0.01 for fMRI timeseries.
- seed (int, optional): the random seed. If not specified, it will use
- the current state of the numpy random number generator.
- Returns:
- NxT numpy array: For each of the N nodes, a timeseries of length T=`num_timepoints` according to the noiseless spatiotemporal model
- """
- assert num_timepoints % 2 == 0, "Must be even timeseries length"
- # Determine the pink noise exponent alpha from the TA-delta1
- alphas = [ta_to_alpha_fast(sample_rate=sample_rate, tslen=num_timepoints, highpass_freq=highpass_freq, target_ta=max(0,ta_delta1)) for ta_delta1 in ta_delta1s]
- # Use these alpha values to construct desired frequency spectra
- spectra = np.asarray([make_spectrum(tslen=num_timepoints, sample_rate=sample_rate, alpha=alpha, highpass_freq=highpass_freq) for alpha in alphas])
- # Spatial autocorrelation matrix
- corr = spatial_exponential_floor(distance_matrix, sa_lambda, sa_inf)
- # Compute timeseries from desired correlation matrix and frequency spectra
- tss = spatial_temporal_timeseries(cm=corr, spectra=spectra, seed=seed)
- return tss
- def spatial_temporal_timeseries(cm, spectra, seed=None):
- """Generate timeseries with given amplitude spectra and correlation matrices
- Args:
- cm (NxN numpy array): The correlation matrix
- spectra (Nxk numpy array): A list of Fourier spectra generated by [make_spectrum][spatiotemporal.models.make_spectrum]
- Each of the N spectra are associated with a row/column of `cm`.
- seed (int, optional): the random seed. If not specified, it will use
- the current state of the numpy random number generator.
- Returns:
- NxT numpy array: N timeseries of length T. Timeseries i will have a power spectrum given by `spectra[i]`,
- and will be correlated with the other timeseries with correlations cm[i].
- """
- N_regions = cm.shape[0]
- N_freqs = len(spectra[0])
- N_timepoints = (N_freqs-1)*2
- assert spectra.shape == (N_regions, N_freqs)
- sum_squares = np.sum(spectra**2, axis=1, keepdims=True)
- cosine_similarity = (spectra @ spectra.T)/np.sqrt(sum_squares @ sum_squares.T)
- covmat = cm / cosine_similarity
- if np.min(np.linalg.eigvalsh(covmat)) < -1e-8:
- raise PositiveSemidefiniteError("Correlation matrix is not possible with those spectra using this method!")
- randstate = np.random.RandomState(seed)
- rvs = randstate.multivariate_normal(np.zeros(N_regions), cov=covmat, size=N_freqs*2)
- reals = rvs[0:N_freqs].T * spectra
- ims = rvs[N_freqs:].T * spectra
- # Since the signal length is even, frequencies +/- 0.5 are equal
- # so the coefficient must be real.
- ims[:,-1] = 0
- # The DC component must be zero and real
- reals[:,0] = 0
- ims[:,0] = 0
- tss = np.fft.irfft(reals + 1J*ims, n=N_timepoints, axis=-1)
- return tss
- def make_spectrum(tslen, sample_rate, alpha, highpass_freq):
- """Create a 1/f^alpha spectrum.
- Args:
- tslen (int): the length of the timeseries represented by the spectrum
- sample_rate (float): the spacing between timepoints (e.g. TR in fMRI)
- alpha (float): the pink noise exponent, between 0 and 2.
- highpass_freq (float): if non-zero, apply a highpass filter above the
- given frequency. A good default is 0.01 for fMRI timeseries.
- Returns:
- length-k numpy array: Return the fourier spectrum (amplitude spectrum)
- """
- freqs = np.fft.rfftfreq(tslen, sample_rate)
- with np.errstate(all="warn"):
- spectrum = freqs**(-alpha/2)
- if highpass_freq > 0:
- butter = scipy.signal.iirfilter(ftype='butter', N=4, Wn=highpass_freq, btype='highpass', fs=1/sample_rate, output='ba')
- butterresp = scipy.signal.freqz(*butter, fs=1/sample_rate, worN=len(freqs), include_nyquist=True)
- assert np.all(np.isclose(freqs, butterresp[0]))
- spectrum = spectrum * np.abs(butterresp[1])
- spectrum[0] = 0
- return spectrum
- def how_much_noise(spectrum, target_ta):
- """Determine the standard deviation of noise to add to achieve a target TA-Δ₁.
- This function answers the following question: If I generate timeseries with
- frequency spectrum (amplitude spectrum) `spectrum`, and then add white
- noise to the generated timeseries, what should the standard deviation of
- this white noise be if I want the timeseries to have the TA-Δ₁ coefficient
- `target_ta`?
- Args:
- spectrum (length-k numpy array): the power spectrum to generate from, e.g.,
- that generated from [make_spectrum][spatiotemporal.models.make_spectrum].
- target_ta (float): the desired
- TA-Δ₁.
- Returns:
- float: The standard deviation of white noise to add
- """
- N = len(spectrum)
- weightedsum = np.sum(spectrum[1:]**2*np.cos(np.pi*np.arange(1, N)/N))
- try:
- sigma = np.sqrt((weightedsum - np.sum(spectrum**2)*target_ta)/(target_ta*N**2))
- except FloatingPointError:
- sigma = 0
- return sigma
- def ta_to_alpha(tslen, sample_rate, highpass_freq, target_ta):
- """Compute the (pink noise) alpha which would give, noiseless, the given TA-Δ₁.
- Generate timeseries with get_spectrum_ta, i.e. high pass filtered.
- Args:
- tslen (int): the length of the timeseries represented by the spectrum
- sample_rate (float): the spacing between timepoints (e.g. TR in fMRI)
- alpha (float): the pink noise exponent, between 0 and 2.
- highpass_freq (float): if non-zero, apply a highpass filter above the
- given frequency. A good default is 0.01 for fMRI timeseries.
- Returns:
- float: a value of alpha such that the filtered pink noise with
- this exponent has TA-Δ₁ coefficient `target_ta`.
- """
- objfunc = lambda alpha : (get_spectrum_ta(make_spectrum(tslen, sample_rate, alpha[0], highpass_freq)) - target_ta)**2
- x = scipy.optimize.minimize(objfunc, 1.5, bounds=[(0, 2)])
- return float(x.x[0])
- def get_spectrum_ta(spectrum):
- """Given a fourier spectrum, return the expected TA-Δ₁ of a timeseries generated with that spectrum.
- Args:
- spectrum (length-k numpy array): the power spectrum to generate from, e.g.,
- that generated from [make_spectrum][spatiotemporal.models.make_spectrum].
- Returns:
- float: the TA-Δ₁ value that would be expected if a timeseries had the given power spectrum and random phases.
- """
- N = len(spectrum)
- weightedsum = np.sum(spectrum**2*np.cos(np.pi*np.arange(0, N)/N))
- return weightedsum/np.sum(spectrum**2)
- ta_to_alpha_cache = {}
- def ta_to_alpha_fast(tslen, sample_rate, highpass_freq, target_ta):
- """Identical to `ta_to_alpha`, but discretize and cache to increase speed.
- See [ta_to_alpha][spatiotemporal.models.ta_to_alpha] for documentation.
- """
- global ta_to_alpha_cache
- taround = round(target_ta, 2)
- key = (tslen, sample_rate, highpass_freq, taround)
- if key in ta_to_alpha_cache.keys():
- return ta_to_alpha_cache[key]
- val = ta_to_alpha(*key)
- ta_to_alpha_cache[key] = val
- return val
- class PositiveSemidefiniteError(Exception):
- pass
models.py at commit c00dec6, no license · at the source
Overview
- Department of Radiology, Nanjing Drum Tower Hospital, Affiliated Hospital of Medical School, Nanjing University, Nanjing 210008, China
- Department of Andrology, Nanjing Drum Tower Hospital, Affiliated Hospital of Medical School, Nanjing University, Nanjing 210008, China
- Institute of Medical Imaging and Artificial Intelligence, Nanjing University, Nanjing 210008, China
- Medical Imaging Center, Department of Radiology, Nanjing Drum Tower Hospital, Affiliated Hospital of Medical School, Nanjing University, Nanjing 210008, China
- Institute of Brain Science, Nanjing University, Nanjing 210008, China
Abstract
Spatial and temporal autocorrelation, as low-dimensional statistical properties, account for a substantial portion of variance in complex functional brain network topology, thereby providing a method for understanding the architecture of brain functional organization in specific populations. In this study, we investigated lifelong premature ejaculation (LPE) by analyzing spatiotemporal autocorrelation and observed increased temporal autocorrelation in the right thalamus, left prefrontal cortex, and left somatomotor cortex, which may reflect abnormal neural signal persistence. Seed-based functional connectivity (FC) analysis further indicated increased FC in the right inferior parietal lobule, left anterior cingulate cortex, and right precuneus, alongside decreased FC in the right superior occipital gyrus. These FC alterations showed significant correlations with spatial autocorrelation metrics. FC in the right precuneus was positively associated with ejaculatory latency and patient-reported control, and negatively correlated with clinical scores. These disrupted spatiotemporal dynamics within prefrontal-somatosensory
Reproduced under the paper's license (CC BY-NC), from the paper cited above.
Repository
Its files are read in the Code ↔ Paper reader above, with 1 match between paragraphs and lines of code.
murraylab/spatiotemporal
c00dec6bb7e1c4547a1402f4432906c1dbb8d87a, 12 March 2022Availability: 1 check, the latest on 30 September 2026: the link answers
- 30 September 2026: the link answers
10 files
- setup.py, Python, 40 lines
- spatiotemporal/
__init__.py , Python, 8 lines - spatiotemporal/
_version.py , Python, 1 line - spatiotemporal/
extras.py , Python, 50 lines - spatiotemporal/
models.py , Python, 214 lines, 1 match - spatiotemporal/
stats.py , Python, 112 lines - spatiotemporal/
surrogates.py , Python, 133 lines - spatiotemporal/
tools.py , Python, 31 lines - tests.py, Python, 109 lines
- README.md, Text, 54 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;
- 9 scripts, each with its path and the digest of its content;
- 1 match 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 and code availability
All data reported in this paper are available from the lead contact upon request.
This paper does not report original code.
Any additional information required to reanalyze the data reported in this paper is available from the lead contact upon request.
Reproduced under the paper's license (CC BY-NC), 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, 30 September 2026: the first record
Recorded: type, language, journal, volume, issue, pages, dates, 7 authors, 3 keywords, 3 funders, 38 references.
Cite
This paper
Deng, Q., Zhang, X., Gao, Q., Wang, C., Wu, X., Lu, J., & Zhang, B. (2026). Alterations in brain spatiotemporal autocorrelation and functional connectivity in lifelong premature ejaculation: A resting-state fMRI study. iScience, 29(4), 115509. https://
BibTeX
@article{deng2026alterat
author = {Deng, Qiming and Zhang, Xin and Gao, Qingqiang and Wang, Cong and Wu, Xiaoyan and Lu, Jiaming and Zhang, Bing},
title = {{Alterations in brain spatiotemporal autocorrelation and functional connectivity in lifelong premature ejaculation: A resting-state fMRI study}},
journal = {iScience},
year = {2026},
month = mar,
volume = {29},
number = {4},
pages = {115509},
publisher = {Elsevier},
issn = {2589-0042},
doi = {10.1016/
url = {https://
pmid = {42006301},
pmcid = {PMC13090730}
}
RIS
TY - JOUR
AU - Deng, Qiming
AU - Zhang, Xin
AU - Gao, Qingqiang
AU - Wang, Cong
AU - Wu, Xiaoyan
AU - Lu, Jiaming
AU - Zhang, Bing
TI - Alterations in brain spatiotemporal autocorrelation and functional connectivity in lifelong premature ejaculation: A resting-state fMRI study
T2 - iScience
J2 - iScience
PY - 2026
DA - 2026/
VL - 29
IS - 4
SP - 115509
SN - 2589-0042
PB - Elsevier
DO - 10.1016/
UR - https://
LA - en
ER -
CSL-JSON
{
"id": "10.1016/
"type": "article-journal",
"title": "Alterations in brain spatiotemporal autocorrelation and functional connectivity in lifelong premature ejaculation: A resting-state fMRI study",
"container-title": "iScience",
"author": [
{
"family": "Deng",
"given": "Qiming"
},
{
"family": "Zhang",
"given": "Xin"
},
{
"family": "Gao",
"given": "Qingqiang"
},
{
"family": "Wang",
"given": "Cong"
},
{
"family": "Wu",
"given": "Xiaoyan"
},
{
"family": "Lu",
"given": "Jiaming"
},
{
"family": "Zhang",
"given": "Bing"
}
],
"container-title-short":
"volume": "29",
"issue": "4",
"page": "115509",
"DOI": "10.1016/
"PMID": "42006301",
"PMCID": "PMC13090730",
"ISSN": "2589-0042",
"publisher": "Elsevier",
"URL": "https://
"language": "en",
"issued": {
"date-parts": [
[
2026,
3,
27
]
]
}
}
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.7554/elife.106081 [code]
- Heritability of movie-evoked brain activity and connectivity.Journal: eLifeIn common: pandas, SciPy, NumPy, 5 references
- [2] doi:10.1038/s42003-025-07517-x [code]
- Mapping and modeling age-related changes in intrinsic neural timescales.Journal: Communications biologyIn common: pandas, SciPy, NumPy, 5 references
- [3] doi:10.1038/s41467-026-74227-1 [code]
- Age-related changes in behavioural and neural variability in a decision-making task.Journal: Nature communicationsIn common: rpy2, pandas, SciPy, 1 other tool, 2 references
- [4] doi:10.1101/2025.08.22.671763 [code]
- Age-related changes in behavioural and neural variability in a decision-making taskJournal: bioRxiv (preprint)In common: rpy2, pandas, SciPy, 1 other tool, 2 references
- [5] doi:10.1162/imag.a.1248 [code]
- Estimating fMRI timescale maps.Journal: Imaging neuroscience (Cambridge, Mass.)In common: pandas, SciPy, NumPy, fMRI, 3 references
- [6] doi:10.1038/s41467-023-38972-x [code]
- Hierarchical fluctuation shapes a dynamic flow linked to states of consciousness.Journal: Nature communicationsIn common: rpy2, pandas, SciPy, 1 other tool, fMRI, 2 references
- [7] doi:10.1038/s41540-025-00626-7 [code]
- Criticality and increased intrinsic neural timescales in stroke.Journal: NPJ systems biology and applicationsIn common: pandas, SciPy, NumPy, 3 references
- [8] doi:10.1038/s41467-026-68700-0 [code]
- The biological role of local and global fMRI BOLD signal variability in multiscale human brain organization.Journal: Nature communicationsIn common: pandas, SciPy, NumPy, fMRI, 3 references
- [9] doi:10.1038/s41540-026-00727-x [code]
- Association-sensory spatiotemporal hierarchy and functional gradient-regularised recurrent neural network with implications for schizophrenia.Journal: NPJ systems biology and applicationsIn common: pandas, SciPy, NumPy, 2 references
- [10] doi:10.1371/journal.pcbi.1012692 [code]
- Extracting interpretable signatures of whole-brain dynamics through systematic comparison.Journal: PLoS computational biologyIn common: pandas, SciPy, NumPy, fMRI, 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.
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, 9 scripts, and 1 match 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:8d9fa5af4ec5ade0…
Add the badge to the code's README
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 -->
[](https://openscicode.org/badge/doi/10.1016/j.isci.2026.115509)
<!-- oscr-badge:end -->reStructuredText
.. oscr-badge:start
.. image:: https://openscicode.org/badge/doi/10.1016/j.isci.2026.115509.svg
:target: https://openscicode.org/badge/doi/10.1016/j.isci.2026.115509
:alt: OSCR
.. oscr-badge:endHTML
<!-- oscr-badge:start -->
<a href="https://openscicode.org/badge/doi/10.1016/j.isci.2026.115509"><img src="https://openscicode.org/badge/doi/10.1016/j.isci.2026.115509.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.
