Mercurial > hg > smallbox
comparison Problems/Cardiac_MRI_problem.m @ 47:2953097411d4
(none)
| author | idamnjanovic |
|---|---|
| date | Mon, 14 Mar 2011 15:43:24 +0000 |
| parents | |
| children |
comparison
equal
deleted
inserted
replaced
| 46:6a37442514c5 | 47:2953097411d4 |
|---|---|
| 1 function data = Cardiac_MRI_Problem(varargin) | |
| 2 % CHANGE!!!!PROB503 Shepp-Logan phantom, partial Fourier with sample mask, | |
| 3 % complex domain, total variation. | |
| 4 % | |
| 5 % PROB503 creates a problem structure. The generated signal will | |
| 6 % consist of a N = 256 by N Shepp-Logan phantom. The signal is | |
| 7 % sampled at random locations in frequency domain generated | |
| 8 % according to a probability density function. | |
| 9 % | |
| 10 % The following optional arguments are supported: | |
| 11 % | |
| 12 % PROB503('n',N,flags) is the same as above, but with a | |
| 13 % phantom of size N by N. The 'noseed' flag can be specified to | |
| 14 % suppress initialization of the random number generators. Both | |
| 15 % the parameter pair and flags can be omitted. | |
| 16 % | |
| 17 % Examples: | |
| 18 % P = prob503; % Creates the default 503 problem. | |
| 19 % | |
| 20 % References: | |
| 21 % | |
| 22 % [LustDonoPaul:2007] M. Lustig, D.L. Donoho and J.M. Pauly, | |
| 23 % Sparse MRI: The application of compressed sensing for rapid MR | |
| 24 % imaging, Submitted to Magnetic Resonance in Medicine, 2007. | |
| 25 % | |
| 26 % [sparsemri] M. Lustig, SparseMRI, | |
| 27 % http://www.stanford.edu/~mlustig/SparseMRI.html | |
| 28 % | |
| 29 % See also GENERATEPROBLEM. | |
| 30 % | |
| 31 %MATLAB SPARCO Toolbox. | |
| 32 | |
| 33 % Copyright 2008, Ewout van den Berg and Michael P. Friedlander | |
| 34 % http://www.cs.ubc.ca/labs/scl/sparco | |
| 35 % $Id: prob503.m 1040 2008-06-26 20:29:02Z ewout78 $ | |
| 36 | |
| 37 % Parse parameters and set problem name | |
| 38 | |
| 39 [opts,varg] = parseDefaultOpts(varargin{:}); | |
| 40 [parm,varg] = parseOptions(varg,{'noseed'},{'n','fold','sigma','slice'}); | |
| 41 n = getOption(parm,'n',256); | |
| 42 info.name = 'Cardiac_MRI'; | |
| 43 opts.show = 1; | |
| 44 | |
| 45 | |
| 46 fold = getOption(parm,'fold', 6); % undersampling level | |
| 47 sigma = getOption(parm,'sigma', 0.05);; % noise level | |
| 48 z = getOption(parm,'slice', 5);; % slice number (1-10) | |
| 49 szt = 20; % number of time samples | |
| 50 | |
| 51 % Return problem name if requested | |
| 52 if opts.getname, data = info.name; return; end; | |
| 53 | |
| 54 % Initialize random number generators | |
| 55 if (~parm.noseed), randn('state',0); rand('twister',2000); end; | |
| 56 | |
| 57 % Set up the data | |
| 58 % if allowed use variable density | |
| 59 %pdf = genPDF([n,n],5,0.1,2,0.1,0); | |
| 60 | |
| 61 | |
| 62 | |
| 63 %load heart images | |
| 64 FS=filesep; | |
| 65 TMPpath=pwd; | |
| 66 [pathstr1, name, ext, versn] = fileparts(which('SMALLboxSetup.m')); | |
| 67 cd([pathstr1,FS,'data',FS,'images',FS,'Cardiac_MRI_dataset',FS,'Images']); | |
| 68 [filename,pathname] = uigetfile({'*.mat;'},'Select a patient MRI image set'); | |
| 69 [pathstr, name, ext, versn] = fileparts(filename); | |
| 70 load(filename); | |
| 71 data.name=name; | |
| 72 cd(TMPpath); | |
| 73 | |
| 74 % Set up the problem | |
| 75 | |
| 76 % Get 3D matrix of heart images (size 256x256, 20 frames) and stack them to | |
| 77 % 2D matrix (256 x 256*20) | |
| 78 data.signal = reshape(sol_yxzt(:,:,z,:), [n n*szt]); | |
| 79 | |
| 80 % make a noise matrix | |
| 81 | |
| 82 noise_var=sqrt(sigma*var(reshape(data.signal, [n*n*szt 1]))); | |
| 83 data.noise = randn(n,n*szt)*noise_var + sqrt(-1)*randn(n,n*szt)*noise_var; | |
| 84 | |
| 85 % make a mask of random lines in phase encode and time domain random - vector | |
| 86 % of 0 and 1 of size n*szt multiplied with vector of 1 of size n | |
| 87 | |
| 88 mask = rand(n*szt,1); | |
| 89 mask(mask>(1-1/fold))=1; | |
| 90 mask(mask<=(1-1/fold))=0; | |
| 91 mask=(mask*ones(1,n))'; | |
| 92 data.op.mask = opMask(mask); | |
| 93 data.op.padding = opPadding([n,n*szt],[n,n*szt]); | |
| 94 | |
| 95 % make an fft 2D dictionary. It will do 2D fft on evry image in the stack | |
| 96 data.op.fft2d = opKron(opDiag(szt,1), opFFT2C(n,n)); | |
| 97 | |
| 98 % make measurement operator mask*padding*fft2d | |
| 99 data.M = opFoG(data.op.mask, data.op.padding, ... | |
| 100 data.op.fft2d); | |
| 101 | |
| 102 % make a mesurement vector b = M* (signal + noise) where s+n is stack to 1d vector | |
| 103 data.b = data.M(reshape(data.signal + data.noise,[n*n*szt,1]),1); | |
| 104 | |
| 105 | |
| 106 data = completeOps(data); | |
| 107 | |
| 108 % Additional information | |
| 109 info.title = 'Cardiac-MRI'; | |
| 110 info.thumb = 'figcardiacProblem'; | |
| 111 info.citations = {'LustDonoPaul:2007','sparsemri'}; | |
| 112 info.fig{1}.title = 'Cardiac MRI'; | |
| 113 % info.fig{1}.filename = 'figProblemCardiac'; | |
| 114 % info.fig{2}.title = 'Probability density function'; | |
| 115 % info.fig{2}.filename = 'figProblem503PDF'; | |
| 116 % info.fig{3}.title = 'Sampling mask'; | |
| 117 % info.fig{3}.filename = 'figProblem503Mask'; | |
| 118 | |
| 119 % Set the info field in data | |
| 120 data.info = info; | |
| 121 opts.figinc=1; | |
| 122 % Plot figures | |
| 123 if opts.update || opts.show | |
| 124 | |
| 125 %figure(opts.figno); opts.figno = opts.figno + opts.figinc; | |
| 126 | |
| 127 mov=reshape(data.signal/500, [n n szt]); | |
| 128 | |
| 129 implay(mov); | |
| 130 clear mov; | |
| 131 | |
| 132 %updateFigure(opts, info.fig{1}.title, info.fig{1}.filename); | |
| 133 | |
| 134 movMeas=reshape(abs(data.A(data.b,2))/500, [n n szt]); | |
| 135 implay(movMeas); | |
| 136 clear movMeas; | |
| 137 % figure(opts.figno); opts.figno = opts.figno + opts.figinc; | |
| 138 % imagesc(pdf), colormap gray; | |
| 139 % updateFigure(opts, info.fig{2}.title, info.fig{2}.filename) | |
| 140 | |
| 141 implay(reshape(mask, [n n szt])); | |
| 142 | |
| 143 % figure(opts.figno); opts.figno = opts.figno + opts.figinc; | |
| 144 % imagesc(mask), colormap gray | |
| 145 % updateFigure(opts, info.fig{3}.title, info.fig{3}.filename) | |
| 146 % | |
| 147 % if opts.update | |
| 148 % mn = min(min(data.signal + real(data.noise))); | |
| 149 % mx = max(max(data.signal + real(data.noise))); | |
| 150 % P = (data.signal + real(data.noise) - mn) / (mx - mn); | |
| 151 % P = scaleImage(P,128,128); | |
| 152 % P = P(1:2:end,1:2:end,:); | |
| 153 % thumbwrite(P, info.thumb, opts); | |
| 154 % end | |
| 155 end |
