View source: R/vis_mesh_atlas.R
| vis.subcortical.region.values | R Documentation |
Render the subcortical structures of a subject and assign one color per structure, based on one value per atlas region. The subcortical atlas is not defined on the cortical surface: it comes with its own surface mesh that contains the 8 subcortical structures per hemisphere (accumbens area, amygdala, caudate, hippocampus, pallidum, putamen, thalamus and lateral ventricle). The mesh and the annotation file are expected in the subject directory ('surf/lh.subcortical', 'surf/rh.subcortical', 'label/lh.subcortical.annot', 'label/rh.subcortical.annot').
The atlas files for the fsaverage template subject are not part of FreeSurfer and are not
required for the package to work. They can be downloaded with download_optional_data or download_fsaverage_atlases into the package cache, which is searched for a subject named 'fsaverage' by default.
Optionally, the structures can be rendered inside a semi-transparent context mesh, typically the cortex of the same subject (see parameter 'cortex'). Note that the context mesh and the atlas mesh must be defined in the same coordinate space, which is why both are taken from the same subject by default.
vis.subcortical.region.values(
subjects_dir = NULL,
subject_id = "fsaverage",
lh_region_value_list,
rh_region_value_list,
atlas = "subcortical",
surface = "subcortical",
cortex = NULL,
views = c("sd_lateral_lh", "sd_medial_lh", "sd_lateral_rh", "sd_medial_rh"),
rgloptions = rglo(),
rglactions = list(),
value_for_unlisted_regions = NA,
draw_colorbar = FALSE,
makecmap_options = mkco.seq(),
style = "default",
silent = FALSE
)
subjects_dir |
string or |
subject_id |
string. The subject identifier. Defaults to 'fsaverage', the template subject for which the subcortical atlas is available for download. |
lh_region_value_list |
named list. A list for the left hemisphere in which the names are atlas regions, and the values are the value to write to all vertices of that region, see |
rh_region_value_list |
named list, the same for the right hemisphere. |
atlas |
string. The name of the atlas to use. Defaults to 'subcortical', the subcortical atlas that ships with the package. Used to construct the annotation file name. |
surface |
string. The name of the surface mesh that belongs to the atlas. Defaults to 'subcortical'. Used to construct the surface file name, in contrast to the other vis functions this is not a cortical surface. |
cortex |
|
views |
list of strings. The views to render. Defaults to lateral and medial views of both hemispheres. See |
rgloptions |
option list passed to |
rglactions |
named list. A list in which the names are from a set of pre-defined actions, see |
value_for_unlisted_regions |
numerical scalar or |
draw_colorbar |
logical. Whether to draw a colorbar. Defaults to FALSE, see |
makecmap_options |
named list of parameters to pass to |
style |
a rendering style for the data meshes, see |
silent |
logical, whether to suppress messages. |
list of coloredmeshes. The coloredmeshes used for the visualization, invisibly. The list contains the data meshes (and the context meshes, if any) as a flat list, so it can be passed to export to save the rendered views into an image file.
Assigning the value NaN to a region hides it: the vertices of the region are removed from the mesh (together with the faces that use them), so the structure is not rendered at all, in contrast to drawing it in the color that represents missing data. This is a per-vertex operation on the shared mesh of all regions of a hemisphere, so hiding is not limited to entire meshes and can be combined with any rendering style.
The values of hidden regions are excluded from the colorbar range, just like NA values. Setting value_for_unlisted_regions = NaN hides all regions that are not listed in the region value lists, which is a convenient way of visualizing only a few structures of an atlas.
The subcortical atlas is defined in MNI305 space (fsaverage surface RAS), so it can be combined with the cortical surfaces of the fsaverage template subject. The 8 structures per hemisphere are colored with the standard FreeSurfer 'aseg' colors when you visualize the atlas itself, this function assigns data-driven colors instead. Region names are the FreeSurfer 'aseg' structure names, e.g., 'Left-Hippocampus' or 'Right-Thalamus-Proper'.
This function is not limited to the subcortical atlas: any atlas that comes with its own mesh and annotation files works, pass the respective names via parameters 'atlas' and 'surface'.
Other visualization functions:
highlight.vertices.on.subject(),
highlight.vertices.on.subject.spheres(),
vis.color.on.subject(),
vis.data.on.fsaverage(),
vis.data.on.subject(),
vis.labeldata.on.subject(),
vis.mask.on.subject(),
vis.region.values.on.subject(),
vis.rglwidget(),
vis.subject.annot(),
vis.subject.label(),
vis.subject.morph.native(),
vis.subject.morph.standard(),
vis.subject.pre(),
vis.symmetric.data.on.subject(),
vis.volume.clusters(),
vis.volume.on.surface(),
vislayout.from.coloredmeshes()
Other region-based visualization functions:
vis.region.values.on.subject(),
vis.subject.annot()
## Not run:
fsbrain::download_optional_data(); # includes the subcortical atlas for fsaverage
subjects_dir = fsbrain::get_optional_data_filepath("subjects_dir");
# One value per region, for all 8 subcortical structures of the left and right hemisphere.
lh_region_values = list("Left-Accumbens-area"=0.1, "Left-Amygdala"=0.2,
"Left-Caudate"=0.3, "Left-Hippocampus"=0.4, "Left-Pallidum"=0.5,
"Left-Putamen"=0.6, "Left-Thalamus-Proper"=0.7, "Left-Lateral-Ventricle"=0.8);
rh_region_values = list("Right-Accumbens-area"=0.1, "Right-Amygdala"=0.2,
"Right-Caudate"=0.3, "Right-Hippocampus"=0.4, "Right-Pallidum"=0.5,
"Right-Putamen"=0.6, "Right-Thalamus-Proper"=0.7, "Right-Lateral-Ventricle"=0.8);
# Render the structures on their own, and save the result to a file:
cm = vis.subcortical.region.values(subjects_dir, "fsaverage", lh_region_values,
rh_region_values, rglactions = list("no_vis" = TRUE));
export(cm, colorbar_legend = "my values", output_img = "subcortical.png");
# Render the structures inside a semi-transparent cortex:
cm_ctx = vis.subcortical.region.values(subjects_dir, "fsaverage", lh_region_values,
rh_region_values, cortex = "white", rglactions = list("no_vis" = TRUE));
export(cm_ctx, colorbar_legend = "my values", output_img = "subcortical_in_cortex.png");
# Visualize only the two hippocampi, by hiding all other regions (they are set to NaN):
cm_hippo = vis.subcortical.region.values(subjects_dir, "fsaverage",
list("Left-Hippocampus" = 0.2), list("Right-Hippocampus" = 0.8),
value_for_unlisted_regions = NaN, rglactions = list("no_vis" = TRUE));
export(cm_hippo, colorbar_legend = "my values", output_img = "subcortical_hippocampi.png");
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.