How to get high resolution activation map in nilearn

Hi,

I’m using nilearn to analyze and visualize my fMRI GLM results. But it looks very burry. Here is the second-level activation map in nilearn (05_glm_second_level/plot_thresholding.html#visualize-the-results). Is there any way to produce high-resolution activation map like MRIcroGL in nilearn?

Here is a high-resolution example from this paper. Not sure what software they used to produced it.

Thank you!

Best Regards,
Kun

Hi @const , you can load a high resolution template and set the argument bg_img in plotting.plot_stat_map to that template, for example:

template = datasets.load_mni152_template(resolution=1) # 1mm res
plotting.plot_stat_map(
    thresholded_map1, cut_coords=display.cut_coords, threshold=threshold1,
    title='Thresholded z map, fpr <.001, clusters > 10 voxels', bg_img=template, black_bg=False)

And you’ll get something like:
Screenshot from 2022-08-24 15-27-41

Sorry I left out a step to resample the stat map to the template, see this instead:

from nilearn.image import resample_to_img
template =  datasets.load_mni152_template(resolution=1)
resampled_stat_img = resample_to_img(thresholded_map1, template)
plotting.plot_stat_map(
    resampled_stat_img, cut_coords=display.cut_coords, threshold=threshold1,
    title='Thresholded z map, fpr <.001, clusters > 10 voxels', bg_img=template, black_bg=False)

To get:

Screenshot from 2022-08-24 15-43-34

1 Like

Hi @ymzayek Thanks for your nice solution! I have a more general question about whether there are some disadvantages of resampling since I rarely see people use it. Is it because of distortion induced by interpolation algorithms?

In the context of the above example, you need to resample since the statistical image and template have different voxel sizes. This is because the pre-computed contrasts that are loaded have a different resolution than the template I loaded in 1mm³ resolution. It wouldn’t be needed if you calculated a higher resolution contrast map on your own data as long as it has the same resolution as whatever template you use. I’m not an expert but I think the disadvantages of resampling depend on the interpolation method as well as at what step it is applied in a processing pipeline. And these disadvantages can sometimes be acceptable depending on what you’re trying to do (e.g. makes sense here for visualization). But I cannot speak more generally about the appropriateness of resampling in regards to fmri processing steps. @bthirion might have some more insight?

Rsampling data to high resolution increases you storage and processing cost for no benefit, so the idea is that you deal with your data at their original resolution. When it comes to plotting, you’re indeed happy that the plotting function nicely interpolates the image :wink:
Best,
Bertrand

1 Like

Sorry for the late reply and thanks for your valuable information! @ymzayek @bthirion