code: def _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
      """
      dt = tr / oversampling
      time_stamps = np.linspace(
          0, time_length, int(float(time_length) / dt)
      )
      time_stamps -= onset / dt
      hrf = gamma.pdf(
          time_stamps, delay / dispersion, dt / dispersion
      ) - ratio * gamma.pdf(
          time_stamps, undershoot / u_dispersion, dt / u_dispersion
      )
      hrf /= hrf.sum()
      return hrf
  
file_path: nipy/nipy/modalities/fmri/hemodynamic_models.py
imports: import warnings
  import numpy
  from scipy.stats import gamma
label_desc: Use image node_id 1 for calling a global function with example usage: _gamma_difference_hrf(tr, oversampling, time_length, onset, delay, undershoot, dispersion, u_dispersion, ratio) and returns: hrf