NiftiResponseFytter

class nideconv.nifti.NiftiResponseFitter(func_img, sample_rate, mask=None, oversample_design_matrix=20, add_intercept=True, detrend=False, standardize=False, confounds_for_extraction=None, memory=None, **kwargs)[source]

Methods

add_confounds(name, confound) Add a timeseries or set of timeseries to the general design matrix as a confound
add_event(event_name[, onset_times, …]) create design matrix for a given event_type.
get_epochs(onsets, interval[, …]) Return a matrix corresponding to specific onsets, within a given interval.
get_rsq() calculate the rsq of a given fit.
regress([type, cv, alphas, store_residuals]) Regress a created design matrix on the input_data.
add_intercept  
get_residuals  
get_time_to_peak  
get_timecourses  
plot_timecourses  
predict_from_design_matrix  
ridge_regress  
add_confounds(name, confound)

Add a timeseries or set of timeseries to the general design matrix as a confound

Parameters:
confound : array

Confound of (n_timepoints) or (n_timepoints, n_confounds)

add_event(event_name, onset_times=None, basis_set='fir', interval=[0, 10], n_regressors=None, durations=None, covariates=None, **kwargs)

create design matrix for a given event_type.

Parameters:
event_name : string

Name of the event_type, used as key to lookup this event_type’s characteristics

**kwargs : dict

keyward arguments to be internalized by the generated and internalized Event object. Needs to consist of the necessary arguments to create an Event object, see Event constructor method.

get_epochs(onsets, interval, remove_incomplete_epochs=True)

Return a matrix corresponding to specific onsets, within a given interval. Matrix size is (n_onsets, n_timepoints_within_interval).

Note that any events that are in the ResponseFitter-object will be regressed out before calculating the epochs.

get_rsq()

calculate the rsq of a given fit. calls predict_from_design_matrix to predict the signal that has been fit

predict_from_design_matrix(X=None)[source]

predict a signal given a design matrix. Requires regression to have been run.

Parameters:
X : np.array, (timepoints, n_regressors)

the design matrix for which to predict data.

regress(type='ols', cv=20, alphas=None, store_residuals=False)

Regress a created design matrix on the input_data.

Creates internal variables betas, residuals, rank and s. The beta values are then injected into the event_type objects the ResponseFitter contains.

Parameters:
type : string, optional

the type of fit to be done. Options are ‘ols’ for np.linalg.lstsq, ‘ridge’ for CV ridge regression.

ridge_regress(*args, **kwargs)[source]

run CV ridge regression instead of ols fit. Uses sklearn’s RidgeCV class

Parameters:
cv : int

number of cross-validation folds

alphas : np.array

the alpha/lambda values to try out in the CV ridge regression