pygrappa.grappa

Python GRAPPA implementation.

More efficient Python implementation of GRAPPA.

Notes

view_as_windows uses numpy.lib.stride_tricks.as_strided which may use up a lot of memory. This is more efficient as we get all the patches in one go as opposed to looping over the image in multiple dimensions. These are stored in temporary memmaps so we don’t crash anyone’s computer (from memory usage, at least…). Note that the recon is always stored in a temporary file memmap to begin with, since its initial size is zero-padded. The final output array or memmap is then initialized at the end with the correct size. This is because it’s hard to resize memmaps, it’s easier to create a temporary one and then copy over the contents to the final one.

We are looping over unique sampling patterns, similar to Miki Lustig’s key-lookup table for kernels. It might be nice to train multiple kernel geometries simultaneously if possible, or at least have an option to do chunks at a time.

Currently each hole in kspace is being looped over when applying weights for a single kernel type. It would be nice to apply the weights for all corresponding holes simultaneously.

pygrappa.grappa.grappa(kspace, calib, kernel_size=(5, 5), coil_axis=-1, lamda=0.01, memmap=False, memmap_filename='out.memmap', silent=True)[source]

GeneRalized Autocalibrating Partially Parallel Acquisitions.

Parameters:
  • kspace (array_like) – 2D multi-coil k-space data to reconstruct from. Make sure that the missing entries have exact zeros in them.
  • calib (array_like) – Calibration data (fully sampled k-space).
  • kernel_size (tuple, optional) – Size of the 2D GRAPPA kernel (kx, ky).
  • coil_axis (int, optional) – Dimension holding coil data. The other two dimensions should be image size: (sx, sy).
  • lamda (float, optional) – Tikhonov regularization for the kernel calibration.
  • memmap (bool, optional) – Store data in Numpy memmaps. Use when datasets are too large to store in memory.
  • memmap_filename (str, optional) – Name of memmap to store results in. File is only saved if memmap=True.
  • silent (bool, optional) – Suppress messages to user.
Returns:

res – k-space data where missing entries have been filled in.

Return type:

array_like

Notes

Based on implementation of the GRAPPA algorithm [1] for 2D images.

If memmap=True, the results will be written to memmap_filename and nothing is returned from the function.

References

[1]Griswold, Mark A., et al. “Generalized autocalibrating partially parallel acquisitions (GRAPPA).” Magnetic Resonance in Medicine: An Official Journal of the International Society for Magnetic Resonance in Medicine 47.6 (2002): 1202-1210.