Assessing first-level fMRI model fit in nilearn

Hi all,

I have fitted fMRI data using nilearn’s FirstLevelModel, for example:

fmri_glm = FirstLevelModel(
    t_r=TR,
    noise_model='ar1',
    hrf_model='spm',
    drift_model='polynomial',
    drift_order=3,
    high_pass=1./128,
    signal_scaling=False,
    minimize_memory=False
)

fmri_glm = fmri_glm.fit(fmri_img, events=event_data_corrected, confounds=motion_params_corrected)

I found the following tutorial very helpful:

However, I am not sure how to apply this approach to my own data. My idea is to examine the predicted versus actual time series for a specific voxel: if the voxel shows a good fit, it might suggest that the model is performing well. I am wondering whether this is a valid approach, or if there are better practices to assess the overall fit of a first-level fMRI model.

Could you kindly suggest recommended approaches, or provide example code for doing this in nilearn? Any guidance would be greatly appreciated.

1 Like

I have been wanting to add model evalutation tools to nilearn for a while but never got around to.

Have a look at this example for some more guidance: Predicted time series and residuals - Nilearn

Some of the evaluation you could even do before you acquire data: if your design does not depend on the participant’s responses you should be able to generate the design matrix and its correlation matrix with no data: those are also plotted by the GLM report. In this case you want to check that the correlation between regressors of interest is “not too high”: specifically between regressor you will contrast.

1 Like

Thank you so much for your detailed explanation! It is extremely helpful, and I really appreciate your time and advice.

A way forward is to look at an F contrasts that encompasses all effects of interest. This contrast should display strong values in region that should be involved in some aspect of the experiment.
I agree that this is not very satisfactory/detailed, but after all, statistical maps precisely reveal how good the model as in fitting data.
My 2c,
Bertrand

1 Like

Thank you for your valuable suggestion, Bertrand! I will try this method of using F contrasts.