NIPY logo

Site Navigation

NIPY Community

Github repo

Table Of Contents

Next topic

modalities.fmri.hrf

This Page

modalities.fmri.hemodynamic_models

Module: modalities.fmri.hemodynamic_models

This module is for canonical hrf specification. Here we provide for SPM, Glover hrfs and finite timpulse response (FIR) models. This module closely follows SPM implementation

Author: Bertrand Thirion, 2011

Functions

nipy.modalities.fmri.hemodynamic_models.compute_regressor(exp_condition, hrf_model, frametimes, con_id='cond', oversampling=16, fir_delays=None)

This is the main function to convolve regressors with hrf model

Parameters :

exp_condition: descriptor of an experimental condition :

hrf_model: string, the hrf model to be used. Can be chosen among: :

‘spm’, ‘spm_time’, ‘spm_time_dispersion’, ‘canonical’, ‘canonical_derivative’, ‘fir’

frametimes: array of shape (n):the sought :

con_id: string, optional identifier of the condition :

oversampling: int, optional, oversampling factor to perform the convolution :

fir_delays: array-like of int, onsets corresponding to the fir basis :

Returns :

creg: array of shape(n_scans, n_reg): computed regressors sampled :

at frametimes

reg_names: list of strings, corresponding regressor names :

Notes

The different hemodynamic models can be understood as follows: ‘spm’: this is the hrf model used in spm ‘spm_time’: this is the spm model plus its time derivative (2 regressors) ‘spm_time_dispersion’: idem, plus dispersion derivative (3 regressors) ‘canonical’: this one corresponds to the Glover hrf ‘canonical_derivative’: the Glover hrf + time derivative (2 regressors) ‘fir’: finite impulse response basis, a set of delayed dirac models

with arbitrary length. This one currently assumes regularly spaced frametimes (i.e. fixed time of repetition).

It is expected that spm standard and Glover model would not yield large differences in most cases.

nipy.modalities.fmri.hemodynamic_models.gamma_difference_hrf(tr, oversampling=16, time_length=32.0, onset=0.0, delay=6, undershoot=16.0, dispersion=1.0, u_dispersion=1.0, ratio=0.167)

Compute an hrf as the difference of two gamma functions

Parameters :

tr: float, scan repeat time, in seconds :

oversampling: int, temporal oversampling factor, optional :

time_length: float, hrf kernel length, in seconds :

onset: float, onset of the hrf :

Returns :

hrf: array of shape(length / tr * oversampling, float), :

hrf sampling on the oversampled time grid

nipy.modalities.fmri.hemodynamic_models.glover_hrf(tr, oversampling=16, time_length=32.0, onset=0.0)

Implementation of the Glover hrf model

Parameters :

tr: float, scan repeat time, in seconds :

oversampling: int, temporal oversampling factor, optional :

time_length: float, hrf kernel length, in seconds :

onset: float, onset of the response :

Returns :

hrf: array of shape(length / tr * oversampling, float), :

hrf sampling on the oversampled time grid

nipy.modalities.fmri.hemodynamic_models.glover_time_derivative(tr, oversampling=16, time_length=32.0, onset=0.0)

Implementation of the flover time derivative hrf (dhrf) model

Parameters :

tr: float, scan repeat time, in seconds :

oversampling: int, temporal oversampling factor, optional :

time_length: float, hrf kernel length, in seconds :

onset: float, onset of the response :

Returns :

dhrf: array of shape(length / tr, float), :

dhrf sampling on the provided grid

nipy.modalities.fmri.hemodynamic_models.resample_regressor(hr_regressor, hr_frametimes, frametimes, kind='linear')

this function samples the regressors at frametimes

Parameters :

hr_regressor: array of shape(n), :

the regressor time course sampled at high temporal resolution

hr_frametimes: array of shape(n), :

the corresponding time stamps

frametimes: array of shape(p), :

the desired time stamps

kind: string, optional, the kind of desired interpolation :

Returns :

regressor: array of shape(p), the resampled regressor :

nipy.modalities.fmri.hemodynamic_models.sample_condition(exp_condition, frametimes, oversampling=16)

this function samples the experimental condition at frametimes

Parameters :

exp_condition: a tuple of 3 arrays of shape n, corresponding :

to (onsets, duration, value), describing the experimental condition

frametimes: array of shape(n) :

over_sampling: int, over_sampling factor :

Returns :

regressor: array of shape(n) :

nipy.modalities.fmri.hemodynamic_models.spm_dispersion_derivative(tr, oversampling=16, time_length=32.0, onset=0.0)

Implementation of the SPM dispersion derivative hrf model

Parameters :

tr: float, scan repeat time, in seconds :

oversampling: int, temporal oversampling factor, optional :

time_length: float, hrf kernel length, in seconds :

onset: float, onset of the response :

Returns :

dhrf: array of shape(length / tr * oversampling, float), :

dhrf sampling on the oversampled time grid

nipy.modalities.fmri.hemodynamic_models.spm_hrf(tr, oversampling=16, time_length=32.0, onset=0.0)

Implementation of the SPM hrf model

Parameters :

tr: float, scan repeat time, in seconds :

oversampling: int, temporal oversampling factor, optional :

time_length: float, hrf kernel length, in seconds :

onset: float, onset of the response :

Returns :

hrf: array of shape(length / tr * oversampling, float), :

hrf sampling on the oversampled time grid

nipy.modalities.fmri.hemodynamic_models.spm_time_derivative(tr, oversampling=16, time_length=32.0, onset=0.0)

Implementation of the SPM time derivative hrf (dhrf) model

Parameters :

tr: float, scan repeat time, in seconds :

oversampling: int, temporal oversampling factor, optional :

time_length: float, hrf kernel length, in seconds :

onset: float, onset of the response :

Returns :

dhrf: array of shape(length / tr, float), :

dhrf sampling on the provided grid