Skip to main content
NIHPA Author Manuscripts logoLink to NIHPA Author Manuscripts
. Author manuscript; available in PMC: 2026 Jul 8.
Published in final edited form as: J Open Res Softw. 2026;14:5. doi: 10.5334/jors.610

The Population Spatial Frequency Toolbox

LUIS D RAMIREZ 1, FEIYI WANG 2, EMILY WIECEK 3, LOUIS N VINKE 4, SAM LING 5
PMCID: PMC13340908  NIHMSID: NIHMS2192666  PMID: 42415731

Abstract

A goal of vision science is to develop computational models that characterize the fundamental response properties of neurons in visual cortex. One such property is spatial frequency (SF) tuning: neural populations in visual cortex selectively respond to specific bands of SF, which determines the level of detail, coarse or fine, represented from the visual input. The Population Spatial Frequency Toolbox (pSF-Toolbox) is a MATLAB package for characterizing the SF tuning of neural populations from functional magnetic resonance imaging (fMRI) data. This open-source toolbox includes stimulus presentation scripts and voxel-wise parameter optimization tools validated across a range of vision studies.

Keywords: population spatial frequency tuning, visual cortex, fMRI, vision science

(1). OVERVIEW

INTRODUCTION

Neurons in the early visual cortex are selective for narrow bands of spatial frequency (SF) [1–6]. This tuning is typically characterized by two fundamental properties: a peak preference (the SF that elicits the strongest response) and a bandwidth (the range that elicits a response). These constraints effectively define the resolution limit for feature processing along the early visuocortical sheet. SF tuning is retinotopically organized as well: foveal populations prefer higher SFs and have smaller receptive fields (RFs), whereas peripheral populations are tuned to lower SFs, with larger RFs [6, 7]. This trade-off increases along the early visuocortical hierarchy; from V1–V3, peak SF preference drops while bandwidth increases [6, 8]. The functional consequence is a visual field that is centrally fine-grained but peripherally coarse.

Precise retinotopic maps of SF tuning are essential for isolating the influence of cognitive states and visuocortical conditions on SF processing (and spatial resolution) [9, 10]. However, previous human fMRI studies characterizing these maps have faced methodological trade-offs: phase-encoding (i.e., traveling wave) approaches map peak SF preference but are blind to tuning profiles, while block designs capture tuning profiles, but are too slow for the large stimulus sets required to attain voxel-wise tuning curves. To resolve this, Aghajari et al. (2020) introduced a population SF tuning (pSFT) method that circumvents these limitations, enabling efficient, voxel-wise estimation of SF tuning across and within the visual hierarchy [8].

The pSF-Toolbox presented here was developed to provide a standardized, open-source pipeline that facilitates the acquisition and estimation of pSFT. Versions of this toolbox have already been successfully deployed across multiple lines of research. For example, recent work utilized pSFT to reveal that attention sharpens bandwidths and attracts peak tuning toward the attended SF [11]. In another study, a new metric of scale invariance, “cycles per field”, was created and found to be constant across early visual cortex, confirming a fundamental assumption about human visual processing [12–15]. In tandem, preliminary research has applied pSFT to clinical questions about SF tuning under amblyopia [16], and to functional questions regarding emotional state-dependent shifts in tuning [17, 18]. These applications demonstrate this toolbox’s capacity to detect shifts in SF tuning under various conditions, and its potential in establishing a standardized, reproducible framework for characterizing visual resolution across basic, cognitive, and clinical neuroscience.

IMPLEMENTATION AND ARCHITECTURE

The software consists of two main modules:

  • measure-pSFT: Provides scripts for stimulus generation, validation, and presentation via Psychtoolbox.

  • estimate-pSFT: Contains scripts for fitting the pSFT model to voxel-wise BOLD signals. There is also a sub-module, validate-pSFT, that contains scripts that demonstrate the computational validity of the pipeline.

STIMULUS GENERATION AND EXPERIMENTAL DESIGN

Measuring pSFT involves presenting a sequence of SF-bandpass filtered stimuli to participants in an fMRI scanner (Figure 1a). The measure-pSFT module generates stimuli designed to drive maximal variation in SF tuning while minimizing adaptation and orientation biases. To achieve unbiased orientation content, every stimulus presented begins as a sample of uniform white noise (Figure 1b, left). In the frequency domain, white noise contains broad, isotropic energy across all orientations and SFs, the latter not ideal for driving responses of SF-selective neurons in early visual cortex (Figure 1b, ‘FFT noise’). Therefore, to isolate specific SF bands, a narrow SF-bandpass filter is applied to the 2D Fast Fourier Transform of the noise sample (Figure 1b, middle), set to a constant linear width of 0.1 cycles per degree of visual angle (cpd). To sample the SF tuning space, 40 SF-bandpass filters are created, with center frequencies that are logarithmically-spaced from 0.5 to 12 cpd (Figure 1c). The space is sampled logarithmically because SFs are represented logarithmically in human visual cortex [6].

Figure 1.

Figure 1

(a) pSFT fMRI scan design. The default scan consists of 6 40-s stimulus blocks surrounded by 10-s blank periods. In each stimulus block, 40 SF bandpass-filtered stimuli are presented in a random order while participants perform a luminance change detection task at fixation. (b) Stimulus generation. Every stimulus presented begins as a random sample of uniform white noise. A 2D fast Fourier transform (FFT) is performed on the noise sample, which is then masked by a circularly symmetric narrow-band filter (filter width is exaggerated here for visualization purposes). The resulting image is returned to the spatial domain and converted to 8-bit grayscale. (c) Examples of bandpass-filtered stimuli. (d) Examples of stimulus SF energy as a function of SF. The target SF (cpd) is provided above the peak of each energy profile.

We provide a verification function that confirms that energy exists solely in the intended SF band (Figure 1d; see /measure-pSFT/stimuli/verifyStimuli.m). This function also has the added benefit that it saves the textures to be used in an experimental session, so as long as the screen and stimulus parameters provided are identical to the experimental setup.

EXPERIMENTAL PROCEDURE

We provide a scan session template script for data acquisition (see /measure-pSFT/run_session.m). This script should be modified to support the experimental setup of the user (e.g., screen parameters).

The script loops through a set number of scan runs, 9 by default — enough to fit within an hour of scanning. In each run, there are 6 stimulus blocks each surrounded by blank periods (Figure 1a) [8]. In short, within each task block, SF bandpass-filtered stimuli are presented in a randomized event-related design. This randomized temporal structure enables efficient estimation of the full Gaussian tuning profile (peak and bandwidth) for every voxel.

At central fixation, the dot will randomly increase in luminance. Participants should be instructed to maintain fixation and press a button when they detect a change in luminance at fixation. Run information is compiled into a structure, run_info, that should be saved. While already in run_info, the matrix containing the SF input time series for every block is stored as a separate .mat file for convenience, as the time series across multiple blocks and runs should be concatenated as an input vector (i.e., time × 1) into the pSFT optimization pipeline.

VOXEL-WISE MODELING

For estimating pSFT parameters from fMRI data, estimatePSFT is the main high-level function, which then calls fitVoxels for voxel-wise parameter optimization.

We include an example workflow for estimating pSFT from sample_data.mat, a structure array that contains concatenated SF input and measured BOLD time series across 9 scan runs from two subjects — 100 voxels in V1, V2, and V3 (see /estimate-pSFT/example_pipeline.m) [11].

estimatePSFT takes as input the stimulus SF time series, the measured BOLD time series in percent signal change (psc), and hemodynamic response function (HRF) to return a structure array pSFT containing:

  • estimated pSFT parameters (μ, σ, β, β0)

  • estimated tuning curves

  • estimated neural time series

  • estimated BOLD time series

  • R2 values

  • SSE values

  • fmincon exit flags

For more detail on the pSFT model itself, we model the blood oxygenation level dependent (BOLD) responses to SFs using a logarithmic Gaussian distribution [8]:

R([f(t)])=e-[log(f(t))-log[μ)]22σ2

where f(t) is the SF presented at time t, μ is the SF that produces the maximum response of the population (the “pSFT peak”), and σ is the linear SF tuning bandwidth — μ and σ being unknown. Because stimuli are not presented during blank periods between stimulus blocks (Figure 1a), the SF input during these periods is set to a small non-zero value (e.g., 0.0001) to avoid taking the logarithm of zero. The population response to a sequence of SFs, R[f(t)], is then convolved with a HRF, h(t), to generate a predicted BOLD signal, B(t) (Figure 2a):

B(t)=β0+β⋅R[f(t)]*h(t)

where β0 and β are unknown and represent the baseline and a scaling coefficient for the BOLD percent signal change, respectively. The HRF, h(t), is by default a gamma function of the form:

h(t)=(t/τ)(n-1)e-(t/τ)τ(n-1)!

where τ is the time constant (fixed to a value of 1.08), n is the phase delay (fixed to a value of 3), and t the delay between stimulus onset and the BOLD response (fixed to a value of 2.05) [19]. Voxel-wise HRFs can be provided by the user so as long as they are organized with time along the first dimension (i.e., time × voxels).

Figure 2.

Figure 2

(a) Voxel-wise estimation of population spatial frequency tuning. A sequence of SFs is fed into a log-Gaussian function to produce a neural response. The neural response is convolved with a HRF to synthesize a BOLD signal that can be compared to the measured BOLD signal. This process is repeated and the pSFT parameters optimized until the sum of squares error (SSE) between the predicted and measured BOLD is minimized. (b) pSFT as a function of pRF eccentricity. pSFT and pRF parameter estimates are from a sample dataset of visual areas V1–V3 [11]. n = 200 in every subplot.

Parameters are estimated on a voxel-wise basis by minimizing the sum of squared errors using MATLAB’s fmincon optimization routine (Figure 2a).

pSFT, when analyzed in conjunction with population receptive field (pRF) estimates [20, 21], should replicate well-established relationships between eccentricity, peak preference, and tuning bandwidth (Figure 2b) [6, 8, 14, 16, 17, 11].

pSFT VALIDATION

The validate-pSFT sub-module demonstrates the effectiveness of the model fitting pipeline. Inspired by the validation framework from Lerma-Usabiaga et al. (2020) [22], validate_pSFT.m generates synthetic BOLD data from known pSFT parameters across BOLD SNR levels, e.g., 5.29, −0.51, and −4.29 dB (Figure 3a). BOLD SNRdB was defined as 20•log10RMSSignalRMSnoise. The script runs the estimation pipeline on this data and benchmarks performance by comparing recovered parameters to ground truth (Figure 3b). Metrics include RMSE and Pearson correlations with bootstrap confidence intervals. Like estimate-pSFT, this module can save timestamped results and figures.

Figure 3. Computational Validity.

Figure 3

(a) Simulated BOLD. Each subplot depicts the simulated BOLD signal of a voxel with one of three BOLD noise levels. Black curves are the clean BOLD signal, while the green, yellow, and red curves are the BOLD signal with noise. (b) Parameter recovery. Each subplot depicts simulated vs. estimated pSFT parameters at each BOLD noise level from 1000 simulated voxels (top row, peak; bottom row, bandwidth). The correlation coefficients are displayed on the bottom right of each subplot.

QUALITY CONTROL

Example data and scripts are provided to test functionality. The estimation module includes a sample pipeline that verifies required toolboxes and processes real data to validate outputs. Required and optional MATLAB toolboxes (Optimization, Parallel Computing) are detailed in the README documentation.

(2). AVAILABILITY

OPERATING SYSTEM

  • Linux Ubuntu 20.04-LTS or 22.04-LTS

  • MacOS 10.15.7 or later

  • Windows 10 or later

PROGRAMMING LANGUAGE

  • MATLAB 2014b or later [23]

ADDITIONAL SYSTEM REQUIREMENTS

  • Disk space: Minimum 30 MB; Requirements scale with input data (and model estimates) and screen resolution (if generating stimulus textures).

  • Processor: Multi-core recommended

  • Memory: Requirements scale with input data (and model estimates) and screen resolution (if generating stimulus textures).

DEPENDENCIES

  • Psychtoolbox-3 [24]

  • MATLAB Optimization Toolbox

  • MATLAB Parallel Computing Toolbox (recommended)

LIST OF CONTRIBUTORS

  • Sara Aghajari (original framework and experimental design)

  • Louis Vinke (early prototype and testing)

SOFTWARE LOCATION

Archive

  • Name: The Population Spatial Frequency Toolbox

  • Persistent identifier: https://doi.org/10.17605/OSF.IO/BU8VE

  • Licence: GPL-3.0

  • Publisher: Luis D Ramirez

  • Version published: 1.0

  • Date published: 01/08/25

Code repository

Emulation environment

  • Name: N/A

  • Identifier: N/A

  • Licence: N/A

  • Date published: N/A

LANGUAGE

  • English

(3). REUSE POTENTIAL

This MATLAB toolbox is intended for researchers studying visual processing with fMRI, particularly those interested in SF tuning. The code is modular and documented to facilitate adaptation for future investigations. For example, the measure-pSFT module could be adapted to investigate orientation or spatiotemporal tuning properties. Additionally, the functional pSFT maps provided by the estimate-pSFT module could serve as priors for multimodal imaging (e.g., EEG/MEG), which could help investigate the temporal dynamics of coarse-to-fine visual processing. The efficiency of the pSFT approach (~1-hour scan) makes it suitable for clinical research, providing a standardized approach for measuring pSFT in healthy or clinical populations. Users can contact the lead author via GitHub issues for questions or contributions. Support is provided through the GitHub repository’s issue tracker and documentation. Users may also contact the lead author directly at luisdramirez95@gmail.com.

ACKNOWLEDGEMENTS

We thank Sara Aghajari and Louis Vinke for providing the framework that this toolbox was based on. We acknowledge the University of Minnesota Center for Magnetic Resonance Research for use of the multiband-EPI pulse sequences.

FUNDING STATEMENT

The development of this toolbox was supported by funding from the National Institutes of Health Grant EY028163 to S. Ling and supported by F99 NS124144 and K00EY036804 to L.D. Ramirez. The sample BOLD data was acquired at the Boston University Cognitive Neuroimaging Center and involved the use of instrumentation supported by the NSF Major Research Instrumentation grant BCS-1625552.

Footnotes

COMPETING INTERESTS

The authors have no competing interests to declare.

Contributor Information

LUIS D. RAMIREZ, Lead Contributor, Department of Psychology, University of California San Diego, US; Department of Psychological & Brain Sciences, Boston University, US; Center for Systems Neuroscience, Boston University, US

FEIYI WANG, Co-contributor, Department of Psychological & Brain Sciences, Boston University, US; Center for Systems Neuroscience, Boston University, US.

EMILY WIECEK, Co-contributor, Department of Psychological & Brain Sciences, Boston University, US; Center for Systems Neuroscience, Boston University, US; Boston Children’s Hospital, Ophthalmology, Harvard Medical School, Ophthalmology, US.

LOUIS N. VINKE, Co-contributor, Department of Psychological & Brain Sciences, Boston University, US; Center for Systems Neuroscience, Boston University, US; Department of Psychiatry, Massachusetts General Hospital, Harvard Medical School, Psychology, US

SAM LING, Principal Investigator, Department of Psychological & Brain Sciences, Boston University, US; Center for Systems Neuroscience, Boston University, US.

REFERENCES

  • 1.Blakemore C, Campbell FW. On the existence of neurones in the human visual system selectively sensitive to the orientation and size of retinal images. The Journal of Physiology. 1969;203(1):237–260. DOI: 10.1113/jphysiol.1969.sp008862 [DOI] [PMC free article] [PubMed] [Google Scholar]
  • 2.Braddick O Spatial frequency analysis in vision. Nature. 1981;291(5810): 9–11. DOI: 10.1038/291009a0 [DOI] [PubMed] [Google Scholar]
  • 3.De Valois RL, Albrecht DG, Thorell LG. Spatial frequency selectivity of cells in macaque visual cortex. Vision Research. 1982;22(5):545–559. DOI: 10.1016/0042-6989(82)90113-4 [DOI] [PubMed] [Google Scholar]
  • 4.Foster KH, Gaska JP, Nagler M, Pollen DA. Spatial and temporal frequency selectivity of neurones in visual cortical areas V1 and V2 of the macaque monkey. The Journal of Physiology. 1985;365(1):331–363. DOI: 10.1113/jphysiol.1985.sp015776 [DOI] [PMC free article] [PubMed] [Google Scholar]
  • 5.Singh KD, Smith AT, Greenlee MW. Spatiotemporal Frequency and Direction Sensitivities of Human Visual Areas Measured Using fMRI. NeuroImage. 2000;12(5):550–564. DOI: 10.1006/nimg.2000.0642 [DOI] [PubMed] [Google Scholar]
  • 6.Henriksson L, Nurminen L, Hyvarinen A, Vanni S. Spatial frequency tuning in human retinotopic visual areas. Journal of Vision. 2008;8(10):5–5. DOI: 10.1167/8.10.5 [DOI] [PubMed] [Google Scholar]
  • 7.Sasaki Y, Hadjikhani N, Fischl B, Liu AK, Marrett S, Dale AM, Tootell RBH. Local and global attention are mapped retinotopically in human occipital cortex. Proceedings of the National Academy of Sciences. 2001;98(4):2077–2082. DOI: 10.1073/pnas.98.4.2077 [DOI] [PMC free article] [PubMed] [Google Scholar]
  • 8.Aghajari S, Vinke LN, Ling S. Population spatial frequency tuning in human early visual cortex. Journal of Neurophysiology. 2020;123(2):773–785. DOI: 10.1152/jn.00291.2019 [DOI] [PMC free article] [PubMed] [Google Scholar]
  • 9.Sowden PT, Schyns PG. Channel surfing in the visual brain. Trends in Cognitive Sciences. 2006;10(12):538–545. DOI: 10.1016/j.tics.2006.10.007 [DOI] [PubMed] [Google Scholar]
  • 10.Anton-Erxleben K, Carrasco M. Attentional enhancement of spatial resolution: linking behavioural and neurophysiological evidence. Nature Reviews Neuroscience. 2013;14(3):188–200. DOI: 10.1038/nrn3443 [DOI] [PMC free article] [PubMed] [Google Scholar]
  • 11.Ramirez LD, Wang F, Ling S. Attention alters population spatial frequency tuning. The Journal of Neuroscience. 2025;45(25):1–12. DOI: 10.1523/JNEUROSCI.0251-25.2025 [DOI] [PMC free article] [PubMed] [Google Scholar]
  • 12.Jamar JHT, Koenderink JJ. Sine-wave gratings: Scale invariance and spatial integration at suprathreshold contrast. Vision Research. 1983;23(8):805–810. DOI: 10.1016/0042-6989(83)90203-1 [DOI] [PubMed] [Google Scholar]
  • 13.Rovamo J, Virsu V. An estimation and application of the human cortical magnification factor. Experimental Brain Research. 1979;37(3). DOI: 10.1007/BF00236819 [DOI] [PubMed] [Google Scholar]
  • 14.Broderick WF, Simoncelli EP, Winawer J. Mapping spatial frequency preferences across human primary visual cortex. Journal of Vision. 2022;22(4):3. DOI: 10.1167/jov.22.4.3 [DOI] [PMC free article] [PubMed] [Google Scholar]
  • 15.Wiecek E, Ramirez LD, Klimova M, Ling S. Spatial frequency tuning follows scale invariance in human visual cortex. The Journal of Neuroscience. 2025; e1490252025. DOI: 10.1523/JNEUROSCI.1490-25.2025 [DOI] [PMC free article] [PubMed] [Google Scholar]
  • 16.Wiecek E, Klimova M, Ramirez LD, Ling S. Is the Loss of Spatial Resolution in Amblyopia Linked to a Deviation in Scale Invariance? Investigative Ophthalmology & Visual Science. 2024. DOI: 10.1167/jov.24.10.692 [DOI] [Google Scholar]
  • 17.Ramirez LD, Pan J, Ling S. How Does Emotional Arousal Modulate Population Spatial Frequency Tuning? Journal of Vision. 2024. DOI: 10.1167/jov.24.10.912 [DOI] [Google Scholar]
  • 18.De Cesarei A, Codispoti M. Spatial frequencies and emotional perception. Reviews in the Neurosciences. 2013;24(1). DOI: 10.1515/revneuro-2012-0053 [DOI] [PubMed] [Google Scholar]
  • 19.Boynton GM, Engel SA, Glover GH, Heeger DJ. Linear Systems Analysis of Functional Magnetic Resonance Imaging in Human V1. The Journal of Neuroscience. 1996;16(13):4207–4221. DOI: 10.1523/JNEUROSCI.16-13-04207.1996 [DOI] [PMC free article] [PubMed] [Google Scholar]
  • 20.Wandell BA, Dumoulin SO, Brewer AA. Visual Field Maps in Human Cortex. Neuron. 2007;56(2):366–383. DOI: 10.1016/j.neuron.2007.10.012 [DOI] [PubMed] [Google Scholar]
  • 21.Dumoulin SO, Wandell BA. Population receptive field estimates in human visual cortex. NeuroImage. 2008;39(2):647–660. DOI: 10.1016/j.neuroimage.2007.09.034 [DOI] [PMC free article] [PubMed] [Google Scholar]
  • 22.Lerma-Usabiaga G, Benson N, Winawer J, Wandell BA. A validation framework for neuroimaging software: The case of population receptive fields. PLOS Computational Biology. 2020;16(6):e1007924. DOI: 10.1371/journal.pcbi.1007924 [DOI] [PMC free article] [PubMed] [Google Scholar]
  • 23.The MathWorks Inc. MATLAB version: 9.3.0.713579 (2017b); 2017.
  • 24.Brainard DH. The Psychophysics Toolbox. Spatial Vision. 1997;10(4):433–436. DOI: 10.1163/156856897X00357 [DOI] [PubMed] [Google Scholar]

RESOURCES