I am trying to fit a General Linear Model (GLM) to a segment of fnirs data using the nilearn package, with the goal of obtaining beta values that relate my fnirs data to a hemodynamic response function (HRF) curve. I want to estimate these beta values similarly to how one might with fMRI data.
Command used:
python
events = pd.DataFrame({"trial_type": ['stim'],"onset": [marker], "duration": [duration]})
design_matrix = make_first_level_design_matrix(
frame_times,
events,
hrf_model="spm",
drift_model=None,
)
data = pd.DataFrame(filtered_data['value']).to_numpy()
labels, estimates = run_glm(data, design_matrix.to_numpy())
This is based on this example: Example of surface-based first-level analysis - Nilearn
Version:
nilearn version: 0.10.4
Environment:
Custom Python installation
Data formatted according to a validatable standard?
The data used is fnirs, preprocessed and formatted as numpy arrays. No BIDS validator was applied.
Screenshots / relevant information:
I am referencing this tutorial: The GLM, part 1: estimation — NI-edu, and my aim is to achieve the following:
python
est_betas = inv(X_with_icept.T @ X_with_icept) @ X_with_icept.T @ y
I would like to know if it is possible to obtain beta values by fitting the fnirs data using the nilearn package’s GLM tools.
Currently my code is this, but I’m not sure if it’s correct.
betas_conv = inv(design_matrix.to_numpy().T @ design_matrix.to_numpy()) @ design_matrix.to_numpy().T @ filtered_data['value'].to_numpy()
Is it possible for nilearn to output beta values directly?