Q & A
HRfunc is a Python library for estimating neural activity and hemodynamic response functions (HRFs) in functional near infrared spectroscopy (fNIRS) data. It builds on top of the MNE ecosystem so you can move seamlessly between preprocessing, deconvolution, and downstream analysis. Explore the tutorial page for a walkthrough and video guide.
Install HRfunc from PyPI with Python 3.8 or later:
pip install hrfunc
The installer pulls in the required scientific stack, including mne, so you can
immediately load NIRx scans, configure montages, and start estimating HRFs.
Typical workflows follow four stages:
- Load raw fNIRS scans through MNE and prepare event timing.
- (Optional) Estimate subject-level HRFs for each participant.
- (Optional) Aggregate subject estimates into a group HRF distribution.
- Estimate neural activity channel-by-channel for every subject.
Subject-level HRFs require an event-based paradigm. Without events, rely on a canonical HRF or browse the HRtree for context-matched estimates contributed by the community. The HRfunc guide walks through each stage in detail.
The HRtree is a growing database of HRF estimates submitted by researchers. Each entry is tagged with detailed experimental context—age range, task, stimulus modality, protocol, demographics, and more—so you can locate HRFs that align with your study. The backend combines tree and hash structures to make filtering and spatial lookups fast.
Once you have HRFs estimated with HRfunc and a DOI-linked paper detailing data collection, head to the HRF submission page. After a light review, your HRFs enter the HRtree so other labs can explore them alongside the metadata you provide.
Experimental contexts are descriptors that capture the conditions under which an HRF was derived—think task, stimulus intensity, medium, age range, demographics, health status, and more. Supplying these details keeps the HRtree searchable and lets teams identify HRFs that match their paradigm. Explore the context reference for the current vocabulary.
HRfunc performs Toeplitz deconvolution with ridge regularization. The library handles preprocessing, edge expansion, and aggregation so you can recover subject-level HRFs and replace hemoglobin traces with estimated neural activity. Curious about extending the pipeline—perhaps with Bayesian approaches? Fork the project on GitHub and experiment with custom estimators.
Toeplitz deconvolution can introduce edge artifacts. HRfunc mitigates this with edge expansion—temporarily
extending the estimation window and trimming excess samples after inversion. If residual variability remains,
increase the edge_expansion parameter when calling montage.estimate_hrfs().
Yes—reusing HRFs is a major advantage of HRfunc, especially when multiple projects share the same montage. Still, weigh differences in paradigm, population, or stimuli that might shift the underlying hemodynamics. If the contexts diverge, consider browsing the HRtree or reverting to the canonical HRF for a safer baseline.
Uploads should originate from the HRfunc pipeline (extensions welcome if documented) and reference a DOI describing data collection. We especially encourage subset HRFs—unique demographic groups, age brackets, or task variants help everyone run richer cross-study analyses. Share yours through the submission form.