Summary of what happened:
I am trying to create a .dlabel.nii atlas out of the Desikan-Killiany parcellation done by FreeSurfer.
-
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
.
-
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.
Version:
Connectome Workbench Version: 2.0.1
For anyone struggling with the same problem, the steps which worked for me in the end were these:
- 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
- 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
- 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)
- 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)
- When combining 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.
The whole pipeline I ended up using for this can be found here GitHub - daviddaubner42/bids_to_fc