% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/coerce.R
\name{as_dwifiber}
\alias{as_dwifiber}
\title{Coerce a streamline or bundle to a \code{dwiFiber} object}
\usage{
as_dwifiber(x, ...)
}
\arguments{
\item{x}{A \link{streamline} or \link{bundle} object.}

\item{...}{Additional arguments (currently unused).}
}
\value{
An S4 object of class \code{dwiFiber} (from \pkg{dti}).
}
\description{
\code{as_dwifiber()} converts a \link{streamline} or \link{bundle} to the S4 class
\code{dwiFiber} from the \pkg{dti} package.
}
\details{
Per-point direction vectors are taken from \verb{@point_data$direction_x},
\verb{@point_data$direction_y}, and \verb{@point_data$direction_z} when
present; otherwise they are estimated via finite differences of the
coordinates (forward difference at the first point, backward difference at
the last, central differences in between), then unit-normalised.

Bundle-level metadata stored in \verb{@bundle_data} under the keys \code{method},
\code{minfa}, \code{maxangle}, \code{ddim}, \code{ddim0}, \code{voxelext}, \code{orientation}, \code{rotation},
\code{level}, and \code{source} are transferred to the corresponding \code{dwiFiber} / \code{dwi}
slots when present. MRI-acquisition metadata that cannot be recovered from a
\code{fiber} object (gradient directions, b-values, etc.) are filled with neutral
placeholders.
}
\examples{
if (requireNamespace("dti", quietly = TRUE)) {
  pts <- matrix(runif(15), ncol = 3, dimnames = list(NULL, c("X", "Y", "Z")))
  sl  <- streamline(points = pts)
  b   <- bundle(streamlines = list(sl))
  dfi <- as_dwifiber(b)
  class(dfi)  # "dwiFiber"
}
}
\seealso{
\code{\link[=as_streamline]{as_streamline()}}, \code{\link[=as_bundle]{as_bundle()}}
}
