How to apply the FreeSurfer aparc+aseg parcellation on CIFTI time series?

Hello everyone,

I am trying to calculate an FC matrix based on rsfMRI data. I used fmriprep to obtain a CIFTI time series, and also the personalised FreeSurfer aparc+aseg parcellation for each subject. I know how to use wb_command -cifti-parcellate to apply a CIFTI label file to a CIFTI timeseries, but I don’t know how to convert the FreeSurfer parcellation into a CIFTI label file. I have used ciftify before, but as it has not been updated in almost 7 years, it doesn’t seem like the best option. Do you know of any other solution - either to just convert the FreeSurfer parcellations into CIFTI labels, or even a completely different way to apply personalised Desikan-Killiany parcellation to CIFTI time series?

if you are comfortable working in R, you can probably do this using the ciftitools R package, and the fslr32k ROI map data from VertexWiseR/data/ROImap_fslr32k.rdata at main · CogBrainHealthLab/VertexWiseR · GitHub

Thank you for the suggestion, but I am not really comfortable with R. I think there must be a way to do this using the commands in freesurfer and wb_command, but I cannot figure it out…

This is what I tried:

  1. I followed the HCP guidelines on how to convert FreeSurfer label files to GIFTI format, and then used these as the left and right cortical surface label inputs into wb_command -cifti-create-label.

  2. For the subcortical volume part, I changed the FreeSurfer aparc+aseg.mgz file into Nifti using mri_convert and then changed it into a label volume using wb_command -volume-label-import.

mri_convert aparc+aseg.mgz aparc+aseg.nii
wb_command -volume-label-import aparc+aseg.nii FreeSurferAllLut.txt aparc+aseg_label.nii -drop-unused-labels

where FreeSurferAllLut.txt is the label table with the following format (first few lines of the file):

LEFT-CEREBRAL-EXTERIOR
1 70 130 180 255
LEFT-CEREBRAL-WHITE-MATTER
2 245 245 245 255
LEFT-CEREBRAL-CORTEX
3 205 62 78 255
LEFT-LATERAL-VENTRICLE
4 120 18 134 255

However, when I run

wb_command -cifti-create-label aparc+aseg_dseg.dlabel.nii \
-left-label aparc_lh.32k_fs_LR.label.gii \
-right-label aparc_rh.32k_fs_LR.label.gii \
-volume aparc+aseg_label.nii aparc+aseg_label.nii

I get the following error:

ERROR: volume label file does not contain any structure names

What could be causing this? I guess the conversion of the parcellation into a label volume was unsuccessfull, but I have no idea what could have gone wrong.

For anyone struggling with the same problem, the steps which worked for me in the end are described bellow. The whole pipeline I ended up using for this can be found here GitHub - daviddaubner42/bids_to_fc

  1. First register the original aparc+aseg.mgz file to the MNI space using

export SUBJECTS_DIR=%path to your FreeSurfer subject directory%

mri_cvs_register --mov %subject ID% --mni

  1. Then convert the result to Nifti

mri_convert %path to your FreeSurfer results for this subject%/cvs/final_CVSmorphed_tocvs_avg35_inMNI152_aseg.mgz aparcaseg.nii.gz

  1. Then change the segmentation to a label volume

wb_command -volume-label-import aparcaseg.nii.gz FreeSurferAllLut.txt aparcaseg_label.nii.gz -drop-unused-labels

You can find the FreeSurferAllLut.txt file in the ciftify github repo (https://github.com/edickie/ciftify/blob/ce1876b22747ef76b797de5056ec38cab8fc5e66/ciftify/data/hcp_config/FreeSurferAllLut.txt#L4)

  1. Resample the atlas to the 2mm space

wb_command -volume-resample aparcaseg_label.nii.gz MNI152_T1_2mm.nii.gz ENCLOSING_VOXEL aparcaseg_dseg.nii.gz

The MNI152_T1_2mm.nii.gz template can be found in the HCPPipelines/global/templates github repo (HCPpipelines/global/templates at master · Washington-University/HCPpipelines · GitHub)

  1. Convert the FreeSurfer cortical parcellation *.aparc.annot files to fsLR space using this guide https://wiki.humanconnectome.org/docs/assets/Resampling-FreeSurfer-HCP_5_8.pdf

  2. When combining subcortical with cortical labels, use the -label-collision flag to avoid label clashes

wb_command -cifti-create-dense-from-template 91282_Greyordinates.dscalar.nii atlas-DesikanKilliany_space-fsLR_den-32k_dseg.dlabel.nii -volume-all aparcaseg_dseg.nii.gz -cifti aparc.32k_fs_LR.dlabel.nii -label-collision SURFACES_FIRST

The 91282_Greyordinates.dscalar.nii template can also be found in the HCPPipelines template github repo.