A bundle is an ordered collection of streamline objects representing a
tractogram or white-matter bundle. It stores three compartments:
@streamlines— a list of streamline objects.@streamline_data— a named list of per-streamline vectors (any type), each of length \(S\) (the number of streamlines). Values common to all streamlines may be lifted here automatically from the individual streamlines'@streamline_dataslots at construction time.@bundle_data— a named list of scalars (length-1 values, any type) holding bundle-level metadata.
Arguments
- streamlines
A list of streamline objects.
- streamline_data
A named list of per-streamline vectors of length S. If not supplied, any
@streamline_datakeys common to all streamlines are lifted automatically.- bundle_data
A named list of bundle-level scalar metadata.
Methods for standard generics
The following methods are defined for bundle objects:
format(x, ...): Returns a cli-formatted string describing the bundle object.print(x, ...): Prints the formatted string to the console and invisibly returnsx.length(x): Returns the number of streamlines (equivalent tox@n_streamlines).x[[i]]: Extracts thei-th streamline from the bundle, with bundle-level@streamline_datapushed back into the streamline.x[i]: Returns a new bundle containing only the selected streamlines, with@bundle_dataand the subset of@streamline_datapreserved.
Additional properties
@n_streamlinesAn integer scalar giving the number of streamlines in the bundle (read-only).
@streamline_attributesA character vector of the names of the per-streamline attributes stored at the bundle level (read-only).
@bundle_attributesA character vector of the names of the bundle-level attributes (read-only).
Examples
sl1 <- streamline(
points = cbind(X = 0:4, Y = 0:4, Z = 0:4),
streamline_data = list(mean_FA = 0.6, label = "CST")
)
sl2 <- streamline(
points = cbind(X = 1:3, Y = 1:3, Z = 1:3),
streamline_data = list(mean_FA = 0.7, label = "CST")
)
# mean_FA and label are common to both streamlines and are lifted
b <- bundle(streamlines = list(sl1, sl2))
b@n_streamlines # 2
#> [1] 2
b@streamline_attributes # c("mean_FA", "label")
#> [1] "mean_FA" "label"
b@streamline_data$mean_FA # c(0.6, 0.7)
#> [1] 0.6 0.7
# Subsetting pushes streamline_data back down
b[[1]]@streamline_data$mean_FA # 0.6
#> [1] 0.6
b[1]@streamline_data$mean_FA # c(0.6)
#> [1] 0.6
