Structural Adaptive Smoothing in Diffusion Tensor Imaging : The R Package dti

Diffusion weighted imaging has become and will certainly continue to be an important tool in medical research and diagnostics. Data obtained with diffusion weighted imaging are characterized by a high noise level. Thus, estimation of quantities like anisotropy indices or the main diffusion direction may be significantly compromised by noise in clinical or neuroscience applications. Here, we present a new package dti for R, which provides functions for the analysis of diffusion weighted data within the diffusion tensor model. This includes smoothing by a recently proposed structural adaptive smoothing procedure based on the propagationseparation approach in the context of the widely used diffusion tensor model. We extend the procedure and show, how a correction for Rician bias can be incorporated. We use a heteroscedastic nonlinear regression model to estimate the diffusion tensor. The smoothing procedure naturally adapts to different structures of different size and thus avoids oversmoothing edges and fine structures. We illustrate the usage and capabilities of the package through some examples.


Introduction
The basic principles of magnetic resonance diffusion weighted imaging (DWI) were introduced in the 1980's (LeBihan and Breton 1985;Merboldt, Hanicke, and Frahm 1985;Taylor and Bushell 1985), after nuclear magnetic resonance (NMR) had long been known to be sensitive to diffusion of molecules in complex systems (Carr and Purcell 1954).Since then, DWI has evolved into a versatile tool for in-vivo examination of tissues in the human brain (Le Bihan, Mangin, Poupon, Clark, Pappata, Molko, and Chabriat 2001) and spinal cord (Clark, Barker, and Tofts 1999).DWI probes microscopic structures well beyond typical image resolutions through water molecule displacement, a fact attracting broad interest in this technique.It can be used in particular to characterize the integrity of neuronal tissue in the central nervous system.
NMR images are acquired from signals measured in k-space by fast Fourier transform.In the case of single receiver coil systems and additive complex Gaussian noise in k-space, referred to as thermal noise below, this results in image grey values that follow a Rician distribution Rice(θ, σ) (Rice 1945).This distribution is characterized by two parameters: θ, corresponding to the signal of interest, and σ related to the noise standard deviation in k-space.
Diffusion in neuronal tissue depends on the particular microscopic structure of the tissue and is usually not isotropic.Different diffusion directions b can be probed by applying bipolar magnetic field diffusion gradients (Stejskal and Tanner 1965).Let S b denote the acquired diffusion weighted image with the "b-value" b, which depends on the pulse sequence parameters.The non-diffusion weighted image (b = 0) is denoted by S 0 .Due to the diffusion of water molecules during the application of the magnetic field gradient, the signal S b is attenuated relative to S 0 : S b ∼ Rice(θ 0 exp(−bD( b)), σ) , S 0 ∼ Rice(θ 0 , σ) where D( b) is the diffusion constant probed in direction b.
Equation 1 imposes several problems for the data analysis.I.The model for the measured data S is nonlinear in D. II.The measured data S suffers from noise typical for NMR images.While for the non-diffusion weighted image S 0 a Gaussian noise model seems to be an appropriate approximation, the Rician distribution of the attenuated signal values S b can be significantly different from a Gaussian.Ignoring this introduces a bias into the estimation of the diffusion constant and hence all derived quantities.III.The lower the noise level in the measured data is, the more accurately the diffusion constant can be estimated.Thus, a noise reduction would be helpful to improve the accuracy of the diagnostic measures derived from the data.
Typically, diffusion weighted images S b are measured for up to 100 (or more) diffusion gradient directions b resulting in very high-dimensional data.It was the development of diffusion tensor imaging (DTI, Basser, Mattiello, and LeBihan 1994a,b), see also Mori (2007) for an introduction, which triggered a plethora of clinical and neuroscience applications of DWI.There, the high-dimensional information in the diffusion weighted images is reduced to a Gaussian distribution model for free anisotropic diffusion.Within this model, diffusion is completely characterized by a rank-2 diffusion tensor D, a symmetric positive definite 3 × 3 matrix with six independent components.This model describes diffusion completely if the microscopic diffusion properties within a voxel are homogeneous and non-restricted.In the presence of partial volume effects, like crossing fibers, this model is only an approximation.For these cases, more sophisticated models exist, which rely on the measurement of diffusion weighted images with high angular resolution (Tuch, Weisskoff, Belliveau, and Wedeen 1999;Frank 2001).These shall not be considered in this paper.
Due to recording the image volumes sequentially in time the data acquisition process is prone to artifacts caused e.g., by head motion, respiration and heartbeat.Image registration is usually applied to reduce these effects.We refer to Brammer (2001); Lazar (2008) or Mori (2007) for an overview and to Eddy, Fitzgerald, and Noll (1996) or Cox and Jesmanowicz (1999) for more specific algorithms.For a comparison of software packages for registration see Oakes, Johnstone, Walsh, Greischar, Alexander, Fox, and Davidson (2005).
DTI suffers from significant noise which may render subsequent analysis or medical decisions more difficult.Noise here summarizes several effects (Lazar 2008), e.g., thermal noise caused by thermal motion of electrons, physiological noise summarizing effects of the respiratory and cardiological cycles and system noise created by fluctuations within the MR hardware.
Physiological noise can partly be controlled within the acquisition process (Hu, Le, Parrish, and Erhard 1995;Glover, Li, and Ress 2000).In the presence of thermal noise the estimation of anisotropy indices from the diffusion tensor is known to be systematically biased (Basser and Pajevic 2000;Hahn, Prigarin, Heim, and Hasan 2006).In addition to the common random errors the order of the diffusion eigenvectors of the tensor which is essential for fiber tracking is subject to a sorting bias especially at high noise levels.Noise reduction is therefore essential.
In Tabelow, Polzehl, Spokoiny, and Voss (2008) we proposed a new smoothing method for noise reduction in DTI based on the propagation-separation (PS) approach (Polzehl and Spokoiny 2006).The procedure has been shown to naturally adapt to the structures of interest at different scales (Tabelow et al. 2008;Polzehl and Spokoiny 2006).Thus, it avoids loss of information on size and shape of structures, which is typically observed when using non-adaptive filters.This is especially important for DTI, where the structures of interest, the white matter fibers, may be very small and anisotropic.
Extending Tabelow et al. (2008) we in this paper discuss the estimation of the diffusion tensor from the diffusion weighted data using heteroscedastic non-linear regression, propose a model for heteroscedastic variances and provide a solution for Rician bias correction within the structural adaptive smoothing procedure.We present a new package dti (Tabelow and Polzehl 2009b) for R (R Development Core Team 2009), which implements this extended PS approach for reducing the noise by adaptive smoothing of diffusion weighted data in the context of the diffusion tensor model.The package provides methods for all steps in a common diffusion tensor analysis from data access to visualization of estimated tensors and indices.
The paper is organized as follows: In Section 2 we review the basic notation of DTI and discuss linear as well as non-linear estimation methods for the diffusion tensor and the estimation of heteroscedastic variances.Section 3 is dedicated to Rician bias and its correction.We outline the extended structural adaptive smoothing procedure in Section 4. Finally, we describe the usage and capabilities of the R package dti and provide several examples in the last Section 5.

The diffusion tensor model and its quantities
Using a Gaussian model of diffusion, the anisotropy can be described by a rank-2 diffusion tensor D, which is represented by a symmetric positive definite 3 × 3 matrix: The "b-value" in Equation 1 is replaced by a "b-matrix" (Mattiello, Basser, andLeBihan 1994, 1997), leading to The components of the diffusion tensor clearly depend on the orientation of the object in the scanner frame xyz.Only rotationally invariant quantities derived from the diffusion tensor circumvent this dependence and are usually used for further analysis, mainly based on the eigenvalues µ i (i = 1, 2, 3) of D with µ i > 0 for positive definite tensors.The eigenvector e 1 corresponding to the principal eigenvalue µ 1 determines the main diffusion direction used for fiber tracking.
The simplest quantity based on the eigenvalues is the trace of the diffusion tensor which is related to the mean diffusivity µ = T r(D)/3.The anisotropy of the diffusion can be described using higher moments of the eigenvalues µ i .The widely used fractional anisotropy (FA) is defined as with 0 ≤ F A ≤ 1, where F A = 0 indicates equal eigenvalues and hence no diffusion anisotropy.
The resulting FA maps together with a color-coding scheme are helpful for medical diagnostics.
The principal eigenvector e 1 = (e 1x , e 1y , e 1z ) is used for assigning each voxel a specific color, interpreting e 1x , e 1y , and e 1z as red, green, and blue contribution weighted with the value In contrast to the eigenvalues and the fractional anisotropy the principal eigenvector depends on the orientation of the object in the scanner frame xyz.Thus, the color coding depends on patient orientation.• F A = F A. Also note, that the direction corresponding to a specific color is not unique since the signs of the eigenvector components are lost.This problem can be circumvented when the diffusion tensor ellipsoid is shown in 3D using the color scheme.
As an alternative to the fractional anisotropy the geodesic anisotropy (GA) has been proposed (Fletcher 2004;Corouge, Fletcher, Joshi, Gouttard, and Gerig 2006) to take the metric structure of the tensor space into account.Note, that 0 ≤ GA < ∞.
The diffusion tensor represents a diffusion ellipsoid with the three main axis given by µ i .To describe the shape of the diffusion tensor a decomposition into three basic shapes -spherical, planar, and linear -can be used (Westin, Maier, Khidhir, Everett, Jolesz, and Kikinis 1999;Alexander, Hasan, Kindlmann, Parker, and Tsuruda 2000): where the sum of the three contributions is C s + C p + C l = 1.Again, we can interpret the three shape values as red, green, and blue component of a color assigned to the voxel in order to visualize the tensor shape.

Linear estimation of the diffusion tensor
To completely determine the diffusion tensor, one has to acquire diffusion weighted images for at least N grad = 7 gradient directions b including the non-diffusion-weighted image S 0 .However, since the estimation errors of the eigenvalues are not rotationally invariant, about 30 gradient directions are required for a robust quantitative measurement of eigenvalues and tensor orientation (Jones 2003(Jones , 2004;;Kinglsey 2006).
In one of our previous publications (Tabelow et al. 2008) at each voxel i the diffusion tensor D i has been estimated via multiple linear regression using the equation: and the assumption that the errors ε b,i are i.i.d.Gaussian N (0, σ i ).The noise variance σ 2 i in voxel i has been estimated from the residuals in the linear model, while the variance of the estimated tensor was assessed from this estimate and the "b-matrix".There are at least two weaknesses in this approach.First, due to the log-transform, error variances are highly heteroscedastic and therefore the ordinary least squares estimate is inefficient and its variance estimate biased.Even more important, if the tensor model is inadequate the residuals from (9) contain structure that is not explained by the model and hence, the variance of the estimated tensor may be strongly over-estimated.This decreases the statistical penalty in the adaptive smoothing procedure proposed in Tabelow et al. (2008) and therefore reduces the effectivity of adaptation.This drawback is avoided with non-linear tensor estimation by use of a modified statistical penalty, see Section 4.

Non-linear estimation of the diffusion tensor
The drawbacks connected with the use of the log-transform of the data in the linearized model ( 9) can be avoided by using the heteroscedastic non-linear regression model for all b including the non-diffusion weighted gradient (b = 0).In this model the parameter θ 0 reflects the expected intensity in non-diffusion weighted images.In order to enforce positive definiteness of the tensor estimates it is possible to re-parameterize the model ( 10) using the Choleski decomposition D = R R with an upper triangular matrix R with non-zero diagonal elements (Koay, Carew, Alexander, Basser, and Meyerand 2006).In Koay, Chang, Pierpaoli, and Basser (2007) the efficiency of this projection method in comparison with an unconstrained nonlinear regression model ( 10) has been investigated.For alternative regularization techniques see e.g., Arsigny et al. (2006); Fillard et al. (2007a) or Pennec et al. (2006).In our implementation we estimate the parameters θ 0,i and D i in each voxel i using the risk function R defined by where the sum is over all diffusion gradient vectors b including the non-diffusion weighted images (b = 0).In θ0,i we use an unconstrained minimization as long as the estimated diffusion tensor is positive definite and the re-parameterization D = R R (Koay et al. 2006), otherwise.Minimization is done using a regularized Gauss-Newton algorithm (Schwetlick 1979, Algorithm 10.2.8).The variability of the tensor estimates can be assessed using profile likelihood.

Variance estimates
In order to estimate the diffusion tensor using ( 11) and ( 12) we need to model the heteroscedastic variances σ 2 b,i . Empirical evidence from various DWI data sets with replicated non-diffusion weighted images suggests the existence of a wide range of image intensity values where the standard deviation σ b,i can be well approximated by a linear function of the observed image intensity.Figure 1 illustrates the situation for two data sets with replicated S 0 images.The linear dependence between noise variance and image intensity seems to reflect properties of physiological noise.
We therefore use the following model for the error standard deviations Here A 0 is set to the minimum, over voxel within the head, intensity in non-diffusion weighted images.For A 1 we use the 0.99 quantile of S 0 intensities within the head.The choice of A 0 and  13) in both cases.Data set 1 is not registered causing a positive bias in voxelwise variance estimates from replications.The dashed curves in the left panel provide the corresponding estimates using mean absolute deviation (mad) as an alternative to voxelwise standard deviation (sd) to lower this effect.For a description of the two data sets see Section 5.5.
A 1 coincides with the range where we observe approximative linearity between the standard deviation and the mean.
The parameters σ 0 and σ 1 are estimated by linear regression between estimated voxelwise standard deviations and mean grey values in the case of a replicated non-diffusion weighted image or from a single non-diffusion weighted image using adaptive smoothing with explicit specification of the dependency between mean and standard deviation, see Polzehl and Tabelow (2007).In both cases the estimates will be restricted to use voxel with intensity within the range (A 0 , A 1 ).

Rician bias
Thermal noise in DWI can be modeled as additive Gaussian noise in both the real and imaginary part of the signal in k-space.After fast Fourier transform into image space the resulting observed signal follows a Rician distribution (Rice 1945) with parameters ζ and σ. ζ is the signal of interest while σ corresponds to the standard deviation of the errors in k-space.
The density of Rician distribution is given by where I 0 is the modified zeroth-order Bessel function of the first kind.Mean and variance of the Rician distribution are given by with For large ζ/σ we get EX ≈ ζ, while for small ζ/σ the expected value of the observed signal is significantly larger than the parameter of interest ζ.This effect is called Rician bias and is more pronounced in the diffusion weighted images where the signal is attenuated, see Equation 1.The Rician bias in the diffusion weighted images may lead to a bias in the estimated tensors as well as in quantities derived from the tensor, see Basu, Fletcher, and Whitaker (2006).We therefore include a correction for Rician bias in our implementation.

Correction for Rician bias
In order to avoid the Rician bias we need to estimate the parameters ζ and σ of the underlying Rician distribution from the measured signals S. Let us assume we have samples k=1 drawn from a Rician distribution Rice(ζ k , σ).This resembles the situation within DWI data assuming that the noise variance in k-space does not depend on the gradient direction.For identifiability of the distribution parameters we need n > 1, which can be achieved by locating voxel with similar parameters within a local vicinity, see Section 4. Let now W = {w 1 , . . ., w n } define a set of weights.We can then define a weighted log-likelihood function as Differentiating with respect to the parameters ζ and σ 2 yields conditions for the likelihood estimate of The estimates ζk and σ2 can thus be obtained as fixpoints of ζk = 1 through iteration.As initial estimate we use the corresponding likelihood estimates for a Gaussian distribution We use a prespecified number of iteration steps depending on the ratio k , i.e., no iteration if the ratio is larger than 10 and up to 6 iterations if the ratio is small.
If an estimate of σ can be obtained from the background it can be used in (20) alternatively, see e.g., Fillard et al. (2007a).

Structural adaptive smoothing
We recently proposed a new structural adaptive smoothing algorithm for diffusion weighted data in the context of the diffusion tensor model (Tabelow et al. 2008).The approach reduces the error of the estimated tensor directions and tensor characteristics like fractional anisotropy by smoothing the observed DWI data.The application of a standard Gaussian filter would be highly inefficient in the DTI applications in view of the anisotropic nature of the diffusion tensor and sharp boundaries between region with different tensor characteristics.Indeed, the tensor direction remains constant mainly along the fiber directions.Averaging over a large symmetric neighborhood of every voxel would thus lead to a loss of directional information.
In order to avoid such a loss our smoothing procedure sequentially determines at increasing scales local weighting schemes with positive weights for voxel that show similar characteristics.
To achieve this we employ the structural assumption that for every voxel there exists a vicinity in which the diffusion tensor is nearly constant.This assumption reflects the fact that the structures of interest are regions with a homogeneous fractional anisotropy, a homogeneous diffusivity, and a locally constant direction field.The shape of this neighborhood can be quite different for different voxel and cannot be described by few simple characteristics like bandwidth or principal directions.
The algorithm for the case of linear tensor estimates using model (9) has been described in detail in Tabelow et al. (2008).Here, we shortly present a modified algorithm that is based on the nonlinear regression model (10) for the diffusion tensor and incorporates the Rician bias correction developed in the previous section: Adaptation: For each voxel pair i, j, we compute the penalty i with the risk R based on the previous estimates ζ(k−1) ij measures the statistical difference between the estimates θ(k−1) 0 and D(k−1) at voxel i and j.Weights are computed as , with appropriate kernel functions K loc and K st , an anisotropic distance function ∆, and a regularized tensor estimate D(k−1) i , see Tabelow et al. (2008) for details.

Rice bias correction and estimation of diffusion weighted images: Compute ζ(k)
.
) by maximizing the log-likelihood ( 18 Parameter estimation: Compute new estimates of the expected non-diffusion weighted images θ 0,i and diffusion tensors D i as Stopping: Stop if k = k * for a preselected number of iteration steps, otherwise set k) , increase k by 1 and continue with the adaptation step.
The term C i (g, h (k−1) ) provides an adjustment under the assumption that spatial smoothness of the errors can be modeled by a convolution of independent errors with a Gaussian kernel of bandwidth g, see e.g., Tabelow et al. (2008) or Tabelow, Polzehl, Voss, and Spokoiny (2006) for details.The Rician bias correction can be omitted using S .,iinstead of ζ(k) .,i in all steps.λ is the main parameter of the procedure and can be determined by simulations, see Polzehl and Spokoiny (2006) or Tabelow et al. (2008) for details.

Using the package dti
This document refers to the versions 0.6-0 or later of the dti package which is available from the Comprehensive R Archive Network (CRAN) at http://CRAN.R-project.org/package=dti.The software is under constant development, see Section 5.8 for details on the plans for the next future.Changes are documented in the HISTORY file of the package.
For the analysis of diffusion weighted data, there is an overlap in functionality needed from other packages.In order to fully use the package dti it is therefore required to install the packages fmri (Tabelow and Polzehl 2009c) for reading and writing medical imaging formats like ANALYZE, NIfTI, or DICOM as well as adimpro (Tabelow and Polzehl 2009a) and rgl (Adler and Murdoch 2009) for visualization.These packages can also be downloaded from CRAN.
For a typical analysis we assume the DWI data to reside in a directory, say "datadir", and the gradient matrix in a file, say "gradient.txt".A script for the analysis could then have the form R> library("dti") R> grad <-read.table("gradient.txt")R> data <-readDWIdata(grad, "datadir", dataformat, ngrad) R> data <-sdpar(data) R> tensor <-dtiTensor(data) R> tensor <-dti.smooth(data,hmax = 4) R> dtind <-dtiIndices(tensor) The steps of the analysis including visualization and some utility functions will be discussed within the next subsections.Memory requirements and computation time will also be illustrated.
For an overview over the package capabilities see help(dti) and run the dti_art demo

Data processing
Diffusion weighted data can often be found collected in (one or several) DICOM folders depending on the acquisition protocol of the scanner, as well as preprocessed compilations of ANALYZE or NIfTI files or other formats.The package provides a function readDWIdata() to read data in these formats from one or more directories that contain solely the imaging files.e.g., DICOM files for all slices and gradient directions.There may be cases, where the slice ordering differs from the alphabetic order of the files.In these cases the order argument of the function can be used.
A region of interest can be specified by index vectors xind, yind, zind for the three dimensions of the data cubes.Reading a region-of-interest (ROI) of DICOM data from two directories is e.g., performed by R> grad <-read.table("gradient.txt")R> dwiobj <-readDWIdata(grad, c("datadir/s0011/","datadir/s0012/"), + " DICOM",72,xind = 129:196,yind = 129:196,zind = 25:30) The two-dimensional array grad has rows corresponding to the gradient vectors including the non-diffusion weighted gradient (0, 0, 0) in the same order as the diffusion weighted data.Note, that in case of DICOM folders depending on the acquisition protocol the slice order may differ from the alphabetic order of the file names.We therefore provide the argument order to put the slices into the correct order.The reason for not providing this automatically is the until now limited capability of the read.DICOM() function in the fmri package.
As an alternative we provide a simple interface for the diffusion weighted data using a binary file.Such a file can be created using the I/O functions from the packages fmri, Ana-lyzeFMRI (Marchini and de Micheaux 2008), DICOM (Whitcher 2005) or others.Diffusion weighted data is a set of N grad three dimensional data sets (e.g., covering the brain) corresponding to N grad diffusion weighted images including the non-diffusion weighted images.These data sets are written in the corresponding order into a binary file of 2 byte integer values, denoted by "S-all" here: R> con <-file("S-all", "wb") R> for (gg in 1:16) { + data <-read.ANALYZE(,<filename>[gg]) + writeBin(as.integer(extract.data(data)),con, 2) + } R> close (con) where <filename> refers to the array of file names for the ANALYZE files containing the diffusion weighted and non-diffusion weighted images in this example.The data from the binary file "S-all" can then be read into the R session using the function dtiData().
R> dwiobj <-dtiData(grad, "S-all", ddim) All three arguments are required.Argument ddim denotes the dimension vector of length 3 of the data set, while the number N grad of diffusion weighted images is implicitely given by the dimension of grad.help(dtiData) provides documentation of the function and more arguments, e.g., the choice of a ROI.The result dwiobj is an object of class "dtiData", see Section 5.2 for details on the class definitions within the package.

R> dwiobj <-sdpar(dwiobj, interactive = TRUE)
is a function to interactively set a threshold that characterizes grey values in non-diffusion weighted images of voxel within the head and to estimates the parameters of the variance model (13).To assist the selection of a cut-off point densities of S 0 intensities are provided for the full data cube as well as three central subcubes of different size.The left mode of the densities is expected to correspond to voxel outside the head, i.e., a cut off point should be selected on the right of this first mode, see the vertical red line in Figure 2. If not called explicitely this function will be used by dtiTensor() in its non-interactive mode.
In the current version of the package diffusion weighted data is processed within the diffusion tensor model.The method dtiTensor() on any object of class "dtiData" estimates the diffusion tensor: R> dtobj <-dtiTensor(dwiobj) The standard method for the tensor estimation uses the non-linear model (10) described in Section 2.3.However, the linearized model ( 9) can be used by specifying the argument method = "linear".The resulting dtobj is an object of class "dtiTensor", see Section 5.2.From the diffusion tensor a number of measures based on the eigenvalue representation of the tensor can be derived, like the trace, fractional anisotropy (FA), geodetic anisotropy (GA), shape parameters or the principal eigenvector defining the main diffusion direction, see Section 2. The method dtiIndices() on objects of class "dtiTensor" returns an object of class "dtiIndices" containing all these quantities: R> dtind <-dtiIndices(dtobj) Visualization of the results can be done using the generic plot() functions on all three objects dwiobj, dtobj, and dtind, which show slices of the data, the tensor components, and color coded directional maps, respectively.If appropriate the plot() function returns an adimproimage which can be further processed using functions from the adimpro package (Polzehl and Tabelow 2007).3D visualization for diffusion tensors and indices is provided by generic function show3D() which makes use of the rgl package.

Objects and methods
The package implements S4 classes and methods.The main class is "dti" from which no instances should be created.This class inherits to three subclasses "dtiData" for diffusion weighted data, "dtiTensor" for the estimated diffusion tensor objects and "dtiIndices" for tensor indices like fractional anisotropy.The class constructors provide consistency checks for these objects.Although not recommended, it is possible to access the slots directly.See class?dti for documentation of the classes.For all subclasses methods for the generic functions plot(), print(), and summary() have been implemented.Generic functions extract() and "[<-" allow for extraction of information and index operation, respectively.See dti: Structural Adaptive Smoothing in Diffusion Tensor Imaging methods?name for documentation of the methods and help(name) for information on the functions.

Data smoothing
Due to the high noise level in diffusion weighted data the package dti provides structural adaptive smoothing of diffusion weighted data as one of its main features.The method dti.smooth() implements the procedure described in the first sections of this paper.Since the algorithm directly smooths the diffusion weighted images it is only implemented for objects of class "dtiData".
dti.smooth() can be used with several parameter switches.One choice is between linear and non-linear tensor estimation as described in the Section 2 of this paper.The default is set to non-linear estimation.Another choice is whether to include the correction for Rician bias, which defaults to TRUE.R> dtobjsmooth <-dti.smooth(dwiobj,hmax = 3, method = "linear", + rician = TRUE) R> dtindsmooth <-dtiIndices(dtobjsmooth) R> plot(dtindsmooth, slice = 30) The main smoothing parameter is the maximum bandwidth hmax used for the iteration.It directly influences the amount of smoothness in the homogeneous regions of the data, and the complexity of the calculations via the number of iteration steps k .Typical values are in the range of 2-4 (voxel).
Other parameters are technical and include the degree of adaptation, the degree of regularization of the tensor estimates for small bandwidths, some display parameters, and choices about the variance model, in case of method = "linear", to be used in the estimation of the variance of the tensor estimates (see help(dti.smooth)).They are intended for expert use only.

Data visualization
For all subclasses of "dti" we implemented the generic plot() function to visualize the objects in two dimensions.If appropriate the function returns an object of class "adimpro" for further processing with the functions of the package adimpro.For "dtiData" objects a slice of the selected diffusion weighted image is shown.For "dtiTensor" objects the tensor components of the selected slice are shown.No image is returned.For "dtiIndices" objects a color coded directional map is shown and returned as adimpro object.See the documention (methods?plot)for details and left part of Figures 4 and 5 for examples.
Based on the package rgl and OpenGL the package dti provides a 3D visualization with the method show3d() for classes "dtiTensor" and "dtiIndices": For a tensor object ellipsoids are shown, while for the tensor indices lines are drawn with length corresponding to the FA value, see Figure 3.

Experimental data examples
For the illustrations in this manuscript we used three different DWI data sets which we briefly describe here.Data set 2 This data set has been made available by A. Anwander (Max Planck Institute for Human Cognitive and Brain Sciences Leipzig, Germany).The data cube consists of 128×128×72 voxel, with spatial resolution 1.71875×1.71875×1.7mm 3.60 diffusion encoding gradients with an b-value of 1000s/mm 2 have been applied with 7 zero weighted images at the beginning and after each block of 10 diffusion weighted images.The whole sequence was replicated three times yielding a total of 180 diffusion weighted and 21 zero weighted images.The data cubes have been registered.Image intensities have been normalized to a relatively, compared to data set 1, small range during image reconstruction, see x-axis in Figure 1.

Interface to MedINRIA
In the current version of the package dti no fiber tracking algorithms are implemented.Therefore, we decided to provide an interface to MedINRIA (Fillard, Souplet, and Toussaint 2007b) which runs on different major platforms.The function tensor2medinria() writes a NIfTI file with the tensor data in an appropriate format which can be read by MedINRIA.

R> tensor2medinria(dtobj, file = <filename>)
It is also possible to read a tensor object from MedINRIA given as NIfTI file for further processing like structure adaptive smoothing with the package dti in R: R> dtobj <-medinria2tensor(file = <filename>)

Computation time and memory requirements
A word of caution concerning the memory usage of the implementation is in place here: DWI data sets are usually very large.A typical full brain data set of matrix size 256×256 and about 70 slices measured at 30 diffusion gradient directions in 2-byte integer representation needs 256×256×70×30×2 ≈ 262.5 MBytes.The structure adaptive smoothing algorithm operates on all diffusion weighted images.In the current implementation these data are therefore kept in memory and it is usually not possible to run a full data set on a Desktop computer.One has to restrict the analysis to a ROI if restricted memory is a problem.
We provide information on memory usage and CPU-time for various steps of the analysis and three DWI data sets in Table 1.Data set 3 (first column) is small, with few gradient directions and without replicated non-diffusion weighted images.Data sets 2 (center) and 3 (third column) are characterized by a large number of gradients and replicated non-diffusion weighted images.All data sets have been reduced in size to a cube containing all voxel within the head.Computations are restricted to voxel inside the head using a mask.The first two data sets have been processed on a PC equipped with an Intel Core 2 Duo E 6850 3 GHz and 4 GByte of memory.For the third data set we used an Intel Xeon CPU 5160 3 GHz and 24 GByte of memory.The operating system was OpenSuse 11.0 with R version 2.7.1.
The values recorded for the mean sum of weights (mean of N i ) for the three data sets reflect the very different variability of the tensor estimates due to the varying number of gradients used.

Future plans
The diffusion tensor model does not appropriately describe diffusion weighted data, since it does not account for complex intravoxel structure (fiber crossings) and partial volume effects.We are therefore currently developing a structure adaptive algorithm for HARDI data, which combines smoothing the diffusion weighted images, estimation of the ODF's or other angular distribution measures and fiber tracking in one algorithm.

Figure 1 :
Figure1: Local polynomial estimates of mean standard deviation as a function of mean grey value (solid) and density of mean grey values (dotted) observed for two DWI data sets with replicated non-diffusion weighted images S 0 .The red and blue curves correspond to variance estimates obtained from replicates (red) and mean variance estimates obtained from single images (blue), respectively, using the model (13) in both cases.Data set 1 is not registered causing a positive bias in voxelwise variance estimates from replications.The dashed curves in the left panel provide the corresponding estimates using mean absolute deviation (mad) as an alternative to voxelwise standard deviation (sd) to lower this effect.For a description of the two data sets see Section 5.5.

Figure 2 :
Figure 2: Selection of cut-off points for characterization of voxel within the head.

Data set 3
This data set (CIBC 2008) was made available by the NIH/NCRR Center for Integrative Biomedical Computing, P41-RR12553.These images are typical examples of diffusion tensor imaging of the brain.They contain twelve diffusion weighted volumes and one non-diffusion weighted (b = 0) reference volume.The data has a spatial resolution of 1.5 mm on each axis.The front of the head is at the top of the image.This scan goes from the top of the head down to about the middle of the brain, below the corpus callosum, but above the eyes.The DTI data was collected on a 3 Tesla MRI scanner in the W.M. Keck Laboratory for Functional Brain Imaging and Behavior by Dr. Andrew Alexander, Departments of Medical Physics and Psychiatry, University of Wisconsin, Madison, funding: NIH RO1 EB002012.The Figures 4 and 5 illustrate some of the properties of the structural adaptive smoothing

Figure 4 :
Figure 4: Real DWI data example: The left column shows the estimated color-coded directional map weighted with FA for slices 22-24 of the CIBC data set (CIBC 2008).White squares mark the extend of the region used in the right column.There, the noisy (top) and smoothed (bandwidth 4, bottom) tensors are visualized.Structural adaptive smoothing apparently leads to a homogenization of the regions without blurring the structural borders.

Figure 5 :
Figure 5: Results for a region within slices 28-30 of the CIBC data set (CIBC 2008).See caption of Figure 4 for interpretation of content.