% Module 1:  gradients, field-of-view and resolution in FLASH imaging
%
% This script loads brains.mat (a Matlab variable that contains proton
% density, T1, T2 & shim information for a single slice) and calls FLASH.m
% to simulate image acquisition.
%
%
% Assignment:
%
%
% 1) load phantom
% 2) use FLASH.m to simulate images with the following parameters:
%    a) FOV = 64 mm, read resolution = phase res. = 64; TE = 5ms; TR = 10ms; alpha = 10; BW = 100kHz
%    b) FOV = 64 mm, read resolution = phase res. = 32; TE = 5ms; TR = 10ms; alpha = 10; BW = 100kHz
%    c) FOV = 64 mm, read resolution = phase res. = 16; TE = 5ms; TR = 10ms; alpha = 10; BW = 100kHz
%    d) FOV = 48 mm, read resolution = phase res. = 32; TE = 5ms; TR = 10ms; alpha = 10; BW = 100kHz

% 3) Turn in the following:  final image, with the following parameters
%    calculated:
%   
%       in-plane resolution (e.g. 2mm x 2mm)
%       delta-k (k-space step-size, e.g. 3.9 m-1)
%       k_max (maximum excursion in k-space, e.g. 125 m-1)
%       Gro (gradient in the read-out direction, e.g. 12 mT/m)
%       dwellTime (time to acquire each point, e.g. 10us)

load phantom

% These are parameters that will be constant throughout
alpha = 10; %degrees
TE = 2.3; % ms
TR = 4.1; % ms
BW = 100e3; % Hz (equivalent to 10 microseconds to acquire each point)

% 1) FOV = 64 mm (same size as phantom), resolution = 64 (for 1 mm in-plane
% resolution).

[image,kData] = FLASH(.064,64,pd,T1,T2,freqMap,BW,TE,TR,alpha);

% 2) FOV = 64 mm (same size as phantom), resolution = 32 (for 2 mm in-plane
% resolution).

[image,kData] = FLASH(.064,32,pd,T1,T2,freqMap,BW,TE,TR,alpha);

% 3) FOV = 64 mm (same size as phantom), resolution = 16 (for 4 mm in-plane
% resolution).

[image,kData] = FLASH(.064,16,pd,T1,T2,freqMap,BW,TE,TR,alpha);

% 4) FOV = 48 mm (smaller than phantom), resolution = 32 (for 2 mm in-plane
% resolution).

[image,kData] = FLASH(.048,32,pd,T1,T2,freqMap,BW,TE,TR,alpha);

% you'll get an error about lowering bandwidth.  This is because the small
% field of view requires a very strong gradient; stronger than the (fake)
% hardware limits in the "sequence."  This will work:  

[image,kData] = FLASH(.048,32,pd,T1,T2,freqMap,50e3,TE,TR,alpha);

% Note aliasing.