NIRSPipe#
A BIDS-compatible fNIRS preprocessing, postprocessing, hyperscanning, and QC pipeline.
Status: in active development. NIRSPipe is changing quickly. Command-line options, output file names and defaults can change between releases without a deprecation period, so it is not yet recommended for production use. Pin a version for any analysis you intend to publish.
Overview#
nirspipe runs at two levels; dyad analysis is a separate set of commands, nirspipe-hyper, which reads the tree nirspipe wrote and writes its own.
Level |
What it does |
|---|---|
|
Preprocessing in a fixed order: optical density, windowed channel screening, motion correction, Beer-Lambert. Then postprocessing when |
|
Cohort pages over the per-run quality records, and over the per-dyad ones where the tree holds dyads. |
Outputs follow the BIDS Derivatives specification, every data file with a provenance sidecar. Each run gets an HTML QC report with a provenance graph and a generated Methods paragraph. Raw-recording, cohort and dyad QC reports, wavelet coherence and inter-subject correlation for dyads with two nulls, a rating viewer and a GUI that runs in your browser complete the package.

Installation#
Python 3.11 or later. Every dependency is resolved by the install:
git clone https://github.com/AU-CONNECT-Lab/NIRSPipe.git
cd NIRSPipe
pip install -e ".[dev]"
See Installation for bids-validator and the optional GPU install.
Quick start#
Raw QC before analysis, a report per recording, then the cohort page:
nirspipe-qc /data/bids /data/qc participant --population adult --sci-threshold 0.8
nirspipe-qc /data/bids /data/qc group
Preprocessing only:
nirspipe /data/bids /data/derivatives participant \
--participant-label 01 02 \
--population adult --sci-threshold 0.8
Preprocessing and a first-level GLM, with the events taken from the SNIRF annotations:
nirspipe /data/bids /data/derivatives participant \
--participant-label 01 \
--population adult --sci-threshold 0.8 \
--mode glm --stim-dur 15 --drift-high-pass 0.01
--population (infant, child, adult or older) fills the cardiac and respiration bands, the DPF and the head template for the age group; a flag typed for one of them overrides it, and --sci-threshold is always typed. Short-channel regression runs by default on a montage with short channels. The drift cutoff depends on the design: --drift-high-pass auto sets it per run from its events. More examples are in Usage.
Hyperscanning#
Wavelet coherence (WTC) and inter-subject correlation (ISC) for every dyad, read from the tree nirspipe wrote. The dyads are listed in a pairs table (group_id,subject_id,task, one row per member) and the regions in a JSON file mapping each region label to its source-detector pairs. Each measure gets its own phase-scrambled null:
nirspipe-hyper /data/derivatives /data/hyper group \
--pairs-csv pairs.csv --roi-mapping roi.json \
--band-fmin 0.02 --band-fmax 0.10 \
--wtc-phase-null 100 --isc-phase-null 100
The re-paired null replaces each dyad’s second member with people from the other dyads who did the same task, for both measures; the cohort test then ranks each dyad’s mean against both nulls:
nirspipe-hyper-pairnull /data/derivatives /data/hyper group \
--pairs-csv pairs.csv --roi-mapping roi.json
nirspipe-hyper-groupnull /data/hyper group --task-label main \
--roi-mapping roi.json
--device cuda on nirspipe-hyper or nirspipe-hyper-pairnull runs the wavelet transforms on an NVIDIA card. Hyperscanning explains what each null controls for; the Tutorial runs public dyads from download to the cohort test.
Commands#
Command |
Purpose |
|---|---|
|
Preprocessing and postprocessing ( |
|
Convert a raw SNIRF file into BIDS |
|
Crop, align dyads, edit markers, write span tables |
|
Raw QC: each recording’s report ( |
|
Redraw the provenance graphs of a tree from its sidecars |
|
Dyad wavelet coherence and inter-subject correlation, with a phase-scrambled null |
|
The re-paired null, cohort tests, re-banding, the dyad index, merged tables |
|
Rating viewers for the QC reports |
|
GUI, a local web app in your browser |
Every flag is listed in Usage.