dipy logo

Site Navigation

NIPY Community

Previous topic

dipy.core.geometry

dipy.core.gradients

class dipy.core.gradients.GradientTable(gradients, big_delta=None, small_delta=None, b0_threshold=0)

Diffusion gradient information

Parameters :

gradients : array_like (N, 3)

N diffusion gradients

b0_threshold : float

Gradients with b-value less than or equal to b0_threshold are considered as b0s i.e. without diffusion weighting.

See also

gradient_table

Attributes

bvals
bvecs
b0s_mask

Methods

b0s_mask
bvals
bvecs
dipy.core.gradients.gradient_table(bvals, bvecs=None, big_delta=None, small_delta=None, b0_threshold=0, atol=0.01)

A general function for creating diffusion MR gradients.

It reads, loads and prepares scanner parameters like the b-values and b-vectors so that they can be useful during the reconstruction process.

Parameters :

bvals : can be any of the four options

  1. an array of shape (N,) or (1, N) or (N, 1) with the b-values.
  2. a path for the file which contains an array like the above (1).
  3. an array of shape (N, 4) or (4, N). Then this parameter is considered to be a b-table which contains both bvals and bvecs. In this case the next parameter is skipped.
  4. a path for the file which contains an array like the one at (3).

bvecs : can be any of two options

  1. an array of shape (N, 3) or (3, N) with the b-vectors.
  2. a path for the file which contains an array like the previous.

big_delta : float

acquisition timing duration (default None)

small_delta : float

acquisition timing duration (default None)

b0_threshold : float

All b-values with values less than or equal to bo_threshold are considered as b0s i.e. without diffusion weighting.

atol : float

All b-vectors need to be unit vectors up to a tolerance.

Returns :

gradients : GradientTable

A GradientTable with all the gradient information.

Notes

  1. Often b0s (b-values which correspond to images without diffusion weighting) have 0 values however in some cases the scanner cannot provide b0s of an exact 0 value and it gives a bit higher values e.g. 6 or 12. This is the purpose of the b0_threshold in the __init__.
  2. We assume that the minimum number of b-values is 7.
  3. B-vectors should be unit vectors.

Examples

>>> from dipy.core.gradients import gradient_table
>>> bvals=1500*np.ones(7)
>>> bvals[0]=0
>>> sq2=np.sqrt(2)/2
>>> bvecs=np.array([[0, 0, 0],
...                 [1, 0, 0],
...                 [0, 1, 0],
...                 [0, 0, 1],
...                 [sq2, sq2, 0],
...                 [sq2, 0, sq2],
...                 [0, sq2, sq2]])
>>> gt = gradient_table(bvals, bvecs)
>>> gt.bvecs.shape == bvecs.shape
True
>>> gt = gradient_table(bvals, bvecs.T)
>>> gt.bvecs.shape == bvecs.T.shape
False
dipy.core.gradients.gradient_table_from_bvals_bvecs(bvals, bvecs, b0_threshold=0, atol=0.01, **kwargs)

Creates a GradientTable from a bvals array and a bvecs array

Parameters :

bvals : array_like (N,)

The b-value, or magnitude, of each gradient direction.

bvecs : array_like (N, 3)

The direction, represented as a unit vector, of each gradient.

b0_threshold : float

Gradients with b-value less than or equal to bo_threshold are considered to not have diffusion weighting.

atol : float

Each vector in bvecs must be a unit vectors up to a tolerance of atol.

Returns :

gradients : GradientTable

A GradientTable with all the gradient information.

Other Parameters:
 

**kwargs : dict

Other keyword inputs are passed to GradientTable.