Package 'cifti'

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

Help Index


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

cifti object

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 cifti object

gii_file

filename of corresponding GIFTI file or gifti object

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 NULL, nifti_2_hdr will be run on the CIFTI.

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 NULL, nifti_2_hdr will be run on the CIFTI.

...

arguments to pass to cifti_xml

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 download.file

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"),
  verbose = TRUE
)

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

verbose

print diagnostic messages

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 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


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


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 options

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, verbose = TRUE)

Arguments

nodeset

Set of XML nodes corresponding to BrainModel

fname

filename of CIFTI file

verbose

print diagnostic messages

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, verbose = TRUE)

Arguments

nodeset

Set of XML nodes corresponding to NamedMap

fname

filename of CIFTI file

verbose

print diagnostic messages

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, verbose = TRUE)

Arguments

nodeset

Set of XML nodes corresponding to Parcel

fname

filename of CIFTI file

verbose

print diagnostic messages

Value

List of values


Parse Surface from CIFTI

Description

Extracts information about Surfaces from CIFTI file

Usage

parse_surface(nodeset)

get_surface(fname, verbose = TRUE)

Arguments

nodeset

Set of XML nodes corresponding to Surface

fname

filename of CIFTI file

verbose

print diagnostic messages

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, verbose = TRUE)

Arguments

nodeset

Set of XML nodes corresponding to Volume

fname

filename of CIFTI file

verbose

print diagnostic messages

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, verbose = 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

verbose

print diagnostic messages

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)
}