Skip to content

Installation

neuroresp runs on Python 3.11 and newer on Linux and macOS. Install it from PyPI into a virtual environment:

python -m pip install neuroresp

For development work or running the test suite from a local clone, install the dev and meg extras together.

git clone https://github.com/brain-body-cognition/neuroresp.git
cd neuroresp
python -m pip install -e ".[dev,meg]"
pytest

Optional dependencies

The default fMRI registration solver (python2d) uses only NumPy and SciPy. Two optional integrations extend input support and backend comparison.

  • Raw MEG and EEG readers: run python -m pip install "neuroresp[meg]" to install mne>=1.6 so neuroresp meg can open .fif, CTF .ds, 4D/BTi, BrainVision, and EDF files directly. Saved 1D ECG arrays stored in .npz files work without mne.
  • AFNI registration (3dvolreg): when AFNI's 3dvolreg binary is on PATH, passing --backend afni to neuroresp extract performs 3D rigid registration on sparse slice stacks or full volumes.

Run neuroresp --help to confirm that the CLI entry point is active.

Input requirements for fMRI extraction

Sub-TR extraction depends on the native slice grid and acquisition timing recorded at the scanner. Before running neuroresp extract, check that your input files meet three conditions.

First, supply the raw, unrealigned 4D BOLD NIfTI from the BIDS func/ directory (sub-*_bold.nii.gz, or sub-*_echo-1_bold.nii.gz in a multi-echo dataset). Preprocessed images such as fMRIPrep's desc-preproc_bold.nii.gz have already been spatially realigned, interpolated in slice time, or resampled to a template. Because spatial interpolation mixes adjacent slices, those steps erase the phase-encoding shifts between slice groups that carry the respiratory signal. neuroresp checks input filenames and warns when tokens suggest a preprocessed derivative.

Second, ensure that a BIDS JSON sidecar supplies RepetitionTime and PhaseEncodingDirection (i, i-, j, j-, k, or k-). neuroresp looks for an adjacent sidecar first and walks up to the BIDS root (dataset_description.json) when parameters are inherited from a root JSON. Sub-TR modes also require SliceTiming with one offset in [0, TR) seconds per slice. If SliceTiming is absent, --mode auto falls back to full-volume registration at the midpoint of each TR and records that choice in metadata.json (see Outputs and Quality Control).

Third, the native NIfTI header must define an orthogonal voxel grid in millimetres, which standard dcm2niix conversions satisfy.

Input requirements for MEG and EEG

neuroresp meg accepts either a raw recording readable by MNE-Python with a named ECG channel or a .npz archive containing a finite 1D ecg array and its sampling rate fs_ecg in Hz. Sampling rates above 80 Hz (typically 250 Hz to 2 kHz) are required so the 0.5–40 Hz filter resolves QRS morphology accurately. Once installed, continue to Usage for command examples.