Filter the k-space data and extract a low-resolution phase estimate
Filtering can help reduce ringing in the phase image
In this section:
- np.pad
- np.hanning
- reshaping 1D array to 2D array using np.newaxis (or None)
- subplots with titles
%% Cell type:code id: tags:
``` python
# create zero-padded hanning filter for ky-filtering
filt=np.pad(np.hanning(48),24,'constant')
# reshape 1D array into 2D array
filt=filt[:,np.newaxis]
# or
# filt = filt[:,None]
# generate low-res image with inverse Fourier transform
low=np.fft.ifft2(np.fft.ifftshift(y*filt,axes=0))
# get phase image
phs=np.exp(1j*np.angle(low))
# show phase estimate alongside true phase
_,ax=plt.subplots(1,2)
ax[0].imshow(np.angle(img))
ax[0].set_title('True image phase')
ax[1].imshow(np.angle(phs))
ax[1].set_title('Estimated phase')
```
%% Cell type:markdown id: tags:
# POCS reconstruction
Perform the projection-onto-convex-sets (POCS) partial Fourier reconstruction method.
POCS is an iterative scheme estimates the reconstructed image as any element in the intersection of the following two (convex) sets:
1. Set of images consistent with the measured data
2. Set of images that are non-negative real
This requires prior knowledge of the image phase (hence the estimate above), and it works because although we have less than a full k-space of measurements, we're now only estimating half the number of free parameters (real values only, instead of real + imag), and we're no longer under-determined. Equivalently, consider the fact that real-valued images have conjugate symmetric k-spaces, so we only require half of k-space to reconstruct our image.
In this section:
- np.zeros
- range() builtin
- point-wise multiplication (*)
- np.fft operations default to last axis, not first
- np.maximum vs np.max
%% Cell type:code id: tags:
``` python
# initialise image estimate to be zeros
est=np.zeros((96,96))
# set the number of iterations
iters=10
# each iteration cycles between projections
foriinrange(iters):
# projection onto data-consistent set:
# use a-priori phase to get complex image
est=est*phs
# Fourier transform to get k-space
est=np.fft.fftshift(np.fft.fft2(est),axes=0)
# replace data with measured lines
est[:72,:]=y[:72,:]
# inverse Fourier transform to get back to image space
est=np.fft.ifft2(np.fft.ifftshift(est,axes=0))
# projection onto non-negative reals:
# remove a-priori phase
est=est*np.conj(phs)
# get real part
est=np.real(est)
# ensure output is non-negative
est=np.maximum(est,0)
```
%% Cell type:markdown id: tags:
# Display error and plot reconstruction
The POCS reconstruction is compared to a zero-filled reconstruction (i.e., where the missing data is zeroed prior to inverse Fourier Transform)