Creating Tiled Montage with nilearn

I have started using nilearn and its plotting capabilities to create beautiful images. I have been using plotting.plot_stat_map function, which is working very well for most of my needs. When trying to plot a large number of slices (>7) the images are concatenated from left to right. Ideally, I would like to specify the number of rows and columns where the images should be placed.

At the moment, I am saving each image individually and then creating a montage with ImageMagick. If anyone has any other suggestions I would appreciate.

Thanks

Bob

1 Like

For the moment, it is not available: https://github.com/nilearn/nilearn/issues/212

EDIT: in this other issue https://github.com/nilearn/nilearn/pull/464, we find this useful snippet:

# Grid of subplots
fh = plt.figure()
for pi, img in enumerate(iter_img(index_img(maps_img, slice(None, 16)))):
    ax = fh.add_subplot(4, 4, pi + 1)
    plot_stat_map(img, axes=ax, display_mode='z', cut_coords=1)
1 Like