knitr::opts_chunk$set(echo = TRUE) rgl::setupKnitr()
First we specify a subjects dir and the subject we want to use. Feel free to replace this with your data.
library('fsbrain') sjd = '~/data/subject1_only' sj = 'subject1'
Now increase the figure size.
fsbrain.set.default.figsize(1000, 1000);
The export()
function provides a high-level interface to export plots.
cm = vis.subject.morph.standard(sjd, sj, 'sulc', rglactions=list('no_vis'=T)); img = export(cm, colorbar_legend='Sulcal depth [mm]');
The image gets exported as a PNG file into the current working directory by default, and you can set the 'output_img' parameter to save it wherever you want. One can also show it directly:
img;
Many more examples and details on the export API are available in the 'Fsbrain export API' notebook (the files examples_export.Rmd
and examples_export.html
in this directory).
You can use fsbrain to plot data for a group of subjects, combined into a single output image. First we define our subjects list, then we plot the Desikan atlas parcellation for all of them:
sjd = '~/data/study1' sjl = paste('subject', 1:7, sep=""); # our subjects list: subject1, subject2, ... , subject7 res = vis.group.annot(sjd, sjl, 'aparc', num_per_row = 3);
The same output image rules as explained above are in place. Once more, to see the image:
res$merged_img;
The function usage is equivalent to the vis.group.annot
function above:
img = vis.group.morph.native(sjd, sjl, 'thickness', num_per_row = 3);
res = vis.group.morph.standard(sjd, sjl, 'thickness', fwhm = "10", num_per_row = 3);
res$merged_img;
Note that the function is vectorized over the subject_id
, measure
and fwhm
parameters, meaning that you can also use it to plot thickness at a number of different smoothing filters for a single subject, or plot 3 different descriptors (with different smoothing values if you feel like it) for a single subject:
vis.group.morph.standard(sjd, 'subject1', 'thickness', fwhm = c("0", "10", "20"), num_per_row = 3); vis.group.morph.standard(sjd, 'subject1', c('thickness', 'area', 'volume'), fwhm = c("10", "10", "20"), num_per_row = 3);
If you have native space data for a group of subjects, you can plot the mean value over all subjects at every vertex using the vis.subject.morph.standard
function. Just pass your subjects list (sjl
in the example above) for the 'subject_id' parameter:
vis.subject.morph.standard(sjd, sjl, 'thickness', fwhm = "10");
A more general method (not restricted to the mean of morphometry data from files) to achieve this is to use vis.data.on.group.standard
, as explained below.
To visualize pre-loaded data on a group of subjects, use vis.data.on.group.native
and vis.data.on.group.standard
. For native space data:
morph_data_both = group.morph.native(sjd, sjl, 'thickness', hemi="both"); # Do whatever you want with the data here, e.g., compute new descriptors. res = vis.data.on.group.native(sjd, sjl, morph_data_both = morph_data_both);
res$merged_img;
Here is another example for standard space group data:
morph_data_both_std = group.morph.standard(sjd, sjl, 'thickness', hemi="both", fwhm = "5"); # Do whatever you want with the data here, e.g., compute new descriptors. res = vis.data.on.group.standard(sjd, vis_subject_id = 'fsaverage', morph_data_both = morph_data_both_std);
res$merged_img;
To learn more, read the vignettes:
browseVignettes('fsbrain');
In general, the vignettes are a great way to get started with fsbrain. You can also read them online at CRAN, they are linked on the fsbrain page on GitHub.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.