tfmri.signal.tensor_to_wavelet_coeffs

tensor_to_wavelet_coeffs(coeff_tensor, coeff_slices)[source]

Extracts wavelet coefficients from tensor into a list.

Parameters
  • coeff_tensor – A tf.Tensor containing all wavelet coefficients. This should have been generated via tfmri.signal.wavelet_coeffs_to_tensor.

  • coeff_slices – A list of slices corresponding to each coefficient as obtained from tensor_to_wavelet_coeffs.

Returns

The wavelet coefficients in the format expected by tfmri.signal.waverec.

Raises

ValueError – If passed an empty list of coefficients.

Notes

A single large array containing all coefficients will have subsets stored, into a waverecn`` list, c, as indicated below:

.. code-block::

c[0]

c[1][‘da’]

c[2][‘da’]

c[2][‘dd’]

c[1][‘ad’]

c[1][‘dd’]

c[2][‘ad’]

Examples

>>> import tensorflow_mri as tfmri
>>> image = tfmri.image.phantom()
>>> coeffs = tfmri.signal.wavedec(image, wavelet='db2', level=3)
>>> tensor, slices = tfmri.signal.wavelet_coeffs_to_tensor(coeffs)
>>> coeffs_from_arr = tfmri.signal.tensor_to_wavelet_coeffs(tensor, slices)
>>> image_recon = tfmri.signal.waverec(coeffs_from_arr, wavelet='db2')
>>> # image and image_recon are equal