Type: | Package |
Title: | Toolbox for Connectivity Informatics Technology Initiative ('CIFTI') Files |
Version: | 0.4.5 |
Maintainer: | John Muschelli <muschellij2@gmail.com> |
Description: | Functions for the input/output and visualization of medical imaging data in the form of 'CIFTI' files https://www.nitrc.org/projects/cifti/. |
License: | GPL-2 |
Imports: | xml2, oro.nifti, gifti, utils, R.utils |
Encoding: | UTF-8 |
LazyData: | true |
RoxygenNote: | 6.0.1.9000 |
Suggests: | covr, knitr, rmarkdown, rgl, matrixStats |
VignetteBuilder: | knitr |
NeedsCompilation: | no |
Packaged: | 2018-02-01 23:18:37 UTC; johnmuschelli |
Author: | John Muschelli [aut, cre] |
Repository: | CRAN |
Date/Publication: | 2018-02-01 23:25:24 UTC |
Extract Brain Structures from CIFTI Brain Models
Description
Extracts the BrainStructure
attribute from a
BrainModel
in a cifti
object
Usage
cifti_brain_structs(file)
Arguments
file |
|
Value
A vector of brain structure names
Map CIFTI values to Coordinates using GIFTI
Description
Maps the data portion of CIFTI data set from a Brain Model to the xyz coordinate triangles
Usage
cifti_coords_gifti(file, gii_file, structure, add_one = TRUE)
Arguments
file |
filename of CIFTI file or |
gii_file |
filename of corresponding
GIFTI file or |
structure |
Structure to map, must be one of the brain models in the CIFTI |
add_one |
should 1 be added to indices (1-based vs. 0-based) |
Value
List of coordinates and values
Extract CIFTI data from file
Description
Extracts the data after the CIFTI XML information
Usage
cifti_data(fname, nim = NULL)
Arguments
fname |
Filename of CIFTI |
nim |
NIfTI-2 header, if already parsed.
If |
Value
Array of values
Read characters with embedded nulls
Description
Simple wrapper for reading in character values with embedded nulls in a binary file
Usage
cifti_read_char(fid, n, to = "UTF-8")
Arguments
fid |
identifier of the open file connection |
n |
number of elements to read |
to |
A character string describing the target encoding. |
Value
Character vector
Extract CIFTI XML
Description
Extracts CIFTI XML from the CIFTI file
Usage
cifti_xml_txt(fname, nim = NULL)
cifti_xml(...)
Arguments
fname |
filename of CIFTI |
nim |
NIfTI-2 header, if already parsed.
If |
... |
arguments to pass to |
Value
Character string of XML information
Download CIFTI Test Data
Description
Downloads CIFTI test data from https://www.nitrc.org/frs/download.php/8541/cifti-2_test_data-1.2.zip
Usage
download_cifti_data(outdir = system.file(package = "cifti"),
overwrite = FALSE, ...)
Arguments
outdir |
Output directory for test file directory |
overwrite |
Should files be overwritten if already exist? |
... |
additional arguments to |
Value
Vector of file names
Get Generic CIFTI Type
Description
Wrapper for multiple types of CIFTI XML types.
Usage
get_cifti_type(fname, type = c("Volume", "Surface", "Parcel", "NamedMap",
"BrainModel"))
cifti_as_list(fname, type = c("Volume", "Surface", "Parcel", "NamedMap",
"BrainModel"))
Arguments
fname |
File name of CIFTI file |
type |
type of data to extract from CIFTI XML |
Value
List of output from each type
Check Presence of CIFTI Test Data
Description
Checks if CIFTI test data is downloaded
Usage
have_cifti_test_data(outdir = system.file(package = "cifti"))
Arguments
outdir |
Output directory for test file directory |
Value
Logical indicator
Test if CIFTI
Description
Simple wrapper to determine if class is CIFTI
Usage
is.cifti(x)
Arguments
x |
object to test |
Value
Logical if x
is CIFTI
Test of numeric CIFTI field
Description
Wrapper of CIFTI fields for easy logical test
Usage
is_cifti_numeric(x)
Arguments
x |
character vector of names |
Value
Logical of length same as x
Extract MatrixIndicesMap nodes from CIFTI
Description
Extracts the nodes from a CIFTI-2 file corresponding to the
MatrixIndicesMap
branch
Usage
matrix_ind_map_nodes(fname)
Arguments
fname |
File of CIFTI data |
Value
Nodes of class xml_nodeset
Read NIfTI-2 Header
Description
Reads a NIfTI-2 header from a filename
Usage
nifti_2_hdr(fname, verbose = FALSE, warn = -1)
Arguments
fname |
Filename |
verbose |
Print diagnostic messages |
warn |
Should warnings be printed? Passed to |
Value
Object of class nifti
Note
The unused_str
part of the header is not returned, but is an
empty string of 15 characters. This code was adapted by
the oro.nifti
package
Parse BrainModel from CIFTI
Description
Extracts information about BrainModels from CIFTI file
Usage
parse_brain_model(nodeset)
get_brain_model(fname)
Arguments
nodeset |
Set of XML nodes corresponding to |
fname |
filename of CIFTI file |
Value
List of values
Examples
## Not run:
doc = cifti_xml(fname)
nodes = xml_find_all(doc, "/CIFTI/Matrix/MatrixIndicesMap")
nodeset = xml_find_all(nodes, "./BrainModel")
## End(Not run)
Parse Named Map from CIFTI
Description
Extracts information about Named Maps from CIFTI file
Usage
parse_named_map(nodeset)
get_named_map(fname)
Arguments
nodeset |
Set of XML nodes corresponding to |
fname |
filename of CIFTI file |
Value
List of values
Examples
## Not run:
doc = cifti_xml(fname)
nodes = xml_find_all(doc, "/CIFTI/Matrix/MatrixIndicesMap")
nodeset = xml_find_all(nodes, "./NamedMap")
parse_named_map(nodeset)
## End(Not run)
Parse Parcel from CIFTI
Description
Extracts information about Parcels from CIFTI file
Usage
parse_parcel(nodeset)
get_parcel(fname)
Arguments
nodeset |
Set of XML nodes corresponding to |
fname |
filename of CIFTI file |
Value
List of values
Parse Surface from CIFTI
Description
Extracts information about Surfaces from CIFTI file
Usage
parse_surface(nodeset)
get_surface(fname)
Arguments
nodeset |
Set of XML nodes corresponding to |
fname |
filename of CIFTI file |
Value
List of values
Examples
## Not run:
doc = cifti_xml(fname)
nodes = xml_find_all(doc, "/CIFTI/Matrix/MatrixIndicesMap")
nodeset = xml_find_all(nodes, "./Surface")
parse_volume(nodeset)
## End(Not run)
Parse Volume from CIFTI
Description
Extracts information about Volumes from CIFTI file
Usage
parse_volume(nodeset)
get_volume(fname)
Arguments
nodeset |
Set of XML nodes corresponding to |
fname |
filename of CIFTI file |
Value
List of values
Examples
## Not run:
doc = cifti_xml(fname)
nodes = xml_find_all(doc, "/CIFTI/Matrix/MatrixIndicesMap")
nodeset = xml_find_all(nodes, "./Volume")
parse_volume(nodeset)
## End(Not run)
Read CIFTI File
Description
Reads CIFTI Files
Usage
read_cifti(fname, drop_data = TRUE, trans_data = TRUE)
readCIFTI(fname, drop_data = TRUE, trans_data = TRUE)
readcii(fname, drop_data = TRUE, trans_data = TRUE)
Arguments
fname |
file name of CIFTI file |
drop_data |
Should the empty data dimensions be dropped? |
trans_data |
Should the data be transposed |
Value
List of information from the CIFTI file
Examples
outdir = tempdir()
if (have_cifti_test_data(outdir = outdir)) {
files = download_cifti_data(outdir = outdir)
fname = grep("MyelinAndCorrThickness.32k_fs_LR.dscalar",
files, value = TRUE)
res = read_cifti(fname)
}