mmt_dipole_cuboid_inversion.inversion_tools#

Module Contents#

Functions#

calculate_covariance_matrix(DipoleClassInstance, sigma)

Calculates the covariance matrix

calculate_condition_number(DipoleClassInstance[, ...])

Returns the condition number of the forward matrix. The cond number is

calculate_forward_field(DipoleClassInstance[, sigma, ...])

Calculates the forward field from the inverted magnetisation. If a standard

Attributes#

mmt_dipole_cuboid_inversion.inversion_tools.calculate_covariance_matrix(DipoleClassInstance, sigma, norm=True, std_dev_file=None, norm_covar_file=None, resol_matrix_file=None)#

Calculates the covariance matrix

Parameters:
DipoleClassInstance

An instance of the Dipole class that was used to calculate the inversion matrices

sigma

The standard deviation of the error of the magnetic field

norm

normalize the covariance matrix (True) or not (False)

std_dev_file

File path to where the standard deviation is written

norm_covar_file

File path to where the normalized covariance matrix is written

resol_matrix_file

File path to where the resolution matrix is written

Returns:
standard_deviation
normalized_covariance_matrix
resolution_matrix
Parameters:
Return type:

Optional[Tuple[numpy.ndarray, numpy.ndarray, numpy.ndarray]]

mmt_dipole_cuboid_inversion.inversion_tools._normOps#
mmt_dipole_cuboid_inversion.inversion_tools.calculate_condition_number(DipoleClassInstance, matrix_norm=None)#

Returns the condition number of the forward matrix. The cond number is defined as the product of the matrix norms of the forward matrix and its pseudo inverse: \(|Q| * |Q^\dagger|\).

Parameters:
matrix_norm

The kind of matrix norm to be used, which is determined by the ord parameter in numpy.linalg.norm. For instance, return_pinv_and_cnumber=’fro’. The Numpy’s inf values in this case are replaced by strings. Notice that the condition number will be determined by the cutoff value for the singular values of the forward matrix.

Parameters:
Return type:

Union[None, float]

mmt_dipole_cuboid_inversion.inversion_tools.calculate_forward_field(DipoleClassInstance, sigma=None, forward_field_file=None)#

Calculates the forward field from the inverted magnetisation. If a standard deviation value is passed a Gaussian noise is estimated and added to the field.

Parameters:
DipoleClassInstance

An instance of the Dipole class that was used to calculate the inversion matrices

sigma

Standard deviation of Gaussian noise to be added in T.

forward_field_file

Path to file to save the inverse forward field

Parameters:
Return type:

numpy.ndarray