Skip to content

Commit

Permalink
ARRUS-87: support for esaote2-us4r6 and esaote2-us4r8 adapters. (#231)
Browse files Browse the repository at this point in the history
Co-authored-by: PiotrKarwat <piotr.karwat@us4us.eu>
  • Loading branch information
pjarosik and PiotrKarwat authored Aug 26, 2021
1 parent 35d9b05 commit e1b6a5f
Show file tree
Hide file tree
Showing 10 changed files with 118 additions and 56 deletions.
65 changes: 41 additions & 24 deletions api/matlab/arrus/Us4R.m
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
%
% Only one of the following parameters should be provided:
%
% :param nUs4OEM: number of Us4OEM modules available in the us4R system. Required.
% :param voltage: a voltage to set, should be in range 0-90 [0.5*Vpp]. Required.
% :param logTime: set to true if you want to display acquisition and reconstruction time. Optional.
% :param probeName: name of the probe to use. The parameter is required when ``probe`` is not provided.
Expand All @@ -37,21 +36,24 @@
methods

function obj = Us4R(varargin)
[nArius, voltage, probeName, adapterType, logTime, probe] = Us4R.parseUs4RParams(varargin{:});
[voltage, probeName, adapterType, logTime, probe] = Us4R.parseUs4RParams(varargin{:});

obj.logTime = logTime;
% System parameters
obj.sys.nArius = nArius; % number of Arius modules
obj.sys.nChArius = 32;

obj.sys.trigTxDel = 240; % [samp] trigger to t0 (tx start) delay

obj.sys.voltage = voltage;

if(isempty(probe))
probe = probeParams(probeName,adapterType);
probe = probeParams(probeName, adapterType);
end

obj.sys.nArius = probe.nUs4OEM; % number of Arius modules
nArius = obj.sys.nArius;
obj.sys.systemType = probe.systemType;

% checking if voltage is safe
isProperVoltageValue = @(x) ...
isnumeric(x) ...
Expand All @@ -71,7 +73,7 @@
end


obj.sys.adapType = probe.adapType; % 0-old(00001111); 1-new(01010101);
obj.sys.adapType = probe.adapType;
obj.sys.txChannelMap = probe.txChannelMap;
obj.sys.rxChannelMap = probe.rxChannelMap;
obj.sys.curvRadius = probe.curvRadius;
Expand Down Expand Up @@ -109,7 +111,7 @@

obj.sys.selElem = reshape( (1:obj.sys.nChArius).' ...
+ (0:3)*obj.sys.nChArius*nArius, [], 1) ...
+ (0:(nArius-1))*obj.sys.nChArius;
+ (0:(nArius-1))*obj.sys.nChArius; % [nchannels x nArius]
obj.sys.actChan = [true(96,nArius); false(32,nArius)];

elseif obj.sys.adapType == 2
Expand All @@ -121,8 +123,18 @@
% nChanTot = obj.sys.nChArius*4*nArius;
obj.sys.selElem = repmat((1:128).',[1 nArius]);
obj.sys.actChan = mod(ceil((1:128)' / obj.sys.nChArius) - 1, nArius) == (0:(nArius-1));
elseif obj.sys.adapType == 3
obj.sys.nChCont = obj.sys.nChArius * nArius;
obj.sys.nChTotal = obj.sys.nChArius * 4 * nArius;

obj.sys.selElem = reshape((1:obj.sys.nChArius).' + (0:3)*obj.sys.nChArius*nArius, [], 1) ...
+ [(0:(nArius/2-1))*2, (0:(nArius/2-1))*2+1]*obj.sys.nChArius; % [nchannels x nArius]

obj.sys.actChan = [true(32, nArius); false(96, nArius)]; % [nchannels x nArius]
else
error("ARRUS:IllegalArgument", ['Unrecognized adapter type: ', obj.sys.adapType]);
end
obj.sys.actChan = obj.sys.actChan & any(obj.sys.selElem == reshape(obj.sys.probeMap,1,1,[]),3);
obj.sys.actChan = obj.sys.actChan & any(obj.sys.selElem == reshape(obj.sys.probeMap, 1, 1, []),3);

end

Expand Down Expand Up @@ -316,7 +328,7 @@ function acquireToBuffer(obj, nElements)

methods(Access = private, Static)

function [nArius, voltage, probeName, adapterType, logTime, probe] = parseUs4RParams(varargin)
function [voltage, probeName, adapterType, logTime, probe] = parseUs4RParams(varargin)
paramsParser = inputParser;
addParameter(paramsParser, 'nUs4OEM', []);
addParameter(paramsParser, 'voltage', []);
Expand All @@ -327,9 +339,9 @@ function acquireToBuffer(obj, nElements)
parse(paramsParser, varargin{:});

nArius = paramsParser.Results.nUs4OEM;
if(~isscalar(nArius))
error("ARRUS:IllegalArgument", ...
"Parameter nArius is required and should be a scalar");
% TODO remove the nUs4OEM parameter value
if(~isempty(nArius))
warning("Parameter 'nUs4OEM' is deprecated and will be ignored.");
end
voltage = paramsParser.Results.voltage;
if(~isscalar(voltage))
Expand Down Expand Up @@ -814,6 +826,23 @@ function programHW(obj)
clear Us4MEX;

%% Program mappings, gains, and voltage


Us4MEX(0, "Initialize", obj.sys.systemType, obj.sys.nArius);
try
Us4MEX(0,"EnableHV");
catch
warning('1st "EnableHV" failed');
Us4MEX(0,"EnableHV");
end

try
Us4MEX(0, "SetHVVoltage", obj.sys.voltage);
catch
warning('1st "SetHVVoltage" failed');
Us4MEX(0, "SetHVVoltage", obj.sys.voltage);
end

for iArius=0:(obj.sys.nArius-1)
% Set Rx channel mapping
% for iChan=1:32
Expand All @@ -836,19 +865,7 @@ function programHW(obj)
Us4MEX(iArius, "SetDTGC","DIS", "0dB"); % EN/DIS? (attenuation actually, 0:6:42)
Us4MEX(iArius, "TGCEnable");

try
Us4MEX(0,"EnableHV");
catch
warning('1st "EnableHV" failed');
Us4MEX(0,"EnableHV");
end

try
Us4MEX(0, "SetHVVoltage", obj.sys.voltage);
catch
warning('1st "SetHVVoltage" failed');
Us4MEX(0, "SetHVVoltage", obj.sys.voltage);
end
end

%% Program Tx/Rx sequence
Expand Down Expand Up @@ -995,7 +1012,7 @@ function closeSequence(obj)
end
rf(:,(obj.seq.rxApSize+1):end,:,:) = [];

elseif obj.sys.adapType == 2 || obj.sys.adapType == 1 || obj.sys.adapType == -1
else
% "ultrasonix" or "new esaote" adapter type
rf0 = permute(rf,[2 1 3 4 6 5]);
rf0 = reshape(rf0,nSamp,nChan*nSubTx*nTx*nArius,nRep);
Expand Down
67 changes: 65 additions & 2 deletions api/matlab/arrus/probeParams.m
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,8 @@
probe.rxChannelMap + 32, ...
probe.rxChannelMap + 64, ...
probe.rxChannelMap + 96];
probe.nUs4OEM = 2;
probe.systemType = "us4rlite";
elseif strcmp(adapterType, "esaote2")
probe.adapType = -1;

Expand All @@ -124,7 +126,8 @@
80 82 81 83 85 84 87 86 88 92 89 94 90 91 95 93] + 1;
probe.rxChannelMap = [probe.rxChannelMap, 128*ones(2,32)]; % channel map length must be = 128
probe.txChannelMap = probe.rxChannelMap;

probe.nUs4OEM = 2;
probe.systemType = "us4rlite";
elseif strcmp(adapterType, "esaote3")
probe.adapType = 1;

Expand All @@ -133,7 +136,63 @@
probe.rxChannelMap + 32, ...
probe.rxChannelMap + 64, ...
probe.rxChannelMap + 96];

probe.nUs4OEM = 2;
probe.systemType = "us4rlite";
elseif strcmp(adapterType, "esaote2-us4r6")
probe.adapType = 3;
% US4OEM 0
probe.rxChannelMap = [ 26 27 25 23 28 22 20 21 24 18 19 15 17 16 29 13 ...
11 14 30 8 12 5 10 9 31 7 3 6 0 2 4 1; ...
... % US4OEM 1
24 23 22 21 25 20 19 17 18 16 15 14 12 13 26 10 ...
11 27 8 9 28 6 29 7 30 2 5 31 4 3 0 1; ...
... % Us4OEM 2
28 29 25 27 24 26 23 21 22 20 19 18 17 16 15 13 ...
14 12 31 11 10 30 9 8 6 0 7 4 1 5 3 2; ...
... % US4OEM 3
4 3 7 5 6 2 8 9 1 11 0 10 13 12 15 14 ...
16 17 19 18 20 25 21 22 23 31 24 27 30 26 28 29; ...
... % US4OEM 4
3 2 4 6 1 5 7 8 0 9 10 11 12 13 14 15 ...
17 16 18 20 19 23 21 22 26 24 27 25 30 29 28 31; ...
... % US4OEM 5
1 3 2 5 0 4 7 6 8 10 9 11 12 13 14 15 ...
16 18 17 19 21 20 23 22 24 28 25 30 26 27 31 29] + 1;

probe.rxChannelMap = [probe.rxChannelMap, 128*ones(6, 96)]; % channel map length must be = 128
probe.txChannelMap = probe.rxChannelMap;
probe.nUs4OEM = 6;
probe.systemType = "us4r";
elseif strcmp(adapterType, "esaote2-us4r8")
probe.adapType = 3;
% US4OEM 0
probe.rxChannelMap = [ 26 27 25 23 28 22 20 21 24 18 19 15 17 16 29 13 ...
11 14 30 8 12 5 10 9 31 7 3 6 0 2 4 1; ...
...% US4OEM 1
24 23 22 21 25 20 19 17 18 16 15 14 12 13 26 10 ...
11 27 8 9 28 6 29 7 30 2 5 31 4 3 0 1; ...
...% US4OEM 2
28 29 25 27 24 26 23 21 22 20 19 18 17 16 15 13 ...
14 12 31 11 10 30 9 8 6 0 7 4 1 5 3 2; ...
...% US4OEM 3
1:32; % doesn't matter - not used
...% US4OEM 4
4 3 7 5 6 2 8 9 1 11 0 10 13 12 15 14 ...
16 17 19 18 20 25 21 22 23 31 24 27 30 26 28 29; ...
...% US4OEM 5
3 2 4 6 1 5 7 8 0 9 10 11 12 13 14 15 ...
17 16 18 20 19 23 21 22 26 24 27 25 30 29 28 31; ...
...% US4OEM 6
1 3 2 5 0 4 7 6 8 10 9 11 12 13 14 15 ...
16 18 17 19 21 20 23 22 24 28 25 30 26 27 31 29; ...
...% US4OEM 7
1:32 % doesn't matter - not used
] + 1;

probe.rxChannelMap = [probe.rxChannelMap, 128*ones(8, 96)]; % channel map length must be = 128
probe.txChannelMap = probe.rxChannelMap;
probe.nUs4OEM = 8;
probe.systemType = "us4r";
else
error(['No adapter of type ' adapterType ' available for the ' probeName ' probe.']);
end
Expand All @@ -148,6 +207,8 @@
probe.rxChannelMap + 32, ...
probe.rxChannelMap + 64, ...
probe.rxChannelMap + 96];
probe.nUs4OEM = 2;
probe.systemType = "us4rlite";
else
error(['No adapter of type ' adapterType ' available for the ' probeName ' probe.']);
end
Expand All @@ -164,6 +225,8 @@
probe.rxChannelMap + 32, ...
probe.rxChannelMap + 64, ...
probe.rxChannelMap + 96];
probe.nUs4OEM = 2;
probe.systemType = "us4rlite";
else
error(['No adapter of type ' adapterType ' available for the ' probeName ' probe.']);
end
Expand Down
5 changes: 1 addition & 4 deletions api/matlab/examples/Us4R_ATL_control.m
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,8 @@

[filtB,filtA] = butter(2,[0.5 1.5]*txFrequency/(samplingFrequency/2),'bandpass');

nUs4OEM = 2;

%% Initialize the system, sequence, and reconstruction
us = Us4R('nUs4OEM', nUs4OEM, ...
'probeName', 'L7-4', ...
us = Us4R('probeName', 'L7-4', ...
'adapterType', 'atl/philips', ...
'voltage', 40);

Expand Down
5 changes: 1 addition & 4 deletions api/matlab/examples/Us4R_ATL_control_batches.m
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@

%% PARAMETERS
nUs4OEM = 2; % This must remain unchanged

nSamples = 1024;
nAngles = 17;
nRepetitions = 100;
Expand Down Expand Up @@ -62,8 +60,7 @@
%% System setup
addpath('../arrus'); % path to the MATLAB API files

usObj = Us4R( 'nUs4OEM', 2, ...
'probeName', 'LA/20/128', ...
usObj = Us4R( 'probeName', 'LA/20/128', ...
'adapterType', 'atl/philips', ...
'voltage', txVoltage, ...
'logTime', true);
Expand Down
4 changes: 1 addition & 3 deletions api/matlab/examples/Us4R_Olympus_control.m
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,7 @@
[filtB,filtA] = butter(2,[0.5 1.5]*txFrequency/(samplingFrequency/fsDivider/2),'bandpass');

%% Initialize the system, sequence, and reconstruction
nUs4OEM = 2;
us = Us4R('nUs4OEM', nUs4OEM, ...
'probeName', '5L128', ...
us = Us4R('probeName', '5L128', ...
'adapterType', 'esaote3', ...
'voltage', 50, ...
'logTime', true);
Expand Down
4 changes: 1 addition & 3 deletions api/matlab/examples/Us4R_Ultrasonix_control.m
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,7 @@
[filtB,filtA] = butter(2,[0.5 1.5]*txFrequency/(samplingFrequency/2),'bandpass');

%% Initialize the system, sequence, and reconstruction
nUs4OEM = 2;
us = Us4R('nUs4OEM', nUs4OEM, ...
'probeName', 'L14-5/38', ...
us = Us4R('probeName', 'L14-5/38', ...
'adapterType', 'ultrasonix', ...
'voltage', 20);

Expand Down
4 changes: 1 addition & 3 deletions api/matlab/examples/Us4R_Vermon_control.m
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,8 @@

[filtB,filtA] = butter(2,[0.5 1.5]*txFrequency/(samplingFrequency/fsDivider/2),'bandpass');

nUs4OEM = 2;
%% Initialize the system, sequence, and reconstruction
us = Us4R('nUs4OEM', nUs4OEM, ...
'probeName', 'LA/20/128', ...
us = Us4R('probeName', 'LA/20/128', ...
'adapterType', 'atl/philips', ...
'voltage', 10, ...
'logTime', true);
Expand Down
12 changes: 5 additions & 7 deletions api/matlab/examples/Us4R_control.m
Original file line number Diff line number Diff line change
@@ -1,19 +1,17 @@

% path to the MATLAB API files
% addpath('../arrus');
addpath('../arrus');

txFrequency = 5e6;
txFrequency = 6e6;
samplingFrequency = 65e6;
fsDivider = 1;

[filtB,filtA] = butter(2,[0.5 1.5]*txFrequency/(samplingFrequency/fsDivider/2),'bandpass');

nUs4OEM = 2;
%% Initialize the system, sequence, and reconstruction
us = Us4R('nUs4OEM', nUs4OEM, ...
'probeName', 'SL1543', ...
'adapterType', 'esaote3', ...
'voltage', 30, ...
us = Us4R('probeName', 'SL1543', ...
'adapterType', 'esaote2-us4r8', ...
'voltage', 50, ...
'logTime', true);

seqSTA = STASequence( 'txApertureCenter', (-15:3:15)*1e-3, ...
Expand Down
4 changes: 1 addition & 3 deletions api/matlab/examples/Us4R_duplex.m
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,8 @@
[filtB,filtA] = butter(2,[0.5 1.5]*txFrequency/(samplingFrequency/fsDivider/2),'bandpass');
[wcfB, wcfA] = butter(4,0.2,'high');

nUs4OEM = 2;
%% Initialize the system, sequence, and reconstruction
us = Us4R('nUs4OEM', nUs4OEM, ...
'probeName', 'LA/20/128', ...
us = Us4R('probeName', 'LA/20/128', ...
'adapterType', 'atl/philips', ...
'voltage', 15, ...
'logTime', true);
Expand Down
4 changes: 1 addition & 3 deletions api/matlab/examples/Us4R_maxSequence.m
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,8 @@

[filtB,filtA] = butter(2,[0.5 1.5]*txFrequency/(samplingFrequency/fsDivider/2),'bandpass');

nUs4OEM = 2;
%% Initialize the system, sequence, and reconstruction
us = Us4R('nUs4OEM', nUs4OEM, ...
'probeName', 'SL1543', ...
us = Us4R('probeName', 'SL1543', ...
'adapterType', 'esaote3', ...
'voltage', 50, ...
'logTime', true);
Expand Down

0 comments on commit e1b6a5f

Please sign in to comment.