-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgenerateH317Trans.m
110 lines (92 loc) · 5.65 KB
/
generateH317Trans.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
function Trans = generateH317Trans(varargin)
Trans = varargin{1};
if ~isfield(Trans,'frequency'), Trans.frequency = 0.2; end % nominal frequency in MHz
% Vantage: 5.208 is closest supported frequency to 5 MHz
if ~isfield(Trans,'Bandwidth'), Trans.Bandwidth = [0.7, 0.9]; end % 250 KHz frequency
Trans.name = 'custom';
Trans.id = 0; % find from the scanner head
Trans.type = 2; % 2D transducer
Trans.connType = 1; % HDI 260-ZIF
Trans.units = 'wavelengths';
Trans.numelements = 128; % no of transducer element
Trans.elementWidth = 9.5; % width of the element in mm or wavelengths
Trans.spacingMm = Trans.elementWidth/0.9; % guess
Trans.elevationApertureMm = Trans.spacingMm;
Trans.radiusMm = 135;
Trans.ElementPos = zeros(Trans.numelements,5);
arraygeom = computeH317Geometry; % Get the x,y,z coordinates (from the test stat)
Trans.ElementPos = arraygeom;
Trans.ElementPos(1:128, 4) = atan(arraygeom(:,1) ./ (Trans.radiusMm-arraygeom(:,3)) ); % AZ = atan(x/z)
Trans.ElementPos(1:128, 5) = atan(arraygeom(:,2) ./ sqrt( arraygeom(:,1).^2 + (Trans.radiusMm-arraygeom(:,3)).^2 ) ); % EL = atan(y/sqrt(x^2+z^2)), where z has to be wrt geometric focus.
Trans.impedance = 90*exp(1j*deg2rad(85)); % Ohms
% ---User Defined if necessary. Conservative value obtained from H-313
if ~isfield(Trans,'maxAvgPower'), Trans.maxAvgPower = 10; end % conservative value for max input power into the transducer
if ~isfield(Trans,'maxHighVoltage'), Trans.maxHighVoltage = 25; end % conservative value for max input voltage into the transducer
Trans.lensCorrection = 0; % guess
if Trans.maxAvgPower>10 || Trans.maxHighVoltage>25
res=questdlg(sprintf("Max Voltage or power higher than conservative values (%f,%f)\nAre you sure you want to continue?",Trans.maxHighVoltage,Trans.maxAvgPower));
if ~strcmp('Yes',res)
msgbox("stopping protocol generation");
error("Stopping protocol generation");
end
end
% Trans.ElementSens = ;
Trans.ConnectorES= [49, 34, 33, 17, 2, 1,113, 98, 97, 81, 66, 65, 50, 51, 35, 36, 18, 19, 3, 4, 114, ...
115, 99, 100, 82, 83, 67, 68, 52, 53, 54, 37, 38, 39, 40, 20, 23, 21, 22, 5, 6, 7, 8, 116, 117, 118, ...
101, 102, 103, 104, 84, 85, 86, 69, 70, 71, 72, 55, 56, 57, 41, 42, 43, 44, 26, 24, 25, 9, 10, 11, ...
12, 122, 119, 120, 121, 105, 106, 107, 108, 90, 87, 88, 89, 73, 74, 75, 76, 58, 59, 62, 63, 64, 45, ...
46, 47, 48, 28, 27, 29, 30, 31, 32, 13, 14, 15, 16, 124, 125, 123, 126, 127, 128, 109, 110, 111, 112, ...
92, 93, 91, 94, 95, 96, 77, 78, 79, 80, 60, 61]';
speedOfSound = 1.540; % default speed of sound in mm/usec
% Set a conservative value for maxHighVoltage, if not already defined
if ~isfield(Trans,'maxHighVoltage'), Trans.maxHighVoltage = 50; end
% Now convert all units as required, based on Trans.units
scaleToWvl = Trans.frequency/speedOfSound; % conversion factor from mm to wavelengths
% regardless of units, always provide spacing and radius in
% wavelengths if they have been defined
if isfield(Trans, 'spacingMm') && ~isempty(Trans.spacingMm)
Trans.spacing = Trans.spacingMm * scaleToWvl; % Spacing between elements in wavelengths.
end
if isfield(Trans, 'radiusMm') && ~isempty(Trans.radiusMm)
Trans.radius = Trans.radiusMm * scaleToWvl; % convert radiusMm to wavelengths
end
% define Trans.ElementSens based on Trans.elementWidth, but only if
% user has not already defined it; assign default elementWidth if
% it doesn't exist or is empty
if ~isfield(Trans,'ElementSens')
% Set element sensitivity function (101 weighting values from -pi/2 to pi/2).
if ~isfield(Trans,'elementWidth') || isempty(Trans.elementWidth)
% create default value of zero if not assigned in case
% statements above (zero implies the element is a point
% source)
Trans.elementWidth = 0;
end
Theta = (-pi/2:pi/100:pi/2);
Theta(51) = 0.0000001; % set to almost zero to avoid divide by zero.
% note at this point elementWidth is in mm, so we have to
% convert to wavelengths for the ElementSens calculation
eleWidthWl = Trans.elementWidth * scaleToWvl;
if eleWidthWl < 0.01
% avoid the divide by zero for very small values (in this
% case the sinc function will be extremely close to 1.0 for
% all Theta, so we only need the cos term)
Trans.ElementSens = abs(cos(Theta));
else
Trans.ElementSens = abs(cos(Theta).*(sin(eleWidthWl*pi*sin(Theta))./(eleWidthWl*pi*sin(Theta))));
end
end
if strcmp(Trans.units, 'wavelengths')
% convert all mm unit variables to wavelengths. Note columns 4
% and 5 of the ElementPos array are angles in radians, and do
% not require units conversion
Trans.elementWidth = Trans.elementWidth * scaleToWvl;
Trans.ElementPos(:,1) = Trans.ElementPos(:,1) * scaleToWvl;
Trans.ElementPos(:,2) = Trans.ElementPos(:,2) * scaleToWvl;
Trans.ElementPos(:,3) = Trans.ElementPos(:,3) * scaleToWvl;
if Trans.type == 3
% for type 3 annular arrays, the fourth column is also a distance, not an angle
Trans.ElementPos(:,4) = Trans.ElementPos(:,4) * scaleToWvl;
end
Trans.lensCorrection = Trans.lensCorrection * scaleToWvl;
end
end