Note

This page is a reference documentation. It only explains the function signature, and not how to use it. Please refer to the user guide for the big picture.

nilearn.glm.first_level.spm_hrf

nilearn.glm.first_level.spm_hrf(t_r, oversampling=50, time_length=32.0, onset=0.0)[source]

Implement the SPM HRF model.

Parameters:
t_rfloat

Repetition time, in seconds (sampling period).

Changed in Nilearn 0.11.0: The old tr parameter was replaced by t_r.

oversamplingint, default=50

Temporal oversampling factor.

time_lengthfloat, default=32.0

HRF kernel length, in seconds.

onsetfloat, default=0.0

HRF onset time, in seconds.

Returns:
hrfarray of shape (length / t_r * oversampling, dtype=float)

HRF sampling on the oversampled time grid

Examples

>>> import numpy as np
>>> from nilearn.glm.first_level import spm_hrf
>>> hrf = spm_hrf(t_r=2.0, oversampling=1, time_length=20.0)
>>> np.round(hrf, 3).tolist()
[0.0, 0.0, 0.161, 0.443, 0.335, 0.139, 0.022, -0.028, -0.04, -0.033]