code: def 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.
      """
      # this is the average tr in this session, not necessarily the true tr
      tr = float(frametimes.max()) / (np.size(frametimes) - 1)
  
      # 1. create the high temporal resolution regressor
      hr_regressor, hr_frametimes = _sample_condition(
          exp_condition, frametimes, oversampling, min_onset
      )
  
      # 2. create the  hrf model(s)
      hkernel = _hrf_kernel(hrf_model, tr, oversampling, fir_delays)
  
      # 3. convolve the regressor and hrf, and downsample the regressor
      conv_reg = np.array(
          [
              np.convolve(hr_regressor, h)[: hr_regressor.size]
              for h in hkernel
          ]
      )
  
      # 4. temporally resample the regressors
      creg = _resample_regressor(conv_reg, hr_frametimes, frametimes)
  
      # 5. ortogonalize the regressors
      if hrf_model != "fir":
          creg = _orthogonalize(creg)
  
      # 6 generate regressor names
      reg_names = _regressor_names(
          con_id, hrf_model, fir_delays=fir_delays
      )
      return creg, reg_names
  
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 12 for calling a global function with example usage: compute_regressor(exp_condition, hrf_model, frametimes, con_id, oversampling, fir_delays, min_onset) and returns: creg,  reg_names