Hi, I am trying to run a lag-optimized cerebrovascular reactivity mapping analysis (in the spirit of http://biorxiv.org/content/early/2020/08/19/2020.08.18.256479.abstract). I have generated regressors with different lags and thought I would run the GLM analysis one at a time and then compare fit quality in terms of the coefficient of determination (R^2) for each lag in order to select the optimal lag. The problem that I am encountering is that the R^2 doesn’t seem to update after each fit. Is this expected behavior? I thought that fmri_glm.r_square[0] would update after each call of fmri_glm.fit(). However, the only way I can generate different fmri_glm.r_square[0] values is by re-intializing frmi_glm inside the loop.
That is:
fmri_glm = nilearn.glm.first_level.FirstLevelModel()
r_sq_out = []
z_out = []
for event in lagged_events:
fmri_glm.fit(fmri_img, event)
r_sq_out.append(fmri_glm.r_square[0])
z_out.append(fmri_glm.compute_contrast(contrasts['CO2'], output_type='z_score'))
Gives identical r_square maps and unique z-score maps for each fit, whereas:
r_sq_out = []
z_out = []
for event in lagged_events:
fmri_glm = nilearn.glm.first_level.FirstLevelModel()
fmri_glm.fit(fmri_img, event)
r_sq_out.append(fmri_glm.r_square[0])
z_out.append(fmri_glm.compute_contrast(contrasts['CO2'], output_type='z_score'))
Gives unique r_square values for each fit
Has anyone else encountered this issue? I don’t mind intializing fmri_glm in each loop (perhaps that is best practice, even) but it was unintitutive to me given that many parts of fmri_glm update after running .fit().