Skip to content

tutorials.8

Vincent Le Garrec edited this page Oct 10, 2025 · 11 revisions

Tutorial - Create an Aquisition

Python

import datetime

import numpy as np
import ultrasound_acquisition_configuration as uac
from helpers import makeLinearArrayUac, makePlaneWavesGroupUac


# Transmit parameters
n_theta = 4  # number of plane waves in the sequence
d_theta = 4  # angular step between plane waves [°]
theta_max = (n_theta - 1) / 2 * d_theta  # maximum plane wave angle [°]
thetas = np.arange(-theta_max, theta_max + d_theta, d_theta)  # list of the angles [°]

transmit_frequency = 8.33e6  # transmit frequency of the pulse [Hz]
voltage = 25  # voltage of the excitation Vpeak [V]
n_periods = 2  # number of transmitted periods
n_frames = 200  # number of frames
frame_rate = 500  # frame rate after compound [Hz]
prf = 10e3  # pulse repetition rate [Hz]

sound_speed = 1540  # celerity of the sound in the medium [m/s]

# Receive parameters
sampling_frequency = 33.3e6  # sampling frequency of the backscattered signal [Hz]
modulation_frequency = 8.33e6  # modulation frequency of the backscattered signal [Hz]
n_samples = 800  # number of received samples for each transmit event
rx_time_offset = 1.2e-6  # time before the sampling of the received signal [s]

# Probe parameters
probe_description = "SL10-2 192 elements"  # description or name of the probe
n_elements = 192  # number of transducers in the ultrasound probe
pitch = 300e-6  # pitch (spatial step) of the array [m]
width = 280e-6  # width of a single transducer [m]
height = 6e-3  # height of a single transducer [m]
# kerf = pitch - width  # space between adjacent transducer elements [m]
channel_mapping = [
    [i] for i in range(n_elements)
]  # order of channels in the interface (start at 0)

# Probe
probe = makeLinearArrayUac(
    n_elements, pitch, width, height, probe_description
)  # build the probe

# Group
[group, excitation] = makePlaneWavesGroupUac(
    thetas,
    voltage,
    n_periods,
    prf,
    n_frames,
    frame_rate,
    transmit_frequency,
    sound_speed,
    n_samples,
    rx_time_offset,
    sampling_frequency,
    modulation_frequency,
    channel_mapping,
    probe,
)  # build the sequence of events

# Acquisition
acquisition = uac.Acquisition()
acquisition.authors = "yourName"
acquisition.description = "Example of plane waves acquisition for a linear array"
acquisition.local_time = str(
    datetime.datetime.strptime("202501010000000000", "%Y%m%d%H%M%S%f").strftime(
        "%Y-%m-%d %H:%M:%S.%f"
    )
)
# local time of the acquisition
acquisition.country_code = "FR"  # country code of the acquisition
acquisition.system = "yourHardware"  # acquisition system description
acquisition.probes = [probe]  # stores probe here for reuse (shared pointer)
acquisition.excitations = [excitation]  # stores excitations here for reuse (shared pointer)
acquisition.groups = [group]  # stores groups
acquisition.initial_group = group

# Dataset
dataset = uac.Dataset()
dataset.acquisition = acquisition
uac.saveToFile(
    "./t8-python.uac", dataset, uac.WriterOptions(False, False, False)
)  # saves the acquisition in a dataset.uac

MATLAB

%% Transmit parameters 
NTheta = 4;                                 % number of plane waves in the sequence
DTheta = 4;                                 % angular step between plane waves [°]
ThetaMax = (NTheta-1)/2 * DTheta;           % maximum plane wave angle [°]
Thetas = -ThetaMax:DTheta:ThetaMax;         % list of the angles [°]

TransmitFrequency = 8.33e6;                 % transmit frequency of the pulse [Hz]
Voltage = 25;                               % voltage of the excitation Vpeak [V] 
NPeriods = 2;                               % number of transmitted periods
NFrames = 200;                              % number of frames 
FrameRate = 500;                            % frame rate after compound [Hz]
Prf = 10e3;                                 % pulse repetition rate [Hz]

SoundSpeed = 1540;                          % celerity of the sound in the medium [m/s]

%% Receive parameters 
SamplingFrequency = 33.3e6;                 % sampling frequency of the backscattered signal [Hz]
ModulationFrequency = 8.33e6;               % modulation frequency of the backscattered signal [Hz]
NSamples = 800;                             % number of received samples for each transmit event
RxTimeOffset = 1.2e-6;                      % time before the sampling of the received signal [s]

%% Probe parameters
ProbeDescription = 'SL10-2 192 elements';   % description or name of the probe
NElements = 192;                            % number of transducers in the ultrasound probe
Pitch = 300e-6;                             % pitch (spatial step) of the array [m]
Width = 280e-6;                             % width of a single transducer [m]
Height = 6e-3;                              % height of a single transducer [m]
Kerf = Pitch - Width;                       % space between adjacent transducer elements [m]
ChannelMapping = 0:NElements-1;             % order of channels in the interface (start at 0)

%% Probe
Probe = makeLinearArrayUac(NElements, Pitch, Width, Height, ProbeDescription);         % build the probe

%% Group
[Group, Excitation] = makePlaneWavesGroupUac(Thetas, Voltage, NPeriods, Prf, NFrames, FrameRate, TransmitFrequency, SoundSpeed, NSamples, RxTimeOffset, SamplingFrequency, ModulationFrequency, ChannelMapping, Probe);

%% Acquisition
Acquisition = uac.Acquisition();
Acquisition.authors = 'yourName';
Acquisition.description = 'Example of plane waves acquisition for a linear array';
Acquisition.localTime = char(datetime([2025 01 01]), 'yyyy-MM-dd HH:mm:ss.SSSSSS');     % local time of the acquisition
Acquisition.countryCode = 'FR';                                                         % country code of the acquisition
Acquisition.system = 'yourHardware';                                                    % acquisition system description
Acquisition.probes = Probe;                                                             % stores probe here for reuse (shared pointer)
Acquisition.excitations = Excitation;                                                   % stores excitations here for reuse (shared pointer)
Acquisition.groups = Group;                                                             % stores groups 
Acquisition.initialGroup = Group;                                                       % initial group during acquisition

%% Dataset
Dataset = uac.Dataset();
Dataset.acquisition = Acquisition;

%% Save
uac.saveToFile('./t8-matlab.uac',Dataset, false, false, false);      % saves the acquisition in a uac file

C++

#include "helpers.h"

#include <algorithm>
#include <cstddef>
#include <cstdint>
#include <memory>
#include <string>
#include <utility>
#include <vector>

#include <urx/utils/io/writer_options.h>

#include <uac/acquisition.h>
#include <uac/dataset.h>
#include <uac/utils/io/writer.h>

int main() {
  // Transmit parameters
  const int n_theta = 4;                                   // number of plane waves in the sequence
  const double d_theta = 4.0;                              // angular step between plane waves [°]
  const double theta_max = (n_theta - 1) / 2.0 * d_theta;  // maximum plane wave angle [°]

  // Generate thetas vector
  std::vector<double> thetas;
  thetas.reserve(n_theta);
  for (size_t i = 0; i < n_theta; ++i) {
    thetas.push_back(-theta_max + i * d_theta);
  }
  const double transmit_frequency = 8.33e6;  // transmit frequency of the pulse [Hz]
  const double voltage = 25.0;               // voltage of the excitation Vpeak [V]
  const int n_periods = 2;                   // number of transmitted periods
  const int n_frames = 200;                  // number of frames
  const double frame_rate = 500.0;           // frame rate after compound [Hz]
  const double prf = 10e3;                   // pulse repetition rate [Hz]
  const double sound_speed = 1540.0;         // celerity of the sound in the medium [m/s]

  // Receive parameters
  const double sampling_frequency = 33.3e6;  // sampling frequency of the backscattered signal [Hz]
  const double modulation_frequency =
      8.33e6;                            // modulation frequency of the backscattered signal [Hz]
  const int n_samples = 800;             // number of received samples for each transmit event
  const double rx_time_offset = 1.2e-6;  // time before the sampling of the received signal [s]

  // Probe parameters
  const std::string probe_description = "SL10-2 192 elements";  // description or name of the probe
  const int n_elements = 192;         // number of transducers in the ultrasound probe
  const double pitch = 300e-6;        // pitch (spatial step) of the array [m]
  const double width = 280e-6;        // width of a single transducer [m]
  const double height = 6e-3;         // height of a single transducer [m]
  const double kerf = pitch - width;  // space between adjacent transducer elements [m]

  // Channel mapping vector
  std::vector<std::vector<uint32_t>> channel_mapping(n_elements);
  for (uint32_t i = 0; i < n_elements; ++i) {
    channel_mapping[i] = {i};
  }

  // Probe
  const auto probe =
      makeLinearArrayUac(n_elements, pitch, width, height, probe_description);  // build the probe

  // Group
  const auto [group, excitation] = makePlaneWavesGroupUac(
      thetas, voltage, n_periods, prf, n_frames, frame_rate, transmit_frequency, sound_speed,
      n_samples, rx_time_offset, sampling_frequency, modulation_frequency, channel_mapping,
      probe);  // build the sequence of events

  // Acquisition
  uac::Acquisition acquisition;
  acquisition.authors = "yourName";
  acquisition.description = "Example of plane waves acquisition for a linear array";

  acquisition.local_time = "2025-01-01 00:00:00.000000";

  acquisition.country_code = "FR";         // country code of the acquisition
  acquisition.system = "yourHardware";     // acquisition system description
  acquisition.probes = {probe};            // stores probe here for reuse (shared pointer)
  acquisition.excitations = {excitation};  // stores excitations here for reuse (shared pointer)
  acquisition.groups = {group};            // stores groups
  acquisition.initial_group = group;

  // Dataset
  uac::Dataset dataset;
  dataset.acquisition = acquisition;
  uac::utils::io::writer::saveToFile(
      "./t8-cpp.uac", dataset, {false, false, false});  // saves the acquisition in a dataset.uac

  return 0;
}
Clone this wiki locally