# Recommendations with converting a surface source estimate object to nifti

If you have a question or issue with MNE-Python, please include the following info:

• MNE-Python version: 0.21.1
• operating system: Windows 10

Good afternoon I am trying to visualize with nifti our roc estimates on brains. Not so important to go into details. In the end now I have a source estimate object where i can visualize using the plot method.
This is however a surface source estimate and I need to convert it into nifti to visualize it. I know that the VolSourceEstimate object has a save as nifti format but not the surface source estimate. How can I proceed? Any advice or opinions?

I took the approach of trying to get a morph object with the mne.compute_source_morph() and then modifying somehow the function _interpolate_data(stc, morph, mri_resolution, mri_space, output) to work on surface source estimates. I however am stuck because I end up getting a morph object with a list of 2 arrays under morphed_data_object[â€˜from verticesâ€™] and not the mentioned arrays in the interpolate_data function:
if mri_resolution:
affine = morph.src_data[â€˜src_affine_voxâ€™]
else:
affine = morph.src_data[â€˜src_affine_srcâ€™]

``````if mri_space:
affine = np.dot(morph.src_data['src_affine_ras'], affine)
``````

I am however a student and relatively new to mne so it may be far fetched my approach to solving the situation.
I know I cant simply just feed the raw stc to the nibabels Nifti1.image function because there should be a transformation prior which I had thought to be the source morph.

1. Use a combination of upsampling to the high resolution mesh using `morph = compute_source_morph(src, subject, smooth='nearest', spacing=None)`, then using `nibabel.freesurfer.io.write_morph_data`, and then FreeSurferâ€™s `mri_surf2vol`.
2. Read FreeSurferâ€™s `ribbon.mgz` for your subject, and for each voxel, take the value of the nearest point in your source space. This will involve a bit of gymnastics involving `vox_mri_t` for the source space, which is really the same thing as nibabelâ€™s `img.header.get_vox2ras_tkr()`.
In principle we could consider adding a `as_volume` / `save_as_volume` for surface source spaces that does the second method.