Fit a GLM with HRF regressor and yield a dataset with model parameters
A univariate GLM is fitted for each feature and model parameters are returned as samples. Model parameters are returned for each regressor in the design matrix. Using functionality from NiPy, design matrices can be generated from event definitions with a variety of customizations (HRF model, confound regressors, ...).
Events need to be specified as a list of dictionaries (see:class:Event) for a helper class. Each dictionary contains all relevant attributes to describe an event.
Parameters : | ds : Dataset
events : list
time_attr : str
condition_attr : str
design_kwargs : dict
glmfit_kwargs : dict
regr_attrs : list
return_model : bool
|
---|---|
Returns : | Dataset :
|
Examples
The documentation also contains an example script showing a spatio-temporal analysis of fMRI data that involves this function.
>>> from mvpa2.datasets import Dataset
>>> ds = Dataset(np.random.randn(10, 25))
>>> ds.sa['time_coords'] = np.linspace(0, 50, len(ds))
>>> events = [{'onset': 2, 'duration': 4, 'condition': 'one'},
... {'onset': 4, 'duration': 4, 'condition': 'two'}]
>>> hrf_estimates = fit_event_hrf_model(
... ds, events,
... time_attr='time_coords',
... condition_attr='condition',
... design_kwargs=dict(drift_model='blank'),
... glmfit_kwargs=dict(model='ols'),
... return_model=True)
>>> print hrf_estimates.sa.condition
['one' 'two']
>>> print hrf_estimates.shape
(2, 25)
>>> len(hrf_estimates.a.model.get_mse())
25
Additional regressors used in GLM modeling are also available in a dataset attribute:
>>> print hrf_estimates.a.add_regs.sa.regressor_names
['constant']
mvpa2.datasets.eventrelated.find_events
mvpa2.datasets.eventrelated.value2idx
Enter search terms or a module, class or function name.