How to Convert an ALE Meta-Analysis Z Map to Surface Space and Visualize It?

Hello,

I am trying to visualize a thresholded Z map (obtained from an ALE meta-analysis and corrected for multiple comparisons) that is based on the MNI152 space by converting it to surface space (fsLR). I would like to use the surfplot package for visualization, but I am encountering some issues along the way. Below, I describe my workflow and the problems I am facing.

What I did:

  1. Converting the Z map to surface space:

    from neuromaps import transforms
    
    control_all = '../results/control_all_z_size_level_thresh.nii'
    controls_surf = transforms.mni152_to_fslr(control_all, '32k')  # Convert to fsLR 32k surface space
    
    • After the transformation, I obtained a result (controls_surf) that contains data for both the left and right hemispheres.
  2. Saving the left and right hemisphere data as .gii files:

    import nibabel as nib
    
    lh_data = controls_surf[0]  # Left hemisphere data
    rh_data = controls_surf[1]  # Right hemisphere data
    
    # Save the left and right hemisphere data to .gii files
    nib.save(lh_data, '../results/lh_data.gii')
    nib.save(rh_data, '../results/rh_data.gii')
    
  3. Loading the .gii files and visualizing with surfplot:

    • I followed the tutorial from Surfplot Documentation to visualize .gii files. However, when running the code, I encountered the following error:
      from surfplot import Plot
      from nilearn.datasets import fetch_surf_fsaverage
      
      # Load the .gii files for left and right hemispheres
      lh_data = nib.load('../results/lh_data.gii')  
      rh_data = nib.load('../results/rh_data.gii')  
      
      # Load the fsLR surface template
      surfaces = fetch_surf_fsaverage()
      
      # Create a surfplot visualization
      p = Plot(lh_data, rh_data)
      
    • Error message:
ValueError: Surface must be a path-like string, an instance of BSPolyData, or None

I am running Mac OS. how can I resolve it?
Thanks for any advice.

Hi @shanshan_zhu,

  1. It looks like you are passing in the nib load objects when you should be passing in a string of the path.
  2. It looks like what is passed in to Plot should be he surfaces themselves, whereas the results (I.e. your z maps) should be added as layers on top of that, according to the documentation you referenced.

Best,
Steven

Thank you very much for your advice! Following your first suggestion, I modified my code as follows:

p = Plot('../results/lh_data.gii', '../results/rh_data.gii')

However, I encountered another error :

Does this indicate that there was an issue during the generation of lh_data.gii and rh_data.gii ? Or could it be that this method of conversion is not not appropriate for thresholded Z maps?

Hi @shanshan_zhu,

  1. I don’t know how you made your gifti files so
    I cannot say.
  2. You should be using plot on the geometric surfaces, while the results are added as layers.

Best,
Steven

1 Like

Hi @shanshan_zhu,

I haven’t worked with surfplot before, so the suggestion below is untested—but I hope it’s helpful!

From a quick look at your code, it seems you’re trying to map fsRL data onto the fsaverage surface. One potential issue could be that the number of vertices differs between the two geometries, which might explain the indexing error you’re encountering.

As a possible solution, you could try using something like:

controls_surf = transforms.mni152_to_fsaverage(control_all) 

You can find more details about the coordinate systems in the neuromaps documentation here.

Best,
Andrea

1 Like