# 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–2013

## Functions

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

  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
    min_onset: float, optional

      minimal onset relative to frametimes[0] (in seconds) events that start before frametimes[0] + min_onset are not considered

  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.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.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