How do you plot the contour of an ROI on a 2D stat map with nilearn?

Hi all,

I wanted to draw the contour of the fusiform gyrus on top of a 2D stat map using nilearn. So far, I haven’t been able to make it work. The code below is what I have, which plots a second brain on top of the first one with the contours. Any ideas how this could be done?


fig, axes = plt.subplots(nrows=1, ncols=1)
plotting.plot_stat_map(faces_diff_corr_img, display_mode="ortho", cut_coords=[20, -45, -12], cmap="RdYlBu_r", vmax=0.1, draw_cross=False, axes=axes)
fusiform = nib.load(os.path.join(out_dir, "fusiform_face_mask.nii.gz"))
plotting.plot_roi(fusiform, display_mode="ortho", cut_coords=[20, -45, -12], draw_cross=False, view_type="contours", axes=axes)

Hi @e.urunuela, objects of nilearn display classes have a method called add_contours. See this example as well: More plotting tools from nilearn - Nilearn

1 Like

That’s exactly what I was looking for.

Thank you @ymzayek !