prfmodel.models.impulse.shifted_gamma¶
Shifted gamma distribution impulse response.
Classes¶
Shifted gamma distribution impulse response model. |
Module Contents¶
- class prfmodel.models.impulse.shifted_gamma.ShiftedGammaImpulse(duration: float = 32.0, offset: float = 0.0001, resolution: float = 1.0, norm: str | None = 'sum', default_parameters: dict[str, float] | None = None)[source]¶
Shifted gamma distribution impulse response model.
Predicts an impulse response that is a shifted gamma distribution. The model has three parameters: delay refers to the positive peak, dispersion to the rate, and shift to the onset of the gamma distribution.
- Parameters:
duration (float, default=32.0) – The duration of the impulse response (in seconds).
offset (float, default=0.0001) – The offset of the impulse response (in seconds). By default a very small offset is added to prevent infinite response values at t = 0.
resolution (float, default=1.0) – The time resultion of the impulse response (in seconds), that is the number of points per second at which the impulse response function is evaluated.
norm (str, optional, default="sum") – The normalization of the response. Can be “sum” (default), “mean”, “max”, “norm”, or None. If None, no normalization is performed.
default_parameters (dict of float, optional) – Dictionary with scalar default parameter values. Keys must be valid parameter names.
Notes
The predicted impulse response at time \(t\) with \(\alpha = delay / dispersion\), \(\lambda = dispersion\), and \(\delta = shift\) is:
\[f(t) = f_{\text{gamma}}(t - \delta; \alpha, \lambda)\]The response prior to the onset of the gamma distribution is set to zero.
See also
shifted_gamma_densityShifted density of the gamma distribution.
Examples
>>> import pandas as pd >>> params = pd.DataFrame({ >>> "delay": [2.0, 1.0, 1.5], >>> "dispersion": [1.0, 1.0, 1.0], >>> "shift": [1.0, 2.0, 5.0], >>> }) >>> impulse_model = ShiftedGammaImpulse( >>> duration=100.0 # 100 seconds >>> ) >>> resp = impulse_model(params) >>> print(resp.shape) # (num_rows, duration) (3, 100)
- property parameter_names: list[str]¶
Names of parameters used by the model.
Parameter names are: delay, dispersion, and shift.
- __call__(parameters: pandas.DataFrame, dtype: str | None = None) prfmodel.typing.Tensor[source]¶
Predict the impulse response.
- Parameters:
parameters (pandas.DataFrame) – Dataframe with columns containing different model parameters and rows containing parameter values for different batches. Must contain the columns delay, dispersion, and shift.
dtype (str, optional) – The dtype of the prediction result. If None (the default), uses the dtype from
prfmodel.utils.get_dtype().
- Returns:
The predicted impulse response with shape (num_batches, num_frames) and dtype dtype.
- Return type:
- property num_frames: int¶
The total number of time frames at which the impulse response function is evaluated.
- property frames: prfmodel.typing.Tensor¶
The time frames at which the impulse response function is evaluated.
Time frames are linearly interpolated between offset and duration and have shape (1, num_frames).