Visualise your surface-based neuroimaging data on flat maps using ciftiTools
Recently I’ve tried to use the fantastic R-package ciftiTools
to visualise surface-based neuroimaging data on flat maps.
This was surprisingly tricky compared to using the standard inflated surfaces, which can be as easy as view_cifti_surface(my_xii)
. However when I supplied the flat surfaces that come with the HCP_S1200_Atlas
, I ran into the issue that nothing was visible because of the initial rotation of the maps. This prevented me to directly use view_cifti_surface()
to save the maps as figures, which was not solved by using the mouse to rotate the maps to the desired orientation. However, I’ve found a solution, which allowed me to match the what you get when using flat maps inside wb_view
. See the code snippet below.
# Flat surface files
flat_surfL <- paste0(support_locations, "HCP_S1200_Atlas/S1200.L.flat.32k_fs_LR.surf.gii")
flat_surfR <- paste0(support_locations, "HCP_S1200_Atlas/S1200.R.flat.32k_fs_LR.surf.gii")
# Rotate flat surface files so they match wb_view's
flat_surfL_gii <- read_surf(flat_surfL, expected_hemisphere = "left")
flat_surfL_gii <- rotate_surf(flat_surfL_gii, r1 = 0, r2 = 90, r3 = 0, units = c("degrees"))
flat_surfL_gii <- rotate_surf(flat_surfL_gii, r1 = 0, r2 = 0, r3 = 90, units = c("degrees"))
flat_surfR_gii <- read_surf(flat_surfR, expected_hemisphere = "right")
flat_surfR_gii <- rotate_surf(flat_surfR_gii, r1 = 0, r2 = 90, r3 = 0, units = c("degrees"))
flat_surfR_gii <- rotate_surf(flat_surfR_gii, r1 = 180, r2 = 0, r3 = 90, units = c("degrees"))
# Create figure
view_cifti_surface(con1_tstat_c1, fname = "flat_map.png",
surfL = flat_surfL_gii, surfR = flat_surfR_gii, view = "medial",
width = CIFTI_width, colors = col_pal_name, zlim = c(-3.51, 3.51),
title = "", legend_fname = "flat_map_legend.png",
legend_embed = FALSE)
This creates this pretty map: