How to plot results in brain Atlas

Hi everyone,

I extracted the fmri signal from atlas_schaefer_2018 using nilearn (time point x 400 matrix), and computed the average timeseries, resulting in a 1x400 array.

Now I want to visualize the average timeseries on the atlas. I transformed the array value back to the atlas using masker.inver_transform() which worked without error. However, I do not know how to plot the masker. I tried the method masker.generate_report(), but it failed with an error say “Mismatch between the number of provided labels (400) and the number of regions in provided label image (401)”.

Therefore, I want to know if there is a way could plot the results with Atlas and export as a Nifti file?

Any ideas will be appreciated. Thanks for your attention.

Qunjun

Have you tried using nilearn’s plot_epi function? There is a great tutorial for it here: Computing a Region of Interest (ROI) mask manually - Nilearn

Another way could be to use a viewer for NIfTI files and look at the files manually for a while, then export some slices from that. For example, you can use MRIcroGL (NITRC: MRIcroGL: Tool/Resource Info) which I quite like.

1 Like

Can you provide a snippet of the code that raises an issue with the masker.generate_report() call ? This may uncover a bug on Nilearn side.
Otherwise, the inverse_transform() call has returned an image (I understand that you only have the time average) that you can indeed simply plot with plot_stat_map or plot_epi.
HTH,
Bertrand

1 Like

Hi Bertrand,

Thank you for your relply.

I did not realize the return of inverse_transform() is a image until you reminded me. Now I know how it works in Nilearn.

I figured out the error in generate_report(). Through the Nilearn document, it has a warning for the “Backgroud” to the list of labels. I modified the code to invert the “Background” to atlas labels and the error disappeared.

Thank you for your help.

best,
Qunjun

Hi LeSasse,

Thank you for your reply,

I read through the tutorial and find it great to cover my needs. Thank you for your recommendation.

best,
Qunjun