CompressedSensing(CS)Workshop ...mlustig/CS/cs_slides.pdfCompressedSensing(CS)Workshop:...

39
Compressed Sensing (CS) Workshop: Basic Elements of Compressed Sensing Mariya Doneva Philips Research Europe Almir Mutapcic Sarajevo School of Science and Technology Miki Lustig EECS Department UC Berkeley, CA, USA Ohrid, June 17, 2011

Transcript of CompressedSensing(CS)Workshop ...mlustig/CS/cs_slides.pdfCompressedSensing(CS)Workshop:...

Page 1: CompressedSensing(CS)Workshop ...mlustig/CS/cs_slides.pdfCompressedSensing(CS)Workshop: BasicElementsofCompressedSensing MariyaDoneva Philips Research Europe AlmirMutapcic Sarajevo

Compressed Sensing (CS) Workshop:

Basic Elements of Compressed Sensing

Mariya DonevaPhilips Research Europe

Almir MutapcicSarajevo School of Science and Technology

Miki LustigEECS Department

UC Berkeley, CA, USA

Ohrid, June 17, 2011

Page 2: CompressedSensing(CS)Workshop ...mlustig/CS/cs_slides.pdfCompressedSensing(CS)Workshop: BasicElementsofCompressedSensing MariyaDoneva Philips Research Europe AlmirMutapcic Sarajevo

Outline

Part I: Sparse Signals and Denoising

Part II: Sparsity of Medical Imaging

Part III: Compressed Sensing MRI

Ohrid, June 17, 2011 1

Page 3: CompressedSensing(CS)Workshop ...mlustig/CS/cs_slides.pdfCompressedSensing(CS)Workshop: BasicElementsofCompressedSensing MariyaDoneva Philips Research Europe AlmirMutapcic Sarajevo

Part I: Sparse Signals and Denoising

Overview:

• sparsity

• incoherency

• sparsity based reconstruction

Ohrid, June 17, 2011 2

Page 4: CompressedSensing(CS)Workshop ...mlustig/CS/cs_slides.pdfCompressedSensing(CS)Workshop: BasicElementsofCompressedSensing MariyaDoneva Philips Research Europe AlmirMutapcic Sarajevo

Sparse Signals and Denoising in 1D

• strong connection between CS and sparse signal denoising

• the sparsity of signal x ∈ Rn, is the number of zero components of x

• similarly, the cardinality of x, card(x), is the number of nonzeros,

we often use ||x||0 to denote cardinality

Ohrid, June 17, 2011 3

Page 5: CompressedSensing(CS)Workshop ...mlustig/CS/cs_slides.pdfCompressedSensing(CS)Workshop: BasicElementsofCompressedSensing MariyaDoneva Philips Research Europe AlmirMutapcic Sarajevo

Sparse signal example

Generate x ∈ R128 with 5 nonzero coefficients (randomly permuted)

>> x = [[1:5]/5 zeros(1,128-5)];

>> x = x(randperm(128));

0 20 40 60 80 100 120−0.2

0

0.2

0.4

0.6

0.8

1

1.2

n

x

Ohrid, June 17, 2011 4

Page 6: CompressedSensing(CS)Workshop ...mlustig/CS/cs_slides.pdfCompressedSensing(CS)Workshop: BasicElementsofCompressedSensing MariyaDoneva Philips Research Europe AlmirMutapcic Sarajevo

Corrupted sparse signal

Corrupt sparse signal with random Gaussian noise σ = 0.05 (y = x+ n)

>> y = x + 0.05*randn(1,128);

0 20 40 60 80 100 120−0.2

0

0.2

0.4

0.6

0.8

1

1.2

n

y

Ohrid, June 17, 2011 5

Page 7: CompressedSensing(CS)Workshop ...mlustig/CS/cs_slides.pdfCompressedSensing(CS)Workshop: BasicElementsofCompressedSensing MariyaDoneva Philips Research Europe AlmirMutapcic Sarajevo

Denoising

Many approaches for denoising (or regularization), i.e., estimation of thesignal from noisy data:

• ℓ2-norm or Tychonov penalty

• ℓ∞-norm or minimax

• ℓ1-norm penalty (more on this soon)

Ohrid, June 17, 2011 6

Page 8: CompressedSensing(CS)Workshop ...mlustig/CS/cs_slides.pdfCompressedSensing(CS)Workshop: BasicElementsofCompressedSensing MariyaDoneva Philips Research Europe AlmirMutapcic Sarajevo

ℓ2-norm denoising

This optimization trades the norm of the solution with data consistency.

argmin1

2||x̂− y||22 + λ

1

2||x̂||22

The solution for this problem is

x̂ =1

1 + λy

Ohrid, June 17, 2011 7

Page 9: CompressedSensing(CS)Workshop ...mlustig/CS/cs_slides.pdfCompressedSensing(CS)Workshop: BasicElementsofCompressedSensing MariyaDoneva Philips Research Europe AlmirMutapcic Sarajevo

Sample solutions

Observe what happens when plot result for λ = 0.1

0 20 40 60 80 100 120−0.2

0

0.2

0.4

0.6

0.8

1

1.2

n

Is the solution sparse?

Ohrid, June 17, 2011 8

Page 10: CompressedSensing(CS)Workshop ...mlustig/CS/cs_slides.pdfCompressedSensing(CS)Workshop: BasicElementsofCompressedSensing MariyaDoneva Philips Research Europe AlmirMutapcic Sarajevo

Sparse signals and the ℓ1-norm

Now we will penalize the ℓ1-norm, i.e.,

||x||1 =∑

|xi|

Specifically we will solve:

argmin1

2||x̂− y||22 + λ||x̂||1

Ohrid, June 17, 2011 9

Page 11: CompressedSensing(CS)Workshop ...mlustig/CS/cs_slides.pdfCompressedSensing(CS)Workshop: BasicElementsofCompressedSensing MariyaDoneva Philips Research Europe AlmirMutapcic Sarajevo

Solution

Variables x̂i’s are independent, so minimize each seperately by solving

argmin1

2|x̂i − yi|

2 + λ|x̂i|

The solution to each x̂i has a closed form. The solution is

x̂ =

y + λ if y < −λ

0 if |y| < λ

y − λ if y > λ

(This is called soft-thresholding or shrinkage).

• Show Movie

Ohrid, June 17, 2011 10

Page 12: CompressedSensing(CS)Workshop ...mlustig/CS/cs_slides.pdfCompressedSensing(CS)Workshop: BasicElementsofCompressedSensing MariyaDoneva Philips Research Europe AlmirMutapcic Sarajevo

Soft thresholding or shrinkage function

SoftThresh (complex input case) function:

S(u, λ) =

{

0 if |u| ≤ λ(|u|−λ)

|u| u if |u| > λ

Ohrid, June 17, 2011 11

Page 13: CompressedSensing(CS)Workshop ...mlustig/CS/cs_slides.pdfCompressedSensing(CS)Workshop: BasicElementsofCompressedSensing MariyaDoneva Philips Research Europe AlmirMutapcic Sarajevo

Matlab implementation

Write a function SoftThresh that accepts u and λ and returns S(u).Plot for u ∈ [−10, 10] and λ = 2.

−10 −5 0 5 10−10

−5

0

5

10

u

S(u)

Ohrid, June 17, 2011 12

Page 14: CompressedSensing(CS)Workshop ...mlustig/CS/cs_slides.pdfCompressedSensing(CS)Workshop: BasicElementsofCompressedSensing MariyaDoneva Philips Research Europe AlmirMutapcic Sarajevo

Back to our example

Apply SoftThresh to the noisy signal with λ = 0.1.

0 20 40 60 80 100 120−0.2

0

0.2

0.4

0.6

0.8

1

1.2

n

Is the solution sparse?

Ohrid, June 17, 2011 13

Page 15: CompressedSensing(CS)Workshop ...mlustig/CS/cs_slides.pdfCompressedSensing(CS)Workshop: BasicElementsofCompressedSensing MariyaDoneva Philips Research Europe AlmirMutapcic Sarajevo

Random Frequency Domain Sampling and Aliasing

• a strong connection between compressed sensing and denoising

• explore this connection and the importance of incoherent sampling

• in compressed sensing, we undersample the measurements

• measure subset of k-space, Xu = Fux where Fu is a Fourier transformevaluated only at a subset of frequency domain samples.

Ohrid, June 17, 2011 14

Page 16: CompressedSensing(CS)Workshop ...mlustig/CS/cs_slides.pdfCompressedSensing(CS)Workshop: BasicElementsofCompressedSensing MariyaDoneva Philips Research Europe AlmirMutapcic Sarajevo

Example: Uniform vs random undersampling

• start with the Fourier transform of a sparse signal

• undersample k-space by taking 32 equispaced samples

• compute the inverse Fourier transform, filling the missing data withzeroes

• multiply by 4 to correct for the fact that we have only 1/4 the samples

>> X = fftc(x);

>> Xu = zeros(1,128);

>> Xu(1:4:128) = X(1:4:128);

>> xu = ifftc(Xu)*4;

this is uniform sampling and minimum ℓ2 norm solution (why?).

Ohrid, June 17, 2011 15

Page 17: CompressedSensing(CS)Workshop ...mlustig/CS/cs_slides.pdfCompressedSensing(CS)Workshop: BasicElementsofCompressedSensing MariyaDoneva Philips Research Europe AlmirMutapcic Sarajevo

Result in signal domain

Plot of the absolute value of the result. Describe what you see.

0 20 40 60 80 100 120−0.2

0

0.2

0.4

0.6

0.8

1

1.2

n

xunif

Will we be able to reconstruct the original signal from the result?

Ohrid, June 17, 2011 16

Page 18: CompressedSensing(CS)Workshop ...mlustig/CS/cs_slides.pdfCompressedSensing(CS)Workshop: BasicElementsofCompressedSensing MariyaDoneva Philips Research Europe AlmirMutapcic Sarajevo

Random sampling

Now, undersample k-space by taking 32 samples at random.>> X = fftc(x);

>> Xr = zeros(1,128);

>> prm = randperm(128);

>> Xr(prm(1:32)) = X(prm(1:32));

>> xr = ifftc(Xr)*4;

Ohrid, June 17, 2011 17

Page 19: CompressedSensing(CS)Workshop ...mlustig/CS/cs_slides.pdfCompressedSensing(CS)Workshop: BasicElementsofCompressedSensing MariyaDoneva Philips Research Europe AlmirMutapcic Sarajevo

Results

Plot the real and imaginary value, and describe the result.

0 20 40 60 80 100 120−0.2

0

0.2

0.4

0.6

0.8

1

1.2

n

ℜ(x

rand)blue,

ℑ(x

rand)green

Ohrid, June 17, 2011 18

Page 20: CompressedSensing(CS)Workshop ...mlustig/CS/cs_slides.pdfCompressedSensing(CS)Workshop: BasicElementsofCompressedSensing MariyaDoneva Philips Research Europe AlmirMutapcic Sarajevo

Reconstruct the original signal?

• Will we be able to reconstruct the signal from the result?

• How does this resemble the denoising problem?

This is the important part, so say it out loud:

By random undersampling, we’ve turned the ill-conditioned probleminto a sparse signal denoising problem.

Ohrid, June 17, 2011 19

Page 21: CompressedSensing(CS)Workshop ...mlustig/CS/cs_slides.pdfCompressedSensing(CS)Workshop: BasicElementsofCompressedSensing MariyaDoneva Philips Research Europe AlmirMutapcic Sarajevo

Reconstruction from Randomly Sampled Frequency

Domain Data

Inspired by the denoising example, we will add an ℓ1 penalty and solve,

argmin1

2||Fux̂− Y ||22 + λ|x̂|1

• x̂ is the estimated signal

• Fux̂ is the undersampled Fourier transform of the estimate

• Y are the samples of the Fourier transform that we have acquired

variables are coupled through FT, no closed-form solution

Ohrid, June 17, 2011 20

Page 22: CompressedSensing(CS)Workshop ...mlustig/CS/cs_slides.pdfCompressedSensing(CS)Workshop: BasicElementsofCompressedSensing MariyaDoneva Philips Research Europe AlmirMutapcic Sarajevo

Iterative solution algorithm

Projection Over Convex Sets (POCS) type algorithm, iterate betweensoft-thresholding and constraining data consistency

Let X̂ = Fx̂. Initially set X̂0 = Y .

1. Compute inverse FT to get signal estimate x̂i = F ∗X̂i

2. Apply SoftThresh x̂i = S(x̂i, λ) in the signal domain

3. Compute the FT X̂i = Fx̂i

4. Enforce data consistency in the frequency domain

X̂i+1[j] =

{

X̂i[j] if Y [j] = 0Y [j] otherwise

5. Repeat until ||x̂i+1 − x̂i|| < ǫ

Ohrid, June 17, 2011 21

Page 23: CompressedSensing(CS)Workshop ...mlustig/CS/cs_slides.pdfCompressedSensing(CS)Workshop: BasicElementsofCompressedSensing MariyaDoneva Philips Research Europe AlmirMutapcic Sarajevo

Matlab implementation

• Y is randomly sampled Fourier data with zeros for non-acquired data

• Initialize estimate of Fourier transform of the signal as X = Y

The core of the iteration can then be written as

>> x = ifftc(X);

>> xst = SofthThresh(x,lambda);

>> X = fftc(xst);

>> X = X.*(Y==0) + Y;

Ohrid, June 17, 2011 22

Page 24: CompressedSensing(CS)Workshop ...mlustig/CS/cs_slides.pdfCompressedSensing(CS)Workshop: BasicElementsofCompressedSensing MariyaDoneva Philips Research Europe AlmirMutapcic Sarajevo

Results

Apply the algorithm (at least 300 iterations) to the undersampled signalwith λ = {0.01, 0.05, 0.1} and plot the results.

0 20 40 60 80 100 120−0.2

0

0.2

0.4

0.6

0.8

1

1.2

n

Ohrid, June 17, 2011 23

Page 25: CompressedSensing(CS)Workshop ...mlustig/CS/cs_slides.pdfCompressedSensing(CS)Workshop: BasicElementsofCompressedSensing MariyaDoneva Philips Research Europe AlmirMutapcic Sarajevo

Plots

Make a plot of error between the true x and x̂i as a function of theiteration number, plotting the result for each of the λs.

0 50 100 150 2000

0.1

0.2

0.3

0.4

0.5

0.6

0.7

0.8

0.9

λ = .01λ = .05λ = .1

iter

max|x

−x̂|

Ohrid, June 17, 2011 24

Page 26: CompressedSensing(CS)Workshop ...mlustig/CS/cs_slides.pdfCompressedSensing(CS)Workshop: BasicElementsofCompressedSensing MariyaDoneva Philips Research Europe AlmirMutapcic Sarajevo

Part II: Sparsity of Medical Imaging

• Medical Images are generally not sparse.

• Images have a sparser representation in a transform domain

• The transform depends on the type of signal

Ohrid, June 17, 2011 25

Page 27: CompressedSensing(CS)Workshop ...mlustig/CS/cs_slides.pdfCompressedSensing(CS)Workshop: BasicElementsofCompressedSensing MariyaDoneva Philips Research Europe AlmirMutapcic Sarajevo

Sparsity of Brain Scans

The file brain.mat contains a very pretty axial T2-weighted FSE image ofa brain stored in the matrix im. Load the file and display the magnitudeimage

>> load brain.mat

>> figure, imshow(abs(im),[])Axial T2-weighted Brain image

Is the brain image sparse?

Ohrid, June 17, 2011 26

Page 28: CompressedSensing(CS)Workshop ...mlustig/CS/cs_slides.pdfCompressedSensing(CS)Workshop: BasicElementsofCompressedSensing MariyaDoneva Philips Research Europe AlmirMutapcic Sarajevo

The Wavelet Transform

The Wavelet transform is known to sparsify natural images.

• Orthogonal transformation (Here)

• Wavelet coefficients are band-pass filters

• Coefficients hold both position and frequency information

• There are many kinds of wavelets (Haar, Daubechies, Symmlets,...)

• Fast to compute

Ohrid, June 17, 2011 27

Page 29: CompressedSensing(CS)Workshop ...mlustig/CS/cs_slides.pdfCompressedSensing(CS)Workshop: BasicElementsofCompressedSensing MariyaDoneva Philips Research Europe AlmirMutapcic Sarajevo

Matlab Implementation

• Original code from Wavelab (David Donoho)http://www-stat.stanford.edu/~wavelab/

• The Matlab class @Wavelet implements the Wavelet transform

• Usage:

>> W = Wavelet; % Daubechies-4 wavelet operator

>> im_W = W*im; % Forward Wavelet transform

>> im_rec = W’*im_W; % Inverse Wavelet transform

• The function imshowWav.m conveniently displays wavelet coefficients.

>> Figure, imshowWAV(im_W)

Ohrid, June 17, 2011 28

Page 30: CompressedSensing(CS)Workshop ...mlustig/CS/cs_slides.pdfCompressedSensing(CS)Workshop: BasicElementsofCompressedSensing MariyaDoneva Philips Research Europe AlmirMutapcic Sarajevo

Wavelet Transform of a Brain Scan

Compute the Wavelet transform of the brain images and display thecoefficients.

>> W = Wavelet; % Daubechies-4 wavelet operator

>> im_W = W*im; % forward Wavelet transform

>> figure, imshowWAV(im_W)Wavelet Transform

Ohrid, June 17, 2011 29

Page 31: CompressedSensing(CS)Workshop ...mlustig/CS/cs_slides.pdfCompressedSensing(CS)Workshop: BasicElementsofCompressedSensing MariyaDoneva Philips Research Europe AlmirMutapcic Sarajevo

Sparsity in The Wavelet Domain

• Each band of wavelet coefficients represent a scale (frequency band) ofthe image.

• The location of the wavelet coefficient within the band represent itslocation in space.

• What you see are edges of the image at different resolutions anddirections.

Wavelet Transform

Is the signal sparse?

Ohrid, June 17, 2011 30

Page 32: CompressedSensing(CS)Workshop ...mlustig/CS/cs_slides.pdfCompressedSensing(CS)Workshop: BasicElementsofCompressedSensing MariyaDoneva Philips Research Europe AlmirMutapcic Sarajevo

Wavelet Thresholding

Threshold the wavelet coefficients retaining only the largest 10% of thecoefficients. Plot the reconstructed image. (Take a note of the thresholdfor later)

• Show Movie

>> m = sort(abs(im_W(:)),’descend’);

>> ndx = floor(length(m)*10/100);

>> thresh = m(ndx);

>> im_W_th = im_W .* (abs(im_W) > thresh);

>> im_denoise = W’*im_W_th;

>> figure, imshow(abs(cat(2,im,im_denoise, ...

(im-im_denoise)*10)),[0,1]);

Ohrid, June 17, 2011 31

Page 33: CompressedSensing(CS)Workshop ...mlustig/CS/cs_slides.pdfCompressedSensing(CS)Workshop: BasicElementsofCompressedSensing MariyaDoneva Philips Research Europe AlmirMutapcic Sarajevo

Wavelet Denoising

Original Thresholded 15% Difference (x10)

Q) What has been thresholded?A) The wavelet transform sparsifies the brain image, and concentrates the“important” image energy into a subset of the coefficients. This helps usdenoise the image by thresholding the coefficients which contain mostlynoise!

Ohrid, June 17, 2011 32

Page 34: CompressedSensing(CS)Workshop ...mlustig/CS/cs_slides.pdfCompressedSensing(CS)Workshop: BasicElementsofCompressedSensing MariyaDoneva Philips Research Europe AlmirMutapcic Sarajevo

Wavelet Over Denoising

Repeat the experiment with a threshold of 2.5%

Original Thresholded 2.5% Difference (x10)

What have been thresholded?What’s the approximate sparsity of the image?

Ohrid, June 17, 2011 33

Page 35: CompressedSensing(CS)Workshop ...mlustig/CS/cs_slides.pdfCompressedSensing(CS)Workshop: BasicElementsofCompressedSensing MariyaDoneva Philips Research Europe AlmirMutapcic Sarajevo

Part III: Compressed Sensing MRI

• In MRI # of measurements ∝ scan time

• Reduce samples to reduce time

• Extrapolate missing samples by enforcing sparsity in transform

Ohrid, June 17, 2011 34

Page 36: CompressedSensing(CS)Workshop ...mlustig/CS/cs_slides.pdfCompressedSensing(CS)Workshop: BasicElementsofCompressedSensing MariyaDoneva Philips Research Europe AlmirMutapcic Sarajevo

Variable-Density Random Sampling

The variable mask_vardens is a ×3-fold subsampled, variable-densityrandom mask, drawn from a probability distribution given bypdf_vardens.

Variable-Density Random Sampling PDF

Ohrid, June 17, 2011 35

Page 37: CompressedSensing(CS)Workshop ...mlustig/CS/cs_slides.pdfCompressedSensing(CS)Workshop: BasicElementsofCompressedSensing MariyaDoneva Philips Research Europe AlmirMutapcic Sarajevo

Linear Reconstruction

Compute the 2D Fourier transform of the image. Multiply with the mask,divide by the PDF. Compute the inverse Fourier transform and display theresult.

>> M = fft2c(im);

>> M_us = (M.*mask_vardens)./pdf_vardens;

>> im_us = ifft2c(M_us);

>> figure, imshow(abs(cat(2,im,im_us, (im_us-im)*10)),[0,1])Original Reconstructed Difference (x10)

Ohrid, June 17, 2011 36

Page 38: CompressedSensing(CS)Workshop ...mlustig/CS/cs_slides.pdfCompressedSensing(CS)Workshop: BasicElementsofCompressedSensing MariyaDoneva Philips Research Europe AlmirMutapcic Sarajevo

Compressed Sensing MRI Reconstuction

Implement the POCS algorithm for 2D images. Use lambda value from thethresholding experiment. Use 20 iterations.

>> DATA = fft2c(im).*mask_vardens;

>> im_cs = ifft2c(DATA./pdf_vardens); % initial value

>> figure;

>> for iter=1:20

>>im_cs = W’*(SoftThresh(W*im_cs,0.025));

>>im_cs = ifft2c(fft2c(im_cs).*(1-mask_vardens) + DATA);

>>imshow(abs(im_cs),[]), drawnow;

>> end

Ohrid, June 17, 2011 37

Page 39: CompressedSensing(CS)Workshop ...mlustig/CS/cs_slides.pdfCompressedSensing(CS)Workshop: BasicElementsofCompressedSensing MariyaDoneva Philips Research Europe AlmirMutapcic Sarajevo

Results

Original Linear Compressed Sensing

Ohrid, June 17, 2011 38