inpystem.restore.DL_ITKrMM_matlab module

This module implements the ITKrMM algorithm.

The ITKrMM algorithm

inpystem.restore.DL_ITKrMM_matlab.ITKrMM_matlab(Y, mask=None, P=5, K=None, L=1, S=None, Nit_lr=10, Nit=40, init_lr=None, init=None, CLS_init=None, save_it=False, PCA_transform=True, PCA_th='auto', verbose=True)

ITKrMM restoration algorithm with matlab code.

Parameters
  • Y ((m, n) or (m, n, l) numpy array) – The input data.

  • mask (optional, None, (m, n) numpy array) – The acquisition mask. Default is None for full sampling.

  • P (optional, int) – The width (or height) of the patch. Default is 5.

  • K (optional, int) – The dictionary dimension. Default is 2*P**2-1.

  • L (optional, int) – The number of low rank components to learn. Default is 1.

  • S (optional, int) – The code sparsity level. Default is P-L. This should be lower than K-L.

  • Nit_lr (optional, int) – The number of iterations for the low rank estimation. Default is 10.

  • Nit (optional, int) – The number of iterations. Default is 40.

  • init_lr (optional, (N, L) numpy array) – Initialization for low-rank component. N is the number of voxel in a patch. Default is random initialization.

  • init (optional, (N, K-L) numpy array) – Initialization for dictionary learning. N is the number of voxel in a patch. Default is random initialization.

  • CLS_init (optional, dico) – CLS initialization infrmation. See Note for details. Default is None.

  • save_it (optional, bool) – Particular parameter to save estimated reconstruction inside learning loops. This is recomended to stay false. Default is False.

  • PCA_transform (optional, bool) – Enables the PCA transformation if True, otherwise, no PCA transformation is processed. Default is True.

  • PCA_th (optional, int, str) – The desired data dimension after dimension reduction. Possible values are ‘auto’ for automatic choice, ‘max’ for maximum value and an int value for user value. Default is ‘auto’.

  • verbose (bool) – The verbose parameter. Default is True.

Returns

  • (m, n) or (m, n, l) numpy array – Restored data.

  • dict – Aditional informations. See Notes.

Notes

The algorithm can be initialized with CLS as soon as CLS_init is not None. In this case, CLS_init should be a dictionary containing the required Lambda key and eventually the CLS init optional argument.

The output information keys are:

  • time: Execution time in seconds.

  • lrc: low rank component.

  • dico: Estimated dictionary.

  • E: Evolution of the error.

The wKSVD algorithm

inpystem.restore.DL_ITKrMM_matlab.wKSVD_matlab(Y, mask=None, P=5, K=None, L=1, S=None, Nit_lr=10, Nit=40, init_lr=None, init=None, CLS_init=None, save_it=False, PCA_transform=True, PCA_th='auto', verbose=True)

wKSVD restoration algorithm with Matlab code.

Parameters
  • Y ((m, n) or (m, n, l) numpy array) – The input data.

  • mask (optional, None, (m, n) numpy array) – The acquisition mask. Default is None for full sampling.

  • P (optional, int) – The width (or height) of the patch. Default is 5.

  • K (optional, int) – The dictionary dimension. Default is 2*P**2-1.

  • L (optional, int) – The number of low rank components to learn. Default is 1.

  • S (optional, int) – The code sparsity level. Default is P-L. This should be lower than K-L.

  • Nit_lr (optional, int) – The number of iterations for the low rank estimation. Default is 10.

  • Nit (optional, int) – The number of iterations. Default is 40.

  • init_lr (optional, (N, L) numpy array) – Initialization for low-rank component. N is the number of voxel in a patch. Default is random initialization.

  • init (optional, (N, K-L) numpy array) – Initialization for dictionary learning. N is the number of voxel in a patch. Default is random initialization.

  • CLS_init (optional, dico) – CLS initialization infrmation. See Note for details. Default is None.

  • save_it (optional, bool) – Particular parameter to save estimated reconstruction inside learning loops. This is recomended to stay false. Default is False.

  • PCA_transform (optional, bool) – Enables the PCA transformation if True, otherwise, no PCA transformation is processed. Default is True.

  • PCA_th (optional, int, str) – The desired data dimension after dimension reduction. Possible values are ‘auto’ for automatic choice, ‘max’ for maximum value and an int value for user value. Default is ‘auto’.

  • verbose (bool) – The verbose parameter. Default is True.

Returns

  • (m, n) or (m, n, l) numpy array – Restored data.

  • dict – Aditional informations. See Notes.

Notes

The algorithm can be initialized with CLS as soon as CLS_init is not None. In this case, CLS_init should be a dictionary containing the required Lambda key and eventually the CLS init optional argument.

The output information keys are:

  • time: Execution time in seconds.

  • lrc: low rank component.

  • dico: Estimated dictionary.

  • E: Evolution of the error.

The dictionary learning interface

class inpystem.restore.DL_ITKrMM_matlab.Matlab_Dico_Learning_Executer(Y, mask=None, P=5, K=None, L=1, S=None, Nit_lr=10, Nit=40, init_lr=None, init=None, CLS_init=None, save_it=False, PCA_transform=True, PCA_th='auto', verbose=True)

Class to define and execute dictionary learning algorithms with matlab interface.

The following class is a common code for most dictionary learning methods. It performs the following tasks:

  • reshapes the data in patch format,

  • performs low-rank component estimation,

  • starts the dictionary learning method,

  • reshape output data,

  • handle CLS initialization to speed-up computation.

Variables
  • Y ((m, n) or (m, n, l) numpy array) – The input data.

  • Y_PCA ((m, n) or (m, n, PCA_th) numpy array) – The input data in PCA space. Its value is Y if Y is 2D.

  • mask ((m, n) numpy array) – The acquisition mask.

  • P (int) – The width (or height) of the patch.

  • K (int) – The dictionary dimension. This dictionary is composed of L low-rank components and K-L non-low-rank components.

  • L (int) – The number of low rank components to learn.

  • S (int) – The code sparsity level.

  • Nit_lr (int) – The number of iterations for the low rank estimation.

  • Nit (int) – The number of iterations.

  • CLS_init (dico) – CLS initialization inofrmation.

  • save_it (bool) – Particular parameter to save estimated reconstruction inside learning loops. This is recomended to stay false.

  • verbose (bool) – The verbose parameter. Default is True.

  • mean_std (2-tuple) – Tuple of size 2 which contains the data mean and std.

  • data ((N, D) numpy array) – The Y data in patch format. N (resp. D) is the number of voxels per patch (resp. patches).

  • mdata ((N, D) numpy array) – The mask in patch format. N (resp. D) is the number of voxels per patch (resp. patches).

  • init ((N, K-L) numpy array) – The low-rank estimation initialization in patch format. N is the number of voxels per patch.

  • init – The dictionary-learning initialization in patch format. N is the number of voxels per patch.

  • PCA_operator (PcaHandler object) – The PCA operator.

Note

The algorithm can be initialized with CLS as soon as CLS_init is not None. In this case, CLS_init should be a dictionary containing the required Lambda key and eventually the CLS init optional argument.