| read.tract.bundles | R Documentation |
Reads one or more tract files in TRK or TCK format (see the
details) and returns them as a named list of bundles, i.e., one entry per
file. This is the input format of vis.tracts. A single
directory can be passed to read a whole tract atlas (one file per bundle, e.g.
the XTRACT atlas, see download_xtract_tracts).
read.tract.bundles(
paths,
coords = "ras",
transform_matrix = NULL,
max_tracks = Inf,
skip_tracks = 0L,
bbox = NULL,
pattern = "\\.(trk|tck)(\\.gz)?$",
silent = FALSE
)
paths |
character string, either the path to a directory containing tract files, or a vector of paths to tract files. |
coords |
character string or NULL, the coordinate system of the returned
coordinates for TRK files, see |
transform_matrix |
a 4x4 numeric matrix or NULL. If given, it is applied
to the coordinates of all files after reading them, e.g. to move a tract
atlas from MNI space into the space of the surfaces, see the note in
|
max_tracks |
numeric, the maximum number of streamlines to read per file.
Use |
skip_tracks |
integer, the number of streamlines to skip per file, see
|
bbox |
numeric vector of length 6 or NULL, a bounding box to select the
streamlines that pass through a region, see
|
pattern |
character string, a regular expression to select the files in a
directory. Ignored if |
silent |
logical, whether to suppress the progress messages. |
The files are read with the readers of the 'freesurferformats' package. Both the TrackVis TRK format (used by FSL, DSI Studio, AFQ, TractSeg and the XTRACT atlas) and the MRtrix3 TCK format (used by MRtrix3, QSIRecon, MRtrix3_connectome) are supported; TCK files may be gzip-compressed, TRK files may not. The bundle names are the file names without the extension, e.g. 'CST_L.trk' becomes the bundle 'CST_L'.
Note that TRK files store a transformation matrix which is not necessarily the
identity: a TRK file can contain coordinates in a voxel grid (e.g. all files of
the XTRACT atlas do). With the default coords = "ras", the coordinates
are returned in RAS+ mm space, which is what the template surfaces of
fsbrain are in, see the parameter documentation. Pass coords = "native"
to get the coordinates exactly as stored in the file.
named list of fs.tracts instances, one per file (see
fs.tracts). The names are the file names
without the extension. The attribute 'files' contains the file paths, and the
attribute 'coords_space' the coordinate system of the coordinates ('ras' or
'native', see the parameter coords). An entry which was read from a
TCK file is a TCK entry, i.e., its [[i]] entries are coordinate
matrices, while the entries of a TRK file also contain the per-point scalars
and per-track properties of the file.
Other tracts functions:
download_xtract_tracts(),
vis.tracts()
## Not run:
# Read a whole tract atlas from a directory, one bundle per file:
atlas_dir = file.path(get_optional_data_filepath("tracts"), "xtract_tiny");
bundles = read.tract.bundles(atlas_dir);
names(bundles);
fs.tracts.lengths(bundles$CST_L);
# Read a single bundle:
cst = read.tract.bundles(file.path(atlas_dir, "CST_L.trk"));
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.