Convenience functions for specifying a design in the GLM
Create a design matrix from specification of blocks block_spec
Create design matrix for linear model from a block specification block_spec, evaluating design rows at a sequence of time values t. Each column in the design matrix will be convolved with each HRF in hrfs.
Parameters : | block_spec : np.recarray
t : np.ndarray
order : int, optional
hrfs : sequence, optional
convolution_padding : float, optional
convolution_dt : float, optional
hrf_interval: length 2 sequence of floats, optional :
level_contrasts : bool, optional
|
---|---|
Returns : | X : np.ndarray
contrasts : dict
|
Create design matrix from event specification event_spec
Create a design matrix for linear model based on an event specification event_spec, evaluating the design rows at a sequence of time values t. Each column in the design matrix will be convolved with each HRF in hrfs.
Parameters : | event_spec : np.recarray
t : np.ndarray
order : int, optional
hrfs : sequence, optional
level_contrasts : bool, optional
|
---|---|
Returns : | X : np.ndarray
contrasts : dict
|
Create a design matrix with columns given by the Fourier basis with a given set of frequencies.
Parameters : | t : np.ndarray
freq : sequence of float
|
---|---|
Returns : | X : np.ndarray |
Examples
>>> t = np.linspace(0,50,101)
>>> drift = fourier_basis(t, np.array([4,6,8]))
>>> drift.shape
(101, 6)
Create a design matrix with columns given by a natural spline of a given order and a specified set of knots.
Parameters : | tvals : np.array
knots : None or sequence, optional
order : int, optional
intercept : bool, optional
|
---|---|
Returns : | X : np.ndarray |
Examples
>>> tvals = np.linspace(0,50,101)
>>> drift = natural_spline(tvals, knots=[10,20,30,40])
>>> drift.shape
(101, 8)
Add some columns to a design matrix that has contrasts matrices already specified, adding some possibly new contrasts as well.
This basically performs an np.hstack of old_X, new_X and makes sure the contrast matrices are dealt with accordingly.
If two contrasts have the same name, an exception is raised.
Parameters : | old_X : np.ndarray
new_X : np.ndarray
old_contrast : dict
new_contrasts : dict
|
---|---|
Returns : | X : np.ndarray
contrasts : dict
|
Create a new F-contrast matrix called ‘name’ based on a sequence of keys. The contrast is added to contrasts, in-place.
Parameters : | contrasts : dict
name : str
keys : sequence of str
|
---|---|
Returns : | None : |
Stack a sequence of design / contrast dictionary pairs. Uses multiple calls to stack2designs
Parameters : | pairs : sequence filled with (np.ndarray, dict) or np.ndarray |
---|---|
Returns : | X : np.ndarray
contrasts : dict
|