-
Notifications
You must be signed in to change notification settings - Fork 1
/
gen_CSMT_pulse_Diffnp.m
125 lines (88 loc) · 3.2 KB
/
gen_CSMT_pulse_Diffnp.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
function [pulses,pulseBB,pulseMF,pulse_weights,b1_max_pulse] = gen_CSMT_pulse_Diffnp(flips,dur,TR,b1rms_total,delta,nband,M,S,varargin)
%%% Function generates a set of pulses for each of the flips, with the
%%% specified B1rms for all pulses, and the specified duration. Uses a
%%% Gaussian shape. Adapted from Shaihan Malik 12-2-2018.
gausswin_sigma = 3; % Shape of basic pulse.
dt = 6.4e-6;
if ~isempty(varargin)
for ii=1:length(varargin)
if strcmpi(varargin{ii},'sigma')
gausswin_sigma = varargin{ii+1};
end
if strcmpi(varargin{ii},'dt')
dt = varargin{ii+1};
end
end
end
nflip = length(flips);
%% Set-up time domain.
nt = ceil(dur/dt);
dur = dt*nt;
%% Basic shape.
pulse = gausswin(nt,gausswin_sigma);
pulse = pulse - min(pulse);
pulse = pulse / max(pulse);
trms = sum(pulse.^2)*dt/max(pulse)^2; % [s]
gam = 267.5221; % [rad/s/uT]
teff = (gam*sum(pulse)*dt)/(gam*max(pulse))/dur; % teff of shape - normalised to duration.
%% Compute ratio of off to on resonance power.
% Maximum flip angle sets the max B1 which is the constraint here.
b1_max_ONres = max(flips)/(gam*teff*dur); % [uT]
b1_rms_ONres = sqrt(b1_max_ONres^2 * trms / TR); % RMS over the TR.
% Compute k factor.
switch nband
case 2
k = ((M+S)/(4*M))*((b1rms_total/b1_rms_ONres)^2-1);
case 3
k = ((M+S)/(2*M))*((b1rms_total/b1_rms_ONres)^2-1);
end
% Modulation function maximum.
mfmax = (2*sqrt(k)+1);
% Compute max pulse amplitude.
b1_max_pulse = mfmax * b1_max_ONres;
%% Make pulses - repeat the above calculations again for each band.
pulses = {};
tt = dt*(1:nt);
for jj=1:nflip
flip_current = flips(jj);
b1_max_ONres = (flip_current)/(gam*teff*dur); % [uT]
b1_rms_ONres = sqrt(b1_max_ONres^2 * trms / TR); % RMS over the TR.
switch nband
case 2
% Compute k factor.
k = ((M+S)/(4*M))*((b1rms_total/b1_rms_ONres)^2-1);
% Modulation function maximum.
mfmax = (2*sqrt(k)+1);
% Compute max pulse amplitude.
b1_max_pulse = mfmax * b1_max_ONres;
% Make modulated pulse.
mf = 2*sqrt(k)*(cos(2*pi*delta*tt)+1i*sin(2*pi*delta*tt)) + 1;
pulses{jj} = pulse(:) .* mf(:) * b1_max_ONres;
case 3
% Compute k factor.
k = ((M+S)/(2*M))*((b1rms_total/b1_rms_ONres)^2-1);
% Modulation function maximum.
mfmax = (2*sqrt(k)+1);
% Compute max pulse amplitude.
b1_max_pulse = mfmax * b1_max_ONres;
% Make modulated pulse.
mf = 2*sqrt(k)*cos(2*pi*delta*tt) + 1;
pulses{jj} = pulse(:) .* mf(:) * b1_max_ONres;
end
end
if nflip==1
pulses = cell2mat(pulses);
end
% Output modulation function and base pulse if nargout > 1. At the moment
% this only works for the last pulse - use with nflip = 1.
if nargout>1
pulseBB = pulse(:) * b1_max_ONres;
pulseMF = mf(:);
switch nband
case 2
pulse_weights = [0 1 2*sqrt(k)];
case 3
pulse_weights = [sqrt(k) 1 sqrt(k)];
end
end
end