annotate Problems/Cardiac_MRI_problem.m @ 51:217a33ac374e

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