Ultrasound Acquisition Configuration
Version 1.3.0 (7.72 MB) by
Moduleus
Ultrasound Raw data eXchange file format C++ implementation and wrapping in Python and Matlab
UAC
Be sure to click on "Show all XX assets" and select your toolbox (uac-X.Y.Z-linux-amd64.mltbx for Linux or uac-X.Y.Z-win-amd64.mltbx for Windows).
Description
The Ultrasound Acquisition Configuration file format is a structure of data to configure ultrasound acquisition.
You may use it with various languages (C++, Python and MATLAB).
Requirements
To use Uac library, you need to have Urx library installed.
C++
CMakeAvailable files
All CMake files will be installed in INSTALL_PATH/lib/cmake/Uac-XXXYYY/ with:
- XXX: the version of the Uac library,
- YYY: empty if library has been built in shared mode, "_static" if library is static.
Configuration
First, you need to get Uac package with find_package.
find_package(Uac REQUIRED)
You don't need to find_package(Urx). The Uac library will do it.
You will have access to targets:
- Uac::Uac: header-only library of the uac struct.
- Uac::UacUtils: library with helper to manipulate uac struct, including read / write in hdf5 file format.
Usage
add_executable(UacTestIo ${SRCS_FILES}) target_link_libraries( UacTestIo PRIVATE Uac::Uac Uac::UacUtils ${HDF5_CXX_LIBRARIES})
Uac::UacUtils is only needed if you use helpers. If you only need the uac file format, only Uac::Uac is needed.
HDF5_CXX_LIBRARIES is only needed if the library has been built with HDF5 support.
You may found a complete example in test/uac or in test/io folders.C++Available files
All files will be installed in :
- INSTALL_PATH/include/Uac-XXXYYY/ (headers),
- INSTALL_PATH/lib (static libraries),
- INSTALL_PATH/bin (executables and libraries for Windows only).
Usage
All dynamic memory allocation should be stored in a shared_ptr.
#include <memory>#include <uac/dataset.h>auto dataset = std::make_shared<uac::Dataset>(); auto probe = std::make_shared<uac::Probe>(); probe->description = "Probe 1"; dataset->acquisition.probes.push_back(probe); uac::utils::io::writer::saveToFile("file.uac", *dataset); auto dataset_loaded = uac::utils::io::reader::loadFromFile("file.uac");
You may found a complete example in file uac/utils/io/test/io.h in function generateFakeDataset.
MATLAB
Available files
All MATLAB files will be installed in :
- INSTALL_PATH/share/Uac-XXXYYY/matlab (scripts),
- INSTALL_PATH/lib (static libraries),
- INSTALL_PATH/bin (shared libraries for Windows only).
C++ compiler
You need a C++ compiler.
If you have an error like MATLAB:mex:NoCompilerFound_link_Win64 or No supported compiler was found, run mex -setup c -v and mex -setup c++ -v.
Example of full error message
If you want to use a free compiler, follow the next steps:
- Download MinGW-w64 from https://www.mingw-w64.org/downloads. You may use LLVM-MinGW at Github https://github.com/mstorsjo/llvm-mingw/releases and get the latest release from the file llvm-mingw-YYYYMMDD-msvcrt-x86_64.zip.
- Extract it and install it on c:\llvm-mingw-YYYYMMDD-msvcrt-x86_64 (path c:\llvm-mingw-YYYYMMDD-msvcrt-x86_64\bin must exist) or anywhere but don't use path with space inside.
- In MATLAB, run:
setenv('MW_MINGW64_LOC', 'C:/llvm-mingw-YYYYMMDD-msvcrt-x86_64') mex -setup c -v mex -setup c++ -v
Check you have a message Found installed compiler 'MinGW64 Compiler (C++)'..
Configuration
If you are using Uac from MATLAB toolkit, you just have to enable Unicode if you need it (feature('DefaultCharacterSet','UTF-8');).
If you built Uac from source, before using Uac in MATLAB, you first need to:
- allow utf-8 caracters,
- load the uac library.
addpath([pwd 'INSTALL_PATH/share/Urx-XXXYYY/matlab']); addpath([pwd 'INSTALL_PATH/share/Uac-XXXYYY/matlab']); feature('DefaultCharacterSet','UTF-8'); urx.LibBinding.getInstance([path to libUrxMatlabBinding.so], [path to INSTALL_PATH/include/Urx-XXXYYY/urx/matlab/bindings.h], {[path to INSTALL_PATH/include/Urx-XXXYYY]}, {}); uac.LibBinding.getInstance([path to libUacMatlabBinding.so], [path to INSTALL_PATH/include/Uac-XXXYYY/uac/matlab/bindings.h], {[path to INSTALL_PATH/include/Urx-XXXYYY], [path to INSTALL_PATH/include/Uac-XXXYYY]}, {});
⚠ When invoking urx.LibBinding.getInstance the first time, environment variable HDF5_DISABLE_VERSION_CHECK is set. MATLAB have it's own version of HDF5 library. Under Linux it will conflict with the one from Uac.
If you try to use dataset.saveToFile(...) or uac.Dataset.loadFromFile(...) without setting HDF5_DISABLE_VERSION_CHECK, MATLAB will crash with error: Headers are 1.8.23, library is 1.8.12.
Example of full error message
Uac must use the same version (at least major / minor number) than the one from MATLAB (here 1.8).
Why is there a problem? Under Linux, the same symbol from two differents libraries are merged. So you can't know which one will be used. By setting HDF5_DISABLE_VERSION_CHECK to 1, you are disabling version check. Under Windows, the operating system keeps symbols from different libraries separate.
Usage
dataset = uac.Dataset(); probe1 = uac.Probe(); probe1.description = 'Probe 1'; dataset.acquisition.excitations = [excitation1]; dataset.saveToFile('test.uac'); dataset2 = uac.Dataset.loadFromFile('test.uac');
You may found a complete example in file test/matlab/+uac/+UnitTests/CreateUff.m.Important note
Some field are optional or can be empty (see C++ UML diagram). If you want to unassign a value, don't use [] but use empty method of the class (i.e. uac.ElementGeometry.empty).
Python
Usage
import ultrasound_acquisition_configuration as uac; dataset = uac.Dataset() probe1 = uac.Probe() probe1.description = 'Probe 1'dataset.acquisition.excitations = [excitation1] uac.saveToFile('test.uac', dataset) dataset2 = uac.loadFromFile('test.uac')
You may found a basic usage in folder test/python.
Build it with CMake
See .gitlab-ci.yml file for various examples.Windows
Under Windows, you need to explicitly set Visual Studio generator.
cmake.exe -S root_path -B CI -G "Visual Studio 17 2022" -A x64Linux
cmake -S . -B CI
Common features
- Install path
Set -DCMAKE_INSTALL_PREFIX= variable to define the installation path.
- Debug or Release
If you use a single build type generator (like Makefile in Linux), you need to set CMAKE_BUILD_TYPE to Debug or Release.
- Static or dynamic libraries
Set BUILD_SHARED_LIBS to OFF or ON.
Note that you should set BUILD_SHARED_LIBS to OFF if you want to build MATLAB or Python buiding.
Be sure to use a vcpkg triplet with the same shared / static link option.
- Use external 3rd party with vcpkg
vcpkg is a package manager. You first need to clone it with git clone https://github.com/microsoft/vcpkg.git.
Also, be sure that submodule vcpkg-registry is initialized with git submodule update --init --recursive.
Then pass the arguments below. ⚠ If you use cmake-gui, be sure to set these variables BEFORE running configure once. Otherwise, you need to reset cache.
Windows:
-DCMAKE_TOOLCHAIN_FILE="vcpkg_path/scripts/buildsystems/vcpkg.cmake"-DVCPKG_TARGET_TRIPLET=x64-wsmep -DVCPKG_HOST_TRIPLET=x64-wsmep -DVCPKG_OVERLAY_TRIPLETS=vcpkg-registry/triplets"
Linux with static libraries (make sure that BUILD_SHARED_LIBS is set to OFF).
-DCMAKE_TOOLCHAIN_FILE="vcpkg_path/scripts/buildsystems/vcpkg.cmake"-DVCPKG_TARGET_TRIPLET=x64-linux -DVCPKG_HOST_TRIPLET=x64-linux -DVCPKG_OVERLAY_TRIPLETS=vcpkg-registry/triplets
We provide various triplet with following syntax:
- w for Windows,
- l for Linux,
- d for Linux dynamic (will be static otherwise),
- sm for Windows static with /MD option (will be dynamic otherwise). See VCPKG_CRT_LINKAGE,
- e to pass environment variable for Windows. See VCPKG_ENV_PASSTHROUGH,
- p to pass Python3_EXECUTABLE to vcpkg via VCPKG_Python3_EXECUTABLE environment variable.
- Urx from vcpkg
If you want to have urx from vcpkg, you need to set WITH_VCPKG_URX:BOOL=ON CMake variable. See various examples in .gitlab-ci.yml.
If you want to have urx from submodule, you need to set URX_SRC=urx CMake variable. URX_SRC is the path of the urx folder. See build:ubuntu-without-3rd-party in .gitlab-ci.yml.
If you want to have urx from find_package, you need to set Urx_DIR CMake variable. Urx_DIR is the path of the CMake files in the Urx install path.
- Enable HDF5
This feature is needed to read / write uac structure to file.
Set WITH_HDF5 to OFF or ON.
- Enable Python binding
Set WITH_PYTHON to OFF or ON.
You can also set WITH_PYTHON_WHL to ON if you want to generate wheel package without using pip wheel.
- Enable MATLAB binding
Set WITH_MATLAB to OFF or ON.
You don't need to have MATLAB installed on your computer to build the MATLAB binding.
- Build with Clang
You need to set lots of CMake variables and use CMake 3.29 if you want to use CMAKE_LINKER_TYPE variable.
-DCMAKE_C_COMPILER=/usr/bin/clang-17-DCMAKE_CXX_COMPILER=/usr/bin/clang++-17-DCMAKE_AR=/usr/bin/llvm-ar-17-DCMAKE_AS=/usr/bin/llvm-as-17-DCMAKE_RANLIB=/usr/bin/llvm-ranlib-17-DCMAKE_LINKER_TYPE=LLD
You may found various command to build Uac in file .gitlab-ci.yml.
Build it with pip wheel
Using vcpkg
You may generate wheel archive by launching pip wheel . from the root directory of the project.
The setup.py file support the following options:
- CMAKE_TOOLCHAIN_FILE to set vcpkg path (repository cloned if option is not given),
- cmake_build_type to set CMAKE_BUILD_TYPE in CMake (Release by default),
- vcpkg_triplet to set vcpkg triplet (guessed if omited),
You can also set CMake variable with -DVARIABLE=VALUE.
Example:
python.exe -m pip install . --config-settings="--global-option=CMAKE_TOOLCHAIN_FILE=vcpkg_path/scripts/buildsystems/vcpkg.cmake"--config-settings="--global-option=cmake_build_type=Release"--config-settings="--global-option=vcpkg_triplet=x64-wsmrep"--config-settings="--global-option=-DBUILD_SHARED_LIBS=OFF"--config-settings="--global-option=-DWITH_HDF5=ON"-v
See build:windows-python and build:ubuntu-python in .gitlab-ci.yml file for real examples.
Without vcpkg
If you want to disable vcpkg and use you own 3rd party library (that you already built), you can set DISABLE_VCPKG to ON and set all XXX_DIR CMake variable (path of the CMake files of the 3rd party).
See CMake target UacPythonWheel in python/CMakeLists.txt file for real example.
MATLAB Release Compatibility
Created with
R2024b
Compatible with any release
Platform Compatibility
Windows macOS LinuxTags
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!Discover Live Editor
Create scripts with code, output, and formatted text in a single executable document.
+uac
+uac/+Group
+uac/+Probe
+uac/+Wave
| Version | Published | Release Notes | |
|---|---|---|---|
| 1.3.0 | See release notes for this release on GitHub: https://github.com/moduleus/uac/releases/tag/1.3.0 |
|
|
| 1.2.0 | See release notes for this release on GitHub: https://github.com/moduleus/uac/releases/tag/1.2.0 |
|
|
| 1.1.0 | See release notes for this release on GitHub: https://github.com/moduleus/uac/releases/tag/1.1.0 |
|
|
| 1.0.2 |
To view or report issues in this GitHub add-on, visit the GitHub Repository.
To view or report issues in this GitHub add-on, visit the GitHub Repository.
