Hey, thank you for reading about my problem. I am trying to visualize my fMRI data after the masking process. (which has been processed in ‘numpy’ format), and I want to visualize the result by Nilearn. But I find that Nilearn can only read or process ‘nii.gz’ format files. I have not found any related guild in the guide book. So anyone who can help me with this question?
Presumably, you saved the data as a .npy right? What kind of object was saved to this .npy file? You should be able to get the file back in it’s original form after loading it with numpy.load(/path/to/file.npy).
I loaded it with the ‘np.load’ function and then tried to use ‘nilearn.plotting.plot_stat_map’ and ‘nilearn.plotting.view_img_on_surf’ to visualize my data. But none of them worked. The feedback told me that I have got a ‘TypeError: Data given cannot be loaded because it is not compatible with nibabel format.’
So I thought that the numpy file might not be compatible with nibabel or nilearn. And here’s my real problem.
where ref_niimg could be your original unsliced image and data is the array you want to make an image out of, and then save it out with my_img.to_filename('/path/to/out.nii.gz').