1% Echo-planar imaging (EPI), 64x64, 3 slices.
2% A basic educational EPI without ramp sampling: one excitation per slice,
3% then the whole k-space plane in a single train of alternating readouts
4% with phase blips. Adapted from pulseq's demoSeq/writeEpi.m.
6seq = mr.Sequence(); % Create a new sequence object
7fov = 220e-3; Nx = 64; Ny = 64; % Define FOV and resolution
8thickness = 3e-3; % slice thickness
9Nslices = 3;
11% Set system limits
12lims = mr.opts('MaxGrad', 32, 'GradUnit', 'mT/m', ...
13 'MaxSlew', 130, 'SlewUnit', 'T/m/s', ...
14 'rfRingdownTime', 30e-6, 'rfDeadTime', 100e-6);
16% Create 90 degree slice selection pulse and gradient
17[rf, gz] = mr.makeSincPulse(pi/2, 'system', lims, 'Duration', 3e-3, ...
18 'SliceThickness', thickness, 'apodization', 0.5, 'timeBwProduct', 4, ...
19 'use', 'excitation');
21% Define other gradients and ADC events
22deltak = 1/fov;
23kWidth = Nx*deltak;
24dwellTime = 4e-6;
25readoutTime = Nx*dwellTime;
26flatTime = ceil(readoutTime*1e5)*1e-5; % round-up to the gradient raster
27gx = mr.makeTrapezoid('x', lims, 'Amplitude', kWidth/readoutTime, 'FlatTime', flatTime);
28adc = mr.makeAdc(Nx, 'Duration', readoutTime, ...
29 'Delay', gx.riseTime + flatTime/2 - (readoutTime - dwellTime)/2);
31% Pre-phasing gradients
32preTime = 8e-4;
33gxPre = mr.makeTrapezoid('x', lims, 'Area', -gx.area/2, 'Duration', preTime);
34gzReph = mr.makeTrapezoid('z', lims, 'Area', -gz.area/2, 'Duration', preTime);
35gyPre = mr.makeTrapezoid('y', lims, 'Area', -Ny/2*deltak, 'Duration', preTime);
37% Phase blip in shortest possible time
38dur = ceil(2*sqrt(deltak/lims.maxSlew)/10e-6)*10e-6;
39gy = mr.makeTrapezoid('y', lims, 'Area', deltak, 'Duration', dur);
41% Define sequence blocks
42for s = 1:Nslices
43 rf.freqOffset = gz.amplitude*thickness*(s-1-(Nslices-1)/2);
44 seq.addBlock(rf, gz);
45 seq.addBlock(gxPre, gyPre, gzReph);
46 for i = 1:Ny
47 seq.addBlock(gx, adc); % Read one line of k-space
48 seq.addBlock(gy); % Phase blip
49 gx.amplitude = -gx.amplitude; % Reverse polarity of read gradient
50 end
51end
53% check whether the timing of the sequence is correct
54[ok, error_report] = seq.checkTiming;
55if ok
56 fprintf('Timing check passed successfully\n');
57else
58 fprintf('Timing check failed! Error listing follows:\n');
59 fprintf([error_report{:}]);
60 fprintf('\n');
61end
63seq.setDefinition('FOV', [fov fov thickness]);
64seq.setDefinition('Name', 'epi');
66seq.write('epi.seq');