Python Sparse data Analysis Package external MRI plugin.
This module some functions used for the dictionary learning Compressed Sensing reconstruction.
-
mri.operators.linear.utils.extract_patches_from_2d_images(img, patch_shape)[source]¶ Return the flattened patches from the 2d image.
- Parameters
img: np.ndarray of floats, the input 2d image
patch_shape: tuple of int, shape of the patches
Returns
——-
patches: np.ndarray of floats, a 2d matrix with
- dim nb_patches*(patch.shape[0]*patch_shape[1])
-
mri.operators.linear.utils.generate_flat_patches(images, patch_size, option='real')[source]¶ Generate flat patches from the real/imaginary/complex images from the list of images.
- Parameters
image: list of list of np.ndarray of float or complex
a sublist containing all the images for one subject
patch_size: int,
width of square patches
option: ‘real’ (default),
‘imag’ real/imaginary part or ‘complex’
Returns
——-
flat_patches: list of np.ndarray as a GENERATOR
The patches flat and concatained as a list
-
mri.operators.linear.utils.learn_dictionary(flat_patches_subjects, nb_atoms=100, alpha=1, n_iter=1, fit_algorithm='lars', transform_algorithm='lasso_lars', batch_size=100, n_jobs=1, verbose=1)[source]¶ Learn the dictionary from the real/imaginary part or complex paches from a training set
- Parameters
flat_patches: generator of 1d array of flat patches (floats)
a list per subject
nb_atoms: int,
number of components of the dictionary (default=100)
alpha: float,
regulation term (default=1)
n_iter: int
number of iterations (default=1)
fit_algorithm: ‘lars’
for more details see MiniBatchDictionaryLearning from the sklearn library
transform_algorithm: ‘lasso_lars’,
for more details see MiniBatchDictionaryLearning from the sklearn library
batch_size: int (default 100),
number of patches taken per iteration to fit the model
n_jobs: int defaul 6,
number of cpu to run the learning
verbose: int default1,
The level of verbosity
- Returns
dico: MiniBatchDictionaryLearning object
Follow us
Inspired by AZMIND template.