code: def _sample_condition(
      exp_condition, frametimes, oversampling=16, min_onset=-24
  ):
      """Make a possibly oversampled event regressor from condition information.
  
      Parameters
      ----------
      exp_condition: 3 x n_events arraylike
          (onsets, durations, amplitudes) of events for this condition
      frametimes: array of shape(n)
          timepoints corresponding to sampled data
      over_sampling: int, optional
          factor for oversampling event regressor
      min_onset: float, optional
          minimal onset relative to frametimes[0] (in seconds)
          events that start before frametimes[0] + min_onset are not considered
  
      Returns
      -------
      regressor: array of shape(n)
          possibly oversampled event regressor
      hr_frametimes : array of shape(n)
          frametimes corresponding to regressor
      """
      # Find the high-resolution frametimes
      n = frametimes.size
      min_onset = float(min_onset)
      n_hr = (
          (n - 1)
          * 1.0
          / (frametimes.max() - frametimes.min())
          * (
              frametimes.max() * (1 + 1.0 / (n - 1))
              - frametimes.min()
              - min_onset
          )
          * oversampling
      ) + 1
  
      hr_frametimes = np.linspace(
          frametimes.min() + min_onset,
          frametimes.max() * (1 + 1.0 / (n - 1)),
          int(n_hr),
      )
  
      # Get the condition information
      onsets, durations, values = tuple(
          map(np.asanyarray, exp_condition)
      )
      if (onsets < frametimes[0] + min_onset).any():
          warnings.warn(
              (
                  "Some stimulus onsets are earlier than %d in the"
                  + " experiment and are thus not considered in the model"
                  % (frametimes[0] + min_onset)
              ),
              UserWarning,
          )
  
      # Set up the regressor timecourse
      tmax = len(hr_frametimes)
      regressor = np.zeros_like(hr_frametimes).astype(np.float64)
      t_onset = np.minimum(
          np.searchsorted(hr_frametimes, onsets), tmax - 1
      )
      regressor[t_onset] += values
      t_offset = np.minimum(
          np.searchsorted(hr_frametimes, onsets + durations), tmax - 1
      )
  
      # Handle the case where duration is 0 by offsetting at t + 1
      for i, to in enumerate(t_offset):
          if to < (tmax - 1) and to == t_onset[i]:
              t_offset[i] += 1
  
      regressor[t_offset] -= values
      regressor = np.cumsum(regressor)
  
      return regressor, hr_frametimes
  
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 7 for calling a global function with example usage: _sample_condition(exp_condition, frametimes, oversampling, min_onset) and returns: regressor,  hr_frametimes