-
Notifications
You must be signed in to change notification settings - Fork 2
/
ss_band_plot.m
99 lines (88 loc) · 2.6 KB
/
ss_band_plot.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
function ss_band_plot(f, a, d, fo, fs, f1, f2, sym)
% SS_BAND_PLOT - Plot filter specification
%
% Inputs:
% f - frequency band edges in normalized frequency [-1..1]
% a - amplitude of bands
% d - ripple weighting
% fo - offset absolute frequency
% fs - sampling frequency
% f1, f2 - upper lower absolute frequencies to plot
% sym - flag whether response is symmetric
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
% Spectral-Spatial RF Pulse Design for MRI and MRSI MATLAB Package
%
% Authors: Adam B. Kerr and Peder E. Z. Larson
%
% (c)2007-2011 Board of Trustees, Leland Stanford Junior University and
% The Regents of the University of California.
% All Rights Reserved.
%
% Please see the Copyright_Information and README files included with this
% package. All works derived from this package must be properly cited.
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
% $Header: /home/adam/cvsroot/src/ss/ss_band_plot.m,v 1.6 2013/08/15 03:34:50 adam Exp $
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Exit if frequency vector is empty
%
if isempty(f),
fprintf(1,'No frequency bands to plot\n');
return;
end;
if sym,
fmod = f;
f = [-fmod(end:-1:1) fmod];
a = [a(end:-1:1) a];
d = [d(end:-1:1) d];
end;
% Plot unaliased frequency bands
%
nf = length(f)/2;
figure;
subplot(211);
hold on;
for idx = 1:nf,
plot(f((idx*2-1):(idx*2))*fs/2+fo, [a(idx) a(idx)]);
plot(f((idx*2-1):(idx*2))*fs/2+fo, [a(idx) a(idx)] + d(idx), '--');
plot(f((idx*2-1):(idx*2))*fs/2+fo, [a(idx) a(idx)] - d(idx), ...
'--');
end;
grid;
title('Unaliased Filter Specification');
xlabel('Frequency');
ylabel('Amplitude Response');
% Plot absolute frequency response
%
subplot(212);
hold on;
% Find what repeating responses need to be considered
%
low_mult = ceil(((fo-f1)-fs/2) / fs);
hi_mult = ceil(((f2-fo)-fs/2) / fs);
for mult = -low_mult:hi_mult,
foff = fo + fs*mult;
for idx = 1:nf,
% Get repeating band edge
%
f_l = (f(idx*2-1) * fs/2) + foff;
f_u = (f(idx*2) * fs/2) + foff;
% Plot if in bounds
%
f_l = min(max(f_l, f1), f2);
f_u = min(max(f_u, f1), f2);
if (f_l ~= f_u),
plot([f_l f_u], [a(idx) a(idx)]);
plot([f_l f_u], [a(idx) a(idx)] + d(idx), '--');
plot([f_l f_u], [a(idx) a(idx)] - d(idx), '--');
end;
end;
end;
grid;
title(sprintf('Filter Specification - Fs: %6.1f Hz', fs));
xlabel('Frequency');
ylabel('Amplitude Response');