nilearn / nistats

Modeling and statistical inference on fMRI data in Python
BSD 3-Clause "New" or "Revised" License
95 stars 55 forks source link

beta/contrast maps for constant #67

Closed rschmaelzle closed 8 years ago

rschmaelzle commented 8 years ago

Hello, I am trying to write out a nifti-image for the contrast of the "constant" (i.e. the last regressor in the design matrix consisting of only ones). My code for the contrasts looks like this:

` z_map, t_map, eff_map, var_map = fmri_glm.transform(contrast_val, contrast_name=contrast_id, output_z=True, output_stat=True, output_effects=True, output_variance=True)

eff_map_image_path = path.join(target_dir, subjs[currsub] + '' + contrast_id + '_eff_map_map.nii') nib.save(eff_map, eff_map_image_path) #and same for t_map, eff_map, var_map etc`

Looping this over my sample, I produce a lot of contrasts and their respective z-,t-, and eff-images that all look pretty reasonable. But the constant doesn't. In particular, my assumption was that the eff_map would correspond to the 'beta' images, and that the beta-image for the constant would represent basically the mean across time (although different packages use weird scaling that I don't fully understand). However, instead of finding values around 100, 400, or even 2000 (depending on the raw values from the scanner), the "eff_map" images for the constant have positive and negative values. Seems I doing something very wrong here, but I couldn't find a solution by going through the code. So basically the question is: does the eff_map represent what I think of as beta (or the contrast - which in case of the constant should be identical)? Is there anything else to consider (in setting up the fmri_glm i am setting standardize to False)?

Perhaps I should say that my ultimate goal is to extract data from ROIs (for which I'd want the interesting effect and the constant image), which I'd do via nilearn (and also 2nd level modeling using the mass-univariate example therein). Thanks, Ralf.

bthirion commented 8 years ago

Have you set percent_signal_change=False when instantiating the glm ? Best,

Bertrand

rschmaelzle commented 8 years ago

that was it, sorry! I had missed that it is set true by default. Still not fully understanding all implications and minute differences between SPM and nistats, but results now look reasonable and the overall pattern between nistats and SPM looks very similar. Thanks for getting me back on track ... Best, Ralf

PS: If anyone is interested: I compared the results for Nistats and SPM in a group sample. Specifically, I computed %-signal change for a simple visual contrast. Across the sample of 10 ppts, the correlation is .97 in visual cortex. I also checked for different ROIs and always saw agreement of >.9. Of course, I wasn't distrusting your package, but rather questioned whether I used it properly - :- ) - but overall this is encouraging and good to have proven.