Type: | Package |
Title: | Tools for Reading, Writing, Viewing and Manipulating CIFTI Files |
Version: | 0.17.4 |
Maintainer: | Amanda Mejia <mandy.mejia@gmail.com> |
Description: | CIFTI files contain brain imaging data in "grayordinates," which represent the gray matter as cortical surface vertices (left and right) and subcortical voxels (cerebellum, basal ganglia, and other deep gray matter). 'ciftiTools' provides a unified environment for reading, writing, visualizing and manipulating CIFTI-format data. It supports the "dscalar," "dlabel," and "dtseries" intents. Grayordinate data is read in as a "xifti" object, which is structured for convenient access to the data and metadata, and includes support for surface geometry files to enable spatially-dependent functionality such as static or interactive visualizations and smoothing. |
License: | GPL-3 |
URL: | https://github.com/mandymejia/ciftiTools |
BugReports: | https://github.com/mandymejia/ciftiTools/issues |
Depends: | R (≥ 3.5.0) |
Imports: | fields, gifti (> 0.7.5), grDevices, oro.nifti, RNifti, RColorBrewer, rgl, viridisLite, xml2 |
Suggests: | covr, ggplot2, ggpubr, grid, gridExtra, htmlwidgets, manipulateWidget, webshot2, knitr, rmarkdown, png, testthat (≥ 3.0.0) |
VignetteBuilder: | knitr |
Encoding: | UTF-8 |
RoxygenNote: | 7.3.2 |
Language: | en-US |
NeedsCompilation: | no |
Packaged: | 2025-01-23 21:08:40 UTC; ddpham |
Author: | Amanda Mejia [aut, cre],
Damon Pham |
Repository: | CRAN |
Date/Publication: | 2025-01-23 22:20:02 UTC |
ciftiTools: Tools for Reading and Visualizing CIFTI Brain Files
Description
Here are groups of commonly-used functions in ciftiTools
:
Details
Functions for reading in CIFTI or GIFTI data:
read_xifti
:Read in a CIFTI file as a
"xifti"
read_xifti2
:Read in GIFTI files as a
"xifti"
as.xifti
:Combine numeric data to form a
"xifti"
read_surf
:Read in a surface GIFTI file as a
"surf"
info_cifti
:Read the metadata in a CIFTI file
load_surf
:Read in a surface included in
ciftiTools
load_parc
:Read in a parcellation included in
ciftiTools
Functions for writing CIFTI or GIFTI data:
write_cifti
:Write a
"xifti"
to a CIFTI filewrite_xifti2
:Write a
"xifti"
to GIFTI and NIFTI fileswrite_metric_gifti
:Write a numeric data matrix to a metric GIFTI file
write_surf_gifti
:Write a
"surf"
to a surface GIFTI filewrite_subcort_nifti
:Write subcortical data to NIFTI files
separate_cifti
:Separate a CIFTI file into GIFTI and NIFTI files
Functions for manipulating "xifti"
s:
apply_xifti
:Apply a function along the rows or columns of the
"xifti"
data matrixcombine_xifti
:Combine multiple
"xifti"
s with non-overlapping brain structuresconvert_xifti
:Convert the intent of a
"xifti"
merge_xifti
:Concatenate data matrices from multiple
"xifti"
snewdata_xifti
:Replace the data matrix in a
"xifti"
remove_xifti
:Remove a brain structure or surface from a
"xifti"
select_xifti
:Select data matrix columns of a
"xifti"
transform_xifti
:Apply a univariate transformation to a
"xifti"
or pair of"xifti"
sadd_surf
:Add surfaces to a
"xifti"
move_from_mwall
:Move medial wall vertices back into the
"xifti"
data matrixmove_to_mwall
:Move rows with a certain value into the
"xifti"
medial wall mask
S3 methods for "xifti"
s:
summary
andprint
:Summarize the contents.
as.matrix
:Convert data to a locations by measurements numeric matrix.
dim
:Obtain number of locations and number of measurements.
plot
:Visualize the cortical surface and/or subcortical data.
+
,-
,*
,/
,^
,%%
,%/%
:Operation between a
"xifti"
and a scalar, or between two"xifti"
s.abs
,ceiling
,exp
,floor
,log
,round
,sign
, andsqrt
:Univariate transformation of
"xifti"
data.
Functions for working with surfaces:
read_surf
:Read in a surface GIFTI file as a
"surf"
is.surf
:Verify a
"surf"
write_surf_gifti
:Write a
"surf"
to a surface GIFTI fileview_surf
:Visualize a
"surf"
resample_surf
:Resample a
"surf"
rotate_surf
:Rotate the geometry of a
"surf"
Author(s)
Maintainer: Amanda Mejia mandy.mejia@gmail.com
Authors:
Damon Pham damondpham@gmail.com (ORCID)
Other contributors:
John Muschelli muschellij2@gmail.com (ORCID) [contributor]
See Also
Useful links:
Report bugs at https://github.com/mandymejia/ciftiTools/issues
Message on attach
Description
Direct user to indicate Connectome Workbench path and check gifti package version.
Usage
.onAttach(...)
Arguments
... |
Not used |
Value
NULL
, invisibly
ROI_brainstructures
Description
ROI_brainstructures
Arguments
ROI_brainstructures |
Character vector indicating which ROIs should be
obtained. ROIs are typically the medial wall masks for the left and right cortex, and the subcortical mask for the subcortex. |
"ROY_BIG_BL" color palette
Description
"ROY_BIG_BL", the default palette from the Connectome Workbench.
Usage
ROY_BIG_BL(min = 0, max = 1, mid = NULL, half = NULL, pos_half = FALSE)
Arguments
min |
The minimum value for the color mapping. As in the original
palette, the last color (aqua) is actually placed at the bottom .5\
the minimum and maximum. Default: |
max |
The maximum value for the color mapping. If this value is lower
than the minimum, the color mapping will be reversed. If this is equal to
the minimum, a palette with only the color black will be returned.
Default: |
mid |
(Optional) The midpoint value for the color mapping. If
|
half |
|
pos_half |
Deprecated. Use |
Details
Yields the landmark color hex codes and values for the "ROY_BIG_BL" palette. This is the same color palette as the default Connectome Workbench palette. Source: https://github.com/Washington-University/workbench/blob/master/src/Files/PaletteFile.cxx
Value
A data.frame with two columns: "color"
(character: color hex
codes) and "value"
(numeric)
See Also
Other coloring:
expand_color_pal()
,
make_color_pal()
,
use_color_pal()
"xifti"
S3 Math methods
Description
Math methods for "xifti"
objects.
Usage
## S3 method for class 'xifti'
Math(x, ...)
Arguments
x |
The |
... |
Additional arguments to the function |
Details
Uses transform_xifti
.
"xifti"
S3 Ops methods
Description
Ops methods for "xifti"
objects.
Usage
## S3 method for class 'xifti'
Ops(e1, e2 = NULL)
Arguments
e1 , e2 |
The arguments to the operation. |
Details
Uses transform_xifti
.
"xifti"
S3 Summary methods
Description
Summary methods for "xifti"
objects.
Usage
## S3 method for class 'xifti'
Summary(..., na.rm = FALSE)
Arguments
... |
The |
na.rm |
Remove |
Add HCP surface(s) to a "xifti"
Description
Add left or right cortical surface geometry from the HCP S1200 release
to a "xifti"
object.
Usage
add_surf(xifti, surfL = NULL, surfR = NULL)
Arguments
xifti |
A |
surfL |
(Optional) Left brain surface model. Can be a file
path to a GIFTI surface geometry file (ends in "*.surf.gii"), a
|
surfR |
(Optional) Right brain surface model. Can be a file
path to a GIFTI surface geometry file (ends in "*.surf.gii"), a
|
Details
surfL
will be added to xifti$surf$cortex_left
and surfR
will be added to xifti$surf$cortex_right
. Any existing surfaces will
be overwritten.
If the resolutions of the data and surfaces do not match, the surfaces will be resampled to match the resolution of the data. The barycentric resampling method, which is recommended for anatomical surfaces, will be used.
Value
the "xifti"
object with added surface geometry components.
See Also
Other manipulating xifti:
apply_parc()
,
apply_xifti()
,
combine_xifti()
,
convert_xifti()
,
impute_xifti()
,
merge_xifti()
,
move_to_mwall()
,
move_to_submask()
,
newdata_xifti()
,
remap_cifti()
,
remove_xifti()
,
resample_cifti()
,
resample_cifti_from_template()
,
scale_xifti()
,
select_xifti()
,
set_names_xifti()
,
smooth_cifti()
,
transform_xifti()
Other surface-related:
boundary_mask_surf()
,
edit_mask_surf()
,
even_vert_samp()
,
is.surf()
,
load_surf()
,
mask_surf()
,
read_surf()
,
resample_surf()
,
rotate_surf()
,
surf_area()
,
view_surf()
,
write_surf_gifti()
All integers?
Description
Check if a data vector or matrix is all integers.
Usage
all_integers(x)
Arguments
x |
The data vector or matrix |
Value
Logical. Is x
all integers?
Apply function over locations in each parcel
Description
Apply a function across all locations in each parcel, for a pair of data and
parcellation "xifti"
objects that are in registration with one
another. By default, the mean value in each parcel is calculated.
Usage
apply_parc(
xii,
parc,
FUN = mean,
mwall_value = NA,
return_as = c("matrix", "xifti"),
...
)
Arguments
xii |
The |
parc |
The |
FUN |
A function that takes as input an Use |
mwall_value |
If there is a medial wall in |
return_as |
|
... |
Additional arguments to |
Value
A P \times Q
matrix, where P
is the number of parcels and
Q
is the length of the output of FUN
. (For mean
,
Q = 1
).
See Also
Other parcellation-related:
load_parc()
,
load_sub_parc()
,
parc_add_subcortex()
,
parc_borders()
,
parc_vals_to_xifti()
Other manipulating xifti:
add_surf()
,
apply_xifti()
,
combine_xifti()
,
convert_xifti()
,
impute_xifti()
,
merge_xifti()
,
move_to_mwall()
,
move_to_submask()
,
newdata_xifti()
,
remap_cifti()
,
remove_xifti()
,
resample_cifti()
,
resample_cifti_from_template()
,
scale_xifti()
,
select_xifti()
,
set_names_xifti()
,
smooth_cifti()
,
transform_xifti()
Apply a function along the rows or columns of a "xifti"
Description
Apply a many-to-N function (e.g. mean) to the rows or columns of a
"xifti"
. If applied row-wise, a "xifti"
with N data column(s)
is returned. (If the "xifti"
had the dlabel intent, and values that
are not labels are created, then it is converted to dscalar.) If applied
column-wise, a numeric matrix with N rows is returned.
For univariate functions, use transform_xifti
instead.
Usage
apply_xifti(xifti, margin = c(1, 2), FUN, ...)
Arguments
xifti |
A |
margin |
The dimension along which to apply |
FUN |
The function. It should take in a numeric vector and return a length-N numeric vector. |
... |
Additional arguments to |
Value
A "xifti"
if margin == 1
, or a numeric matrix if
margin == 2
See Also
Other manipulating xifti:
add_surf()
,
apply_parc()
,
combine_xifti()
,
convert_xifti()
,
impute_xifti()
,
merge_xifti()
,
move_to_mwall()
,
move_to_submask()
,
newdata_xifti()
,
remap_cifti()
,
remove_xifti()
,
resample_cifti()
,
resample_cifti_from_template()
,
scale_xifti()
,
select_xifti()
,
set_names_xifti()
,
smooth_cifti()
,
transform_xifti()
area_original_Param
Description
area_original_Param
Arguments
areaL_original_fname , areaR_original_fname |
File paths to the surfaces
to use for vertex area correction during adaptive resampling. (Only used if
resampling with the adaptive method.) For resampling: the Workbench command for adaptive resampling requires the
target surfaces for area correction too. But to make the workflow easier,
For remapping: |
area_target_Param
Description
area_target_Param
Arguments
areaL_target_fname , areaR_target_fname |
File paths to the surfaces
to use for vertex area correction during adaptive resampling. (Only used if
resampling with the adaptive method.) |
Convert a "xifti"
to a matrix
Description
Converts a "xifti"
to a matrix by concatenating the data from each
brainstructure along the rows. Surfaces and metadata are discarded.
Usage
## S3 method for class 'xifti'
as.matrix(x, subcortex_by_bs = FALSE, ...)
Arguments
x |
A |
subcortex_by_bs |
If subcortical data exists in |
... |
Unused |
Value
The input as a matrix. Each brainstructure's data is concatenated.
Format metric data as a "gifti"
Description
Format a V \times T
numeric matrix (V vertices, T measurements) or a length-T list
of length-V numeric vectors as a "gifti"
using a template
"gifti"
. The brain hemisphere (left or right) must be indicated.
Usage
as.metric_gifti(
data,
hemisphere = c("left", "right"),
intent = "NONE",
data_type = NULL
)
Arguments
data |
|
hemisphere |
The side of the brain the data represents: |
intent |
The NIFTI intent, with prefix "NIFTI_INTENT_*". Default:
|
data_type |
The NIFTI type of |
Details
If data
is already a "gifti"
, data$data
will be
used and any metadata will be overwritten by the template or discarded.
Value
The "gifti"
Format surface data as a "gifti"
Description
Format a "surf"
or a list with elements "pointset"
and "triangle"
as a "gifti"
using a template
"gifti"
. The brain hemisphere (left or right) must be indicated.
Usage
as.surf_gifti(surf, hemisphere = c("left", "right"))
Arguments
surf |
A |
hemisphere |
The side of the brain the surface represents: |
Value
The "gifti"
Assemble a "xifti"
from data
Description
Assembles cortical data, subcortical data, and/or surface geometry to form a
"xifti"
. The inputs must be data objects (vectors, matrices or
arrays, depending on the argument).
Usage
as.xifti(
cortexL = NULL,
cortexL_mwall = NULL,
cortexR = NULL,
cortexR_mwall = NULL,
mwall_values = c(NA, NaN),
subcortVol = NULL,
subcortLabs = NULL,
subcortMask = NULL,
surfL = NULL,
surfR = NULL,
col_names = NULL,
HCP_32k_auto_mwall = TRUE,
validate = TRUE
)
as_xifti(
cortexL = NULL,
cortexL_mwall = NULL,
cortexR = NULL,
cortexR_mwall = NULL,
mwall_values = c(NA, NaN),
subcortVol = NULL,
subcortLabs = NULL,
subcortMask = NULL,
surfL = NULL,
surfR = NULL
)
as.cifti(
cortexL = NULL,
cortexL_mwall = NULL,
cortexR = NULL,
cortexR_mwall = NULL,
mwall_values = c(NA, NaN),
subcortVol = NULL,
subcortLabs = NULL,
subcortMask = NULL,
surfL = NULL,
surfR = NULL
)
as_cifti(
cortexL = NULL,
cortexL_mwall = NULL,
cortexR = NULL,
cortexR_mwall = NULL,
mwall_values = c(NA, NaN),
subcortVol = NULL,
subcortLabs = NULL,
subcortMask = NULL,
surfL = NULL,
surfR = NULL
)
Arguments
cortexL , cortexL_mwall |
Left cortex data and ROI. Each must be a data matrix or vector. If If Since the unmasked cortices must have the same number of vertices,
|
cortexR , cortexR_mwall |
Right cortex data and ROI. Each must be a data matrix or vector. If If Since the unmasked cortices must have the same number of vertices,
|
mwall_values |
If |
subcortVol , subcortLabs , subcortMask |
|
surfL , surfR |
(Optional) Surface geometries for the left or right cortex.
Can be a surface GIFTI file path or |
col_names |
Names of each measurement/column in the data. |
HCP_32k_auto_mwall |
If left and/or right cortex data is provided, and
the number of vertices matches that of the HCP 32k mesh (29696 on left, and
29716 on right), should the medial wall masks be added to the |
validate |
Validate that the result is a |
Details
Each data or surface component is optional. Metadata components
(cortex[L/R]_mwall
, subcortLabs
, and subcortMask
) will
be ignored if its corresponding data component is not provided. If no data or
surface components are provided, then the template_xifti
will
be returned.
If cortical data are provided without a corresponding medial wall mask, or
if the provided mask is invalid or empty, then the medial wall will be
inferred from data rows that are constantly a value in mwall_values
.
But if mwall_values
is NULL
, no attempt to infer the medial
wall will be made and the medial wall metadata entry will be NULL
.
The total number of grayordinates will be
G = (V_L - mwall_L) + (V_R - mwall_R) + V_S
: V_L - mwall_L
left
vertices, V_R - mwall_R
right vertices and V_S
subcortical
voxels. T
, the total number of measurements (columns of data), must be
the same for each brainstructure.
Value
A "xifti"
See Also
Other reading:
info_cifti()
,
load_parc()
,
load_surf()
,
read_cifti()
,
read_surf()
,
read_xifti2()
Assure this is a parcellation
Description
Assure an input "xifti"
object represents a parcellation. Keep only
the first column if multiple columns are present.
Usage
assure_parc(parc)
Arguments
parc |
The putative parcellation. |
Value
parc
, if it's a parcellation.
Boundary region of a mask
Description
Identify the vertices within boundary_width
edges of a vertex in the
input mask on a triangular mesh. Returns a logical indicating if a vertex
is within boundary_width
edges of the mask.
Usage
boundary_mask_surf(faces, mask, boundary_width = 10)
Arguments
faces |
An |
mask |
A length |
boundary_width |
A positive integer representing the width of the
boundary to compute. The furthest vertices from the input mask will be this
number of edges away from the closest vertex in the input mask. Default:
|
Value
A length-V logical vector. Each entry corresponds to the vertex
with the same index. The value is true if a vertex is within
boundary_width
edges of a vertex in the mask, but is not within the
mask itself.
See Also
Other surface-related:
add_surf()
,
edit_mask_surf()
,
even_vert_samp()
,
is.surf()
,
load_surf()
,
mask_surf()
,
read_surf()
,
resample_surf()
,
rotate_surf()
,
surf_area()
,
view_surf()
,
write_surf_gifti()
brainstructures
Description
brainstructures
Arguments
brainstructures |
Character vector indicating which brain structure(s)
to read in: If a brain structure is indicated but does not exist, a warning will be raised and that brain structure will be skipped. |
Check CIFTI type
Description
Check that a CIFTI's NIFTI intent matches its file name extension.
Usage
check_cifti_type(intent, extn)
Arguments
intent |
The NIFTI |
extn |
The file name extension, e.g. "dtseries.nii" |
Value
If the intent is supported, returns TRUE
.
If the intent is not supported, an error is raised.
Validate a ciftiTools
option and value
Description
Checks if a ciftiTools option and value are valid.
Usage
ciftiTools.checkOption(opt, val = NULL)
Arguments
opt |
The option. |
val |
The value to set the option as. |
Value
The (corrected) val
ciftiTools
files
Description
CIFTI and surface GIFTI files included in the ciftiTools
package
Usage
ciftiTools.files()
Details
The CIFTI files are from NITRC: cifti-2_test_data-1.2.zip at https://www.nitrc.org/frs/?group_id=454
The surfaces are from the HCP and are included according to these data use terms: Data were provided [in part] by the Human Connectome Project, WU-Minn Consortium (Principal Investigators: David Van Essen and Kamil Ugurbil; 1U54MH091657) funded by the 16 NIH Institutes and Centers that support the NIH Blueprint for Neuroscience Research; and by the McDonnell Center for Systems Neuroscience at Washington University.
Only the inflated surfaces are available as GIFTI files. To access the other
surfaces included in the package (very inflated and midthickness), see
load_surf
.
Value
a list of file paths
Get a ciftiTools
option
Description
Gets an R option (with prefix "ciftiTools_") value.
See ciftiTools.listOptions
.
Usage
ciftiTools.getOption(opt)
Arguments
opt |
The option. |
Value
The value, val
List ciftiTools
options
Description
List ciftiTools
options
Usage
ciftiTools.listOptions()
Value
data.frame
describing the options
Set a ciftiTools
option
Description
Sets an R option (with prefix "ciftiTools_").
See ciftiTools.listOptions
.
Usage
ciftiTools.setOption(opt, val)
Arguments
opt |
The option. |
val |
The value to set the option as. |
Value
The new value, val
Print suppressible message
Description
Print message only if ciftiTools Option "suppress_msgs" is FALSE
.
Usage
ciftiTools_msg(msg)
Arguments
msg |
The message |
Value
NULL
, invisibly
Print suppressible warning
Description
Print warning only if ciftiTools Option "suppress_msgs" is FALSE
.
Usage
ciftiTools_warn(warn)
Arguments
warn |
The warning message |
Value
NULL
, invisibly
Get CIFTI component suffix default
Description
Get the default file name suffix for a certain type of GIFTI/NIFTI file
Usage
cifti_component_suffix(label, GIFTI_type = "func")
Arguments
label |
the file type: one of
|
GIFTI_type |
Used to make the suffix. Default: |
Value
The default file name suffix
cifti_fname
Description
cifti_fname
Arguments
cifti_fname |
File path to a CIFTI file (ending in ".d*.nii"). |
Combine "xifti"
s with non-overlapping brain structures
Description
Combine two to three "xifti"
s with non-overlapping brain structures into
a single "xifti"
. The names, intent, and surfaces of the first will be used,
if present. To add more surfaces to the result, use add_surf
.
Usage
combine_xifti(..., xii_list = NULL, meta = c("first", "all"))
Arguments
... |
The |
xii_list |
Alternatively, a list of |
meta |
|
Value
A "xifti"
with data from the inputs
See Also
Other manipulating xifti:
add_surf()
,
apply_parc()
,
apply_xifti()
,
convert_xifti()
,
impute_xifti()
,
merge_xifti()
,
move_to_mwall()
,
move_to_submask()
,
newdata_xifti()
,
remap_cifti()
,
remove_xifti()
,
resample_cifti()
,
resample_cifti_from_template()
,
scale_xifti()
,
select_xifti()
,
set_names_xifti()
,
smooth_cifti()
,
transform_xifti()
Confirm the Connectome Workbench command path
Description
Confirm that the path to the Connectome Workbench executable is valid. (For example, if the "wb_path" option was relative and the user changed the current working directory, the path is no longer valid.)
Usage
confirm_wb_cmd_path(wb_path)
Arguments
wb_path |
(Optional) Path to the Connectome Workbench folder or executable. |
Value
NULL
, invisibly
Convert "xifti"
Description
Convert the intent of a CIFTI file or "xifti"
object
Usage
convert_xifti(
x,
to = c("dscalar", "dtseries", "dlabel"),
cifti_target_fname = NULL,
...
)
convert_to_dlabel(
x,
cifti_target_fname = NULL,
levels_old = NULL,
levels = NULL,
labels = NULL,
nsig = Inf,
colors = "Set2",
add_white = TRUE,
return_conversion_table = FALSE
)
convert_to_dscalar(x, cifti_target_fname = NULL, names = NULL)
convert_to_dtseries(
x,
cifti_target_fname = NULL,
time_start = 0,
time_step = 1,
time_unit = c("second", "hertz", "meter", "radian")
)
Arguments
x |
The CIFTI file name or |
to |
The desired intent: |
cifti_target_fname |
File name for the converted CIFTI. Only used if
|
... |
Only used if |
levels_old , levels , labels |
(Optional) If New label names can be set with Note: |
nsig |
Take this many significant digits for the data values. If
|
colors |
(Optional) "ROY_BIG_BL", the name of a ColorBrewer palette
(see |
add_white |
Append white to the beginning of the colors? Default: |
return_conversion_table |
Return the conversion table along with the
converted |
names |
The column names. If |
time_start , time_step , time_unit |
(Optional) metadata for the new dtseries |
Value
If x
is a CIFTI, the target is a "dlabel"
and
return_conversion_table
, a length-2 list with the first entry being
the ".dlabel" "xifti"
and the second being the conversion table.
Otherwise, the "xifti"
or the output CIFTI file name is directly
returned.
See Also
Other manipulating xifti:
add_surf()
,
apply_parc()
,
apply_xifti()
,
combine_xifti()
,
impute_xifti()
,
merge_xifti()
,
move_to_mwall()
,
move_to_submask()
,
newdata_xifti()
,
remap_cifti()
,
remove_xifti()
,
resample_cifti()
,
resample_cifti_from_template()
,
scale_xifti()
,
select_xifti()
,
set_names_xifti()
,
smooth_cifti()
,
transform_xifti()
Examples
## Not run:
# Example: change label names
levels_old <- xii$meta$cifti$labels[[1]]$Key
newLabels <- paste0("New Label #", seq(length(levels_old)))
xii <- convert_to_dlabel(xii, levels_old=levels_old, levels=levels_old, labels=newLabels)
# Example: add an empty level
levels_old <- xii$meta$cifti$labels[[1]]$Key
levels_old <- c(levels_old, max(levels_old)+1)
labels <- c(rownames(xii$meta$cifti$labels[[1]]), "Empty")
xii <- convert_to_dlabel(xii, levels_old=levels_old, levels=levels_old, labels=labels)
# Example: set all but the lowest value to the same value & re-label
levels_old <- xii$meta$cifti$labels[[1]]$Key
levels <- ifelse(levels_old==min(levels_old), min(levels_old), min(levels_old)+1)
labels <- ifelse(levels_old==min(levels_old), "Minimum", "Not minimum")
xii <- convert_to_dlabel(xii, levels_old=levels_old, levels=levels, labels=labels)
## End(Not run)
Convert coordinate list to volume
Description
Converts a sparse coordinate list to its non-sparse volumetric representation.
Usage
coordlist_to_vol(coords, fill = FALSE)
Arguments
coords |
The sparse coordinate list. Should be a data.frame or matrix
with voxels along the rows and three or four columns. The first three
columns should be integers indicating the spatial coordinates of the voxel.
If the fourth column is present, it will be the value used for that voxel.
If it is absent, the value will be |
fill |
Fill value for the volume. Must be logical or numeric. Default:
|
Value
The volumetric data
Crop image
Description
Crop whitespace from image
Usage
crop_image(x, dims = seq(2))
Arguments
x |
An image read by |
dims |
The dimensions to crop. Default: |
Value
The cropped image
Crop a 3D array
Description
Remove empty (zero-valued) edge slices from a 3D array.
Usage
crop_vol(x)
Arguments
x |
The 3D array to crop. |
Dimensions of a "xifti"
Description
Returns the number of rows (vertices + voxels) and columns (measurements) in
the "xifti"
data.
Usage
## S3 method for class 'xifti'
dim(x)
Arguments
x |
A |
Value
The number of rows and columns in the "xifti"
data.
Distance from mask on surface
Description
Identify the vertices within boundary_width
edges of a vertex in the
input mask on a triangular mesh. Returns the number of edges a vertex is
away from the closest mask vertex.
Usage
dist_from_mask_surf(faces, mask, boundary_width = 10)
Arguments
faces |
An |
mask |
A length |
boundary_width |
A positive integer representing the width of the
boundary to compute. The furthest vertices from the input mask will be this
number of edges away from the closest vertex in the input mask. Default:
|
Value
A length-V numeric vector. Each entry corresponds to the vertex with the same index. For vertices within the boundary, the value will be the number of vertices away from the closest vertex in the input mask. Vertices inside the input mask but at the edge of it (i.e. the vertices that define the boundary) will have value 0. Then, all other vertices will have value -1.
Edit mask on surface
Description
Erode, dilate, or get the borders of a mask along the cortical surface
Usage
edit_mask_surf(
x,
mwall = NULL,
surf = NULL,
hemisphere = c("left", "right"),
do = c("erode", "dilate", "borders"),
depth = 1
)
erode_mask_surf(
x,
mwall = NULL,
surf = NULL,
hemisphere = c("left", "right"),
depth = 1
)
dilate_mask_surf(
x,
mwall = NULL,
surf = NULL,
hemisphere = c("left", "right"),
depth = 1
)
Arguments
x , mwall |
Vector of the data mask to edit, and the medial wall mask.
These can be specified in two ways. First, Second, In either case, |
surf , hemisphere |
Provide one: the surface in the same resolution as the data, or the name of the hemisphere of the surface to resample and use (default: resample the left surface). |
do |
|
depth |
How many iterations of the edit? Default: |
Details
The depth of the edit is determined by the number of edges between the
vertices. To erode or dilate based on spatial distance (mm), see
-cifti-dilate
and -cifti-erode
.
Value
x
after erosion or dilation.
See Also
Other surface-related:
add_surf()
,
boundary_mask_surf()
,
even_vert_samp()
,
is.surf()
,
load_surf()
,
mask_surf()
,
read_surf()
,
resample_surf()
,
rotate_surf()
,
surf_area()
,
view_surf()
,
write_surf_gifti()
Evenly sample vertices of mesh
Description
Get a subset of the mesh vertices that are spatially evenly-sampled, by resampling the mesh and choosing the original vertices closest (Euclidian distance) to the new vertices.
Usage
even_vert_samp(surf, n_vert)
Arguments
surf |
A |
n_vert |
The desired number of vertices in the evenly-spaced sample.
Note that the actual size of the subset will likely be close to but not
exactly |
Value
An integer vector giving the indices of the vertices in the subset.
See Also
Other surface-related:
add_surf()
,
boundary_mask_surf()
,
edit_mask_surf()
,
is.surf()
,
load_surf()
,
mask_surf()
,
read_surf()
,
resample_surf()
,
rotate_surf()
,
surf_area()
,
view_surf()
,
write_surf_gifti()
Interpolates between entries in the input palette to make a larger palette with COLOR_RES entries.
Description
Interpolates between entries in the input palette to make a larger palette with COLOR_RES entries.
Usage
expand_color_pal(pal, COLOR_RES = 255)
Arguments
pal |
The color palette to expand, as a data.frame with two columns:
|
COLOR_RES |
The number of entries to have in the output palette. |
Value
A data.frame with two columns: "color"
(character: color hex
codes) and "value"
(numeric)
See Also
Other coloring:
ROY_BIG_BL()
,
make_color_pal()
,
use_color_pal()
Expect these "xifti"
s to match
Description
Raise an error if the "xifti"
s do not match.
Usage
expect_equal_xifti(xii1, xii2)
Arguments
xii1 |
The first |
xii2 |
The second |
Details
cifti$intent
is only compared if it
exists for both files. cifti$brainstructures
and cifti$misc
are not compared.
Value
TRUE
, invisibly
faces
Description
faces
Arguments
faces |
An |
Fix GIFTI medial wall
Description
Replace implicit medial wall values (not indicated in ROI, but are in
mwall_values
) with explicit medial wall values (indicated in ROI)
in a metric GIFTI file.
Usage
fix_gifti_mwall(
metric_fname,
fixed_metric_fname,
ROI_fname,
fixed_ROI_fname,
mwall_values = c(NA, NaN)
)
Arguments
metric_fname |
File path to the data GIFTI |
fixed_metric_fname |
File path to the revised data GIFTI |
ROI_fname |
File path to the ROI GIFTI |
fixed_ROI_fname |
File path to the revised ROI GIFTI |
mwall_values |
The values to use to infer the medial wall. Default:
|
Value
NULL
, invisibly
Fix a "xifti"
Description
Make adjustments to a putative "xifti"
so that it is valid. Each
adjustment is reported.
Usage
fix_xifti(xifti, verbose = TRUE)
Arguments
xifti |
A |
verbose |
Report each adjustment? Default: |
Details
Right now it: coerces the data to numeric matrices; adds the "Other" level to the subcortex labels.
Value
The fixed "xifti"
Flatten a "xifti"
Description
Concatenates the data in a "xifti"
object row-wise to form a single matrix.
Usage
flatten_xifti(xifti, medial_wall = NULL, subcort_order = "alphabetical")
Arguments
xifti |
A |
medial_wall |
Should vertices for the medial wall be included with the
cortical data? If |
subcort_order |
"alphabetical" (default) to match the Connectome
Workbench command |
Details
If all brain structures are present, and if
is.null(medial_wall)
and subcort_order=="alphabetical"
(the default arguments), then the result will be identical to the matrix
obtained with the Connectome Workbench command
-cifti-export-dense-mapping
.
Value
The flattened "xifti"
, a data matrix
Format a path
Description
Normalize and validate a path (optionally, within a certain directory).
Usage
format_path(path, dir = NULL, mode = NA)
Arguments
path |
The path to normalize. |
dir |
(Optional) the directory to append to the beginning of the path.
|
mode |
The mode for |
Value
The normalized path, or NULL
if the path was NULL
.
Get CIFTI file extension
Description
Get CIFTI file extension
Usage
get_cifti_extn(cifti_fname)
Arguments
cifti_fname |
File path to a CIFTI file (ending in ".d*.nii"). |
Value
Character file extension of CIFTI file, e.g. "dtseries.nii", "dscalar.nii"
Extract data-related metadata from CIFTI
Description
Extract data-related metadata from CIFTI header XML (second "MatrixIndicesMap" entry)
Usage
get_data_meta_from_cifti_xml(xml, intent = 3000)
Arguments
xml |
List representing "MatrixIndicesMap" entry XML
( |
intent |
The CIFTI's NIFTI intent code. Not used right now, but might be
used later. Default: |
Value
The metadata, a list
Extract intent-specific metadata from CIFTI
Description
Extract intent-specific Metadata from CIFTI header XML (first "MatrixIndicesMap" entry)
Usage
get_intn_meta_from_cifti_xml(xml, intent = 3000)
Arguments
xml |
List representing "MatrixIndicesMap" entry XML
( |
intent |
The CIFTI's NIFTI intent code |
Value
The metadata, a list
Get kwargs
Description
Get the names of the arguments of a function as a character vector.
Usage
get_kwargs(fun)
Arguments
fun |
The function to get the argument names for. |
Value
The names of the arguments of fun
as a character vector
Extract misc metadata from CIFTI
Description
Extract misc metadata from CIFTI header XML ("Metadata" entry)
Usage
get_misc_meta_from_cifti_xml(xml, intent = 3000)
Arguments
xml |
List representing "Metadata" entry XML
( |
intent |
The CIFTI's NIFTI intent code. Not used right now, but may be later.
Default: |
Value
The metadata, a list
Get the Connectome Workbench command path
Description
Retrieves the path to the Connectome Workbench executable from a file path that may point to the executable itself, or to the Workbench folder which contains it (i.e., "path/to/workbench/bin_linux64/wb_command" or "path/to/workbench".)
Usage
get_wb_cmd_path(wb_path)
Arguments
wb_path |
(Optional) Path to the Connectome Workbench folder or executable. |
Value
The path to the Connectome Workbench executable
Get NIFTI header (of a CIFTI)
Description
Wrapper for Connectome Workbench command
-nifti-information [fname] -print-header
Usage
header_cifti(cifti_fname)
Arguments
cifti_fname |
File path to a CIFTI file (ending in ".d*.nii"). |
Value
The header, as a character vector
idx
Description
idx
Arguments
idx |
Numeric vector indicating the data indices (columns) to read. If
For high-resolution CIFTI files, reading in only a subset of the data saves memory, but will be slower than reading in the entire file due to the required intermediate steps. |
Impute "xifti"
data
Description
Impute locations using the values of neighboring locations.
Usage
impute_xifti(
xifti,
mask = NULL,
impute_FUN = function(x) {
mean(x, na.rm = TRUE)
},
...
)
Arguments
xifti |
A |
mask |
A logical vector whose length matches the number of rows in
If On the other hand, if |
impute_FUN |
The function to use to impute the values. It should accept
a vector of numeric values (the values of neighboring locations) and return
a single numeric value (the value to assign). Default: |
... |
Additional arguments to |
Details
Cortex vertices will be imputed using the five or six other vertices which share a face. Subcortex voxels will be imputed using the up to six immediate neighbors.
Note that during imputation, locations in mask
, as well as the medial
wall for the cortex, are temporarily set to NA
.
Note that handling of NA
values and the mask slightly differs from
the cortex and subcortex. impute_FUN
like mean
will behave
similarly, but functions which change depending on the amount of neighbor
locations with NA
values may differ.
impute_FUN
should handle NA
values accordingly.
For most use cases, it will make sense to pass na.rm=TRUE
to
...
if impute_FUN
is a summary function like mean
.
Value
The input xifti
with imputed data values.
See Also
Other manipulating xifti:
add_surf()
,
apply_parc()
,
apply_xifti()
,
combine_xifti()
,
convert_xifti()
,
merge_xifti()
,
move_to_mwall()
,
move_to_submask()
,
newdata_xifti()
,
remap_cifti()
,
remove_xifti()
,
resample_cifti()
,
resample_cifti_from_template()
,
scale_xifti()
,
select_xifti()
,
set_names_xifti()
,
smooth_cifti()
,
transform_xifti()
Infer resolution from "xifti"
and surfaces
Description
Infer the numbers of vertices on each cortex of a "xifti"
object.
Also supports the result of info_cifti
.
Usage
infer_resolution(xifti, surfL = NULL, surfR = NULL)
Arguments
xifti |
A |
surfL |
Left surface |
surfR |
Right surface |
Value
The inferred resolutions for the left and right cortex.
Get CIFTI metadata
Description
Get CIFTI metadata from the NIFTI header and XML using the Connectome
Workbench command -nifti-information
. The information is formatted as
the meta
component in a "xifti"
object
(see template_xifti
), and includes:
medial wall masks for the left and right cortex
the subcortical labels (ordered spatially)
the subcortical mask
other NIFTI intent-specific metadata
Usage
info_cifti(cifti_fname)
infoCIfTI(cifti_fname)
infocii(cifti_fname)
Arguments
cifti_fname |
File path to a CIFTI file (ending in ".d*.nii"). |
Details
Additional metadata depends on the type of CIFTI file:
- "dtseries"
-
- time_start:
Start time
- time_step:
The TR
- time_unit:
Unit of time
- "dscalar"
-
- names:
Name of each data column
- "dlabels"
-
- names:
( Names of each data column.)
- labels:
( List of
L \times 5
data.frames. Row names are the label names. Column names are Key, Red, Green, Blue, and Alpha. List entry names are the names of each data column.)
Value
The metadata component of a "xifti"
for the input CIFTI file
Connectome Workbench
This function interfaces with the "-nifti-information"
Workbench command.
Label Levels
xifti$meta$subcort$labels
is a factor with the following levels:
Cortex-L
Cortex-R
Accumbens-L
Accumbens-R
Amygdala-L
Amygdala-R
Brain Stem
Caudate-L
Caudate-R
Cerebellum-L
Cerebellum-R
Diencephalon-L
Diencephalon-R
Hippocampus-L
Hippocampus-R
Pallidum-L
Pallidum-R
Putamen-L
Putamen-R
Thalamus-L
Thalamus-R
These correspond to the same structures as given by
ft_read_cifti
in the cifti-matlab
MATLAB toolbox. Note that
the first two levels (left and right cortex) are not used.
See Also
Other reading:
as.xifti()
,
load_parc()
,
load_surf()
,
read_cifti()
,
read_surf()
,
read_xifti2()
Validate a 3d binary mask
Description
Check if object is a 3D binary mask.
Usage
is.3D_mask(x)
Arguments
x |
The putative subcortical mask. |
Details
This is a helper function for is.xifti
.
Requirements: the mask must be a boolean 3D array. TRUE
should
indicate voxels included in the mask, whereas FALSE
should indicate voxels outside of it.
Value
Logical. Is x
a valid subcortical mask?
Validate a "xifti"
object
Description
Check if object is valid for a "xifti"
. This alias for
is.xifti
is offered as a convenience, and a message will warn
the user. We recommend using is.xifti
instead.
Usage
is.cifti(x, messages = TRUE)
is_cifti(x, messages = TRUE)
isCIfTI(x, messages = TRUE)
Arguments
x |
The putative |
messages |
If |
Details
Requirements: it is a list with the same structure as
template_xifti
. The size of each data entry must be
compatible with its corresponding mask (medial wall for the cortex and
volumetric mask for the subcortex). Metadata should be present if and only
if the corresponding data is also present. The surfaces can be present
whether or not the cortex data are present.
See the "Label Levels" section for the requirements of
xifti$meta$subcort$labels
.
Value
Logical. Is x
a valid "xifti"
?
Label Levels
xifti$meta$subcort$labels
is a factor with the following levels:
Cortex-L
Cortex-R
Accumbens-L
Accumbens-R
Amygdala-L
Amygdala-R
Brain Stem
Caudate-L
Caudate-R
Cerebellum-L
Cerebellum-R
Diencephalon-L
Diencephalon-R
Hippocampus-L
Hippocampus-R
Pallidum-L
Pallidum-R
Putamen-L
Putamen-R
Thalamus-L
Thalamus-R
These correspond to the same structures as given by
ft_read_cifti
in the cifti-matlab
MATLAB toolbox. Note that
the first two levels (left and right cortex) are not used.
See Also
Other common:
read_cifti()
,
resample_cifti()
,
smooth_cifti()
,
view_xifti()
,
write_cifti()
Is this an existing file path?
Description
Simple check if something is an existing file.
Usage
is.fname(x)
Arguments
x |
The potential file name |
Value
Logical. Is x
an existing file?
Validate a numeric matrix
Description
Check if object is a numeric matrix.
Usage
is.nummat(x)
Arguments
x |
The putative numeric matrix |
Details
This is a helper function for is.xifti
.
Value
Logical. Is x
a valid numeric matrix?
Validate a factor vector of subcortical labels
Description
Check if object is a factor vector of subcortical structures.This is a helper
function for is.xifti
.
Usage
is.subcort_labs(x)
Arguments
x |
The putative factor vector of brain substructures. |
Details
Requirements: see the "Label Levels" section for the expected factor levels.
Value
Logical. Is x
a factor vector of subcortical
structures?
Label Levels
xifti$meta$subcort$labels
is a factor with the following levels:
Cortex-L
Cortex-R
Accumbens-L
Accumbens-R
Amygdala-L
Amygdala-R
Brain Stem
Caudate-L
Caudate-R
Cerebellum-L
Cerebellum-R
Diencephalon-L
Diencephalon-R
Hippocampus-L
Hippocampus-R
Pallidum-L
Pallidum-R
Putamen-L
Putamen-R
Thalamus-L
Thalamus-R
These correspond to the same structures as given by
ft_read_cifti
in the cifti-matlab
MATLAB toolbox. Note that
the first two levels (left and right cortex) are not used.
Validate a "surf"
object (vertices + faces)
Description
Check if object is valid for xifti$surf$cortex_left
or
xifti$surf$cortex_right
, where xifti
is a "xifti"
object.
Usage
is.surf(x)
Arguments
x |
The putative |
Details
This is a helper function for is.xifti
.
Requirements: the "surf"
must be a list of three components: "vertices",
"faces", and "hemisphere". The first two should each be a numeric matrix
with three columns. The values in "vertices" represent spatial coordinates
whereas the values in "faces" represent vertex indices defining the face.
Thus, values in "faces" should be integers between 1 and the number of
vertices. The last list entry, "hemisphere", should be "left", "right",
or NULL indicating the brain hemisphere which the surface represents.
Value
Logical. Is x
a valid "surf"
?
See Also
Other surface-related:
add_surf()
,
boundary_mask_surf()
,
edit_mask_surf()
,
even_vert_samp()
,
load_surf()
,
mask_surf()
,
read_surf()
,
resample_surf()
,
rotate_surf()
,
surf_area()
,
view_surf()
,
write_surf_gifti()
Validate a "xifti"
object.
Description
Check if object is valid for a "xifti"
object.
Usage
is.xifti(x, messages = TRUE)
is_xifti(x, messages = TRUE)
Arguments
x |
The putative |
messages |
If |
Details
Requirements: it is a list with the same structure as
template_xifti
. The size of each data entry must be
compatible with its corresponding mask (medial wall for the cortex and
volumetric mask for the subcortex). Metadata should be present if and only
if the corresponding data is also present. The surfaces can be present
whether or not the cortex data are present.
See the "Label Levels" section for the requirements of
xifti$meta$subcort$labels
.
Value
Logical. Is x
a valid "xifti"
object?
Label Levels
xifti$meta$subcort$labels
is a factor with the following levels:
Cortex-L
Cortex-R
Accumbens-L
Accumbens-R
Amygdala-L
Amygdala-R
Brain Stem
Caudate-L
Caudate-R
Cerebellum-L
Cerebellum-R
Diencephalon-L
Diencephalon-R
Hippocampus-L
Hippocampus-R
Pallidum-L
Pallidum-R
Putamen-L
Putamen-R
Thalamus-L
Thalamus-R
These correspond to the same structures as given by
ft_read_cifti
in the cifti-matlab
MATLAB toolbox. Note that
the first two levels (left and right cortex) are not used.
Validate the "data" component of a "xifti"
object
Description
Check if object is valid for xifti$data
, where xifti
is a
"xifti"
object.
Usage
is.xifti_data(x)
Arguments
x |
The putative "data" component. |
Details
This is a helper function for is.xifti
.
Requirements: a list with entries "cortex_left", "cortex_right", and
"subcort". Each must be either NULL
or a numeric matrix with
grayordinates along the rows and measurements along the columns.
The cortical matrices should have the same number of rows (vertices), and
all should have the same number of columns (measurements). At least one data
entry should be present.
Value
Logical. Is x
a valid "data" component?
Validate the "meta"
component of a "xifti"
object
Description
Check if object is valid for xifti$meta
, where xifti
is a
"xifti"
object.
Usage
is.xifti_meta(x)
Arguments
x |
The putative |
Details
This is a helper function for is.xifti
.
Requirements: the structure must match that of the "meta"
component
of template_xifti
.
Value
Logical. Is x
a valid "meta"
component?
labels
Description
labels
Label Levels
xifti$meta$subcort$labels
is a factor with the following levels:
Cortex-L
Cortex-R
Accumbens-L
Accumbens-R
Amygdala-L
Amygdala-R
Brain Stem
Caudate-L
Caudate-R
Cerebellum-L
Cerebellum-R
Diencephalon-L
Diencephalon-R
Hippocampus-L
Hippocampus-R
Pallidum-L
Pallidum-R
Putamen-L
Putamen-R
Thalamus-L
Thalamus-R
These correspond to the same structures as given by
ft_read_cifti
in the cifti-matlab
MATLAB toolbox. Note that
the first two levels (left and right cortex) are not used.
Load a parcellation included in ciftiTools
Description
Load a parcellation included in ciftiTools
.
Usage
load_parc(
name = c("Schaefer_100", "Schaefer_400", "Schaefer_1000", "Yeo_7", "Yeo_17")
)
Arguments
name |
The name of the parcellation to load:
|
Details
When using these parcellations, please cite the corresponding paper(s):
Yeo, B. T. T. et al. The organization of the human cerebral cortex estimated by intrinsic functional connectivity. J Neurophysiol 106, 1125-1165 (2011).
Schaefer, A. et al. Local-Global Parcellation of the Human Cerebral Cortex from Intrinsic Functional Connectivity MRI. Cereb Cortex 28, 3095-3114 (2018).
Kong, R. et al. Individual-Specific Areal-Level Parcellations Improve Functional Connectivity Prediction of Behavior. Cerebral Cortex (2021+) doi:10.1093/cercor/bhab101.
Note that the Schaefer parcels have been matched to networks from Kong (2021+).
Value
The parcellation as a dlabel "xifti"
with one column. Each key
represents one unique parcel.
See Also
Other reading:
as.xifti()
,
info_cifti()
,
load_surf()
,
read_cifti()
,
read_surf()
,
read_xifti2()
Other parcellation-related:
apply_parc()
,
load_sub_parc()
,
parc_add_subcortex()
,
parc_borders()
,
parc_vals_to_xifti()
Load subcortical parcellation
Description
Load the MNI subcortical parcellation included in ciftiTools
as a
"dlabel" "xifti"
object.
Usage
load_sub_parc()
Details
Colors are based on https://surfer.nmr.mgh.harvard.edu/fswiki/FsTutorial/AnatomicalROI/FreeSurferColorLUT
Value
The subcortical parcellation
See Also
Other parcellation-related:
apply_parc()
,
load_parc()
,
parc_add_subcortex()
,
parc_borders()
,
parc_vals_to_xifti()
Load a "surf"
included in ciftiTools
Description
Load a "surf"
object from one of the three 32k anatomical surfaces
included in ciftiTools
.
Usage
load_surf(
hemisphere = c("left", "right"),
name = c("inflated", "very inflated", "midthickness"),
resamp_res = NULL
)
Arguments
hemisphere |
|
name |
The name of the surface geometry to load: |
resamp_res |
The resolution to resample the surfaces to. If |
Details
The surfaces are from the HCP and are included according to these data use terms: Data were provided [in part] by the Human Connectome Project, WU-Minn Consortium (Principal Investigators: David Van Essen and Kamil Ugurbil; 1U54MH091657) funded by the 16 NIH Institutes and Centers that support the NIH Blueprint for Neuroscience Research; and by the McDonnell Center for Systems Neuroscience at Washington University.
Value
The "surf"
object
See Also
Other reading:
as.xifti()
,
info_cifti()
,
load_parc()
,
read_cifti()
,
read_surf()
,
read_xifti2()
Other surface-related:
add_surf()
,
boundary_mask_surf()
,
edit_mask_surf()
,
even_vert_samp()
,
is.surf()
,
mask_surf()
,
read_surf()
,
resample_surf()
,
rotate_surf()
,
surf_area()
,
view_surf()
,
write_surf_gifti()
Make a color palette.
Description
Control the mapping of values to colors with colors
,
color_mode
, and zlim
.
Usage
make_color_pal(
colors = NULL,
color_mode = c("sequential", "qualitative", "diverging"),
zlim = NULL
)
Arguments
colors |
(Optional) "ROY_BIG_BL", the name of a ColorBrewer palette
(see |
color_mode |
(Optional) |
zlim |
(Optional) Controls the mapping of values to each color in
|
Details
There are three kinds of arguments for colors
: "ROY_BIG_BL"
,
the name of a ColorBrewer palette (see RColorBrewer::brewer.pal.info
and colorbrewer2.org), the name of a viridisLite palette, or a character
vector of color names.
If colors=="ROY_BIG_BL"
, the "ROY_BIG_BL" palette will be used. It is
the same palette as the default for the Connectome Workbench application
(https://github.com/Washington-University/workbench/blob/master/src/Files/PaletteFile.cxx).
The midpoint will be colored
black. From the midpoint toward the upper bound, colors will proceed from
black to red to yellow. From the midpoint toward the lower bound, colors
will proceed from black to blue to purple to green to aqua. Here is how each
color mode behaves if colors=="ROY_BIG_BL"
:
color_mode=="sequential"
Only half of the palette will be used. If
zlim
is length 2, the higher value will be the maximum and the lower value will be the minimum. Setzlim[1] > zlim[2]
to reverse the color scale. (Note that the second half, black –> red –> yellow, is used by default. To use the negative half specifycolors=="ROY_BIG_BL_neg"
instead. It will also be used automatically byxifti_read_surface
when the data range is negative.)zlim
can also be length 10, in which case each value corresponds to the position of an individual color in the half palette.color_mode=="qualitative"
"ROY_BIG_BL" is not recommended for qualitative data, so a warning will be issued. Palette colors will be selected from the landmark "ROY_BIG_BL" colors, with interpolated colors added if the number of colors in the palette (18) is less than this range.
zlim
should be a single number: the number of unique colors to get.color_mode=="diverging"
If
zlim
is length 2 or 3, the lowest number will be the lower bound and the highest number will be the upper bound. Ifzlim
is length 3, the middle number will be the midpoint (black). The lower and upper bounds will be aqua and yellow, respectively, except ifzlim
is in descending order, in which case the color scale will be reversed (lowest is yellow; highest is aqua).zlim
can also be length 19, in which case each value corresponds to the position of an individual color in the palette.
If colors
is the name of an RColorBrewer palette (see
RColorBrewer::brewer.pal.info
) or viridisLite palette, the colors in
that palette will be used, and the following behavior applies.
If colors
is a character vector of color names (hex codes or standard
R color names), the following behavior applies directly:
color_mode=="sequential"
If
zlim
is length 2, the higher value will be the maximum and the lower value will be the minimum. Setzlim[1] > zlim[2]
to reverse the color scale.zlim
can also be the same length as the palette, in which case each value corresponds to the position of an individual color in the palette.color_mode=="qualitative"
zlim
should be a single number: the number of unique colors to get. Color interpolation will be used if the number of colors in the palette is less than this range. Iflength(zlim)==length(colors)
, each color will be mapped to each corresponding value.color_mode=="diverging"
If
zlim
is length 2 or 3, the lowest number will be the lower bound and the highest number will be the upper bound. Ifzlim
is length 3, the middle number will be the midpoint. Setzlim
in descending order to reverse the color scale.zlim
can also be the same length as the palette, in which case each value corresponds to the position of an individual color in the palette.
Value
A data.frame with two columns: "color"
(character: color hex
codes) and "value"
(numeric)
See Also
Other coloring:
ROY_BIG_BL()
,
expand_color_pal()
,
use_color_pal()
Make the cortical components of a "xifti"
Description
Coerce a path to a GIFTI file, metric or label "gifti"
object,
data matrix or vector to a data matrix representing cortical data
(and optionally a corresponding mask).
That is, entries for xifti$data$cortex_\[left/right\]
and
xifti$meta$cortex$medial_wall_mask$\[left/right\]
. If cortex
is
a path to a GIFTI file or a metric "gifti"
, any column names or
a non-empty label table will also be extracted.
Usage
make_cortex(
cortex,
mwall = NULL,
idx = NULL,
cortex_is_masked = NULL,
rm_blank_mwall = TRUE,
rm_bad_mwall = TRUE,
mwall_values = NULL,
side = NULL,
mwall_source = NULL
)
Arguments
cortex |
A path to a metric or label GIFTI file, metric or label
If |
mwall |
A path to a metric or label GIFTI file, metric or label |
idx |
Only applies if |
cortex_is_masked |
Has the medial wall been masked from If |
rm_blank_mwall |
If the medial wall mask is all |
rm_bad_mwall |
If the medial wall mask doesn't match up with the
data (e.g. the vertex count doesn't add up), should it be discarded?
Default: |
mwall_values |
If the medial wall mask was not provided (or if it was
discarded), infer it from rows in |
side |
|
mwall_source |
Description of where the mwall came from. Just used to print warnings. |
Value
A list with components "data", "mwall", "col_names" and "labels".
Make the subcortical components of a "xifti"
Description
Coerce subcortical data into valid entries for xifti$data$subcort
and xifti$meta$subcort
. The data arguments can be matrices/arrays or
NIFTI file paths. If the mask is not provided, it will be inferred from the
labels.
Usage
make_subcort(vol, labs, mask = NULL, idx = NULL, validate_mask = FALSE)
Arguments
vol |
represents the data values of the subcortex. It is either a NIFTI
file path, 3D/4D data array ( |
labs |
represents the brainstructure labels of each voxel: see
|
mask |
is a NIFTI file path or logical 3D data array ( |
idx |
Only applies if |
validate_mask |
If |
Details
To read in the labels as the primary data, use the labels NIFTI for both
vol
and labs
.
Value
A list with components "data", "labels", "mask", and "trans_mat". The first two will be vectorized and ordered spatially.
The volume can be recovered using:
vol <- unvec_vol(data, mask, fill=NA)
labs <- unvec_vol(labels, mask, fill=0)
Label Levels
xifti$meta$subcort$labels
is a factor with the following levels:
Cortex-L
Cortex-R
Accumbens-L
Accumbens-R
Amygdala-L
Amygdala-R
Brain Stem
Caudate-L
Caudate-R
Cerebellum-L
Cerebellum-R
Diencephalon-L
Diencephalon-R
Hippocampus-L
Hippocampus-R
Pallidum-L
Pallidum-R
Putamen-L
Putamen-R
Thalamus-L
Thalamus-R
These correspond to the same structures as given by
ft_read_cifti
in the cifti-matlab
MATLAB toolbox. Note that
the first two levels (left and right cortex) are not used.
Make the subcortical transformation matrix
Description
Make the transformation matrix for the subcortical volume from the sform data in the header.
Usage
make_trans_mat(nii_fname)
Arguments
nii_fname |
Path to NIFTI file |
Value
4x4 matrix representing the transformation matrix. (This includes
the last row, c(0,0,0,1)
).
Assemble a "xifti"
object
Description
Assembles cortical data, subcortical data, and/or surface geometry to form a
"xifti"
object. The inputs can be file paths, GIFTI or NIFTI files
which have been read in, or data objects (vectors, matrices or arrays,
depending on the argument). See as.xifti
for a user-function wrapper
that only works with data objects.
Usage
make_xifti(
cortexL = NULL,
cortexL_mwall = NULL,
cortexR = NULL,
cortexR_mwall = NULL,
subcortVol = NULL,
subcortLabs = NULL,
subcortMask = NULL,
mwall_values = c(NA, NaN),
cifti_info = NULL,
surfL = NULL,
surfR = NULL,
idx = NULL,
col_names = NULL,
HCP_32k_auto_mwall = TRUE,
read_dir = NULL,
validate = TRUE
)
Arguments
cortexL , cortexL_mwall |
Left cortex data and ROI. Each must be a path to
a GIFTI file, If If Since the unmasked cortices must have the same number of vertices,
|
cortexR , cortexR_mwall |
Right cortex data and ROI. Each must be a path to
a GIFTI file, If If Since the unmasked cortices must have the same number of vertices,
|
subcortVol , subcortLabs , subcortMask |
|
mwall_values |
If |
cifti_info |
(Optional) The result of The intent can be specified like so:
Column names from
|
surfL , surfR |
(Optional) Surface geometries for the left or right cortex.
Can be a surface GIFTI file path or |
idx |
For file paths provided to |
col_names |
Names of each measurement/column in the data. Overrides
names indicated in |
HCP_32k_auto_mwall |
If left and/or right cortex data is provided, and
the number of vertices matches that of the HCP 32k mesh (29696 on left, and
29716 on right), should the medial wall masks be added to the |
read_dir |
(Optional) Append a directory to all file names in the
arguments. If |
validate |
Validate that the result is a |
Details
Each data or surface component is optional. Metadata components
(cortex[L/R]_mwall
, subcortLabs
, and subcortMask
) will
be ignored if its corresponding data component is not provided. If no data or
surface components are provided, then the template_xifti
will
be returned.
If cortical data are provided without a corresponding medial wall mask, or
if the provided mask is invalid or empty, then the medial wall will be
inferred from data rows that are constantly a value in mwall_values
.
But if mwall_values
is NULL
, no attempt to infer the medial
wall will be made and the medial wall metadata entry will be NULL
.
The total number of grayordinates will be
G = (V_L - mwall_L) + (V_R - mwall_R) + V_S
: V_L - mwall_L
left
vertices, V_R - mwall_R
right vertices and V_S
subcortical
voxels. T
, the total number of measurements (columns of data), must be
the same for each brainstructure.
Value
A "xifti"
object; see template_xifti
Label Levels
xifti$meta$subcort$labels
is a factor with the following levels:
Cortex-L
Cortex-R
Accumbens-L
Accumbens-R
Amygdala-L
Amygdala-R
Brain Stem
Caudate-L
Caudate-R
Cerebellum-L
Cerebellum-R
Diencephalon-L
Diencephalon-R
Hippocampus-L
Hippocampus-R
Pallidum-L
Pallidum-R
Putamen-L
Putamen-R
Thalamus-L
Thalamus-R
These correspond to the same structures as given by
ft_read_cifti
in the cifti-matlab
MATLAB toolbox. Note that
the first two levels (left and right cortex) are not used.
mask: vertices
Description
mask: vertices
Arguments
mask |
A length |
Mask surface
Description
Mask a surface mesh.
Usage
mask_surf(surf, mask)
Arguments
surf |
A |
mask |
A length |
Details
Apply a binary mask to a "surf"
object (list of vertices and
corresponding faces). Vertices not in the mask are removed, and faces
(triangles) with any vertices not in the mask are removed. Finally,
vertex numbering for the new faces matrix is corrected.
Value
The masked "surf"
object.
See Also
Other surface-related:
add_surf()
,
boundary_mask_surf()
,
edit_mask_surf()
,
even_vert_samp()
,
is.surf()
,
load_surf()
,
read_surf()
,
resample_surf()
,
rotate_surf()
,
surf_area()
,
view_surf()
,
write_surf_gifti()
Apply Mask With Boundary To Mesh
Description
Make a boundary around a mask with two levels of decimation, and apply to a mask.
Usage
mask_with_boundary_surf(
vertices,
faces,
mask,
width1 = 4,
k1 = 2,
width2 = 6,
k2 = 3
)
Arguments
vertices |
A |
faces |
An |
mask |
A length |
width1 , width2 |
the width of the middle/outer region. All vertices in the middle/outer region
are between 1 and |
k1 , k2 |
roughly, the triangle size multiplier. Every |
Details
The boundary consists of a width1
-vertex-wide middle region and a
width2
-vertex-wide outer region, for a total of width1 + width2
layers
of vertices surrounding the input mask. In the first layer, every k1
vertex within every k1
layer (beginning with the innermost
layer) is retained; the rest are discarded. In the second layer, every
k2
vertex within every k2
layer (beginning with the innermost
layer) is retained; the rest are discarded. It is recommended to make width1
a multiple of k1
and width2
a multiple of k2
.
Default boundary: a 4-vertex wide middle region with triangles twice as long, and a 6-vertex wide outer region with triangles three times as long.
Value
A new mesh (list with components vertices and faces)
Do these character vectors match exactly?
Description
Checks if a user-defined character vector matches an expected character
vector. That is, they share the same lengths and entries in the same order.
For vectors of the same lengths, the result is all(a == b)
.
Usage
match_exactly(
user,
expected,
fail_action = c("message", "warning", "stop", "nothing")
)
Arguments
user |
Character vector of user input. |
expected |
Character vector of expected/allowed values. |
fail_action |
If any value in |
Details
Attributes are ignored.
Value
Logical. Do user
and expected
match?
Match user inputs to expected values
Description
Match each user input to an expected/allowed value.
Usage
match_input(
user,
expected,
fail_action = c("stop", "warning", "message", "nothing"),
user_value_label = NULL
)
Arguments
user |
Character vector of user input. These will be matched to
|
expected |
Character vector of expected/allowed values. |
fail_action |
If any value in |
user_value_label |
How to refer to the user input in a stop or warning
message. If |
Details
Raise a warning if either
several user inputs match the same expected value, or at least one could not
be matched to any expected value. ciftiTools
uses this function to
match keyword arguments for a function call. Another use is to match
brainstructure labels ("left", "right", or "subcortical").
Value
The matched user inputs
Merges two kwargs
Description
Merge two kwarg lists. If a kwarg is present in both lists but with different values, an error is raised.
Usage
merge_kwargs(
kwargsA,
kwargsB,
labelA = "first kwarg(s)",
labelB = "second kwarg(s)",
extraMsg = "[DEFAULT]"
)
Arguments
kwargsA |
The first list of kwargs. |
kwargsB |
The second list of kwargs. If duplicates are present, the default
message recommends the user to remove the kwarg here in favor of placing the
correct one in |
labelA |
(Optional) Descriptor of |
labelB |
(Optional) Descriptor of |
extraMsg |
(Optional) Extra text for error statement. "[DEFAULT]" (default) will use this message: "Note that a kwarg only has to be provided to one of these. Place the correct value in the first location and remove the kwarg from the second location". |
Value
A list with the union of kwargsA
and kwargsB
Concatenate "xifti"
s
Description
Concatenate "xifti"
objects along the columns. They must have the same
brainstructures and resolutions. The first "xifti"
's metadata will be
retained, including its intent.
Usage
merge_xifti(..., xifti_list = NULL)
Arguments
... , xifti_list |
Provide as arguments the |
Value
The concatenated "xifti"
See Also
Other manipulating xifti:
add_surf()
,
apply_parc()
,
apply_xifti()
,
combine_xifti()
,
convert_xifti()
,
impute_xifti()
,
move_to_mwall()
,
move_to_submask()
,
newdata_xifti()
,
remap_cifti()
,
remove_xifti()
,
resample_cifti()
,
resample_cifti_from_template()
,
scale_xifti()
,
select_xifti()
,
set_names_xifti()
,
smooth_cifti()
,
transform_xifti()
Move data locations from medial wall
Description
Move all medial wall locations into the cortical data matrices by assigning them a specific value (e.g. NA).
Usage
move_from_mwall(xifti, value = NA, name = "Medial_Wall", RGBA = c(1, 1, 1, 0))
Arguments
xifti |
A |
value |
The value to assign the medial wall locations. Default: |
name , RGBA |
Only used if the Currently, only one name and set of RGBA values are supported, meaning that
the medial wall locations will have the same Key, name, and color across
all data columns in the Defaults: |
Value
The "xifti"
with re-organized data and medial wall masks
See Also
move_to_mwall
unmask_cortex
Move data locations from subcortex mask
Description
Move subcortex mask locations into the subcortex data matrix by assigning them a specific value (e.g. NA).
Usage
move_from_submask(
xifti,
new_mask,
value = NA,
label_value = "Other",
name = "Other",
RGBA = c(1, 1, 1, 0)
)
Arguments
xifti |
A |
new_mask |
The new mask, of which the current mask should be a subset.
( |
value |
The value to assign the new locations. Default: |
label_value |
The label value to assign the new locations. Default:
|
name , RGBA |
Only used if the Currently, only one name and set of RGBA values are supported, meaning that
the out-of-mask subcortex locations will have the same Key, name, and color
across all data columns in the Defaults: |
Value
The "xifti"
with re-organized data and subcortex masks
See Also
move_to_submask
unmask_cortex
Move data locations to the medial wall
Description
Move cortical data locations with a specific value(s) to the medial wall mask. For example, dlabel CIFTIs often have medial wall vertices set to a specific key value, rather than a medial wall mask. This function can move those data locations from the data matrix to the medial wall mask in the metadata.
Usage
move_to_mwall(xifti, values = c(NA, NaN), drop = FALSE)
Arguments
xifti |
A |
values |
Medial wall values. Default: |
drop |
Only used if the |
Value
The "xifti"
with re-organized data and medial wall masks
See Also
move_from_mwall
Other manipulating xifti:
add_surf()
,
apply_parc()
,
apply_xifti()
,
combine_xifti()
,
convert_xifti()
,
impute_xifti()
,
merge_xifti()
,
move_to_submask()
,
newdata_xifti()
,
remap_cifti()
,
remove_xifti()
,
resample_cifti()
,
resample_cifti_from_template()
,
scale_xifti()
,
select_xifti()
,
set_names_xifti()
,
smooth_cifti()
,
transform_xifti()
Move data locations to the subcortex mask
Description
Move subcortex data locations with a specific value(s) to the subcortex mask.
Usage
move_to_submask(xifti, values = c(NA, NaN), drop = FALSE)
Arguments
xifti |
A |
values |
Values to mask out. Default: |
drop |
Only used if the |
Value
The "xifti"
with re-organized data and subcortex masks
See Also
move_from_submask
Other manipulating xifti:
add_surf()
,
apply_parc()
,
apply_xifti()
,
combine_xifti()
,
convert_xifti()
,
impute_xifti()
,
merge_xifti()
,
move_to_mwall()
,
newdata_xifti()
,
remap_cifti()
,
remove_xifti()
,
resample_cifti()
,
resample_cifti_from_template()
,
scale_xifti()
,
select_xifti()
,
set_names_xifti()
,
smooth_cifti()
,
transform_xifti()
Counts the number of columns in a "xifti"
.
Description
Counts the number of columns in the "xifti"
data. Doesn't bother
to validate the input.
Usage
ncol_xifti(xifti)
Value
The number of columns in the "xifti"
data.
Replace the data in a "xifti"
Description
Replace the data in a "xifti"
with new data from a data matrix.
Usage
newdata_xifti(xifti, newdata, newnames = NULL, subcortex_by_bs = FALSE)
Arguments
xifti |
A |
newdata |
The If Can also be a length-one vector to set all values equally. |
newnames |
Replaces the names in the |
subcortex_by_bs |
If subcortical data is being provided in
|
Details
If the "xifti"
has V
grayordinates and T
measurements\,
newdata
should be a V \times Q
matrix. If Q
is not equal to T
, then any column names or label tables will be
removed. (A "dlabel" will be converted to a "dscalar".)
Value
The new "xifti"
See Also
Other manipulating xifti:
add_surf()
,
apply_parc()
,
apply_xifti()
,
combine_xifti()
,
convert_xifti()
,
impute_xifti()
,
merge_xifti()
,
move_to_mwall()
,
move_to_submask()
,
remap_cifti()
,
remove_xifti()
,
resample_cifti()
,
resample_cifti_from_template()
,
scale_xifti()
,
select_xifti()
,
set_names_xifti()
,
smooth_cifti()
,
transform_xifti()
Counts the number of rows (vertices + voxels) in a "xifti"
.
Description
Counts the number of data locations in the "xifti"
data. Doesn't bother
to validate the input.
Usage
nrow_xifti(xifti)
Arguments
xifti |
A |
Value
The number of rows in the "xifti"
data.
original_fnames: for remapping
Description
original_fnames: for remapping
Arguments
original_fnames |
The files to remap. This is a named list
where each element's name is a file type label, and each element's value
is a file name. Labels must be one of the following: "cortexL", "cortexR",
"ROIcortexL", "ROIcortexR". If |
original_fnames: for resampling
Description
original_fnames: for resampling
Arguments
original_fnames |
The files to resample. This is a named list
where each element's name is a file type label, and each element's value
is a file name. Labels must be one of the following: "cortexL", "cortexR",
"ROIcortexL", "ROIcortexR", "surfL", or "surfR". If
|
Pad a 3D Array
Description
Pad a 3D array by a certain amount in each direction, along each dimension. This effectively undoes a crop.
Usage
pad_vol(x, padding, fill = NA)
uncrop_vol(x, padding, fill = NA)
Arguments
x |
A 3D array, e.g. |
padding |
A |
fill |
Values to pad with. Default: |
Value
The padded array
Add subcortex to cortical parcellation
Description
Add the subcortex, with each brain structure as a separate parcel, to a "dlabel" cortical parcellation.
Usage
parc_add_subcortex(parc, parc_sub = "MNI")
Arguments
parc |
A single-column "dlabel" |
parc_sub |
A single-column |
Value
The new parcellation with added subcortical data and labels.
See Also
Other parcellation-related:
apply_parc()
,
load_parc()
,
load_sub_parc()
,
parc_borders()
,
parc_vals_to_xifti()
Parcellation borders
Description
Identify vertices which lie on the border of different parcels.
Usage
parc_borders(parc, surf = NULL, hemisphere = c("left", "right"))
Arguments
parc |
Integer vector the same length as the number of vertices. Each entry indicates the parcel that vertex belongs to. |
surf |
The surface which the vertices belong to, or just the |
hemisphere |
Only used to choose which default surface to use if
|
Value
Logical vector the same length as parc
indicating if the
vertex lies on a border.
See Also
Other parcellation-related:
apply_parc()
,
load_parc()
,
load_sub_parc()
,
parc_add_subcortex()
,
parc_vals_to_xifti()
Make parcellation mean matrix
Description
Create a matrix that compute the average value for each parcel.
Usage
parc_mean_mat(parc)
Arguments
parc |
A single-column "dlabel" |
Details
From a single-column "dlabel" "xifti"
object, make a K \times V
matrix where row k
is a vector corresponding to the kth Key value,
with 1/k_i
at locations with that key value, and 0
elsewhere.
k_i
is the total number of locations inside Key k
.
So, the sum of each row will be 1
, and each column will only
have exactly one non-zero value (because each location only has one Key
value) except medial wall locations will have all zeroes.
Multiplying the result of parc_mean_mat
with a V \times T
matrix
of timeseries data, e.g. from as.matrix(dlabel_xii)
, will yield the
average value for each Key.
Value
The parcellation matrix
Convert parcellation values to "xifti"
Description
From a parcellation and a corresponding value matrix, make a "xifti"
object that has the value vector of each parcel across its locations.
Usage
parc_vals_to_xifti(parc, vals)
Arguments
parc |
A single-column "dlabel" |
vals |
A numeric matrix. Rows should correspond to rows in
the color table of |
Value
A "xifti"
object
See Also
Other parcellation-related:
apply_parc()
,
load_parc()
,
load_sub_parc()
,
parc_add_subcortex()
,
parc_borders()
S3 method: plot surface
Description
Visualize a single surface
Usage
## S3 method for class 'surf'
plot(x, ...)
Arguments
x |
A |
... |
Additional arguments to |
S3 method: use view_xifti
to plot a "xifti"
object
Description
S3 method: use view_xifti
to plot a "xifti"
object
Usage
## S3 method for class 'xifti'
plot(x, ...)
Arguments
x |
A |
... |
Additional arguments to |
Order Vertices on Circular Manifold
Description
Order vertices on circular manifold by radians (after 2D CMDS projection).
Usage
radial_order_surf(vertices)
Arguments
vertices |
A |
Value
Index ordering of vertices
Read a CIFTI file
Description
Read in a CIFTI file as a "xifti"
object.
Usage
read_cifti(
cifti_fname = NULL,
surfL_fname = NULL,
surfR_fname = NULL,
brainstructures = "existing",
idx = NULL,
resamp_res = NULL,
resamp_method = c("barycentric", "adaptive"),
areaL_original_fname = NULL,
areaR_original_fname = NULL,
flat = FALSE,
mwall_values = c(NA, NaN),
verbose = FALSE,
...
)
readCIfTI(
cifti_fname = NULL,
surfL_fname = NULL,
surfR_fname = NULL,
brainstructures = "existing",
idx = NULL,
resamp_res = NULL,
resamp_method = c("barycentric", "adaptive"),
areaL_original_fname = NULL,
areaR_original_fname = NULL,
flat = FALSE,
mwall_values = c(NA, NaN),
verbose = FALSE,
...
)
readcii(
cifti_fname = NULL,
surfL_fname = NULL,
surfR_fname = NULL,
brainstructures = "existing",
idx = NULL,
resamp_res = NULL,
resamp_method = c("barycentric", "adaptive"),
areaL_original_fname = NULL,
areaR_original_fname = NULL,
flat = FALSE,
mwall_values = c(NA, NaN),
verbose = FALSE,
...
)
read_xifti(
cifti_fname = NULL,
surfL_fname = NULL,
surfR_fname = NULL,
brainstructures = "existing",
idx = NULL,
resamp_res = NULL,
resamp_method = c("barycentric", "adaptive"),
areaL_original_fname = NULL,
areaR_original_fname = NULL,
flat = FALSE,
mwall_values = c(NA, NaN),
verbose = FALSE,
...
)
Arguments
cifti_fname |
File path to a CIFTI file (ending in ".d*.nii"). |
surfL_fname |
(Optional) File path to a GIFTI surface geometry file representing the left cortex. |
surfR_fname |
(Optional) File path to a GIFTI surface geometry file representing the right cortex. |
brainstructures |
Character vector indicating which brain structure(s)
to read in: If a brain structure is indicated but does not exist, a warning will be raised and that brain structure will be skipped. |
idx |
Numeric vector indicating the data indices (columns) to read. If
For high-resolution CIFTI files, reading in only a subset of the data saves memory, but will be slower than reading in the entire file due to the required intermediate steps. |
resamp_res |
Resolution to resample the cortical data and surface to.
Default: |
resamp_method |
While adaptive resampling is recommended for metric or label
data, it requires that Note that surfaces will resampled using barycentric resampling regardless of
|
areaL_original_fname , areaR_original_fname |
File paths to the surfaces
to use for vertex area correction during adaptive resampling. (Only used if
resampling with the adaptive method.) For resampling: the Workbench command for adaptive resampling requires the
target surfaces for area correction too. But to make the workflow easier,
For remapping: |
flat |
Should the result be flattened into a single matrix? If If If |
mwall_values |
If the medial wall locations are not indicated in the
CIFTI, use these values to infer the medial wall mask. Default:
|
verbose |
Should occasional updates be printed? Default: |
... |
Additional arguments to |
Details
First, metadata is obtained with info_cifti
. Then, if no
resampling is requested, the -cifti-convert -to-gifti-ext
Workbench
Command is used to "flatten" the data and save it as a metric or label GIFTI
file, which is read in and separated by brainstructure according to the metadata
(read_cifti_convert
). Otherwise, if sampling is requested,
then the CIFTI is separated into its GIFTI and NIFTI components, resampled,
and then re-assembled (read_cifti_separate
). The former is
much faster for large CIFTI files, so the latter is only used when necessary
for resampling.
If cifti_fname
is not provided, then only the surfaces are read in.
Value
If !flat
, a "xifti"
object. Otherwise, a T \times G
matrix (T
measurements, G
grayordinates).
Connectome Workbench
This function interfaces with the "-cifti-convert"
Workbench command if
resampling is not needed, and the "-cifti-separate"
Workbench command
if resampling is needed.
Label Levels
xifti$meta$subcort$labels
is a factor with the following levels:
Cortex-L
Cortex-R
Accumbens-L
Accumbens-R
Amygdala-L
Amygdala-R
Brain Stem
Caudate-L
Caudate-R
Cerebellum-L
Cerebellum-R
Diencephalon-L
Diencephalon-R
Hippocampus-L
Hippocampus-R
Pallidum-L
Pallidum-R
Putamen-L
Putamen-R
Thalamus-L
Thalamus-R
These correspond to the same structures as given by
ft_read_cifti
in the cifti-matlab
MATLAB toolbox. Note that
the first two levels (left and right cortex) are not used.
See Also
Other common:
is.cifti()
,
resample_cifti()
,
smooth_cifti()
,
view_xifti()
,
write_cifti()
Other reading:
as.xifti()
,
info_cifti()
,
load_parc()
,
load_surf()
,
read_surf()
,
read_xifti2()
Read a CIFTI file quickly
Description
Read a CIFTI file by exporting it as a single GIFTI
using -cifti-convert -to-gifti-ext
(read_cifti_flat
),
and obtaining the brainordinate mapping using
-cifti-export-dense-mapping
(info_cifti
).
Usage
read_cifti_convert(
cifti_fname,
surfL_fname = NULL,
surfR_fname = NULL,
brainstructures = "existing",
idx = NULL,
mwall_values = c(NA, NaN),
verbose = FALSE,
...
)
Arguments
cifti_fname |
File path to a CIFTI file (ending in ".d*.nii"). |
surfL_fname |
(Optional) File path to a GIFTI surface geometry file representing the left cortex. |
surfR_fname |
(Optional) File path to a GIFTI surface geometry file representing the right cortex. |
brainstructures |
Character vector indicating which brain structure(s)
to read in: If a brain structure is indicated but does not exist, a warning will be raised and that brain structure will be skipped. |
idx |
Numeric vector indicating the data indices (columns) to read. If
For high-resolution CIFTI files, reading in only a subset of the data saves memory, but will be slower than reading in the entire file due to the required intermediate steps. |
mwall_values |
If the medial wall mask is not present in the CIFTI,
infer it from these data values. Default: |
verbose |
Should occasional updates be printed? Default: |
... |
Additional arguments to |
Value
A "xifti"
object. See is.xifti
.
Read only the data matrix in a CIFTI file
Description
Reads the CIFTI data matrix by converting it to a GIFTI using the
-cifti-convert -to-gifti-ext
Connectome Workbench command. The result
will be a T \times G
matrix (T
measurements, G
non-empty
grayordinates). All brainstructures in the CIFTI will be obtained, with no
indication for which brainstructure each brainordinate corresponds to.
Medial wall vertices and voxels outside the subcortical mask will not be
included. No spatial information is included. This is the fastest way to
read in CIFTI data.
Usage
read_cifti_flat(
cifti_fname,
keep = FALSE,
gifti_fname = NULL,
idx = NULL,
write_dir = NULL
)
Arguments
cifti_fname |
File path to a CIFTI file (ending in ".d*.nii"). |
keep |
This function works by converting the CIFTI file to a GIFTI file
and then reading it in. Should the GIFTI file be kept? If |
gifti_fname |
File path of GIFTI-format data to save the CIFTI as. Should end with ".func.gii" for dscalar and dtseries CIFTI, and ".label.gii" for dlabel CIFTI. Default: the CIFTI_fname but with the CIFTI extension replaced with the appropriate GIFTI extension. |
idx |
Numeric vector indicating the data indices (columns) to read. If
For high-resolution CIFTI files, reading in only a subset of the data saves memory, but will be slower than reading in the entire file due to the required intermediate steps. |
write_dir |
The directory in which to save the GIFTI, if it is being
kept. If |
Value
A T \times G
matrix, where T
is the number of measurements
and G
is the number of grayordinates in the CIFTI file.
Read a CIFTI file with optional resampling
Description
Read a CIFTI file by writing each component into a GIFTI and NIFTI file
(separate_cifti
), optionally resampling the GIFTIs,
(resample_gifti
), and then reading each separated
component into R (make_xifti
). Surfaces can also be provided;
they will be resampled along with the CIFTI for viewing.
Usage
read_cifti_separate(
cifti_fname,
surfL_fname = NULL,
surfR_fname = NULL,
brainstructures = "existing",
idx = NULL,
resamp_res = NULL,
resamp_method = c("barycentric", "adaptive"),
areaL_original_fname = NULL,
areaR_original_fname = NULL,
mwall_values = c(NA, NaN),
verbose = TRUE
)
Arguments
cifti_fname |
File path to a CIFTI file (ending in ".d*.nii"). |
surfL_fname |
(Optional) File path to a GIFTI surface geometry file representing the left cortex. |
surfR_fname |
(Optional) File path to a GIFTI surface geometry file representing the right cortex. |
brainstructures |
Character vector indicating which brain structure(s)
to read in: If a brain structure is indicated but does not exist, a warning will be raised and that brain structure will be skipped. |
idx |
Numeric vector indicating the data indices (columns) to read. If
For high-resolution CIFTI files, reading in only a subset of the data saves memory, but will be slower than reading in the entire file due to the required intermediate steps. |
resamp_res |
(Optional) Target resolution for resampling (number of
cortical surface vertices per hemisphere). If |
resamp_method |
While adaptive resampling is recommended for metric or label
data, it requires that Note that surfaces will resampled using barycentric resampling regardless of
|
areaL_original_fname , areaR_original_fname |
File paths to the surfaces
to use for vertex area correction during adaptive resampling. (Only used if
resampling with the adaptive method.) For resampling: the Workbench command for adaptive resampling requires the
target surfaces for area correction too. But to make the workflow easier,
For remapping: |
mwall_values |
If the medial wall locations are not indicated in the
CIFTI, use these values to infer the medial wall mask. Default:
|
verbose |
Should occasional updates be printed? Default: |
Details
The subcortical component (NIFTI) is not resampled.
Value
A "xifti"
object. See is.xifti
.
read_dir: separated files
Description
read_dir: separated files
Arguments
read_dir |
Directory to append to the path of every file being read,
e.g.
|
Get a "surf"
object
Description
Coerce a file path to a surface GIFTI, a "gifti"
object, a list with
entries "pointset" and "triangle", or a "surf"
to a
"surf"
.
Usage
read_surf(surf, expected_hemisphere = NULL, resamp_res = NULL)
make_surf(surf, expected_hemisphere = NULL, resamp_res = NULL)
Arguments
surf |
Either a file path to a surface GIFTI; a |
expected_hemisphere |
The expected hemisphere ( |
resamp_res |
The resolution to resample the surfaces to. If |
Value
The "surf"
: a list with components "vertices"
(3D spatial locations), "faces"
(defined by three vertices), and
"hemisphere"
("left"
, "right"
, or NULL
if
unknown).
See Also
Other reading:
as.xifti()
,
info_cifti()
,
load_parc()
,
load_surf()
,
read_cifti()
,
read_xifti2()
Other surface-related:
add_surf()
,
boundary_mask_surf()
,
edit_mask_surf()
,
even_vert_samp()
,
is.surf()
,
load_surf()
,
mask_surf()
,
resample_surf()
,
rotate_surf()
,
surf_area()
,
view_surf()
,
write_surf_gifti()
Read in GIFTI files as a "xifti"
object
Description
Read in GIFTI metric or label files as a "xifti"
object. May also include
surface geometry GIFTI files and perform resampling.
Usage
read_xifti2(
cortexL = NULL,
cortexL_mwall = NULL,
cortexR = NULL,
cortexR_mwall = NULL,
mwall_values = c(NA, NaN),
surfL = NULL,
surfR = NULL,
resamp_res = NULL,
col_names = NULL,
HCP_32k_auto_mwall = TRUE,
read_dir = NULL,
validate = TRUE
)
Arguments
cortexL , cortexL_mwall |
Left cortex data and ROI. Each must be a path to a metric or label GIFTI file. If If Since the unmasked cortices must have the same number of vertices,
|
cortexR , cortexR_mwall |
Right cortex data and ROI. Each must be a path to a metric or label GIFTI file. If If Since the unmasked cortices must have the same number of vertices,
|
mwall_values |
If |
surfL , surfR |
(Optional) File path(s) to surface GIFTI(s) for the left or right cortex. |
resamp_res |
Resolution to resample the cortical data and surface to.
Default: |
col_names |
Names of each measurement/column in the data. Overrides names indicated in the data components. |
HCP_32k_auto_mwall |
If left and/or right cortex data is provided, and
the number of vertices matches that of the HCP 32k mesh (29696 on left, and
29716 on right), should the medial wall masks be added to the |
read_dir |
(Optional) Append a directory to all file names in the
arguments. If |
validate |
Validate that the result is a |
Value
The "xifti"
object containing all the data in the input giftis.
See Also
Other reading:
as.xifti()
,
info_cifti()
,
load_parc()
,
load_surf()
,
read_cifti()
,
read_surf()
Remap CIFTI data
Description
Remap CIFTI data between two different spaces, such as between FreeSurfer fsaverage group data and fs_LR group data.
Usage
remap_cifti(
x,
cifti_target_fname = NULL,
remap_method = c("adaptive", "barycentric"),
areaL_original_fname = NULL,
areaR_original_fname = NULL,
areaL_target_fname = NULL,
areaR_target_fname = NULL,
sphereL_original_fname = NULL,
sphereR_original_fname = NULL,
sphereL_target_fname = NULL,
sphereR_target_fname = NULL,
write_dir = NULL,
mwall_values = c(NA, NaN),
verbose = TRUE
)
remapCIfTI(
x,
cifti_target_fname = NULL,
remap_method = c("adaptive", "barycentric"),
areaL_original_fname = NULL,
areaR_original_fname = NULL,
areaL_target_fname = NULL,
areaR_target_fname = NULL,
sphereL_original_fname = NULL,
sphereR_original_fname = NULL,
sphereL_target_fname = NULL,
sphereR_target_fname = NULL,
write_dir = NULL,
mwall_values = c(NA, NaN),
verbose = TRUE
)
remapcii(
x,
cifti_target_fname = NULL,
remap_method = c("adaptive", "barycentric"),
areaL_original_fname = NULL,
areaR_original_fname = NULL,
areaL_target_fname = NULL,
areaR_target_fname = NULL,
sphereL_original_fname = NULL,
sphereR_original_fname = NULL,
sphereL_target_fname = NULL,
sphereR_target_fname = NULL,
write_dir = NULL,
mwall_values = c(NA, NaN),
verbose = TRUE
)
remap_xifti(
x,
cifti_target_fname = NULL,
remap_method = c("adaptive", "barycentric"),
areaL_original_fname = NULL,
areaR_original_fname = NULL,
areaL_target_fname = NULL,
areaR_target_fname = NULL,
sphereL_original_fname = NULL,
sphereR_original_fname = NULL,
sphereL_target_fname = NULL,
sphereR_target_fname = NULL,
write_dir = NULL,
mwall_values = c(NA, NaN),
verbose = TRUE
)
Arguments
x |
The CIFTI file name or |
cifti_target_fname |
File name for the resampled CIFTI. Will be placed
in |
remap_method |
For remapping fs_LR group data to fsaverage, barycentric should be used. For remapping FreeSurfer fsaverage group data to fs_LR, adaptive should be used. |
areaL_original_fname , areaL_target_fname |
File paths to the left cortex
surfaces to use for vertex area correction during adaptive resampling.
Required if |
areaR_original_fname , areaR_target_fname , sphereR_original_fname , sphereR_target_fname |
See the corresponding arguments for the left cortex. |
sphereL_original_fname , sphereL_target_fname |
File paths to the sphere surfaces in the original and target spaces, for the left cortex. |
write_dir |
Where to write the resampled CIFTI (and surfaces if present.)
If |
mwall_values |
If the medial wall locations are not indicated in the
CIFTI, and if Correctly indicating the medial wall locations is important for remapping, because the medial wall mask is taken into account during remapping calculations. |
verbose |
Should occasional updates be printed? Default: |
Details
Can accept a "xifti"
object as well as a path to a CIFTI-file. If
the input "xifti"
object has surface geometry, it will be removed.
This function is in active development: its arguments and behavior may change greatly in future versions of the package.
See Also
Other manipulating xifti:
add_surf()
,
apply_parc()
,
apply_xifti()
,
combine_xifti()
,
convert_xifti()
,
impute_xifti()
,
merge_xifti()
,
move_to_mwall()
,
move_to_submask()
,
newdata_xifti()
,
remove_xifti()
,
resample_cifti()
,
resample_cifti_from_template()
,
scale_xifti()
,
select_xifti()
,
set_names_xifti()
,
smooth_cifti()
,
transform_xifti()
remap_cifti
wrapper
Description
Wrapper for remap_cifti
. Calls resample_cifti_components
using
the original file names listed in the original_fnames
argument and
the target file names listed in the remap_fnames
argument.
Usage
remap_cifti_wrapper(
original_fnames,
remap_fnames = NULL,
remap_method = c("adaptive", "barycentric"),
areaL_original_fname = NULL,
areaR_original_fname = NULL,
areaL_target_fname = NULL,
areaR_target_fname = NULL,
sphereL_original_fname = NULL,
sphereR_original_fname = NULL,
sphereL_target_fname = NULL,
sphereR_target_fname = NULL,
read_dir = NULL,
write_dir = NULL
)
Arguments
original_fnames |
The files to remap. This is a named list
where each element's name is a file type label, and each element's value
is a file name. Labels must be one of the following: "cortexL", "cortexR",
"ROIcortexL", "ROIcortexR". If |
remap_fnames |
Where to write the resampled files. This is a named list where each entry's name is a file type label, and each entry's value is a file name indicating where to write the corresponding resampled file. The recognized file type labels are: "cortexL", "cortexR", "ROIcortexL", "ROIcortexR", "validROIcortexL", and "validROIcortexR". Entry values can be Entries in The |
remap_method |
For remapping between fs_LR group data and FreeSurfer fsaverage group data, adaptive resampling should be used. |
areaL_original_fname , areaR_original_fname |
File paths to the surfaces
to use for vertex area correction during adaptive resampling. (Only used if
resampling with the adaptive method.) For resampling: the Workbench command for adaptive resampling requires the
target surfaces for area correction too. But to make the workflow easier,
For remapping: |
areaL_target_fname , areaR_target_fname |
File paths to the surfaces
to use for vertex area correction during adaptive resampling. (Only used if
resampling with the adaptive method.) |
read_dir |
Directory to append to the path of every file being read,
e.g.
|
write_dir |
Where should the separate files be placed?
|
Value
The return value of the resample_cifti_components
call
Remap GIFTI metric or label data
Description
Remap GIFTI metric or label data between two different spaces, such as
between FreeSurfer fsaverage group data and fs_LR group data. This function
is a wrapper to resample_gifti
.
Usage
remap_gifti(
original_fname,
target_fname,
hemisphere = c("left", "right"),
remap_method = c("adaptive", "barycentric"),
area_original_fname,
area_target_fname,
ROIcortex_original_fname,
ROIcortex_target_fname,
sphere_original_fname,
sphere_target_fname
)
Arguments
original_fname |
The GIFTI file to remap. |
target_fname |
Where to save the remapped file. |
hemisphere |
|
remap_method |
For remapping between fs_LR group data and FreeSurfer fsaverage group data, adaptive resampling should be used. |
area_original_fname , area_target_fname |
File paths to the surfaces to
use for vertex area correction during adaptive resampling. Required if
|
ROIcortex_original_fname , ROIcortex_target_fname |
|
sphere_original_fname , sphere_target_fname |
File paths to the sphere surfaces in the original and target spaces. |
Value
The remapped GIFTI file name, invisibly
Connectome Workbench
This function interfaces with the "-metric-resample"
, "-label-resample"
,
and/or "-surface-resample"
Workbench commands, depending on the input.
See Also
Other gifting:
resample_gifti()
,
smooth_gifti()
Remove a component from a "xifti"
Description
Remove a brain structure, surface, or subcortical structure from a
"xifti"
.
Usage
remove_xifti(xifti, remove = NULL, remove_sub = NULL)
Arguments
xifti |
A |
remove |
A character vector containing one or more of the following:
|
remove_sub |
A vector containing subcortical structures to be removed
from |
Value
The new "xifti"
with the requested component(s) removed
See Also
Other manipulating xifti:
add_surf()
,
apply_parc()
,
apply_xifti()
,
combine_xifti()
,
convert_xifti()
,
impute_xifti()
,
merge_xifti()
,
move_to_mwall()
,
move_to_submask()
,
newdata_xifti()
,
remap_cifti()
,
resample_cifti()
,
resample_cifti_from_template()
,
scale_xifti()
,
select_xifti()
,
set_names_xifti()
,
smooth_cifti()
,
transform_xifti()
resamp_method
Description
resamp_method
Arguments
resamp_method |
While adaptive resampling is recommended for metric or label
data, it requires that Note that surfaces will resampled using barycentric resampling regardless of
|
resamp_res: optional
Description
resamp_res: optional
Arguments
resamp_res |
(Optional) Target resolution for resampling (number of
cortical surface vertices per hemisphere). If |
resamp_res: required
Description
resamp_res: required
Arguments
resamp_res |
Target resolution for resampling (number of cortical surface vertices per hemisphere). |
Resample CIFTI data
Description
Performs spatial resampling of CIFTI data on the cortical surface by separating it into GIFTI and NIFTI files, resampling the GIFTIs, and then putting them together. (The subcortex is not resampled.)
Usage
resample_cifti(
x = NULL,
cifti_target_fname = NULL,
surfL_original_fname = NULL,
surfR_original_fname = NULL,
surfL_target_fname = NULL,
surfR_target_fname = NULL,
resamp_res,
resamp_method = c("barycentric", "adaptive"),
areaL_original_fname = NULL,
areaR_original_fname = NULL,
write_dir = NULL,
mwall_values = c(NA, NaN),
verbose = TRUE
)
resampleCIfTI(
x = NULL,
cifti_target_fname = NULL,
surfL_original_fname = NULL,
surfR_original_fname = NULL,
surfL_target_fname = NULL,
surfR_target_fname = NULL,
resamp_res,
resamp_method = c("barycentric", "adaptive"),
areaL_original_fname = NULL,
areaR_original_fname = NULL,
write_dir = NULL,
mwall_values = c(NA, NaN),
verbose = TRUE
)
resamplecii(
x = NULL,
cifti_target_fname = NULL,
surfL_original_fname = NULL,
surfR_original_fname = NULL,
surfL_target_fname = NULL,
surfR_target_fname = NULL,
resamp_res,
resamp_method = c("barycentric", "adaptive"),
areaL_original_fname = NULL,
areaR_original_fname = NULL,
write_dir = NULL,
mwall_values = c(NA, NaN),
verbose = TRUE
)
resample_xifti(
x = NULL,
cifti_target_fname = NULL,
surfL_original_fname = NULL,
surfR_original_fname = NULL,
surfL_target_fname = NULL,
surfR_target_fname = NULL,
resamp_res,
resamp_method = c("barycentric", "adaptive"),
areaL_original_fname = NULL,
areaR_original_fname = NULL,
write_dir = NULL,
mwall_values = c(NA, NaN),
verbose = TRUE
)
Arguments
x |
The CIFTI file name or |
cifti_target_fname |
File name for the resampled CIFTI. Will be placed
in |
surfL_original_fname , surfR_original_fname |
(Optional) Path to a GIFTI surface geometry file representing the left/right cortex. One or both can be provided. These will be resampled too, and are convenient for visualizing the resampled data. If |
surfL_target_fname , surfR_target_fname |
(Optional) File names for the
resampled GIFTI surface geometry files. Will be placed in |
resamp_res |
Target resolution for resampling (number of cortical surface vertices per hemisphere). |
resamp_method |
While adaptive resampling is recommended for metric or label
data, it requires that Note that surfaces will resampled using barycentric resampling regardless of
|
areaL_original_fname , areaR_original_fname |
File paths to the surfaces
to use for vertex area correction during adaptive resampling. (Only used if
resampling with the adaptive method.) For resampling: the Workbench command for adaptive resampling requires the
target surfaces for area correction too. But to make the workflow easier,
For remapping: |
write_dir |
Where to write the resampled CIFTI (and surfaces if present.)
If |
mwall_values |
If the medial wall locations are not indicated in the
CIFTI, use these values to infer the medial wall mask. Default:
Correctly indicating the medial wall locations is important for resampling, because the medial wall mask is taken into account during resampling calculations. |
verbose |
Should occasional updates be printed? Default: |
Details
Can accept a "xifti"
object as well as a path to a CIFTI-file.
If surface data is included, it will be resampled with the barycentric
method even if resamp_method=="adaptive"
because the barycentric
method is recommended for surface geometry data.
Value
A named character vector of written files: "cifti"
and
potentially "surfL"
(if surfL_original_fname
was provided)
and/or "surfR"
(if surfR_original_fname
was provided).
Connectome Workbench
This function interfaces with the "-metric-resample"
, "-label-resample"
,
and/or "-surface-resample"
Workbench commands, depending on the input.
See Also
Other manipulating xifti:
add_surf()
,
apply_parc()
,
apply_xifti()
,
combine_xifti()
,
convert_xifti()
,
impute_xifti()
,
merge_xifti()
,
move_to_mwall()
,
move_to_submask()
,
newdata_xifti()
,
remap_cifti()
,
remove_xifti()
,
resample_cifti_from_template()
,
scale_xifti()
,
select_xifti()
,
set_names_xifti()
,
smooth_cifti()
,
transform_xifti()
Other common:
is.cifti()
,
read_cifti()
,
smooth_cifti()
,
view_xifti()
,
write_cifti()
Resample a series of GIFTIs related to a CIFTI file
Description
Performs spatial resampling of various CIFTI file components on
the cortical surface. (The subcortical data is not resampled here.)
GIFTI surface geometry files can additionally be included: see
surfL_original_fname
and surfR_original_fname
.
Usage
resample_cifti_components(
original_res = NULL,
resamp_res = NULL,
resamp_method = NULL,
areaL_original_fname = NULL,
areaR_original_fname = NULL,
areaL_target_fname = NULL,
areaR_target_fname = NULL,
cortexL_original_fname = NULL,
cortexR_original_fname = NULL,
cortexL_target_fname = NULL,
cortexR_target_fname = NULL,
ROIcortexL_original_fname = NULL,
ROIcortexR_original_fname = NULL,
ROIcortexL_target_fname = NULL,
ROIcortexR_target_fname = NULL,
sphereL_original_fname = NULL,
sphereR_original_fname = NULL,
sphereL_target_fname = NULL,
sphereR_target_fname = NULL,
surfL_original_fname = NULL,
surfR_original_fname = NULL,
surfL_target_fname = NULL,
surfR_target_fname = NULL,
read_dir = NULL,
write_dir = NULL
)
Arguments
original_res |
The original resolution(s) of the CIFTI cortical surface(s). |
resamp_res |
Target resolution for resampling (number of cortical surface vertices per hemisphere). |
resamp_method |
While adaptive resampling is recommended for metric or label
data, it requires that Note that surfaces will resampled using barycentric resampling regardless of
|
areaL_original_fname , areaR_original_fname |
File paths to the surfaces
to use for vertex area correction during adaptive resampling. (Only used if
resampling with the adaptive method.) For resampling: the Workbench command for adaptive resampling requires the
target surfaces for area correction too. But to make the workflow easier,
For remapping: |
areaL_target_fname , areaR_target_fname |
File paths to the surfaces
to use for vertex area correction during adaptive resampling. (Only used if
resampling with the adaptive method.) |
cortexL_original_fname , cortexR_original_fname |
(Optional) File path of GIFTI data for [left/right] cortex to resample. |
cortexL_target_fname , cortexR_target_fname |
(Optional) File path to
save the resampled GIFTI data for [left/right] cortex as.
If NULL (default) and |
ROIcortexL_original_fname , ROIcortexR_original_fname |
(Optional) File
path of GIFTI ROI corresponding to |
ROIcortexL_target_fname , ROIcortexR_target_fname |
(Optional) File path
of to save the resampled GIFTI ROI corresponding to
|
surfL_original_fname |
(Optional) File path to a GIFTI surface geometry file representing the left cortex. |
surfR_original_fname |
(Optional) File path to a GIFTI surface geometry file representing the right cortex. |
surfL_target_fname |
(Optional) Where to save the resampled GIFTI surface geometry file representing the left cortex. |
surfR_target_fname |
(Optional) Where to save the resampled GIFTI surface geometry file representing the right cortex. |
read_dir |
Directory to append to the path of every file being read,
e.g.
|
write_dir |
Where should the separate files be placed?
|
Details
Step 1: Generate spheres in the original and target resolutions Step 2: Use -metric-resample to resample surface/cortex files Step 3: Use -surface-resample to resample gifti files
Value
A named character vector of file paths to each resampled file
Get resampled file name default
Description
Get the default file name for a resampled file.
Usage
resample_cifti_default_fname(original_fname, resamp_res)
Arguments
original_fname |
The original file name |
resamp_res |
Target resolution for resampling (number of cortical surface vertices per hemisphere). |
Value
The default file name
Resample a CIFTI from a template
Description
Resample a CIFTI from a template, ensuring the new CIFTI's resolution matches that of the template.
Usage
resample_cifti_from_template(original_fname, template_fname, target_fname)
Arguments
original_fname |
A CIFTI file to resample. |
template_fname |
A CIFTI file to use as the template. |
target_fname |
The file name to save the resampled CIFTI. |
Value
The target_fname
, invisibly
Connectome Workbench
This function interfaces with the "-cifti-resample"
Workbench command.
See Also
Other manipulating xifti:
add_surf()
,
apply_parc()
,
apply_xifti()
,
combine_xifti()
,
convert_xifti()
,
impute_xifti()
,
merge_xifti()
,
move_to_mwall()
,
move_to_submask()
,
newdata_xifti()
,
remap_cifti()
,
remove_xifti()
,
resample_cifti()
,
scale_xifti()
,
select_xifti()
,
set_names_xifti()
,
smooth_cifti()
,
transform_xifti()
resample_cifti
wrapper
Description
Calls resample_cifti_components
using the original file names
listed in the original_fnames
argument and the target file names
listed in the resamp_fnames
argument.
Usage
resample_cifti_wrapper(
original_fnames,
resamp_fnames = NULL,
original_res,
resamp_res,
resamp_method = c("barycentric", "adaptive"),
areaL_original_fname = NULL,
areaR_original_fname = NULL,
surfL_original_fname = NULL,
surfR_original_fname = NULL,
surfL_target_fname = NULL,
surfR_target_fname = NULL,
read_dir = NULL,
write_dir = NULL
)
Arguments
original_fnames |
The files to resample. This is a named list
where each element's name is a file type label, and each element's value
is a file name. Labels must be one of the following: "cortexL", "cortexR",
"ROIcortexL", "ROIcortexR", "surfL", or "surfR". If
|
resamp_fnames |
Where to write the resampled files. This is a named list where each entry's name is a file type label, and each entry's value is a file name indicating where to write the corresponding resampled file. The recognized file type labels are: "cortexL", "cortexR", "ROIcortexL", "ROIcortexR", "validROIcortexL", and "validROIcortexR". Entry values can be Entries in The |
original_res |
The original resolution(s) of the CIFTI cortical surface(s). |
resamp_res |
Target resolution for resampling (number of cortical surface vertices per hemisphere). |
surfL_target_fname , surfR_target_fname |
(Optional) File path for the resampled GIFTI surface geometry file representing the left/right cortex. If NULL (default), |
read_dir |
Directory to append to the path of every file being read,
e.g.
|
write_dir |
Where should the separate files be placed?
|
Details
Currently used by read_cifti and resample_cifti.
Value
The return value of the resample_cifti_components
call
Resample a GIFTI file (with its ROI)
Description
Perform spatial resampling of GIFTI data on the cortical surface (metric and label), or of GIFTI surface geometry data itself.
Usage
resample_gifti(
original_fname,
target_fname,
hemisphere = c("left", "right"),
file_type = NULL,
original_res = NULL,
resamp_res = NULL,
resamp_method = c("barycentric", "adaptive"),
area_original_fname = NULL,
area_target_fname = NULL,
ROIcortex_original_fname = NULL,
ROIcortex_target_fname = NULL,
sphere_original_fname = NULL,
sphere_target_fname = NULL,
read_dir = NULL,
write_dir = NULL
)
resampleGIfTI(
original_fname,
target_fname,
hemisphere,
file_type = NULL,
original_res = NULL,
resamp_res,
ROIcortex_original_fname = NULL,
ROIcortex_target_fname = NULL,
read_dir = NULL,
write_dir = NULL
)
resamplegii(
original_fname,
target_fname,
hemisphere,
file_type = NULL,
original_res = NULL,
resamp_res,
ROIcortex_original_fname = NULL,
ROIcortex_target_fname = NULL,
read_dir = NULL,
write_dir = NULL
)
Arguments
original_fname |
The GIFTI file to resample. |
target_fname |
Where to save the resampled file. |
hemisphere |
|
file_type |
|
original_res |
The resolution of the original file. If In general, |
resamp_res |
Target resolution for resampling (number of
cortical surface vertices per hemisphere). Alternatively, provide
In general, |
resamp_method |
While adaptive resampling is recommended for metric or label
data, it requires that |
area_original_fname , area_target_fname |
File paths to the surfaces to
use for vertex area correction during adaptive resampling. (Ignored if
resampling with the barycentric method.) |
ROIcortex_original_fname |
The name of the ROI file corresponding to
|
ROIcortex_target_fname |
The name of the resampled ROI file. Only
applicable if |
sphere_original_fname , sphere_target_fname |
File paths to the sphere
surfaces in the original and target resolutions. If possible, the simpler
arguments |
read_dir |
Directory to append to the path of every file name in
|
write_dir |
Directory to append to the path of every file name in
|
Value
The resampled GIFTI file name, invisibly
Connectome Workbench
This function interfaces with the "-metric-resample"
, "-label-resample"
,
and/or "-surface-resample"
Workbench commands, depending on the input.
See Also
Other gifting:
remap_gifti()
,
smooth_gifti()
Resample a "surf"
object
Description
Resample a "surf"
object by writing it to a GIFTI, using the Connectome
Workbench to resample it, and then reading the new file. The barycentric
resampling method, which is recommended for anatomical surfaces, will be
used.
Usage
resample_surf(surf, resamp_res, hemisphere = c("left", "right"))
Arguments
surf |
A |
resamp_res |
The desired resolution |
hemisphere |
|
Value
The new "surf"
Connectome Workbench
This function interfaces with the "-surface-resample"
Workbench command.
See Also
Other surface-related:
add_surf()
,
boundary_mask_surf()
,
edit_mask_surf()
,
even_vert_samp()
,
is.surf()
,
load_surf()
,
mask_surf()
,
read_surf()
,
rotate_surf()
,
surf_area()
,
view_surf()
,
write_surf_gifti()
Navigating and Embedding the Interactive Plots
Description
Navigating and Embedding the Interactive Plots
Navigating and Embedding the Interactive Plots
To navigate the interactive Open GL window and html widget, left click and
drag the cursor to rotate the meshes. Use the scroll wheel or right click
and drag to zoom. Press the scroll wheel and drag to change the field-of-view.
For Open GL windows, execute
snapshot
to save the current window as a .png file,
close3d
to close the window, and
view3d
to programmatically control the
perspective.
To embed an interactive plot in an R Markdown document, first execute
rgl::setupKnitr()
to prepare the document for embedding the widget.
Then execute the plot command as you normally would to create a widget (i.e.
without specifying fname
, and by requesting more than one idx
or by setting widget
to TRUE
). When the R Markdown document is
knitted, the interactive widget should be displayed below the chunk in which
the plot command was executed. See the vignette for an example.
Embedding the Static Plots
Description
Embedding the Static Plots
Embedding the Static Plots
To embed a static plot in an R Markdown document, first execute
rgl::setupKnitr()
to prepare the document for embedding the snapshot
of the Open GL window. Then execute the plot command as you normally would
to create an Open GL window (i.e. without specifying fname
, and by
requesting only one idx
). In the options for the chunk in which the
plot command is executed, set rgl=TRUE, format="png"
. You can also
control the image dimensions here e.g. fig.height=3.8, fig.width=5
.
When the R Markdown document is knitted, the static plots should be
displayed below the chunk in which the plot command was executed. See the
vignette for an example.
Rotate a "surf"
object
Description
Rotate a "surf"
. Can be used to adjust the mesh orientation prior
to view_xifti_surface
.
Usage
rotate_surf(surf, r1 = 0, r2 = 0, r3 = 0, units = c("radians", "degrees"))
Arguments
surf |
The |
r1 , r2 , r3 |
Angle to rotate along the first, second, and third column's
axis, in With |
units |
|
Value
The rotated "surf"
See Also
Other surface-related:
add_surf()
,
boundary_mask_surf()
,
edit_mask_surf()
,
even_vert_samp()
,
is.surf()
,
load_surf()
,
mask_surf()
,
read_surf()
,
resample_surf()
,
surf_area()
,
view_surf()
,
write_surf_gifti()
Wrapper for Connectome Workbench Commands
Description
Runs a Connectome Workbench command that has already been formatted.
Usage
run_wb_cmd(cmd, intern = TRUE, ignore.stdout = NULL, ignore.stderr = NULL)
Arguments
cmd |
The full command, beginning after the workbench path. |
intern |
Return printed output? If |
ignore.stdout , ignore.stderr |
The "ignore.stdout" and "ignore.stderr"
arguments to |
Value
If intern==TRUE
, the printed output of the command.
If intern==FALSE
, a logical indicating if the command finished
successfully.
Scale CIFTI
Description
Scale CIFTI data. Similar to scale
.
Usage
scale_xifti(xifti, center = TRUE, scale = TRUE)
Arguments
xifti |
A |
center , scale |
Arguments to |
Value
The input "xifti"
with scaled columns.
See Also
Other manipulating xifti:
add_surf()
,
apply_parc()
,
apply_xifti()
,
combine_xifti()
,
convert_xifti()
,
impute_xifti()
,
merge_xifti()
,
move_to_mwall()
,
move_to_submask()
,
newdata_xifti()
,
remap_cifti()
,
remove_xifti()
,
resample_cifti()
,
resample_cifti_from_template()
,
select_xifti()
,
set_names_xifti()
,
smooth_cifti()
,
transform_xifti()
Select columns of a "xifti"
Description
Select column indices to keep in a "xifti"
. Can also be used to
reorder the columns.
Usage
select_xifti(xifti, idx, add_meta = "select")
Arguments
xifti |
A |
idx |
The column indices to keep, in order. |
add_meta |
Add |
Value
The "xifti"
with only the selected columns.
See Also
Other manipulating xifti:
add_surf()
,
apply_parc()
,
apply_xifti()
,
combine_xifti()
,
convert_xifti()
,
impute_xifti()
,
merge_xifti()
,
move_to_mwall()
,
move_to_submask()
,
newdata_xifti()
,
remap_cifti()
,
remove_xifti()
,
resample_cifti()
,
resample_cifti_from_template()
,
scale_xifti()
,
set_names_xifti()
,
smooth_cifti()
,
transform_xifti()
Separate a CIFTI file
Description
Separate a CIFTI file into GIFTI files for the cortical data and NIFTI files
for the subcortical data and labels. ROIs can also be written to indicate
the medial wall mask (cortex) and volume mask (subcortex). This uses the
Connectome Workbench command -cifti-separate
.
Usage
separate_cifti(
cifti_fname,
brainstructures = "existing",
cortexL_fname = NULL,
cortexR_fname = NULL,
subcortVol_fname = NULL,
subcortLabs_fname = NULL,
ROI_brainstructures = "all",
ROIcortexL_fname = NULL,
ROIcortexR_fname = NULL,
ROIsubcortVol_fname = NULL,
write_dir = NULL
)
separateCIfTI(
cifti_fname,
brainstructures = "existing",
cortexL_fname = NULL,
cortexR_fname = NULL,
subcortVol_fname = NULL,
subcortLabs_fname = NULL,
ROI_brainstructures = "all",
ROIcortexL_fname = NULL,
ROIcortexR_fname = NULL,
ROIsubcortVol_fname = NULL,
write_dir = NULL
)
separatecii(
cifti_fname,
brainstructures = "existing",
cortexL_fname = NULL,
cortexR_fname = NULL,
subcortVol_fname = NULL,
subcortLabs_fname = NULL,
ROI_brainstructures = "all",
ROIcortexL_fname = NULL,
ROIcortexR_fname = NULL,
ROIsubcortVol_fname = NULL,
write_dir = NULL
)
Arguments
cifti_fname |
File path to a CIFTI file (ending in ".d*.nii"). |
brainstructures |
What brain structure(s) to write: |
cortexL_fname , cortexR_fname |
(Optional) GIFTI file names (*.[func/label].gii) to save the [left/right] cortex data to. dtseries and dscalar files should use "func", whereas dlabel files should use "label". If |
subcortVol_fname , subcortLabs_fname |
(Optional) NIFTI file names to save the subcortical [volume/labels] to. Provide both or neither. If |
ROI_brainstructures |
Which ROIs should be obtained? |
ROIcortexL_fname , ROIcortexR_fname |
(Optional) GIFTI file names (*.[func/label].gii) to save the [left/right] cortex ROI to. dtseries and dscalar files should use "func", whereas dlabel files should use "label". If The cortical ROIs typically represent the medial wall
mask, with values of 1 for in-ROI (non-medial wall) vertices and 0 for
out-of-ROI (medial wall) vertices. Will be written in |
ROIsubcortVol_fname |
(Optional) NIFTI file names to save the subcortical ROI to. If The subcortical ROI typically represents the volumetric
mask for the entire subcortical structure, with values of 1 for in-ROI
(in subcortex) voxels and 0 for out-of-ROI (not in subcortex) voxels. Will
be written in |
write_dir |
(Optional) A path to an existing directory. If provided,
every component in the |
Details
Time unit, start, and step (dtseries files) will not be written to the GIFTI/NIFTIs. Column names (dscalar files) will not be written to the GIFTIs, as well as label names and colors (dlabel files). (Haven't checked the NIFTIs yet.)
ROI/medial wall behavior: If there are 32k vertices in the left cortex with
3k representing the medial wall, then both cortexL_fname
and
ROIcortexL_fname
will have 32k entries, 3k of which having a value of
0 indicating the medial wall. The non-medial wall entries will have the
data values in cortexL_fname
and a value of 1 in
ROIcortexL_fname
. Thus, exporting ROIcortexL_fname
is vital if
the data values include 0, because 0-valued non-medial wall vertices and
medial wall vertices cannot be distinguished from one another within
cortexL_fname
alone.
Value
A named character vector with the file paths to the written NIFTI and GIFTI files
Connectome Workbench
This function interfaces with the "-cifti-separate"
Workbench command.
See Also
Other writing:
write_cifti()
,
write_metric_gifti()
,
write_subcort_nifti()
,
write_surf_gifti()
,
write_xifti2()
Separate CIFTI: file names
Description
File paths for writing GIFTI and NIFTI files from a CIFTI or "xifti"
Usage
separate_cifti_files(
bs_present,
intent = 3006,
brainstructures = "existing",
cortexL_fname = NULL,
cortexR_fname = NULL,
subcortVol_fname = NULL,
subcortLabs_fname = NULL,
ROI_brainstructures = "all",
ROIcortexL_fname = NULL,
ROIcortexR_fname = NULL,
ROIsubcortVol_fname = NULL,
write_dir = NULL
)
Arguments
bs_present |
The brain structures actually present in the CIFTI or
|
intent |
3002 (default), 3006, or 3007 |
brainstructures |
What brain structure(s) to write: |
cortexL_fname , cortexR_fname |
(Optional) GIFTI file names (*.[func/label].gii) to save the [left/right] cortex data to. dtseries and dscalar files should use "func", whereas dlabel files should use "label". If |
subcortVol_fname , subcortLabs_fname |
(Optional) NIFTI file names to save the subcortical [volume/labels] to. Provide both or neither. If |
ROI_brainstructures |
Which ROIs should be obtained? |
ROIcortexL_fname , ROIcortexR_fname |
(Optional) GIFTI file names (*.[func/label].gii) to save the [left/right] cortex ROI to. dtseries and dscalar files should use "func", whereas dlabel files should use "label". If The cortical ROIs typically represent the medial wall
mask, with values of 1 for in-ROI (non-medial wall) vertices and 0 for
out-of-ROI (medial wall) vertices. Will be written in |
ROIsubcortVol_fname |
(Optional) NIFTI file names to save the subcortical ROI to. If The subcortical ROI typically represents the volumetric
mask for the entire subcortical structure, with values of 1 for in-ROI
(in subcortex) voxels and 0 for out-of-ROI (not in subcortex) voxels. Will
be written in |
write_dir |
(Optional) A path to an existing directory. If provided,
every component in the |
Details
If write_dir
is NULL
, only components with provided file names
will be written. If write_dir
is not NULL
, files for all
existing brain components will be written to that directory.
Value
List of three: do
, ROI_do
, and sep_fnames
separate_cifti
wrapper
Description
Calls separate_cifti
using the file names listed in the
argument sep_fnames
.
Usage
separate_cifti_wrapper(
cifti_fname,
brainstructures = "existing",
ROI_brainstructures = "all",
sep_fnames = NULL,
write_dir = NULL
)
Arguments
cifti_fname |
File path to a CIFTI file (ending in ".d*.nii"). |
brainstructures |
Character vector indicating which brain structure(s)
to read in: If a brain structure is indicated but does not exist, a warning will be raised and that brain structure will be skipped. |
ROI_brainstructures |
Character vector indicating which ROIs should be
obtained. ROIs are typically the medial wall masks for the left and right cortex, and the subcortical mask for the subcortex. |
sep_fnames |
Where to write the separated files (override their default file names). This is a named list where each entry's name is a file type label, and each entry's value is a file name indicating where to write the corresponding separated file. The recognized file type labels are: "cortexL", "cortexR", "ROIcortexL", "ROIcortexR", "subcortVol", and "subcortLabs". Entry values can be Entries in The |
write_dir |
Where should the separate files be placed?
|
Details
Currently used by read_cifti
and resample_cifti
.
Value
The return value of the separate_cifti
call
Set "xifti"
column names
Description
Change the column names of a "dscalar"
or "dlabel"
"xifti"
object.
Usage
set_names_xifti(xifti, names)
Arguments
xifti |
A |
names |
The new column names, as a character vector with length
equal to the same number of columns in |
Value
xifti
with the new column names.
See Also
Other manipulating xifti:
add_surf()
,
apply_parc()
,
apply_xifti()
,
combine_xifti()
,
convert_xifti()
,
impute_xifti()
,
merge_xifti()
,
move_to_mwall()
,
move_to_submask()
,
newdata_xifti()
,
remap_cifti()
,
remove_xifti()
,
resample_cifti()
,
resample_cifti_from_template()
,
scale_xifti()
,
select_xifti()
,
smooth_cifti()
,
transform_xifti()
Smooth CIFTI data
Description
Spatially smooth the metric data of a CIFTI file or "xifti"
object.
Usage
smooth_cifti(
x,
cifti_target_fname = NULL,
surf_FWHM = 5,
vol_FWHM = 3,
surfL_fname = NULL,
surfR_fname = NULL,
cerebellum_fname = NULL,
subcortical_zeroes_as_NA = FALSE,
cortical_zeroes_as_NA = FALSE,
subcortical_merged = FALSE
)
smoothCIfTI(
x,
cifti_target_fname = NULL,
surf_FWHM = 5,
vol_FWHM = 5,
surfL_fname = NULL,
surfR_fname = NULL,
cerebellum_fname = NULL,
subcortical_zeroes_as_NA = FALSE,
cortical_zeroes_as_NA = FALSE,
subcortical_merged = FALSE
)
smoothcii(
x,
cifti_target_fname = NULL,
surf_FWHM = 5,
vol_FWHM = 5,
surfL_fname = NULL,
surfR_fname = NULL,
cerebellum_fname = NULL,
subcortical_zeroes_as_NA = FALSE,
cortical_zeroes_as_NA = FALSE,
subcortical_merged = FALSE
)
smooth_xifti(
x,
cifti_target_fname = NULL,
surf_FWHM = 5,
vol_FWHM = 5,
surfL_fname = NULL,
surfR_fname = NULL,
cerebellum_fname = NULL,
subcortical_zeroes_as_NA = FALSE,
cortical_zeroes_as_NA = FALSE,
subcortical_merged = FALSE
)
Arguments
x |
The CIFTI file name or |
cifti_target_fname |
File name for the smoothed CIFTI. If
|
surf_FWHM , vol_FWHM |
The full width at half maximum (FWHM) parameter
for the gaussian surface or volume smoothing kernel, in mm. Default: |
surfL_fname , surfR_fname |
(Required if the corresponding cortex is
present) Surface GIFTI files for the left and right cortical surfaces. If
not provided, the surfaces in |
cerebellum_fname |
(Optional) Surface GIFTI file for the cerebellar surface |
subcortical_zeroes_as_NA , cortical_zeroes_as_NA |
Should zero-values in
the subcortical volume or cortex be treated as NA? Default: |
subcortical_merged |
Smooth across subcortical structure boundaries?
Default: |
Details
If the CIFTI is a ".dlabel" file (intent 3007), then it will be converted to a ".dscalar" file because the values will no longer be integer indices. Unless the label values were ordinal, this is probably not desired so a warning will be printed.
Can accept a "xifti"
object as well as a path to a CIFTI-file.
Surfaces are required for each hemisphere in the CIFTI. If they are not provided, the default inflated surfaces will be used.
Conversion for sigma: \sigma \times 2 \times \sqrt(2 \times \log(2)) = FWHM
Value
The cifti_target_fname
, invisibly, if x
was a CIFTI
file name. A "xifti"
object if x
was a "xifti"
object.
Connectome Workbench
This function interfaces with the "-cifti-smoothing"
Workbench command.
See Also
Other manipulating xifti:
add_surf()
,
apply_parc()
,
apply_xifti()
,
combine_xifti()
,
convert_xifti()
,
impute_xifti()
,
merge_xifti()
,
move_to_mwall()
,
move_to_submask()
,
newdata_xifti()
,
remap_cifti()
,
remove_xifti()
,
resample_cifti()
,
resample_cifti_from_template()
,
scale_xifti()
,
select_xifti()
,
set_names_xifti()
,
transform_xifti()
Other common:
is.cifti()
,
read_cifti()
,
resample_cifti()
,
view_xifti()
,
write_cifti()
Smooth a metric GIFTI file
Description
Smooths metric GIFTI data along the cortical surface. The results are written to a new GIFTI file.
Usage
smooth_gifti(
original_fname,
target_fname,
surf_fname = NULL,
surf_FWHM = 5,
hemisphere = c("left", "right"),
ROI_fname = NULL,
zeroes_as_NA = FALSE
)
smoothGIfTI(
original_fname,
target_fname,
surf_fname,
surf_FWHM = 5,
zeroes_as_NA = FALSE
)
smoothgii(
original_fname,
target_fname,
surf_fname,
surf_FWHM = 5,
zeroes_as_NA = FALSE
)
Arguments
original_fname |
The GIFTI file to smooth. |
target_fname |
Where to save the smoothed file. |
surf_fname |
Surface GIFTI files cortical surface along which to smooth. If not provided, the default inflated surfaces will be used. |
surf_FWHM |
The full width at half maximum (FWHM) parameter
for the gaussian surface smoothing kernel, in mm. Default: |
hemisphere |
The cortex hemisphere: |
ROI_fname |
The ROI to limit smoothing to, as a metric file. This is used to exclude the medial wall from smoothing. If not provided (default) all the data is smoothed across the surface. |
zeroes_as_NA |
Should zero-values be treated as NA? Default: |
Value
The smoothed GIFTI file name, invisibly
Connectome Workbench
This function interfaces with the "-metric-smoothing"
Workbench command.
See Also
Other gifting:
remap_gifti()
,
resample_gifti()
Substructure table
Description
Table of labels for cortex hemispheres (left and right) and subcortical
substructures. The same labels used by the HCP data are here, plus "Other".
Names from the CIFTI format ("CIFTI_STRUCTURE_*") and the names used by
ciftiTools
are given.
Usage
substructure_table()
Details
The names used by ciftiTools
are based on those in
FT_READ_CIFTI
from the FieldTrip MATLAB toolbox.
Value
A data.frame with each substructure along the rows. The first
column gives the CIFTI format name and the second column gives the
ciftiTools
name.
Summarize a "surf"
object
Description
Summary method for class "surf"
Usage
## S3 method for class 'surf'
summary(object, ...)
## S3 method for class 'summary.surf'
print(x, ...)
## S3 method for class 'surf'
print(x, ...)
Arguments
object |
|
... |
further arguments passed to or from other methods. |
x |
Object of class "surf". |
Summarize a "xifti"
object
Description
Summary method for class "xifti"
Usage
## S3 method for class 'xifti'
summary(object, ...)
## S3 method for class 'summary.xifti'
print(x, ...)
## S3 method for class 'xifti'
print(x, ...)
Arguments
object |
Object of class |
... |
further arguments passed to or from other methods. |
x |
A |
The NIFTI intents supported by ciftiTools
Description
Table of CIFTI file types (NIFTI intents) supported by ciftiTools
.
Usage
supported_intents()
Details
See https://www.nitrc.org/forum/attachment.php?attachid=334&group_id=454&forum_id=1955 for information about the different NIFTI intents.
Value
A data.frame
with each supported file type along the rows, and
column names "extension", "intent_code", "value", and "intent_name"
surfL
Description
surfL
Arguments
surfL |
(Optional) Left brain surface model. Can be a file
path to a GIFTI surface geometry file (ends in "*.surf.gii"), a
|
surfL_fname
Description
surfL_fname
Arguments
surfL_fname |
(Optional) File path to a GIFTI surface geometry file representing the left cortex. |
surfL_original_fname
Description
surfL_original_fname
Arguments
surfL_original_fname |
(Optional) File path to a GIFTI surface geometry file representing the left cortex. |
surfL_target_fname
Description
surfL_target_fname
Arguments
surfL_target_fname |
(Optional) Where to save the resampled GIFTI surface geometry file representing the left cortex. |
surfR
Description
surfR
Arguments
surfR |
(Optional) Right brain surface model. Can be a file
path to a GIFTI surface geometry file (ends in "*.surf.gii"), a
|
surfR_fname
Description
surfR_fname
Arguments
surfR_fname |
(Optional) File path to a GIFTI surface geometry file representing the right cortex. |
surfR_original_fname
Description
surfR_original_fname
Arguments
surfR_original_fname |
(Optional) File path to a GIFTI surface geometry file representing the right cortex. |
surfR_target_fname
Description
surfR_target_fname
Arguments
surfR_target_fname |
(Optional) Where to save the resampled GIFTI surface geometry file representing the right cortex. |
Surface area calculation
Description
Calculate surface area of a "surf"
object by vertex or face. Surface
area calculation by vertex matches the Workbench command
"-surface-vertex-areas".
Usage
surf_area(surf, by = c("vertex", "face"))
Arguments
surf |
The |
by |
|
Value
Vector of surface areas by
vertex or face, in the same order
as how the vertices or faces are listed in surf
. The units are the
square of the units of surf$vertices
.
See Also
Other surface-related:
add_surf()
,
boundary_mask_surf()
,
edit_mask_surf()
,
even_vert_samp()
,
is.surf()
,
load_surf()
,
mask_surf()
,
read_surf()
,
resample_surf()
,
rotate_surf()
,
view_surf()
,
write_surf_gifti()
Surface plot
Description
Surface plot
Arguments
view |
Which view to display: |
widget |
Display the plot in an htmlwidget? Should be logical or
|
title |
Optional title(s) for the plot(s). It will be printed at the top in a separate subplot with 1/4 the height of the brain cortex subplots. Default: To use a custom title(s), use a length 1 character vector (same title for
each plot) or length If the title is non-empty but does not appear, try lowering |
fname |
Save the plot(s) (and color legend if applicable)? If If If neither of the cases above apply, a png image will be written for each
|
fname_suffix |
Either the data column names ( |
cex.title |
Font size multiplier for the title. |
text_color |
Color for text in title and colorbar legend. Default:
|
bg |
Background color. |
NA_color |
The color for the medial wall and |
alpha |
Transparency value for mesh coloring, between 0 and 1. Default:
|
edge_color |
Outline each edge in this color. Default: |
vertex_color |
Draw each vertex in this color. Default:
|
vertex_size |
Draw each vertex with this size. Default: |
material |
A list of materials from |
width , height |
The dimensions of the RGL window, in pixels. If both are
The plot will be taller than If multiple |
zoom |
Adjust the sizes of the brain meshes. Default: |
Format a path for system
Description
Right now, it uses shQuote
Usage
sys_path(R_path)
Arguments
R_path |
The name of the file. It should be properly formatted: if it
exists, |
Value
The name of the file
Make a template "xifti"
object
Description
Make a "xifti"
object with all terminal entries NULL
. Useful for
seeing the structure of a "xifti"
object or creating a new one.
Usage
template_xifti()
Details
Additional metadata depends on the type of CIFTI file:
- "dtseries"
-
- time_start:
Start time
- time_step:
The TR
- time_unit:
Unit of time
- "dscalar"
-
- names:
Name of each data column
- "dlabels"
-
- names:
Name of each data column
- labels:
-
Length
T
list ofL \times 5
data.frames. List entry names are data column names. Row names are label names. Column names are: Key, Red, Green, Blue, and Alpha.
Value
An empty "xifti"
object with a valid list structure
Apply a univariate transformation to a "xifti"
or pair of "xifti"
s.
Description
Apply a univariate transformation to each value in a "xifti"
or pair of
"xifti"
s. If a pair, they must share the same dimensions (brainstructures)
and number of measurements.
Usage
transform_xifti(xifti, FUN, xifti2 = NULL, idx = NULL, ...)
Arguments
xifti |
A |
FUN |
The function. If |
xifti2 |
The second xifti, if applicable. Otherwise, |
idx |
The column indices for which to apply the transformation.
If |
... |
Additional arguments to |
Details
If the "xifti"
had the dlabel intent, and the transformation creates
any value that is not a label value (e.g. a non-integer), then it is converted
to a dscalar.
Technically, the function does not have to be univariate: it only has to return the
same number of values as the input. The function will be applied to the matrix
for each brain structure separately. For example, the function
function(q){(q - mean(q)) / sd(q)}
will scale each brainstructure, while
scale
will scale each column of each brainstructure.
Value
A "xifti"
storing the result of applying FUN
to the input(s).
The data dimensions will be the same. The metadata of xifti
will be retained,
and the metadata of xifti2
will be discarded (if provided).
See Also
Other manipulating xifti:
add_surf()
,
apply_parc()
,
apply_xifti()
,
combine_xifti()
,
convert_xifti()
,
impute_xifti()
,
merge_xifti()
,
move_to_mwall()
,
move_to_submask()
,
newdata_xifti()
,
remap_cifti()
,
remove_xifti()
,
resample_cifti()
,
resample_cifti_from_template()
,
scale_xifti()
,
select_xifti()
,
set_names_xifti()
,
smooth_cifti()
Unmask cortex
Description
Get cortex data with medial wall vertices
Usage
unmask_cortex(cortex, mwall, mwall_fill = NA)
Arguments
cortex |
V vertices x T measurements matrix |
mwall |
Logical vector with T |
mwall_fill |
The fill value to use for medial wall vertices. |
Value
The unmasked cortex data
Undo the volumetric mask to the subcortex
Description
Un-applies the mask to the subcortical data in a "xifti"
to yield its
volumetric representation.
Usage
unmask_subcortex(xifti, fill = NA)
Arguments
xifti |
A |
fill |
The value for locations outside the mask. Default: |
Value
The 3D or 4D unflattened volume array
Convert vectorized data back to volume
Description
Un-applies a mask to vectorized data to yield its volumetric representation.
The mask and data should have compatible dimensions: the number of rows in
dat
should equal the number of locations within the mask
.
Usage
unvec_vol(dat, mask, fill = NA)
Arguments
dat |
Data matrix with locations along the rows and measurements along the columns. If only one set of measurements were made, this may be a vector. |
mask |
Volumetric binary mask. |
fill |
The value for locations outside the mask. Default: |
Value
The 3D or 4D unflattened volume array
Use a color palette
Description
Applies a palette to a data vector to yield a vector of colors.
Usage
use_color_pal(data_values, pal, color_NA = "white", indices = FALSE)
Arguments
data_values |
The values to map to colors |
pal |
The palette to use to map values to colors |
color_NA |
The color to use for |
indices |
Return the numeric indices of colors in |
Value
A character vector of color names (or integers if indices
).
See Also
Other coloring:
ROY_BIG_BL()
,
expand_color_pal()
,
make_color_pal()
verbose: FALSE
Description
verbose: FALSE
Arguments
verbose |
Should occasional updates be printed? Default: |
verbose: TRUE
Description
verbose: TRUE
Arguments
verbose |
Should occasional updates be printed? Default: |
Vertex Adjacency Matrix
Description
Make adjacency matrix between two sets of vertices on the same mesh.
Usage
vert_adjacency(faces, v1, v2 = NULL)
Arguments
faces |
An |
v1 , v2 |
The first and second set of vertices. These are logical vectors
the same length as |
Value
Adjacency matrix
vertices
Description
vertices
Arguments
vertices |
A |
View composite of images
Description
Create a single image which displays multiple image files. Tailored to support
composite layouts of plots from view_xifti
.
Usage
view_comp(
img,
ncol = NULL,
nrow = NULL,
legend = NULL,
title = NULL,
legend_height = 0.3,
title_height = 0.1,
title_fsize = 5,
newpage = is.null(fname),
fname = NULL,
...
)
Arguments
img |
Character vector of paths to images to include. They will be arranged by row. |
ncol , nrow |
Control the layout of the composite image. |
legend |
File path to a legend image to add, or |
title |
A length-one character vector to use as the title, or |
legend_height , title_height |
Heights of the legend and title, if
applicable. Specified relative to all the plots, so |
title_fsize |
Multiplier for font size. Default: |
newpage |
Call |
fname |
If |
... |
Additional arguments to |
Details
Requires the following packages: png
, grid
, gridExtra
How it works: the non-legend images (plots) are composited in a call to
grid::arrangeGrob
. If a title or legend exists, it's added to the top and
bottom, respectively, of the plots after with another call to grid::arangeGrob
.
Value
The composite plot
See Also
Other visualizing:
view_surf()
,
view_xifti()
,
view_xifti_surface()
,
view_xifti_volume()
View "surf"
object(s)
Description
Visualize one or two "surf"
objects(s), or the "surf"
component(s) in a "xifti"
using an interactive Open GL window
made with rgl
. The rgl
package is required.
Usage
view_surf(
...,
view = c("both", "lateral", "medial"),
widget = NULL,
title = NULL,
fname = FALSE,
cex.title = NULL,
text_color = "black",
bg = NULL,
alpha = 1,
edge_color = NULL,
vertex_color = NULL,
vertex_size = 0,
material = NULL,
width = NULL,
height = NULL,
zoom = NULL
)
Arguments
... |
One of: A |
view |
Which view to display: |
widget |
Display the plot in an htmlwidget? Should be logical or
|
title |
Optional title(s) for the plot(s). It will be printed at the top in a separate subplot with 1/4 the height of the brain cortex subplots. Default: To use a custom title(s), use a length 1 character vector (same title for
each plot) or length If the title is non-empty but does not appear, try lowering |
fname |
Save the plot(s) (and color legend if applicable)? If If If neither of the cases above apply, a png image will be written for each
|
cex.title |
Font size multiplier for the title. |
text_color |
Color for text in title and colorbar legend. Default:
|
bg |
Background color. |
alpha |
Transparency value for mesh coloring, between 0 and 1. Default:
|
edge_color |
Outline each edge in this color. Default: |
vertex_color |
Draw each vertex in this color. Default:
|
vertex_size |
Draw each vertex with this size. Default: |
material |
A list of materials from |
width , height |
The dimensions of the RGL window, in pixels. If both are
The plot will be taller than If multiple |
zoom |
Adjust the sizes of the brain meshes. Default: |
Details
This function works as a wrapper to view_xifti_surface
, but
some arguments are not applicable (e.g. color scheme and legend). Also,
instead of using the hemisphere
argument, name the surface arguments
surfL
or surfR
(see description for parameter ...
).
Finally, the default value for param
is "surf"
, not
"xifti"
.
Navigating and Embedding the Interactive Plots
To navigate the interactive Open GL window and html widget, left click and
drag the cursor to rotate the meshes. Use the scroll wheel or right click
and drag to zoom. Press the scroll wheel and drag to change the field-of-view.
For Open GL windows, execute
snapshot
to save the current window as a .png file,
close3d
to close the window, and
view3d
to programmatically control the
perspective.
To embed an interactive plot in an R Markdown document, first execute
rgl::setupKnitr()
to prepare the document for embedding the widget.
Then execute the plot command as you normally would to create a widget (i.e.
without specifying fname
, and by requesting more than one idx
or by setting widget
to TRUE
). When the R Markdown document is
knitted, the interactive widget should be displayed below the chunk in which
the plot command was executed. See the vignette for an example.
Embedding the Static Plots
To embed a static plot in an R Markdown document, first execute
rgl::setupKnitr()
to prepare the document for embedding the snapshot
of the Open GL window. Then execute the plot command as you normally would
to create an Open GL window (i.e. without specifying fname
, and by
requesting only one idx
). In the options for the chunk in which the
plot command is executed, set rgl=TRUE, format="png"
. You can also
control the image dimensions here e.g. fig.height=3.8, fig.width=5
.
When the R Markdown document is knitted, the static plots should be
displayed below the chunk in which the plot command was executed. See the
vignette for an example.
See Also
Other visualizing:
view_comp()
,
view_xifti()
,
view_xifti_surface()
,
view_xifti_volume()
Other surface-related:
add_surf()
,
boundary_mask_surf()
,
edit_mask_surf()
,
even_vert_samp()
,
is.surf()
,
load_surf()
,
mask_surf()
,
read_surf()
,
resample_surf()
,
rotate_surf()
,
surf_area()
,
write_surf_gifti()
View a "xifti"
object
Description
Displays the data in a "xifti"
object using view_xifti_surface
and/or view_xifti_volume
. Compared to calling these two
functions separately on the same data, this function may be more convenient
since the automatic choice of color mode and limits is determined across
the entire data and shared between the two plots. Also, if writing files
the subcortical plots will not overwrite the cortical plots.
Usage
view_xifti(xifti, what = NULL, ...)
view_cifti(xifti, ...)
viewCIfTI(xifti, ...)
viewcii(xifti, ...)
Arguments
xifti |
A |
what |
|
... |
Additional arguments to pass to either view function. |
Value
The return value of view_xifti_surface
or
view_xifti_volume
.
See Also
Other common:
is.cifti()
,
read_cifti()
,
resample_cifti()
,
smooth_cifti()
,
write_cifti()
Other visualizing:
view_comp()
,
view_surf()
,
view_xifti_surface()
,
view_xifti_volume()
Make the colorbar for view_xifti_surface
Description
See view_xifti_surface
for details.
Usage
view_xifti.cbar(pal_base, pal, color_mode, text_color, digits, scientific = NA)
Arguments
pal_base |
Base palette |
pal |
Full palette |
color_mode |
|
text_color |
Color of text |
digits |
Value
A list of keyword arguments to image.plot
Draw color legend for qualitative mode
Description
See view_xifti_surface
for details.
Usage
view_xifti.cleg(pal_base, leg_ncol, text_color, scale = 1, title_sub = FALSE)
Arguments
pal_base |
Base palette + labels for each row |
leg_ncol |
Number of columns in legend. |
text_color |
Color of text |
scale |
of text |
Value
A color legend from ggplot2
Get title for view_xifti_surface
or view_xifti_volume
Description
Determine the title(s) for the cortical surface or subcortical volume plot, if it was not provided by the user.
Usage
view_xifti.title(xifti_meta, idx)
Arguments
xifti_meta |
|
idx |
The index |
Value
The RGL object ID for the title
View cortical surface data in a "xifti"
Description
Visualize "xifti"
cortical data using an interactive Open GL window
or htmlwidget made with rgl
. The rmarkdown
package is
required for the htmlwidget functionality.
Usage
view_xifti_surface(
xifti = NULL,
surfL = NULL,
surfR = NULL,
color_mode = "auto",
zlim = NULL,
colors = NULL,
idx = NULL,
hemisphere = NULL,
together = NULL,
together_ncol = NULL,
together_title = NULL,
view = c("both", "lateral", "medial"),
widget = NULL,
title = NULL,
slider_title = "Index",
fname = FALSE,
fname_suffix = c("names", "idx"),
legend_fname = "[fname]_legend",
legend_ncol = NULL,
legend_alllevels = FALSE,
legend_embed = NULL,
digits = NULL,
scientific = NA,
cex.title = NULL,
text_color = "black",
bg = NULL,
NA_color = "white",
borders = FALSE,
alpha = 1,
edge_color = NULL,
vertex_color = NULL,
vertex_size = 0,
material = NULL,
shadows = 1,
width = NULL,
height = NULL,
zoom = NULL
)
view_cifti_surface(
xifti = NULL,
surfL = NULL,
surfR = NULL,
color_mode = "auto",
zlim = NULL,
colors = NULL,
idx = NULL,
hemisphere = NULL,
together = NULL,
together_ncol = NULL,
together_title = NULL,
view = c("both", "lateral", "medial"),
widget = NULL,
title = NULL,
slider_title = "Index",
fname = FALSE,
fname_suffix = c("names", "idx"),
legend_fname = "[fname]_legend",
legend_ncol = NULL,
legend_alllevels = FALSE,
legend_embed = NULL,
digits = NULL,
scientific = NA,
cex.title = NULL,
text_color = "black",
bg = NULL,
NA_color = "white",
borders = FALSE,
alpha = 1,
edge_color = NULL,
vertex_color = NULL,
vertex_size = 0,
material = NULL,
shadows = 1,
width = NULL,
height = NULL,
zoom = NULL
)
viewCIfTI_surface(
xifti = NULL,
surfL = NULL,
surfR = NULL,
color_mode = "auto",
zlim = NULL,
colors = NULL,
idx = NULL,
hemisphere = NULL,
together = NULL,
together_ncol = NULL,
together_title = NULL,
view = c("both", "lateral", "medial"),
widget = NULL,
title = NULL,
slider_title = "Index",
fname = FALSE,
fname_suffix = c("names", "idx"),
legend_fname = "[fname]_legend",
legend_ncol = NULL,
legend_alllevels = FALSE,
legend_embed = NULL,
digits = NULL,
scientific = NA,
cex.title = NULL,
text_color = "black",
bg = NULL,
NA_color = "white",
borders = FALSE,
alpha = 1,
edge_color = NULL,
vertex_color = NULL,
vertex_size = 0,
material = NULL,
shadows = 1,
width = NULL,
height = NULL,
zoom = NULL
)
viewcii_surface(
xifti = NULL,
surfL = NULL,
surfR = NULL,
color_mode = "auto",
zlim = NULL,
colors = NULL,
idx = NULL,
hemisphere = NULL,
together = NULL,
together_ncol = NULL,
together_title = NULL,
view = c("both", "lateral", "medial"),
widget = NULL,
title = NULL,
slider_title = "Index",
fname = FALSE,
fname_suffix = c("names", "idx"),
legend_fname = "[fname]_legend",
legend_ncol = NULL,
legend_alllevels = FALSE,
legend_embed = NULL,
digits = NULL,
scientific = NA,
cex.title = NULL,
text_color = "black",
bg = NULL,
NA_color = "white",
borders = FALSE,
alpha = 1,
edge_color = NULL,
vertex_color = NULL,
vertex_size = 0,
material = NULL,
shadows = 1,
width = NULL,
height = NULL,
zoom = NULL
)
Arguments
xifti |
A |
surfL , surfR |
(Optional) The brain surface model to use. Each can be a
|
color_mode |
(Optional) |
zlim |
(Optional) Controls the mapping of values to each
color in |
colors |
(Optional) |
idx |
The time/column index of the data to display. If its length is greater than one, and |
hemisphere |
Which brain cortex to display: "both" (default), "left", or "right". Each will be plotted in a separate panel column. If a brain cortex is requested but no surface is available, a default inflated surface will be used. This argument can also be Surfaces without data will be colored white. |
together |
Only applies if saving image files (
|
together_ncol |
If |
together_title |
If a composite image is made based on |
view |
Which view to display: |
widget |
Display the plot in an htmlwidget? Should be logical or
|
title |
Optional title(s) for the plot(s). It will be printed at the top in a separate subplot with 1/4 the height of the brain cortex subplots. Default: To use a custom title(s), use a length 1 character vector (same title for
each plot) or length If the title is non-empty but does not appear, try lowering |
slider_title |
Text at bottom of plot that will be added if a slider
is used, to provide a title for it. Default: |
fname |
Save the plot(s) (and color legend if applicable)? If If If neither of the cases above apply, a png image will be written for each
|
fname_suffix |
Either the data column names ( |
legend_fname |
Save the color legend? Since the legend is the same
for each |
legend_ncol |
Number of columns in color legend. If
|
legend_alllevels |
Show all label levels in the color legend? If
|
legend_embed |
Should the colorbar be embedded in the plot?
It will be positioned in the bottom-left corner, in a separate subplot
with 1/4 the height of the brain cortex subplots. Default: Only applies if the color bar is used (sequential or diverging data)
or if |
digits |
The number of digits for the colorbar legend ticks.
If |
scientific |
Use scientific notation? If |
cex.title |
Font size multiplier for the title. |
text_color |
Color for text in title and colorbar legend. Default:
|
bg |
Background color. |
NA_color |
The color for the medial wall and |
borders |
Only applicable if |
alpha |
Transparency value for mesh coloring, between 0 and 1. Default:
|
edge_color |
Outline each edge in this color. Default: |
vertex_color |
Draw each vertex in this color. Default:
|
vertex_size |
Draw each vertex with this size. Default: |
material |
A list of materials from |
shadows |
Number from 0 (maximum added lighting) to 1 (no added
lighting) to control the darkness and extent of shadowing on the 3D surface.
Default: |
width , height |
The dimensions of the RGL window, in pixels. If both are
The plot will be taller than If multiple |
zoom |
Adjust the sizes of the brain meshes. Default: |
Value
If a png or html file(s) were written, the names of the files for each index (and color legend if applicable) will be returned. Otherwise, the widget itself is returned if a widget was used, and the rgl object IDs are returned if an Open GL window was used. The rgl object IDs are useful for further programmatic manipulation of the Open GL window.
Navigating and Embedding the Interactive Plots
To navigate the interactive Open GL window and html widget, left click and
drag the cursor to rotate the meshes. Use the scroll wheel or right click
and drag to zoom. Press the scroll wheel and drag to change the field-of-view.
For Open GL windows, execute
snapshot
to save the current window as a .png file,
close3d
to close the window, and
view3d
to programmatically control the
perspective.
To embed an interactive plot in an R Markdown document, first execute
rgl::setupKnitr()
to prepare the document for embedding the widget.
Then execute the plot command as you normally would to create a widget (i.e.
without specifying fname
, and by requesting more than one idx
or by setting widget
to TRUE
). When the R Markdown document is
knitted, the interactive widget should be displayed below the chunk in which
the plot command was executed. See the vignette for an example.
Embedding the Static Plots
To embed a static plot in an R Markdown document, first execute
rgl::setupKnitr()
to prepare the document for embedding the snapshot
of the Open GL window. Then execute the plot command as you normally would
to create an Open GL window (i.e. without specifying fname
, and by
requesting only one idx
). In the options for the chunk in which the
plot command is executed, set rgl=TRUE, format="png"
. You can also
control the image dimensions here e.g. fig.height=3.8, fig.width=5
.
When the R Markdown document is knitted, the static plots should be
displayed below the chunk in which the plot command was executed. See the
vignette for an example.
See Also
Other visualizing:
view_comp()
,
view_surf()
,
view_xifti()
,
view_xifti_volume()
Get the palettes and data color mapping for view_xifti_surface
Description
See view_xifti_surface
for details.
Usage
view_xifti_surface.color(
hemisphere,
values,
idx,
colors,
color_mode,
zlim,
digits,
xifti_meta,
surfL,
surfR
)
Arguments
hemisphere , values , idx |
idx see |
colors , color_mode , zlim |
digits see
|
xifti_meta |
|
surfL , surfR |
Value
A list with entries "pal_base", "pal", "color_vals", and "unique_vals"
Draw brain hemisphere mesh in RGL
Description
See view_xifti_surface
for details.
Usage
view_xifti_surface.draw_mesh(
mesh,
mesh_color,
alpha,
vertex_color,
vertex_size,
edge_color,
material
)
Arguments
mesh |
RGL brain mesh |
mesh_color |
The color at each vertex |
alpha , vertex_color , vertex_size , edge_color |
Value
NULL
, invisibly
Draw title in RGL
Description
See view_xifti_surface
for details.
Usage
view_xifti_surface.draw_title(
title,
xifti_meta,
this_idx,
cex.title,
text_color,
indiv_panel_width
)
Arguments
title |
Title text or |
xifti_meta |
|
this_idx |
The index |
cex.title , text_color |
|
indiv_panel_width |
The width of the panel to write the title in |
Value
The RGL object ID for the title
Get the mesh(es) and data values for view_xifti_surface
Description
See view_xifti_surface
for details.
Usage
view_xifti_surface.mesh_val(
xifti,
surfL,
surfR,
hemisphere,
idx,
material = NULL
)
Arguments
xifti |
The |
surfL |
Left surface |
surfR |
Right surface |
hemisphere |
Hemisphere |
idx |
Index |
material |
|
Value
A list with entries "mesh" and "values"
Sort out surface & hemisphere args for view_xifti_surface
Description
See view_xifti_surface
for details.
Usage
view_xifti_surface.surf_hemi(xifti, surfL, surfR, hemisphere)
Arguments
xifti |
A |
surfL |
Left surface |
surfR |
Right surface |
hemisphere |
Hemisphere |
Value
A list with entries "surfL", "surfR" and "hemisphere"
View subcortical data in a "xifti"
Description
Visualize the subcortical data in a "xifti"
using a series of 2D
slices (based on overlay
) or an interactive widget
(based on papayar::papaya
). Note: papayar
has been removed
from CRAN so the widget is not available. If papayar
returns to CRAN
the widget will be made available again.
Usage
view_xifti_volume(
xifti,
structural_img = "MNI",
color_mode = "auto",
zlim = NULL,
colors = NULL,
structural_img_colors = gray(0:255/280),
title = NULL,
idx = NULL,
plane = c("axial", "sagittal", "coronal"),
convention = c("neurological", "radiological"),
n_slices = 9,
slices = NULL,
together = NULL,
together_ncol = NULL,
together_title = NULL,
widget = FALSE,
fname = FALSE,
fname_suffix = c("names", "idx"),
fname_sub = FALSE,
legend_fname = "[fname]_legend",
legend_ncol = NULL,
legend_alllevels = FALSE,
legend_embed = NULL,
digits = NULL,
scientific = NA,
cex.title = NULL,
ypos.title = 0,
xpos.title = 0,
orientation_labels = TRUE,
crop = TRUE,
text_color = "white",
bg = NULL,
width = NULL,
height = NULL,
...
)
view_cifti_volume(
xifti,
structural_img = "MNI",
color_mode = "auto",
zlim = NULL,
colors = NULL,
structural_img_colors = gray(0:255/280),
title = NULL,
idx = NULL,
plane = c("axial", "sagittal", "coronal"),
convention = c("neurological", "radiological"),
n_slices = 9,
slices = NULL,
together = NULL,
together_ncol = NULL,
together_title = NULL,
widget = FALSE,
fname = FALSE,
fname_suffix = c("names", "idx"),
fname_sub = FALSE,
legend_fname = "[fname]_legend",
legend_ncol = NULL,
legend_alllevels = FALSE,
legend_embed = NULL,
digits = NULL,
scientific = NA,
cex.title = NULL,
ypos.title = 0,
xpos.title = 0,
orientation_labels = TRUE,
crop = TRUE,
text_color = "white",
bg = NULL,
width = NULL,
height = NULL,
...
)
viewCIfTI_volume(
xifti,
structural_img = "MNI",
color_mode = "auto",
zlim = NULL,
colors = NULL,
structural_img_colors = gray(0:255/280),
title = NULL,
idx = NULL,
plane = c("axial", "sagittal", "coronal"),
convention = c("neurological", "radiological"),
n_slices = 9,
slices = NULL,
together = NULL,
together_ncol = NULL,
together_title = NULL,
widget = FALSE,
fname = FALSE,
fname_suffix = c("names", "idx"),
fname_sub = FALSE,
legend_fname = "[fname]_legend",
legend_ncol = NULL,
legend_alllevels = FALSE,
legend_embed = NULL,
digits = NULL,
scientific = NA,
cex.title = NULL,
ypos.title = 0,
xpos.title = 0,
orientation_labels = TRUE,
crop = TRUE,
text_color = "white",
bg = NULL,
width = NULL,
height = NULL,
...
)
viewcii_volume(
xifti,
structural_img = "MNI",
color_mode = "auto",
zlim = NULL,
colors = NULL,
structural_img_colors = gray(0:255/280),
title = NULL,
idx = NULL,
plane = c("axial", "sagittal", "coronal"),
convention = c("neurological", "radiological"),
n_slices = 9,
slices = NULL,
together = NULL,
together_ncol = NULL,
together_title = NULL,
widget = FALSE,
fname = FALSE,
fname_suffix = c("names", "idx"),
fname_sub = FALSE,
legend_fname = "[fname]_legend",
legend_ncol = NULL,
legend_alllevels = FALSE,
legend_embed = NULL,
digits = NULL,
scientific = NA,
cex.title = NULL,
ypos.title = 0,
xpos.title = 0,
orientation_labels = TRUE,
crop = TRUE,
text_color = "white",
bg = NULL,
width = NULL,
height = NULL,
...
)
Arguments
xifti |
A |
structural_img |
The structural MRI image on which to overlay the
subcortical plot. Can be a file name, |
color_mode |
(Optional) |
zlim |
(Optional) Controls the mapping of values to each
color in |
colors |
(Optional) |
structural_img_colors |
Colors to use for the background image. These
will be assigned in order from lowest to highest value with equal spacing
between the colors. ( |
title |
Optional title(s) for the plot(s). It will be printed at the top. Default: To use a custom title(s), use a length 1 character vector (same title for
each plot) or length If the title is non-empty but does not appear, try lowering |
idx |
The time/column index of the data to display. If If |
plane |
The plane to display for the slices:
|
convention |
|
n_slices |
The number of slices to display. Default: |
slices |
Which slices to display. If provided, this argument will
override |
together |
Only applies if saving image files (
|
together_ncol |
If |
together_title |
If a composite image is made based on |
widget |
Create an interactive widget using Note that the widget can only display one Note: |
fname , fname_suffix |
Save the plot(s) (and color legend if applicable)? If If If neither of the cases above apply, a png image will be written for each
|
fname_sub |
Add "_sub" to the end of the names of the files being saved?
Default: |
legend_fname |
Save the color legend? Since the legend is the same
for each |
legend_ncol |
Number of columns in color legend. If
|
legend_alllevels |
Show all label levels in the color legend? If
|
legend_embed |
Should the colorbar be embedded in the plot?
It will be positioned at the bottom. Default: Only applies if the color bar is used (sequential or diverging data). The color legend (qualitative data) cannot be embedded at the moment. |
digits |
The number of digits for the colorbar legend ticks.
If |
scientific |
Use scientific notation? If |
cex.title |
Font size multiplier for the title. |
ypos.title , xpos.title |
The positioning of the title can be finicky,
especially when using an R Markdown document interactively in which case it
appears too high in the plot. Use these arguments to nudge the title up
or down ( |
orientation_labels |
Show orientation labels at the top left and top
right of the plot? These will indicate the directions along the left-right
axis for each slice image. Default: |
crop |
Crop the slice subplots to the subcortical structures, instead of
showing the full anatomical image? Default: |
text_color |
Color for text in title and colorbar legend. Default:
|
bg |
Background color. |
width , height |
The dimensions of the plot, in pixels. Only affects saved
images (if Currently, there is no way to control the dimensions of the plot if working interactively in RStudio or creating a knitted R Markdown document. The default appears to be a wide aspect ratio. |
... |
Additional arguments to pass to |
Details
Note that color_mode
, zlim
, and colors
only affect the
color scale of the data values whereas structural_img_colors
only
affects the color scale of the background image.
Currently, the color-related arguments only affect the 2D slice view. The color limits and palette must be edited using the widget controls once it's rendered.
Arguments concerning anatomical orientation assume that the subcortical data is stored in the following way: first dimension is normal to the sagittal plane, going left to right; second dimension is normal to the coronal plane, going from the front of the head (anterior) to the back (posterior); third dimension is normal to the axial plane, going from the top of the head (superior) to the neck (inferior).
For non-interactive plots, if n_slices > 1
and convention="neurological"
,
axial slices are ordered from the neck (inferior) to the top of the head
(superior), sagittal slices are ordered left to right, and coronal slices
are ordered back (posterior) to front (anterior). If
convention="radiological"
, sagittal slices are instead ordered right
to left.
Value
If a png or pdf file(s) were written, the names of the files for
each index (and color legend if applicable) will be returned. Otherwise,
NULL
is invisibly returned.
See Also
Other visualizing:
view_comp()
,
view_surf()
,
view_xifti()
,
view_xifti_surface()
Get spatial locations of each voxel
Description
Use subcortical metadata (mask, transformation matrix and units) to get voxel locations in 3D space.
Usage
vox_locations(mask, trans_mat, trans_units = NULL)
Arguments
mask , trans_mat , trans_units |
The subcortical metadata |
Value
A list: coords
and units
Request "wb_path"
Description
Print a message requesting that the ciftiTools
option "wb_path"
be set.
Usage
wb_path_request()
Value
The message (length 1 character vector)
Welcome message
Description
Print the welcome message.
Usage
welcome_msg()
Value
The message (length 1 character vector)
Write a CIFTI file from a "xifti"
object
Description
Write out a "xifti"
object as a CIFTI file and (optionally) GIFTI
surface files.
Usage
write_cifti(
xifti,
cifti_fname,
surfL_fname = NULL,
surfR_fname = NULL,
verbose = TRUE
)
writeCIfTI(
xifti,
cifti_fname,
surfL_fname = NULL,
surfR_fname = NULL,
verbose = TRUE
)
writecii(
xifti,
cifti_fname,
surfL_fname = NULL,
surfR_fname = NULL,
verbose = TRUE
)
write_xifti(
xifti,
cifti_fname,
surfL_fname = NULL,
surfR_fname = NULL,
verbose = TRUE
)
Arguments
xifti |
A |
cifti_fname |
File path to a CIFTI file (ending in ".d*.nii"). |
surfL_fname , surfR_fname |
If the [left/right] surface is present, it
will be a written to a GIFTI file at this file path. If |
verbose |
Should occasional updates be printed? Default: |
Details
See write_xifti2
to write a "xifti"
object out as
separate GIFTI and/or NIFTI files instead.
Value
Named character vector of the written files
Connectome Workbench
This function interfaces with the "-cifti-create-dense-timeseries"
,
"-cifti-create-dense-scalar"
, or "-cifti-create-label"
Workbench
Command, depending on the input.
See Also
Other common:
is.cifti()
,
read_cifti()
,
resample_cifti()
,
smooth_cifti()
,
view_xifti()
Other writing:
separate_cifti()
,
write_metric_gifti()
,
write_subcort_nifti()
,
write_surf_gifti()
,
write_xifti2()
Write a CIFTI file from NIFTI and GIFTI files
Description
Make a CIFTI file from component NIFTI/GIFTI files using the
-cifti-create-...
Connectome Workbench commands.
Usage
write_cifti_from_separate(
cifti_fname,
cortexL_fname = NULL,
ROIcortexL_fname = NULL,
cortexR_fname = NULL,
ROIcortexR_fname = NULL,
subcortVol_fname = NULL,
subcortLabs_fname = NULL,
timestep = NULL,
timestart = NULL,
names = NULL
)
Arguments
cifti_fname |
Path to the CIFTI to write. |
cortexL_fname |
The left cortex file. |
ROIcortexL_fname |
The left cortex ROI file. |
cortexR_fname |
The right cortex file. |
ROIcortexR_fname |
The right cortex ROI file. |
subcortVol_fname |
The subcortical data file. |
subcortLabs_fname |
The subcortical labels file. |
timestep |
If a dense time series ("dtseries.nii") file is being written,
this is the time between measurements. If |
timestart |
If a dense time series ("dtseries.nii") file is being written,
this is starting time. If |
names |
For "dscalar.nii" or "dlabel.nii", these are the column names. |
Details
Every provided component will be included. The ROIs are only used if the corresponding cortex is provided. Either both or none of the subcortical NIFTIs should be provided.
write_dir: generic
Description
write_dir: generic
Arguments
write_dir |
Where should the separate files be placed?
|
Write label table to text file
Description
Write xii$meta$cifti$labels[[idx]]
to a text file for use with the
Connectome Workbench command -volume-label-import
.
Usage
write_label_table(label_table, fname)
Arguments
label_table |
The label table (one at a time!) |
fname |
Where to write the label table text file |
Write a data matrix to a GIFTI metric file
Description
Write the data for the left or right cortex to a metric GIFTI file.
Usage
write_metric_gifti(
x,
gifti_fname,
hemisphere = c("left", "right"),
intent = NULL,
data_type = NULL,
encoding = NULL,
endian = c("LittleEndian", "BigEndian"),
col_names = NULL,
label_table = NULL
)
Arguments
x |
A |
gifti_fname |
Where to write the GIFTI file. |
hemisphere |
|
intent |
"NIFTI_INTENT_*". |
data_type |
the type of |
encoding |
One of "ASCII", "Base64Binary", or "GZipBase64Binary". If
|
endian |
"LittleEndian" (default) or "BigEndian". If |
col_names |
The names of each data column in |
label_table |
A data.frame with labels along rows. The row names should be the label names. The column names should be among: "Key", "Red", "Green", "Blue", and "Alpha". The "Key" column is required whereas the others are optional (but very often included). Values in the "Key" column should be non-negative integers, typically beginning with 0. The other columns should be floating-point numbers between 0 and 1. Although CIFTI files support a different label table for each data column, GIFTI files only support a single label table. So this label table should be applicable to each data column. |
Value
Whether the GIFTI was successfully written
See Also
Other writing:
separate_cifti()
,
write_cifti()
,
write_subcort_nifti()
,
write_surf_gifti()
,
write_xifti2()
Generate GIFTI sphere surface files
Description
This function generates a pair of GIFTI vertex-matched left and right spheres in the target resolution. These are required for resampling CIFTI and GIFTI files.
Usage
write_spheres(sphereL_fname, sphereR_fname, resamp_res, write_dir = NULL)
Arguments
sphereL_fname |
File path to left-hemisphere spherical GIFTI to be created |
sphereR_fname |
File path to right-hemisphere spherical GIFTI to be created |
resamp_res |
Target resolution for resampling (number of cortical surface vertices per hemisphere). |
write_dir |
(Optional) directory to place the sphere files in. If
|
Value
The names of the written sphere files, invisibly
Write subcortical data to NIFTI files
Description
Write subcortical data to NIFTI files representing the data values,
subcortical structure labels, and volumetric mask. The input formats of
subcortVol
, subcortLabs
, and subcortMask
correspond to the data structures of xifti$data$subcort
,
xifti$meta$subcort$labels
, and xifti$meta$subcort$mask
respectively. subcortVol
and subcortLabs
should be vectorized,
so if they are volumes consider using RNifti::writeNIfTI
.
Usage
write_subcort_nifti(
subcortVol,
subcortLabs,
subcortMask,
trans_mat = NULL,
trans_units = NULL,
col_names = NULL,
label_table = NULL,
subcortVol_fname,
subcortLabs_fname,
ROIsubcortVol_fname = NULL,
fill = 0
)
Arguments
subcortVol |
A vectorized data matrix: V voxels by T measurements |
subcortLabs |
Numeric (0 and 3-22) or factor vector corresponding to
subcortical structure labels. See |
subcortMask |
Logical volumetric mask. Values of 0 represent out-of-mask voxels (not subcortical), and values of 1 represent in-mask voxels (subcortical), |
trans_mat |
The TransformationMatrixIJKtoXYZ, or equivalently the desired
sform matrix (srow_x, srow_y and srow_z) to write. If |
trans_units |
The units of |
col_names |
(Optional) Column names. |
label_table |
(Optional) |
subcortVol_fname , subcortLabs_fname , ROIsubcortVol_fname |
File path to
a NIFTI to save the corresponding data. |
fill |
Values to use for out-of-mask voxels. Default: |
Details
All file path arguments are required except ROIsubcortVol_fname
. If
not provided, the volumetric mask will not be written. (It's redundant with
the 0 values in subcortLabs_fname
because valid labels have positive
indexes.)
Note that for label data (i.e. if label_table
is provided) only one
label table can be saved.
Value
Named character vector with the "subcortVol"
,
"subcortLabs"
, and "ROIsubcortVol"
file names (if written)
Connectome Workbench
This function interfaces with the "-volume-label-import"
Workbench
Command.
See Also
Other writing:
separate_cifti()
,
write_cifti()
,
write_metric_gifti()
,
write_surf_gifti()
,
write_xifti2()
Write a "surf"
to a GIFTI surface file
Description
Write the data for the left or right surface to a surface GIFTI file.
Usage
write_surf_gifti(
x,
gifti_fname,
hemisphere = c("left", "right"),
encoding = NULL,
endian = c("LittleEndian", "BigEndian")
)
write_surf(
x,
gifti_fname,
hemisphere = c("left", "right"),
encoding = NULL,
endian = c("LittleEndian", "BigEndian")
)
Arguments
x |
A |
gifti_fname |
Where to write the GIFTI file. |
hemisphere |
"left" (default) or "right". Ignored if |
encoding |
A length-2 vector with elements chosen among "ASCII",
"Base64Binary", and "GZipBase64Binary". If |
endian |
"LittleEndian" (default) or "BigEndian". |
Value
Whether the GIFTI was successfully written
See Also
Other writing:
separate_cifti()
,
write_cifti()
,
write_metric_gifti()
,
write_subcort_nifti()
,
write_xifti2()
Other surface-related:
add_surf()
,
boundary_mask_surf()
,
edit_mask_surf()
,
even_vert_samp()
,
is.surf()
,
load_surf()
,
mask_surf()
,
read_surf()
,
resample_surf()
,
rotate_surf()
,
surf_area()
,
view_surf()
Write a "xifti"
object to GIFTI and NIFTI files
Description
Write metric or label GIFTIs for the cortical surface data and NIFTIs for the
subcortical labels and mask in a "xifti"
object. Each present
brainstructure will be written; if a brainstructure is absent the
corresponding file is not written.
Usage
write_xifti2(
xifti,
brainstructures = "existing",
cortexL_fname = NULL,
cortexR_fname = NULL,
subcortVol_fname = NULL,
subcortLabs_fname = NULL,
ROI_brainstructures = "all",
ROIcortexL_fname = NULL,
ROIcortexR_fname = NULL,
ROIsubcortVol_fname = NULL,
write_dir = NULL,
verbose = FALSE
)
Arguments
xifti |
A |
brainstructures |
What brain structure(s) to write: |
cortexL_fname , cortexR_fname |
(Optional) GIFTI file names (*.[func/label].gii) to save the [left/right] cortex data to. dtseries and dscalar files should use "func", whereas dlabel files should use "label". If |
subcortVol_fname , subcortLabs_fname |
(Optional) NIFTI file names to save the subcortical [volume/labels] to. Provide both or neither. If |
ROI_brainstructures |
Which ROIs should be obtained? |
ROIcortexL_fname , ROIcortexR_fname |
(Optional) GIFTI file names (*.[func/label].gii) to save the [left/right] cortex ROI to. dtseries and dscalar files should use "func", whereas dlabel files should use "label". If The cortical ROIs typically represent the medial wall
mask, with values of 1 for in-ROI (non-medial wall) vertices and 0 for
out-of-ROI (medial wall) vertices. Will be written in |
ROIsubcortVol_fname |
(Optional) NIFTI file names to save the subcortical ROI to. If The subcortical ROI typically represents the volumetric
mask for the entire subcortical structure, with values of 1 for in-ROI
(in subcortex) voxels and 0 for out-of-ROI (not in subcortex) voxels. Will
be written in |
write_dir |
(Optional) A path to an existing directory. If provided,
every component in the |
verbose |
Should occasional updates be printed? Default: |
Value
List of written files
See Also
Other writing:
separate_cifti()
,
write_cifti()
,
write_metric_gifti()
,
write_subcort_nifti()
,
write_surf_gifti()
x: xifti
Description
x: xifti
Arguments
x |
A |
xifti
Description
xifti
Arguments
xifti |
A |
Get XML of a CIFTI
Description
Wrapper for Connectome Workbench command
-nifti-information [fname] -print-xml
Usage
xml_cifti(cifti_fname)
Arguments
cifti_fname |
File path to a CIFTI file (ending in ".d*.nii"). |
Value
The XML as a list