mri.operators.linear.dictionary#

Provide linear operators classes dedicated to dictionary learning.

class DictionaryLearning(img_shape, dictionary_r, dictionary_i=None)[source]#

Bases: mri.operators.base.OperatorBase

Sparse encoder using a learned dictionary.

This implementation relies on MiniBatchDictionaryLearning and its back projection from sklearn

Parameters
  • img_shape (tuple of int,) – shape of the image (not necessarly a square image).

  • dictonary_r (sklearn MiniBatchDictionaryLearning object) – containing the ‘transform’ method.

  • dictonary_i ((default=None)) – sklearn MiniBatchDictionaryLearning object if images are complex-valued, None if images are real-valued.

two_dico#
Type

bool

_op(dictionary, image)[source]#

Private operator for real-valued images and dictionaries.

This method returns the representation of the input data in the learned dictionary, e.g the sparse coefficients.

Parameters
  • dictionary (sklearn MiniBatchDictionaryLearning object) – containing the ‘transform’ method

  • image (numpy.ndarray) – Input data array, a 2D image.

Returns

coeffs – the sparse coefficients.

Return type

numpy.ndarray of floats, 2d matrix dim nb_patches*nb_components,

op(data)[source]#

Operator.

This method returns the representation of the input data in the learned dictionary, that is to say the sparse coefficients.

Remark: This method only works for squared patches

Parameters

data (numpy.ndarray) – Input data array, a 2D image.

Returns

coeffs – 2d matrix dim nb_patches*nb_components, the sparse coefficients.

Return type

numpy.ndarray of complex if is_complex, default(float)

_adj_op(coeffs, atoms)[source]#

Private Adjoint operator.

This method returns the reconsructed image from the sparse coefficients.

Parameters
  • coeffs (numpy.ndarray of floats,) – 2d matrix dim nb_patches*nb_components, the sparse coefficients.

  • atoms (numpy.ndarray of floats,) – 2d matrix dim nb_components*nb_pixels_per_patch, the dictionary components.

Returns

Return type

ndarray, the reconstructed data.

Notes

This method only works for squared patches

adj_op(coeffs)[source]#

Adjoint operator.

This method returns the reconsructed image from the sparse coefficients.

Parameters

coeffs (numpy.ndarray of floats,) – 2d matrix dim nb_patches*nb_components, the sparse coefficients.

Returns

Return type

ndarray, the reconstructed data.

Notes

This method only works for squared patches

l2norm(data_shape)[source]#

Compute the L2 norm.

Parameters

data_shape (uplet) – the data shape.

Returns

norm – the L2 norm.

Return type

float