converting surface annot file to volume

AFNI version info (afni -ver): Precompiled binary linux_openmp_64: Sep 11 2024 (Version AFNI_24.2.06 'Macrinus')

I have a custom annot file that needs to be converted to a volume to be used as an ROI in a volumetric analysis. What I end up with is this.

It looked like this in Freeview.

In addition to the AFNI code pasted below, I also did this with Freesurfer's mri_label2vol and got the same result.

Is there a way to make the volumetric ROIs less sparse?

FSread_annot \
-input ../label/lh.203264_CLOCK_run1_gpip_labels.annot \
-roi_1D ./lh.203264_CLOCK_run1_gpip_labels.annot.1D.roi

 ROI2dataset -prefix lh.test -input lh.203264_CLOCK_run1_gpip_labels.annot.1D

3dSurf2Vol -surf_A lh.white.gii -surf_B pial \
-sv fsaverage5_SurfVol.nii \
-grid_parent fsaverage5_SurfVol.nii \
-map_func mode -f_steps 30 -f_index points \
-sdata lh.test.niml.dset -prefix lh_test_vol.nii

Those projection results should look better than this, but I would recommend using @surf_to_vol_spackle instead of the 3dSurf2Vol program to fill in holes better. If you use @SUMA_MakeSpecFS to convert the Freesurfer output to standard meshes, you can use the spec files it creates and any other dataset with the same standard mesh, including the MNI152 2009c or MNI N27 surfaces.

        foreach hemi ( lh rh )
	        # project to volume - ribbon mask
	        rm ${hemi}_ribbon.nii.gz
	        @surf_to_vol_spackle -mode -maskset ${hemi}.ribbon.nii.gz \
	            -spec ${surfdir}/std.141.MNI152_2009_${hemi}.spec \
	            -surfA smoothwm -surfB pial -datum short \
	            -surfset myrois.niml.dset \
	            -prefix ${hemi}_ribbon_vol
	     end

	     # combine hemispheres  
	     # overlap gives priority to right side
	     # ranked volume projected from surface needs nparcel for right side 
	     3dcalc -b rh_ribbon_vol.nii.gz \
	      -a lh_ribbon_vol.nii.gz \
	      -expr "a*not(b)+(b*step(b)" -datum short -nscale \
	      -prefix ribbon_vol.nii.gz -overwrite
	     3drefit -cmap INT_CMAP -space MNI ribbon_vol.nii.gz 
   end

Welcome back and thanks for the suggestion. I tried the following and I got a file that appears to be empty, although autorange suggests that at least one voxel has a value of 1.

@surf_to_vol_spackle -mode -maskset ~/suma_MNI/suma_MNI_N27/lh.ribbon.nii \
-spec ~/suma_MNI/suma_MNI_N27/std.141.MNI_N27_lh.spec -surfA smoothwm -surfB pial \
-datum short -surfset lh.203264_CLOCK_run1_gpip_labels.annot -prefix sub-203264.left_hemisphere

For this method to work, you have to have a surface, the parcellation and a matching volume, all in the same space. The standard mesh will make this easier, but you can use any set of surfaces and a volume in the same space with each other. The "surfset" here gets projected from the surface into the volume. That will typically be in a niml.dset format for afni/suma commands, so you should convert that first. If you use the MNI152 volume and surfaces, then that data should be converted to the standard mesh first too.
In the end, you will need to be sure all surfaces and the data mapped onto those surfaces make sense, and they are aligned with the volume you to which you want to project.

I got it to work. Thanks for the help.

Be careful to be consistent if you're using MNI_N27 (MNI_caez_N27+tlrc in our distribution) or the MNI152_2009_template.nii.gz templates and surfaces. Your previous command example used the N27 dataset, but these latest images show the MNI 2009c template. The cortical ribbon mask will be filled in if you do it properly too.

Good catch. It does look much better on the N27 template.

1 Like

Looks good now!