Perform a GLM from BOLD signal, given the conditons, onset, TR (repetition time of the scanner) and the BOLD signal.
This method is able to fir a variety of models, available through the mode keyword. These are:
- glm: standard GLM
- glms: GLM with separate designs
- r1glm: Rank-1 GLM
- r1glms: Rank-1 GLM with separate designs
basis:
- hrf: single element basis
- 3hrf: basis with 3 elements
- fir: basis with hrf_length elements (in multiples of TR)
Note the output parameters need are not normalized. Rank-1 models are specified up to a constant term between the betas and the HRF. This implies that some normalization must be done prior to interpreting the activation coefficients. Typically the HRF is normalized to have unit amplitude and to correlate positively with a reference HRF.
Parameters: | conditions: array-like, shape (n_trials) :
onsets: array-like, shape (n_trials) :
TR: float :
Y : array-like, shape (n_scans, n_voxels)
mode: {‘r1glm’, ‘r1glms’, ‘glms’, ‘glm’} :
rtol : float
maxiter : int
verbose : {0, 1, 2}
n_jobs: int :
method: {‘L-BFGS-B’, ‘TNC’} :
|
---|---|
Returns: | U : array
V : array, shape (p, n_voxels)
dmtx: array, :
|
Estimates a R1-GLM model with a given design matrix.
This methods solves a problem of the form
argmin_{hrf, betas} ||y - X vec(hrf betas.T)||^2
for given y and X
Parameters: | X : array-like, shape (n_scans, n_regressors)
y_i: array-like, shape (n_scans, n_voxels) :
n_basis : int
w_i : array-like
method: {‘L-BFGS-B’, ‘TNC’} :
bounds: {True, False} :
|
---|---|
Returns: | U : array
V : array
|
SPM canonical HRF, HRF values for time values t
This is the canonical HRF function as used in SPM. It has the following defaults:
defaults (seconds)
delay of response (relative to onset) 6 delay of undershoot (relative to onset) 16 dispersion of response 1 dispersion of undershoot 1 ratio of response to undershoot 6 onset (seconds) 0 length of kernel (seconds) 32
SPM canonical HRF dispersion derivative, values for time values t
This is the canonical HRF dispersion derivative function as used in SPM.
It is the numerical difference between the HRF sampled at time t, and values at t for another HRF shape with a small change in the peak dispersion parameter (peak_disp in func:spm_hrf_compat).
Apply a Savitzky-Golay filter to an array.
This is a 1-d filter. If x has dimension greater than 1, axis determines the axis along which the filter is applied.
Parameters: | x : array_like
window_length : int
polyorder : int
deriv : int, optional
delta : float, optional
axis : int, optional
mode : str, optional
cval : scalar, optional
|
---|---|
Returns: | y : ndarray, same shape as x
|
See also
savgol_coeffs
Notes
Details on the mode options:
- ‘mirror’:
- Repeats the values at the edges in reverse order. The value closest to the edge is not included.
- ‘nearest’:
- The extension contains the nearest input value.
- ‘constant’:
- The extension contains the value given by the cval argument.
For example, if the input is [1, 2, 3, 4, 5, 6, 7, 8], and window_length is 7, the following shows the extended data for the various mode options (assuming cval is 0):
mode | Ext | Input | Ext
-----------+---------+------------------------+---------
'mirror' | 4 3 2 | 1 2 3 4 5 6 7 8 | 7 6 5
'nearest' | 1 1 1 | 1 2 3 4 5 6 7 8 | 8 8 8
'constant' | 0 0 0 | 1 2 3 4 5 6 7 8 | 0 0 0
Examples
>>> np.set_printoptions(precision=2) # For compact display.
>>> x = np.array([2, 2, 5, 2, 1, 0, 1, 4, 9])
Filter with a window length of 5 and a degree 2 polynomial. Use the defaults for all other parameters.
>>> y = savgol_filter(x, 5, 2)
array([ 1.66, 3.17, 3.54, 2.86, 0.66, 0.17, 1. , 4. , 9. ])
Note that the last five values in x are samples of a parabola, so when mode=’interp’ (the default) is used with polyorder=2, the last three values are unchanged. Compare that to, for example, mode=’nearest’:
>>> savgol_filter(x, 5, 2, mode='nearest')
array([ 1.74, 3.03, 3.54, 2.86, 0.66, 0.17, 1. , 4.6 , 7.97])
Parameters: | conditions: list of conditions : onset: list of onsets : TR: float :
n_scans: number of scans : basis: one of {‘fir’, ‘3hrf’, ‘2hrf’, ‘hrf’} : |
---|---|
Returns: | design_matrix : basis : |