foa3d.spharm

foa3d.spharm.compute_fiber_angles(fbr_vec, norm)

Estimate the spherical coordinates (φ azimuth and θ polar angles) of the fiber orientation vectors returned by the Frangi filtering stage (all-zero background vectors are excluded).

Parameters
  • fbr_vec (numpy.ndarray (shape=(N,3), dtype=float)) – array of fiber orientation vectors (reshaped super-voxel of shape=(Nz,Ny,Nx), i.e. N=Nz*Ny*Nx)

  • norm (numpy.ndarray (shape=(N,), dtype=float)) – 2-norm of fiber orientation vectors

Returns

  • phi (numpy.ndarray (shape=(N,), dtype=float)) – fiber azimuth angle [rad]

  • theta (numpy.ndarray (shape=(N,), dtype=float)) – fiber polar angle [rad]

foa3d.spharm.compute_real_sph_harm(degree, order, phi, sin_theta, cos_theta, norm_factors)

Estimate the coefficients of the real spherical harmonics series expansion as described by Alimi et al. (Medical Image Analysis, 2020).

Parameters
  • degree (int) – degree index of the spherical harmonics expansion

  • order (int) – order index of the spherical harmonics expansion

  • phi (float) – azimuth angle [rad]

  • sin_theta (float) – polar angle sine

  • cos_theta (float) – polar angle cosine

  • norm_factors (numpy.ndarray (dtype: float)) – normalization factors

Returns

real_sph_harm – real-valued spherical harmonic coefficient

Return type

float

foa3d.spharm.factorial(n)

Retrieve factorial using pre-computed LUT.

Parameters

n (int) – integer number (max: 20)

Returns

f – factorial

Return type

int

foa3d.spharm.fiber_angles_to_sph_harm(phi, theta, degrees, norm_factors, ncoeff)

Generate the real-valued symmetric spherical harmonics series expansion from fiber φ azimuth and θ polar angles, i.e. the spherical coordinates of the fiber orientation vectors.

Parameters
  • phi (numpy.ndarray (shape=(N,), dtype=float)) – fiber azimuth angles [rad] (reshaped super-voxel of shape=(Nz,Ny,Nx), i.e. N=Nz*Ny*Nx)

  • theta (numpy.ndarray (shape=(N,), dtype=float)) – fiber polar angle [rad] (reshaped super-voxel of shape=(Nz,Ny,Nx), i.e. N=Nz*Ny*Nx)

  • degrees (int) – degrees of the spherical harmonics expansion

  • norm_factors (numpy.ndarray (dtype: float)) – normalization factors

  • ncoeff (int) – number of spherical harmonics coefficients

Returns

real_sph_harm – array of real-valued spherical harmonics coefficients building the spherical harmonics series expansion

Return type

numpy.ndarray (shape=(ncoeff,), dtype=float)

foa3d.spharm.fiber_vectors_to_sph_harm(fbr_vec, degrees, norm_factors)

Generate the real-valued symmetric spherical harmonics series expansion from the fiber orientation vectors returned by the Frangi filter stage.

Parameters
  • fbr_vec (numpy.ndarray (shape=(N,3), dtype=float)) – array of fiber orientation vectors (reshaped super-voxel of shape=(Nz,Ny,Nx), i.e. N=Nz*Ny*Nx)

  • degrees (int) – degrees of the spherical harmonics expansion

  • norm_factors (numpy.ndarray (dtype: float)) – normalization factors

Returns

real_sph_harm – real-valued spherical harmonics coefficients

Return type

numpy.ndarray (shape=(ncoeff,), dtype=float)

foa3d.spharm.get_sph_harm_ncoeff(degrees)

Get the number of coefficients of the real spherical harmonics series expansion.

Parameters

degrees (int) – degrees of the spherical harmonics series expansion

Returns

ncoeff – number of spherical harmonics coefficients

Return type

int

foa3d.spharm.get_sph_harm_norm_factors(degrees)

Estimate the normalization factors of the real spherical harmonics series expansion.

Parameters

degrees (int) – degrees of the spherical harmonics series expansion

Returns

norm_factors – 2D array of spherical harmonics normalization factors

Return type

numpy.ndarray (dtype: float)

foa3d.spharm.norm_factor(n, m)

Compute the normalization factor of the term of degree n and order m of the real-valued spherical harmonics series expansion.

Parameters
  • n (int) – degree index

  • m (int) – order index

Returns

nf – normalization factor

Return type

float