Nifti to surface does not work
seralouk opened this issue · 2 comments
Hello,
First of all, thanks for this amazing repo.
I have a 3D nifti file that I would like to project to the fsaverage surface for a nice visualization output.
My nifti file is already in MNI space.
I have tried the following but the output an empty nii.gz files.
lh, rh = vol_to_fsaverage("/Users/makis/Desktop/stat_map.nii", 'output', template_type='MNI152_orig')
How can I solve this issue?
Data:https://easyupload.io/260ldc
Pass: makis
Hi @seralouk,
Thanks for opening this issue and providing the data. I tested this out with the CLI and vol_to_fsaverage
and tried to replicate your problem, but couldn't. Here are the commands I ran:
CLI:
regfusion -s stat_map.nii -o output
And with vol_to_fsaverage
:
lh, rh = vol_to_fsaverage("stat_map.nii", 'output', template_type='MNI152_orig')
The output viewed in freeview:
So, it seems to be working as expected on my end. I'm running this on a Linux machine (Ubuntu 20.04).
However, when checked your file I noticed it included several NaNs, which were also flagged by freeview (18542 vertices in the left hemisphere, 17465 vertices in the right hemisphere). Perhaps replacing NaNs in your file might resolve things on your end?
I noticed in the above figure that the sign has been swapped (i.e negative voxels are positive vertices on the surface, and vice versa). This was true even after replacing NaNs with 0.
I checked with two other stat maps I have, each created using different software (nilearn and SPM) and the projections were correct (no sign flipping). So this issue seems to be specific to your file.
As a temporary fix, you could a) replace the NaNs with 0, and b) flip the sign of voxels stat_map.nii
so that they would be correct on the surface. Not sure what is causing this issue that is specific to your file.