Contents
seq=mr.Sequence();
fov=250e-3; Nx=64; Ny=64;
thickness=3e-3;
Nslices=3;
TE=40e-3;
pe_enable=1;
ro_os=1;
readoutTime=4.2e-4;
partFourierFactor=0.75;
tRFex=2e-3;
tRFref=2e-3;
spoilFactor=1.5;
lims = mr.opts('MaxGrad',32,'GradUnit','mT/m',...
'MaxSlew',130,'SlewUnit','T/m/s',...
'rfRingdownTime', 30e-6, 'rfDeadtime', 100e-6);
B0=2.89;
sat_ppm=-3.45;
sat_freq=sat_ppm*1e-6*B0*lims.gamma;
rf_fs = mr.makeGaussPulse(110*pi/180,'system',lims,'Duration',8e-3,...
'bandwidth',abs(sat_freq),'freqOffset',sat_freq);
gz_fs = mr.makeTrapezoid('z',lims,'delay',mr.calcDuration(rf_fs),'Area',1/1e-4);
[rf, gz, gzReph] = mr.makeSincPulse(pi/2,'system',lims,'Duration',tRFex,...
'SliceThickness',thickness,'apodization',0.5,'timeBwProduct',4);
[rf180, gz180] = mr.makeSincPulse(pi,'system',lims,'Duration',tRFref,...
'SliceThickness',thickness,'apodization',0.5,'timeBwProduct',4,'PhaseOffset',pi/2,'use','refocusing');
[~, gzr1_t, gzr1_a]=mr.makeExtendedTrapezoidArea('z',0,gz180.amplitude,spoilFactor*gz.area,lims);
[~, gzr2_t, gzr2_a]=mr.makeExtendedTrapezoidArea('z',gz180.amplitude,0,-gzReph.area+spoilFactor*gz.area,lims);
if gz180.delay>(gzr1_t(4)-gz180.riseTime)
gz180.delay=gz180.delay-(gzr1_t(4)-gz180.riseTime);
else
rf180.delay=rf180.delay+(gzr1_t(4)-gz180.riseTime)-gz180.delay;
gz180.delay=0;
end
gz180n=mr.makeExtendedTrapezoid('z','system',lims,'times',[gzr1_t gzr1_t(4)+gz180.flatTime+gzr2_t]+gz180.delay, 'amplitudes', [gzr1_a gzr2_a]);
trig=mr.makeDigitalOutputPulse('osc0','duration', 100e-6);
deltak=1/fov;
kWidth = Nx*deltak;
blip_dur = ceil(2*sqrt(deltak/lims.maxSlew)/10e-6/2)*10e-6*2;
gy = mr.makeTrapezoid('y',lims,'Area',-deltak,'Duration',blip_dur);
extra_area=blip_dur/2*blip_dur/2*lims.maxSlew;
gx = mr.makeTrapezoid('x',lims,'Area',kWidth+extra_area,'duration',readoutTime+blip_dur);
actual_area=gx.area-gx.amplitude/gx.riseTime*blip_dur/2*blip_dur/2/2-gx.amplitude/gx.fallTime*blip_dur/2*blip_dur/2/2;
gx.amplitude=gx.amplitude/actual_area*kWidth;
gx.area = gx.amplitude*(gx.flatTime + gx.riseTime/2 + gx.fallTime/2);
gx.flatArea = gx.amplitude*gx.flatTime;
adcDwellNyquist=deltak/gx.amplitude/ro_os;
adcDwell=floor(adcDwellNyquist*1e7)*1e-7;
adcSamples=floor(readoutTime/adcDwell/4)*4;
adc = mr.makeAdc(adcSamples,'Dwell',adcDwell,'Delay',blip_dur/2);
time_to_center=adc.dwell*((adcSamples-1)/2+0.5);
adc.delay=round((gx.riseTime+gx.flatTime/2-time_to_center)*1e6)*1e-6;
gy_parts = mr.splitGradientAt(gy, blip_dur/2, lims);
[gy_blipup, gy_blipdown]=mr.align('right',gy_parts(1),'left',gy_parts(2),gx);
gy_blipdownup=mr.addGradients({gy_blipdown, gy_blipup}, lims);
gy_blipup.waveform=gy_blipup.waveform*pe_enable;
gy_blipdown.waveform=gy_blipdown.waveform*pe_enable;
gy_blipdownup.waveform=gy_blipdownup.waveform*pe_enable;
Ny_pre=round(partFourierFactor*Ny/2-1);
Ny_post=round(Ny/2+1);
Ny_meas=Ny_pre+Ny_post;
gxPre = mr.makeTrapezoid('x',lims,'Area',-gx.area/2);
gyPre = mr.makeTrapezoid('y',lims,'Area',Ny_pre*deltak);
[gxPre,gyPre]=mr.align('right',gxPre,'left',gyPre);
gyPre = mr.makeTrapezoid('y',lims,'Area',gyPre.area,'Duration',mr.calcDuration(gxPre,gyPre));
gyPre.amplitude=gyPre.amplitude*pe_enable;
durationToCenter = (Ny_pre+0.5)*mr.calcDuration(gx);
rfCenterInclDelay=rf.delay + mr.calcRfCenter(rf);
rf180centerInclDelay=rf180.delay + mr.calcRfCenter(rf180);
delayTE1=ceil((TE/2 - mr.calcDuration(rf,gz) + rfCenterInclDelay - rf180centerInclDelay)/lims.gradRasterTime)*lims.gradRasterTime;
delayTE2=ceil((TE/2 - mr.calcDuration(rf180,gz180n) + rf180centerInclDelay - durationToCenter)/lims.gradRasterTime)*lims.gradRasterTime;
assert(delayTE1>=0);
delayTE2=delayTE2+mr.calcDuration(rf180,gz180n);
gxPre.delay=0;
gxPre.delay=delayTE2-mr.calcDuration(gxPre);
assert(gxPre.delay>=mr.calcDuration(rf180));
gyPre.delay=mr.calcDuration(rf180);
assert(mr.calcDuration(gyPre)<=mr.calcDuration(gxPre));
for s=1:Nslices
seq.addBlock(rf_fs,gz_fs);
rf.freqOffset=gz.amplitude*thickness*(s-1-(Nslices-1)/2);
rf180.freqOffset=gz180.amplitude*thickness*(s-1-(Nslices-1)/2);
seq.addBlock(rf,gz,trig);
seq.addBlock(mr.makeDelay(delayTE1));
seq.addBlock(rf180,gz180n,mr.makeDelay(delayTE2),gxPre,gyPre);
for i=1:Ny_meas
if i==1
seq.addBlock(gx,gy_blipup,adc);
elseif i==Ny_meas
seq.addBlock(gx,gy_blipdown,adc);
else
seq.addBlock(gx,gy_blipdownup,adc);
end
gx.amplitude = -gx.amplitude;
end
end
check whether the timing of the sequence is correct
[ok, error_report]=seq.checkTiming;
if (ok)
fprintf('Timing check passed successfully\n');
else
fprintf('Timing check failed! Error listing follows:\n');
fprintf([error_report{:}]);
fprintf('\n');
end
Timing check passed successfully
do some visualizations
seq.plot();
[ktraj_adc, ktraj, t_excitation, t_refocusing, t_adc] = seq.calculateKspace();
time_axis=(1:(size(ktraj,2)))*lims.gradRasterTime;
figure; plot(time_axis, ktraj');
hold on; plot(t_adc,ktraj_adc(1,:),'.');
figure; plot(ktraj(1,:),ktraj(2,:),'b');
axis('equal');
hold on;plot(ktraj_adc(1,:),ktraj_adc(2,:),'r.');
new higher-performabce trajectory calculation
[ktraj_adc1, t_adc1, ktraj1, t_ktraj1, t_excitation1, t_refocusing1] = seq.calculateKspacePP();
figure; plot(t_ktraj1, ktraj1');
hold on; plot(t_adc1,ktraj_adc1(1,:),'.');
figure; plot(ktraj1(1,:),ktraj1(2,:),'b');
axis('equal');
hold;plot(ktraj_adc1(1,:),ktraj_adc1(2,:),'r.');
Current plot held
prepare the sequence output for the scanner
seq.setDefinition('FOV', [fov fov thickness]);
seq.setDefinition('Name', 'epi');
seq.write('epise_rs.seq');
very optional slow step, but useful for testing during development e.g. for the real TE, TR or for staying within slewrate limits
rep = seq.testReport;
fprintf([rep{:}]);
Number of blocks: 180
Number of events:
RF: 9
Gx: 171
Gy: 171
Gz: 9
ADC: 168
Delay: 6
Sequence duration: 0.217350s
TE: 0.039997s
TR: 0.012750s
Flip angle: 90.00°
Flip angle: 110.00°
Flip angle: 180.00°
Unique k-space positions (a.k.a. columns, rows, etc): 80
Unique k-space positions (a.k.a. columns, rows, etc): 56
Dimensions: 2
Spatial resolution: 3.93 mm
Spatial resolution: 3.91 mm
Repetitions/slices/contrasts: 3 range: [3 3]
Cartesian encoding trajectory detected
Block timing check passed successfully
Max. Gradient: 789936 Hz/m == 18.55 mT/m
Max. Gradient: 368000 Hz/m == 8.64 mT/m
Max. Gradient: 1362398 Hz/m == 32.00 mT/m
Max. Slew Rate: 5.4818e+09 Hz/m/s == 128.75 T/m/s
Max. Slew Rate: 5.25714e+09 Hz/m/s == 123.48 T/m/s
Max. Slew Rate: 5.44959e+09 Hz/m/s == 128.00 T/m/s
Max. Absolute Gradient: 1406597 Hz/m == 33.04 mT/m
Max. Absolute Slew Rate: 7.47569e+09 Hz/m/s == 175.58 T/m/s