Title: | Toolbox for Connectivity Informatics Technology Initiative ('CIFTI') Files |
---|---|
Description: | Functions for the input/output and visualization of medical imaging data in the form of 'CIFTI' files <https://www.nitrc.org/projects/cifti/>. |
Authors: | John Muschelli [aut, cre] |
Maintainer: | John Muschelli <[email protected]> |
License: | GPL-2 |
Version: | 0.4.7 |
Built: | 2024-11-22 04:07:00 UTC |
Source: | https://github.com/muschellij2/cifti |
Extracts the BrainStructure
attribute from a
BrainModel
in a cifti
object
cifti_brain_structs(file)
cifti_brain_structs(file)
file |
|
A vector of brain structure names
Maps the data portion of CIFTI data set from a Brain Model to the xyz coordinate triangles
cifti_coords_gifti(file, gii_file, structure, add_one = TRUE)
cifti_coords_gifti(file, gii_file, structure, add_one = TRUE)
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) |
List of coordinates and values
Extracts the data after the CIFTI XML information
cifti_data(fname, nim = NULL)
cifti_data(fname, nim = NULL)
fname |
Filename of CIFTI |
nim |
NIfTI-2 header, if already parsed.
If |
Array of values
Simple wrapper for reading in character values with embedded nulls in a binary file
cifti_read_char(fid, n, to = "UTF-8")
cifti_read_char(fid, n, to = "UTF-8")
fid |
identifier of the open file connection |
n |
number of elements to read |
to |
A character string describing the target encoding. |
Character vector
Extracts CIFTI XML from the CIFTI file
cifti_xml_txt(fname, nim = NULL) cifti_xml(...)
cifti_xml_txt(fname, nim = NULL) cifti_xml(...)
fname |
filename of CIFTI |
nim |
NIfTI-2 header, if already parsed.
If |
... |
arguments to pass to |
Character string of XML information
Downloads CIFTI test data from https://www.nitrc.org/frs/download.php/8541/cifti-2_test_data-1.2.zip
download_cifti_data( outdir = system.file(package = "cifti"), overwrite = FALSE, ... )
download_cifti_data( outdir = system.file(package = "cifti"), overwrite = FALSE, ... )
outdir |
Output directory for test file directory |
overwrite |
Should files be overwritten if already exist? |
... |
additional arguments to |
Vector of file names
Wrapper for multiple types of CIFTI XML types.
get_cifti_type( fname, type = c("Volume", "Surface", "Parcel", "NamedMap", "BrainModel"), verbose = TRUE ) cifti_as_list( fname, type = c("Volume", "Surface", "Parcel", "NamedMap", "BrainModel") )
get_cifti_type( fname, type = c("Volume", "Surface", "Parcel", "NamedMap", "BrainModel"), verbose = TRUE ) cifti_as_list( fname, type = c("Volume", "Surface", "Parcel", "NamedMap", "BrainModel") )
fname |
File name of CIFTI file |
type |
type of data to extract from CIFTI XML |
verbose |
print diagnostic messages |
List of output from each type
Checks if CIFTI test data is downloaded
have_cifti_test_data(outdir = system.file(package = "cifti"))
have_cifti_test_data(outdir = system.file(package = "cifti"))
outdir |
Output directory for test file directory |
Logical indicator
Wrapper of CIFTI fields for easy logical test
is_cifti_numeric(x)
is_cifti_numeric(x)
x |
character vector of names |
Logical of length same as x
Simple wrapper to determine if class is CIFTI
is.cifti(x)
is.cifti(x)
x |
object to test |
Logical if x
is CIFTI
Extracts the nodes from a CIFTI-2 file corresponding to the
MatrixIndicesMap
branch
matrix_ind_map_nodes(fname)
matrix_ind_map_nodes(fname)
fname |
File of CIFTI data |
Nodes of class xml_nodeset
Reads a NIfTI-2 header from a filename
nifti_2_hdr(fname, verbose = FALSE, warn = -1)
nifti_2_hdr(fname, verbose = FALSE, warn = -1)
fname |
Filename |
verbose |
Print diagnostic messages |
warn |
Should warnings be printed? Passed to |
Object of class nifti
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
Extracts information about BrainModels from CIFTI file
parse_brain_model(nodeset) get_brain_model(fname, verbose = TRUE)
parse_brain_model(nodeset) get_brain_model(fname, verbose = TRUE)
nodeset |
Set of XML nodes corresponding to |
fname |
filename of CIFTI file |
verbose |
print diagnostic messages |
List of values
## Not run: doc = cifti_xml(fname) nodes = xml_find_all(doc, "/CIFTI/Matrix/MatrixIndicesMap") nodeset = xml_find_all(nodes, "./BrainModel") ## End(Not run)
## Not run: doc = cifti_xml(fname) nodes = xml_find_all(doc, "/CIFTI/Matrix/MatrixIndicesMap") nodeset = xml_find_all(nodes, "./BrainModel") ## End(Not run)
Extracts information about Named Maps from CIFTI file
parse_named_map(nodeset) get_named_map(fname, verbose = TRUE)
parse_named_map(nodeset) get_named_map(fname, verbose = TRUE)
nodeset |
Set of XML nodes corresponding to |
fname |
filename of CIFTI file |
verbose |
print diagnostic messages |
List of values
## 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)
## 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)
Extracts information about Parcels from CIFTI file
parse_parcel(nodeset) get_parcel(fname, verbose = TRUE)
parse_parcel(nodeset) get_parcel(fname, verbose = TRUE)
nodeset |
Set of XML nodes corresponding to |
fname |
filename of CIFTI file |
verbose |
print diagnostic messages |
List of values
Extracts information about Surfaces from CIFTI file
parse_surface(nodeset) get_surface(fname, verbose = TRUE)
parse_surface(nodeset) get_surface(fname, verbose = TRUE)
nodeset |
Set of XML nodes corresponding to |
fname |
filename of CIFTI file |
verbose |
print diagnostic messages |
List of values
## 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)
## 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)
Extracts information about Volumes from CIFTI file
parse_volume(nodeset) get_volume(fname, verbose = TRUE)
parse_volume(nodeset) get_volume(fname, verbose = TRUE)
nodeset |
Set of XML nodes corresponding to |
fname |
filename of CIFTI file |
verbose |
print diagnostic messages |
List of values
## 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)
## 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)
Reads CIFTI Files
read_cifti(fname, drop_data = TRUE, trans_data = TRUE, verbose = TRUE) readCIFTI(fname, drop_data = TRUE, trans_data = TRUE) readcii(fname, drop_data = TRUE, trans_data = TRUE)
read_cifti(fname, drop_data = TRUE, trans_data = TRUE, verbose = TRUE) readCIFTI(fname, drop_data = TRUE, trans_data = TRUE) readcii(fname, drop_data = TRUE, trans_data = TRUE)
fname |
file name of CIFTI file |
drop_data |
Should the empty data dimensions be dropped? |
trans_data |
Should the data be transposed |
verbose |
print diagnostic messages |
List of information from the CIFTI file
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) }
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) }