Scripts

stdeconv

For calculating the single-tissue response functions and the fODFs for given data run the following command [Ankele17]:

$ stdeconv -i /path/to/your/data

The specified folder should contain the following files:

  • bvecs: b-vectors

  • bvals: b-values

  • data.nii.gz: The diffusion weighted data

  • dti_FA.nii.gz: Diffusion tensor Fractional Anisotropy map

  • dti_V1.nii.gz: The first eigenvector of the diffusion tensor

The dti_* files can be generated using FSL’s dtifit. This script works if we have no T1 data.

Optional, but recommended:

  • mask.nii.gz: Binary mask, specifying brain voxels in which to estimate the model.

  • fast_pve_2.nii.gz: WM mask

Further important parameters are:

  • --rank: The rank of the computed fODF. Higher ranks lead to sharper peaks as well as higher susceptibility to noise. Default: 4. Supported: 4,6,8

  • --kernel: The single tissue response kernel used to estimate the CSD. Options are either rank1 a single fiber rank-1 fiber corresponding to the rotational harmonic parts of the spherical harmonics up to the specified order or delta a single peak. rank1 reduces the susceptibility to noise. Default: rank1

If you want to see a list of parameters type the following:

$ stdeconv -h

mtdeconv

For calculating the multi-tissue response functions and the fODFs for given data run the following command [Ankele17]:

$ mtdeconv -i /path/to/your/data

The specified folder should contain the following files:

  • bvecs: b-vectors

  • bvals: b-values

  • data.nii.gz: The diffusion weighted data

  • dti_FA.nii.gz: Diffusion tensor Fractional Anisotropy map

  • fast_pve_0.nii.gz: CSF mask

  • fast_pve_1.nii.gz: GM mask

  • fast_pve_2.nii.gz: WM mask

  • dti_V1.nii.gz: The first eigenvector of the diffusion tensor

The dti_* files can be generated using FSL’s dtifit. The fast_* files can be generated from coregistered T1 weighted images using FSL’s fast.

Optional, but recommended to greatly speed up computation:

  • mask.nii.gz: Binary mask, specifying brain voxels in which to estimate the model.

Further important parameters are:

  • --rank: The rank of the computed fODF. Higher ranks lead to sharper peaks as well as higher susceptibility to noise. Default: 4. Supported: 4,6,8

  • --kernel: The single tissue response kernel used to estimate the CSD. Options are either rank1 a single fiber rank-1 fiber corresponding to the rotational harmonic parts of the spherical harmonics up to the specified order or delta a single peak. rank1 reduces the susceptibility to noise. Default: rank1

If you want to see a list of parameters type the following:

$ mtdeconv -h

low-rank-k-approx

For calculating the low-rank k approximation [Schultz08] of a given 4th order fODF run the following command:

$ low-rank-k-approx -i /path/to/your/fODF.nrrd -o path/to/output.nrrd

With additional argument

  • -r: Rank of low rank approximation. Default = 3

The output is a dim (4,r,x,y,z) array. Here the first axis contains in place 0: \(\lambda\) the volume fraction and in the remaining places \(\mathbb{v}\) the unit direction.

peak-modelling

Build a new model (Selection or Averaging) from given low rank k = 1,2,3 approximations [Gruen22] by running the following command:

$ peak-modelling -f path/to/fODF.nrrd -i path/to/rank-1.nrrd path/to/rank-2.nrrd path/to/rank-3.nrrd -o path/to/outfile.nrrd

Further the parameters can be set

  • -t: selection or averaging. Default averaging

  • -a: a parameter for Kumaraswarmy PDF. Default a = 1

  • -b: b parameter for Kumaraswarmy PDF. Default b = 20

The output is a dim (4,3,x,y,z) array. Here the first axis contains in place 0: \(\lambda\) the volume fraction and in the remaining places \(\mathbb{v}\) the unit direction. If a voxel contains only 1 or 2 directions they are at the first entries of the second axis.

csd-peaks

For extracting maxima from a given 8th order fODF (These can be generated by running the mtdeconv script with additional parameters -k delta -r 8 -C nonneg) by run the following command:

$ csd-peaks path/to/fODF.nrrd path/to/output.nrrd

Further parameters can be set

  • -r: Count of fibers to extract. Default 3

  • -sa: Minimum separation angle in degrees. Default 0

  • -m: Minimum height of peak. Default 0

The output is a dim (4,r,x,y,z) array. Here the first axis contains in place 0: \(\lambda\) the volume fraction and in the remaining places \(\mathbb{v}\) the unit direction.

prob-tracking

Within the generated multivectorfields, which are an output of either low-rank-approx, peak-modelling or csd-peaks, running the following command

$ prob-tracking --i /path/to/inputs -o /path/to/output.ply

generates streamlines for each seed point. Depending on the parameters, this script performs a basic form of streamline tractography, uses model averaging over fiber estimates with different numbers of compartments [Gruen22], or spatial regularization via joint approximation or an Unscented Kalman Filter [Gruen23].

If not further specified, the input folder has to contain the following:

  • rank3.nrrd

    Multidirectionfield, where the first dimension defines the length and the unit direction of the vector, second dimension defines different directions and remaining dimensions diffine the coordinate.

    If the file is named differently, use the --infile argument

  • wmvolume.nrrd

    The white matter mask, which is an output of mtdeconv.

    If the file is named differently, use the --wmmask argument

  • seedpoint.pts

    The seed point file in world coordinates. First 3 dimensions of row give world coordinates. Additionally a initial direction can be set by appending 3 columns to each row denoting the direction in (x,y,z) space.

    If the file is named differently, use the --seedpoint argument.

If the -ukf flag is set, the input folder should also contain:

  • bvals

    A text file which contains the bvals for each gradient direction.

    If the file is namend differenty, use the --ukf_bvals argument

  • bvecs

    A text file which contains all gradient directions in the format Ax3 If the file is named differently, use the --ukf_bvecs argument

  • data.nrrd

    The file with the data. If the --ukfmethod flag is set to

    • MultiTensor it should be the raw data.

    • LowRank it should be the fodf.nrrd output from mtdeconv

    If the file is named differently, use the --ukf_data argument.

  • baseline.nrrd

    File with b0 measurements

    If the file is named differently, use the --ukf_baseline argument

If the -disk flag is set and we want to append to a file, the inputfolder should contain
  • output.txt

    A textfile with the streamlines generated so far. If the file is named differently, use the --disk_append argument.

The output file is in ply format, which contain the vertex coordinates and the length of each streamline.

Further parameters can be set:

  • --infile: 5D (4,3,x,y,z) Multivectorfield, where the first dimension gives the length and the direction of the vector, the second dimension denotes different directions.

  • --wmvolume: WM Mask - output of mtdeconv

  • --act: 5tt output of 5ttgen. Will perform act if supplied.

  • --seedpoints: Seedspointfile: Each row denotes a seed point, where the first 3 columns give the seed point in (x,y,z). Further 3 additional columns can specified to define a initial direction. Columns should be seperated by whitespace.

  • --wmmin: Minimum WM density before tracking stops, default=0.15

  • --sw_save: Only each x step is saved. Reduces memory consumption greatly, default=1

  • --sw: Stepwidth for integration, default=0.9

  • --o: Filename for output file in ply or tck format. Only ply is fully supported.

  • --mtlength: Maximum track steps, default=300

  • --samples: Samples per seed, default=1

  • --max_angle: Max angle over the last 30 mm of the streamline, default=130

  • --var: Variance for probabilistic direction selection, default=1

  • --exp: Expectation for probabilistic direction selection, default=0

  • --interpolation: decide between FACT interpolation and Trilinear interpolation.’, default=’Trilinear’

  • --sigma_1: Only useful if interpolation is set to TrilinearFODF and dist>0. Controls sigma1 for low-rank, default=1

  • --data: Only useful if interpolation is set to TrilinearFODF and dist>0. Controls sigma1 for low-rank

  • --sigma_2: Only useful if interpolation is set to TrilinearFODF and dist>0. Controls sigma2 for low-rank, default=1

  • --dist: Only useful if interpolation is set to TrilinearFODF. Radius of points to include, default=0

  • --rank: Only useful if interpolation is set to TrilinearFODF. Rank of low-rank approx.’, default=3

  • --integration: Decide between Euler integration, Trilinear and TrilinearFODF integration, default=’TrilinearFODF’

  • --prob: Decide between Laplacian, Gaussian, Scalar, ScalarNew, Deterministic and Deterministic2, default=’ScalarNew’)

  • --disk: Write streamlines to file instead of using ram, default=True

  • --disk_file: Name of disk file. If not set a random filename is chosen.

  • --disk_delete: Delete file after finish. Otherwise further Streamlines can be appended if more streamlines are needed.

  • --ukf: The following arguments are just important if the –ukf flag is set to MultiTensor or LowRank

  • --ukf_data: File containing the raw data for ukf.

  • --ukf_bvals: File containg the bvals for each gradient direction

  • --ukf_bvecs: File containg the bvecs

  • --ukf_baseline: File containg the baseline’

  • --ukf_fodf_order: order of fODF. Only 4 and 8 are supported, default=4

  • --ukf_dim_model: Dimensions of model

  • --ukf_pnoise: Process noise

  • --ukf_mnoise: Measurement noise

For a set of possible directions \(v_i\) and a given current direction \(w\), the probability of the next direction is given either by Gaussian

\[p \left( v_i \right) = \exp \left( -1/2 \left(\frac{ \theta_i - b }{\sigma } \right)^2 \right)\]

Laplacian

\[p \left( v_i \right) = 1/2 \exp \left( - \left| \frac{ \theta_i - b } { \sigma } \right| \right)\]

ScalarOld

\[p \left( v_i \right) = \mathbb{1}_{ \lbrace \theta_i < \frac{1}{3}\pi \rbrace } \lambda_i \cos \left( \left( \frac{3}{\sqrt{2 \pi}} \theta_i \right)^2 \right)^2\]

ScalarNew

\[p \left( v_i \right) = \mathbb{1}_{ \lbrace \theta_i < \frac{1}{3}\pi \rbrace } \lambda_i \cos \left( \left( \frac{3}{\sqrt{2 \pi}} \theta_i \right)^2 \right)^2 \exp \left( - \frac{\left( \| v_i \| - \| w \| \right)^2}{\sigma} \right)\]

where \(\theta_i\) denotes the angle between \(\pm v_i\) and \(w\) (Select \(\pm v_i\) such that \(\theta_i \leq 90\)) and \(b\) is set via -exp and \(\sigma\) is set via -var. Then the next direction is chosen by an random draw.

The output file is in ply format, which contains two elements. Firstly, vertices: contains spatial information about the streamlines, e.g. coordinates in 3D. Further the seed-coordinate is marked by a 1. These are saved in the properties: x, y, z, seedpoint. Secondly, fiber. Contains the property endindex, which denotes the end index of a streamline.

bundle-filtering

The generated streamlines can be filtered by running the following command:

$ bundle-filtering -i path/to/trackingResults.ply -m path/to/fODF.nrrd -o path/to/outfile.ply

It has been used for filtering tractography results in [Gruen22] and [Gruen23]. If this script is applied to self generated ply data, it is important that this ply file contains the following: Firstly, vertices: contains spatial information about the streamlines, e.g. coordinates in 3D. Further the seed-coordinate is marked by a 1. These are saved in the properties: x, y, z, seedpoint. Secondly, fiber. Contains the property endindex, which denotes the end index of a streamline.

Further several filter parameters can be set:

  • --mask: Minimal streamline density. Creates a voxel mask and cuts of each streamline at the first intersection with the complement of the mask. Default 5

  • --exclusion: Filters out all streamlines which intersect with a given plane e.g. x<10. Several planes can be seperated with white spaces. Default “”

  • --exclusionc: Filters out all streamlines which intersect with a given cube e.g. 10<x<20,5<y90,40<z<100. Several cubes can be seperated by a white space Default “”

  • --minlen: Filters out all streamlines which not at least minlen long. Default 0.

kurtosis

Fits the diffusional kurtosis (DKI) model using quadratic cone programming to guarantee a minimum diffusivity. This increases robustness of the fit, and is described in the methods section of [Groeschel16]. The script also computes a number of measures based on the result, including mean, axial, and radial kurtosis.

If not specified otherwise, the input folder has to contain the following files:

  • data.nii.gz: The diffusion weighted data

  • mask.nii.gz: A binary brain mask for the diffusion weighted data

and the output is written to the same folder:

  • da.nii: Axial diffusivity

  • dr.nii: Radial diffusivity

  • dm.nii: Mean diffusivity

  • fa.nii: Fractional Anisotropy

  • ka.nii: Axial kurtosis

  • kr.nii: Radial kurtosis

  • km.nii: Mean kurtosis

Moreover, the following parameters can be set:

  • -d: to specify a different filename for the diffusion weighted data

  • -m: to specify a different filename for the brain mask

  • -o: to specify a different folder for the output files

  • -t: to specify a threshold for b-values that should be treated as zero (default: 0)

  • -R: to only fit the DKI model, without computing invariants