Learn R Programming

⚠️There's a newer version (0.5.5) of this package.Take me there.

fsbrain (version 0.4.3)

Managing and Visualizing Brain Surface Data

Description

Provides high-level access to neuroimaging data from standard software packages like 'FreeSurfer' on the level of subjects and groups. Load morphometry data, surfaces and brain parcellations based on atlases. Mask data using labels, load data for specific atlas regions only, and visualize data and statistical results directly in 'R'.

Copy Link

Version

Install

install.packages('fsbrain')

Monthly Downloads

465

Version

0.4.3

License

MIT + file LICENSE

Issues

Pull Requests

Stars

Forks

Maintainer

Tim Schc3<a4>fer

Last Published

May 12th, 2021

Functions in fsbrain (0.4.3)

arrange.brainview.images.grid

Combine several brainview images as a grid into a new figure.
alphablend

Perform alpha blending for pairs of RGBA colors.
brainview.sd

Visualize a list of colored meshes from a single defined angle.
annot.outline

Compute outline vertex colors from annotation.
brainview.si

Visualize a list of colored meshes from a single viewpoint, interactively.
boxcoords.from.bbox

Compute the coordinates of the 8 corners of a 3D box.
apply.labeldata.to.morphdata

Apply a label to morphometry data.
apply.label.to.morphdata

Load a label from file and apply it to morphometry data.
can.plot.colorbar

Determine whether colorbar can be plotted with given metadata.
apply.transform

Apply matmult transformation to input.
arrange.brainview.images

Combine several brainview images into a new figure.
can.plot.colorbar.from.coloredmeshes

Determine whether colorbar can be plotted with given coloredmeshes.
cm.qual

Return the standard fsbrain qualitative colormap.
cm.heat

Return the standard fsbrain heat colormap.
brainview.t4

Visualize a list of colored meshes from four angles.
brainview.sr

Visualize a list of colored meshes, rotating the camera around them.
brainview.t9

Visualize a list of colored meshes from nine angles.
cm.seq

Return the standard fsbrain sequential colormap.
check.subjectslist

Check whether the subjects_list looks good, warn if not.
collayer.from.mask.data

Compute surface color layer from morph-like data.
collayer.from.annotdata

Compute surface color layer from annotation or atlas data.
coloredmesh.from.morph.native

Create a coloredmesh from native space morphometry data.
coloredmesh.from.morph.standard

Create a coloredmesh from standard space morphometry data.
common.makecmap.range

Get cmap and colorlayer from data and makecmap_options.
collayer.bg.atlas

Compute atlas or annotation surface color layer.
cube3D.tris

Return triangles for a 3D cube or cuboid.
collayer.bg.meancurv

Compute binarized mean curvature surface color layer.
brainviews

Show one or more views of the given meshes in rgl windows.
coloredmesh.from.annot

Create a coloredmesh from an annotation of an atlas.
coloredmesh.from.color

Create a coloredmesh from a mesh and pre-defined colors.
coloredmesh.plot.colorbar.separate

Draw colorbar for coloredmeshes in separate 2D plot.
combine.colorbar.with.brainview.image

Combine a colorbar and a brainview image into a new figure.
combine.colorbar.with.brainview.image.vertical

Combine a vertical colorbar and a brainview image into a new figure.
cm.cbry

Get cyan blue red yellow colormap function.
draw.colorbar

Draw coloredbar into background of current plot.
download_optional_paper_data

Download extra data to reproduce the figures from the fsbrain paper.
clip.data

Clip data at quantiles to remove outliers.
collayer.bg.sulc

Compute binarized sulcal depth surface color layer.
collayer.bg

Compute binarized mean curvature surface color layer.
coloredmesh.from.morphdata

Create a coloredmesh from arbitrary data.
coloredmesh.from.preloaded.data

Generate coloredmesh from loaded data.
fs.home

Return FreeSurfer path.
coloredmeshes.combined.data.range

Retrieve combined data range from hemilist of coloredmeshes.
collayer.from.annot

Compute surface color layer from annotation or atlas data.
fsaverage.path

Return path to fsaverage dir.
fs.value.list.from.agg.res

Create a named value list from a dataframe.
download_fsaverage3

Download the FreeSurfer v6 low-resolution fsaverage3 subject.
download_optional_data

Download optional data for this package if required.
collayer.from.morphlike.data

Compute surface color layer from morph-like data.
cm.div

Return the standard fsbrain diverging colormap.
collayers.merge

Merge two or more color layers based on their transparency values.
force.to.range

Change data to ensure requested data_range.
coloredmesh.from.mask

Create a coloredmesh from a mask.
combine.colorbar.with.brainview.animation

Combine a colorbar and a brain animation in gif format into a new animation.
colorlist.brain.clusters

Return diverging color list
coloredmesh.from.label

Create a coloredmesh from a label.
delete_all_optional_data

Delete all data in the package cache.
fs.coloredmesh

fs.coloredmesh constructor
eeg_coords

Internal function to get some demo EEG electrode coordinates. Will be removed from public API. Do not use this.
coloredmeshes.from.color

Create coloredmeshes for both hemis using pre-defined colors.
fsbrain.renderable

Check whether object can be rendered by fsbrain
coloredmeshes.get.md

Retrieve metadata from hemilist of coloredmeshes.
export.coloredmesh.ply

Export a coloredmeshes with vertexcolors in PLY format.
flc

Given a list of path coordinates, create matrix containing only the first and last point of each path.
cubes3D.tris

Vectorized version of cube3D.tris
find.subjectsdir.of

Find the subject directory containing the fsaverage subject (or others) on disk.
demographics.to.fsgd.file

Write FreeSurfer Group Descriptor (FSGD) file from demographics dataframe.
deg2rad

Convert degree to radians
desaturate

Perform simple desaturation or grayscale conversion of RGBA colors.
group.morph.agg.standard

Aggregate standard space (fsaverage) morphometry data over one hemisphere for a group of subjects.
find.freesurferhome

Find the FREESURFER_HOME directory on disk.
face.edges

Enumerate all edges of the given faces or mesh.
fsbrain.set.default.figsize

Set default figure size for fsbrain visualization functions.
get.rglstyle.default

Get the default visualization style parameters as a named list.
get.rglstyle

Get the default visualization style parameters as a named list.
get_optional_data_filepath

Access a single file from the package cache by its file name.
download_fsaverage

Download the FreeSurfer v6 fsaverage subject.
group.agg.atlas.native

Aggregate native space morphometry data over brain atlas regions and subjects for a group of subjects.
group.multimorph.agg.standard

Aggregate standard space (fsaverage) morphometry data for multiple measures over hemispheres for a group of subjects.
get.rglstyle.parameters

Produce the named list of style parameters from style definition.
get.slice.indices

Compute slice indices from slice definition.
get.rglstyle.edges

Get the mesh edges visualization style parameters as a named list.
group.surface

Retrieve surface mesh data for a group of subjects.
gen.test.volume

Generate test 3D volume of integers. The volume has an outer background area (intensity value 'bg') and an inner foreground areas (intensity value 200L).
get.rglstyle.semitransparent

Get the semi-transparent visualization style parameters as a named list.
hemilist.derive.hemi

Derive 'hemi' string from the data in a hemilist
group.concat.measures.native

Concatenate native space data for a group of subjects.
magick.grid

Arrange a multi-frame ImageMagick image into a grid.
image.remap.color

Remap a color in an image, typically used to set the background color to transparent.
group.concat.measures.standard

Concatenate standard space data for a group of subjects.
hemilist.get.combined.data

Get combined data of hemi list
group.morph.agg.standard.vertex

Aggregate standard space morphometry data over subjects.
images.annotate

Annotate image with text.
get.subject.class

Construct FSGD Class name from group and non-continuous covariate columns.
images.same.height

Extent all images to the height of the image with maximal height.
fup

Transform first character of a string to uppercase.
qc.from.segstats.table

Perform data quality check based on a segstats table.
regions.to.ignore

Give suggestions for regions to ignore for an atlas.
qc.from.segstats.tables

Perform data quality check based on a segstats table.
principal.curvatures

Computes principal curvatures according to 2 definitions from raw k1 and k2 values.
pp.named.list

Pretty-print a named list or vector.
makecmakeopts.merge

Create final `makecmap_options` list
get.view.angle.names

Get list of valid view angle names.
images.same.width

Extent all images to the width of the image with maximal width.
images.dimmax

Compute max width and height of magick images.
shift.hemis.apart

Shift hemispheres apart.
report.on.demographics

Print a demographics report
shift.hemis.rglactions

Shift hemis apart if indicated in rglactions
limit_fun

Get data limiting function.
subject.morph.standard

Retrieve standard space morphometry data for a single subject.
subject.morph.native

Retrieve native space morphometry data for a single subject.
get.rglstyle.shiny

Get a shiny visualization style.
group.label

Retrieve label data for a group of subjects.
group.multimorph.agg.native

Aggregate native space morphometry data for multiple measures over hemispheres for a group of subjects.
group.morph.standard.sf

Read combined data for a group from a single file.
group.data.to.array

Convert group 1D data to array format.
vis.color.on.subject

Visualize pre-defined vertex colors on a subject.
vis.coloredmesh

Draw a coloredmesh using a style.
group.morph.native

Retrieve native space morphometry data for a group of subjects.
getIn

Retrieve values from nested named lists
limit_fun_na

Get data limiting function to NA.
vis.fs.surface

Visualize fs.surface mesh
vis.export.from.coloredmeshes

Export high-quality brainview image with a colorbar.
label.border

Compute border of a label.
mesh.vertex.included.faces

Return all faces which are made up completely of the listed vertices.
label.colFn

A simple colormap function for binary colors.
mesh.vertex.neighbors

Compute neighborhood of a vertex
is.fs.coloredmesh

Check whether object is an fs.coloredmesh (S3)
normalize

Normalize data.
is.Triangles3D

Check whether object is a Triangles3D instance
mask.from.labeldata.for.hemi

Create a binary mask from labels.
vis.paths

Visualize many paths.
vis.path.along.verts

Draw a 3D line from vertex to vertex
group.morph.standard

Retrieve standard space morphometry data for a group of subjects.
print.fs.coloredmesh

Print description of a brain coloredmesh (S3).
perform.rglactions

Perform rglactions, like taking screenshots.
print.fs.coloredvoxels

Print description of fs.coloredvoxels (S3).
get.atlas.region.names

Determine atlas region names from a subject.
merge.hemi.annots

Merge the annotations from two hemispheres into one annot.
plot.fsbrain.colorbar

Draw a simple colorbar from colors.
group.annot

Load annotations for a group of subjects.
group.label.from.annot

Extract a region from an atlas annotation as a label for a group of subjects.
group.agg.atlas.standard

Aggregate standard space morphometry data over brain atlas regions and subjects for a group of subjects.
images.rescale.to.max.canvas

Rescale all images canvas to match the largest one.
hemilist.unwrap

Unwrap hemi data from a named hemi list.
hasIn

Check for values in nested named lists
group.morph.agg.native

Aggregate native space morphometry data over one hemisphere for a group of subjects.
hemi.lobe.labels

Compute lobe labels for a single hemi from aparc atlas.
label.colFn.inv

A simple colormap function for binary colors.
limit_fun_na_inside

Get data limiting function, setting values inside range to NA.
path.slopes

Compute slopes of paths relative to axes.
label.from.annotdata

Extract a region from an annotation as a label.
list_optional_data

Get file names available in package cache.
path.colors.from.orientation

Compute path color from its orientation.
highlight.vertices.on.subject

Highlight vertices given by index on a subject's meshes.
hull.retain.along.axis

Copy the first *n* foreground voxel values.
hemilist.wrap

Wrap data into a named hemi list.
perform.na.mapping

Perform NA mapping for transparency
label.to.annot

Merge several labels into an annotation
labeldata.from.mask

Create labeldata from a mask.
mkco.cluster

Return recommended 'makecmap_options' for diverging cluster data.
mkco.heat

Return recommended 'makecmap_options' for sequential data with heatmap style.
mkco.div

Return recommended 'makecmap_options' for diverging data.
mkco.seq

Return recommended 'makecmap_options' for sequential data.
is.fs.coloredvoxels

Check whether object is an fs.coloredvoxels instance (S3)
qc.for.group

Perform data quality check based on computed region stats.
qc.from.regionwise.df

Perform data quality check based on a dataframe containing aggregated region-wise data.
qc.vis.failcount.by.region

Visualize the number of outlier subjects per region in your dataset.
is.hemilist

Check whether x is a hemilist
read.md.demographics

Read demographics file
rglactions

Create rglactions list, suitable to be passed as parameter to vis functions.
rgl.coord.lines

Plot x, y and z axes in R,G,B.
ras2vox_tkr

The FreeSurfer default ras2vox_tkr matrix.
read.md.subjects.from.fsgd

Read subjects list from an FSGD file.
read.colorcsv

Read colors from CSV file.
spread.values.over.subject

Spread the values in the region_value_list and return them for one hemisphere.
read.md.subjects

Read subjects file
vol.boundary.box.apply

Apply a boundary box to a volume, returning the inner volume part
vol.boundary.mask

Compute foreground pixels over the whole 3D imagestack.
rglactions.has.key

Check for a key in names of rglactions.
rglot

Get rgloptions for testing.
rglo

Get rgloptions and consider global options.
recycle

Recycle parameters or whatever.
spread.values.over.hemi

Spread the values in the region_value_list and return them for one hemisphere.
spread.values.over.annot

Spread a single value for a region to all region vertices.
subject.lobes

Load labels representing brain lobes.
shape.descriptor.names

Get all shape descriptor names.
rglactions.transform

Apply data transformation rglactions.
subject.label

Retrieve label data for a single subject.
subject.label.from.annot

Extract a region from an atlas annotation as a label for a subject.
rad2deg

Convert raduians to degree
sort.coloredmeshes.by.hemi

Sort coloredmeshes into 2 lists by their 'hemi' property.
sph2fs

Transform spherical coordinates to FreeSurfer surface space to plot things around a brain.
rglvoxels

Draw 3D boxes at locations using rgl.
scale.to.range.zero.one

Scale given values to range 0..1.
shape.descriptors

Computes geometric curvature-based descriptors.
subject.filepath.morph.standard

Construct filepath of standard space morphometry data file.
subject.filepath.morph.native

Construct filepath of native space morphometry data file.
test.numerical.meandiff.paired

Perform tests for group differences on paired data (repeated measurements) for two conditions or time points.
test.numerical.meandiff.unpaired

Perform tests for group differences on unpaired data for two groups.
vis.group.annot

Plot atlas annotations for a group of subjects.
subject.mask

Compute a mask for a subject.
symmrange

Given data, compute symmetric range around zero.
test.numerical.meandiff

Perform tests for group differences on paired or unpaired data for two groups.
surf.radius.fsaverage

Get pre-computed radius for fsaverage white surface.
surfs.props

Compute simple version of center and radius of 2 meshes.
vis.dti.trk

Visualize DTI tracks from Diffusion Toolkit/TrackVis TRK format file.
vis.data.on.subject

Visualize arbitrary data on the surface of any subject.
track.length

Compute the total length of a path given by the coordinates of its points.
vis.renderable

Visualize a renderable object
vis.region.values.on.subject

Visualize arbitrary data, one value per atlas region, on the surface of any subject (including template subjects).
vislayout.from.coloredmeshes

Visualize coloredmeshes from several angles and combine the images into a new figure.
subject.num.verts

Get subjects vertex count.
vis.coloredmeshes

Visualize a list of colored meshes in a single scene.
subject.surface

Load a surface for a subject.
subject.annot

Load an annotation for a subject.
vis.group.coloredmeshes

Plot coloredmeshes for a group of subjects.
vis.group.morph.native

Plot native space morphometry data for a group of subjects.
vis.colortable.legend

Create a separate legend plot for a colortable or an annotation.
vdata.split.by.hemi

Split morph data vector at hemisphere boundary.
subject.atlas.agg

Aggregate morphometry data over brain atlas regions for a subject.
subject.filepath.any

Construct filepath of any freesurfer file.
vol.boundary.box

Compute 3D bounding box of a volume.
vis.data.on.group.native

Visualize native space data on a group of subjects.
vis.coloredmeshes.rotating

Visualize a list of colored meshes in a single scene and rotate them, movie-style.
vis.data.on.group.standard

Visualize standard space data for a group on template.
vol.hull

Retain only the outer hull voxels of the foreground.
vol.intensity.to.color

Convert integer intensity image to RGB color string form.
vol.imagestack

Turn volume into an ImageMagick image stack.
vol.mask.from.segmentation

Extract subset from a volume by value.
write.region.aggregated

Write data aggregated over regions to morphometry file for group.
write.group.morph.standard.sf

Write combined data for a group to a single MGH file.
vol.planes

Translate names and indices of planes.
subject.volume

Read a brain volume.
vol.overlay.colors.from.colortable

Compute voxel colors based on colortable.
vis.subject.annot

Visualize an annotation for a subject.
vol.plane.axes

Get indices of the axes defining the given plane.
surf.center.fsaverage

Get pre-computed center for fsaverage white surface.
vis.rotated.coloredmeshes

Rotate and visualize coloredmeshes, applying a style.
vis.group.morph.standard

Plot standard space morphometry data for a group of subjects.
write.region.values

Write one value per atlas region for a subject.
vol.slice

Extract a slice of a 3D image stack.
write.region.values.fsaverage

Write one value per atlas region for a template subject.
vis.labeldata.on.subject

Visualize a label on the surface of a subject.
vis.subject.morph.standard

Visualize native space morphometry data for a subject or a group.
vol.vox.from.crs

Compute R voxel index for FreeSurfer CRS voxel index.
vis.symmetric.data.on.subject

Visualize clusters or activation data on the surface of any subject.
vis.mask.on.subject

Visualize a vertex mask on the surface of a subject.
vis.data.on.fsaverage

Visualize arbitrary data on the fsaverage template subject, if available.
vis.subject.label

Visualize a binary label for a subject.
vox2ras_tkr

The FreeSurfer default vox2ras_tkr matrix.
volvis.contour

Visualize contour of a volume.
wrapped.image.append

Wrapper around magick::image_append that allows specifying the background color when working with images of different width/height.
vis.subject.morph.native

Visualize native space morphometry data for a subject.
volvis.lightbox

Draw a lightbox view from volume slices.
volvis.voxels

Voxel-based visualization of volume mask at surface RAS positions.
vol.overlay.colors.from.activation

Generate colors for a 3D volume, based on the activation data and a colormap.
vol.merge

Merge background volume and overlay to new colors.