The Verasonics Vantage software is designed to provide users with unparalleled flexibility for leading-edge research in many ultrasound and ultrasonic applications. One of the features of the Vantage System that enables flexibility is the External Function feature. This built-in capability enables a researcher to apply their own processing algorithms and functions to the Vantage signal path by a simple reference in the user’s sequence specification. While straightforward integration is provided for custom functions written in MATLAB™, any legacy code or new implementation in C, C++, FORTRAN and JAVA or other compatible language can be used. Custom processing of data to augment or replace Verasonics’ built-in software functionality can thus be performed at any desired point in the user’s ultrasound sequence. This approach enables user-defined processing of acquired data in real-time.
The External Function capability on the Vantage Research Ultrasound platform enables researchers to implement many types of algorithms, including:
External functions may be written in MATLAB script language to take advantage of the many features, functions and tool kits available. However, when speed is essential for real-time processing, it is often preferred to code an external function in a compiled language, such as C or FORTRAN. The simplest way to accomplish this is to use the MATLAB MEX interface (MEX: Matlab executable), which allows a function written in a compatible language to be compiled and called in a manner similar to calling a native MATLAB function. Thus, the external function capability is built into all Vantage system configurations.
Verasonics supplies a large collection of working examples called “example setup scripts” to illustrate Vantage programming techniques and to provide ready-made imaging sequences for the new programmer to use right away. Many example scripts use external functions, including a few that do the following:
- Acquire pulse-echo ultrasound data and plot one channel in real time
- Perform Doppler imaging and processing using an external function written in MATLAB
- Perform filtering of the RF data on a GPU (using CUDA) prior to reconstruction
- Illustrate Shear Wave Imaging (using nine separate external functions)
- Provide a template for multi-threaded operation using C
- Describe how to create an external function with compiled C on a Windows platform
The last example of a C language external function is accompanied by a tutorial document that details the procedure to follow to add a custom function written in C. The approach is very similar for other supported language types.
In the tutorial example, a simple external C function is called by the MATLAB script to implement Envelope Detection, which computes the magnitude of the complex reconstructed data. The external function replaces the built-in B-mode imaging application processing by taking the matrix of reconstructed IQ data as input (from the “inter buffer” as shown below) and returning an image of “detected” data as output into the storage location the built-in software would have used (“image buffer”) for uninterrupted post-processing and display by the built-in software. (Fig 1)
One can modify the tutorial external function to apply other custom processing techniques implemented in C, including CUDA for GPU acceleration.
On a Windows 10 platform, the recommended Vantage System configuration for compiling C programs is:
- Vantage Software Version 4.x (with Image Reconstruction Option if not included)
- MATLAB 2018a
- MATLAB Min-GW-w64 C/C++ Compiler Add-On
As indicated, in order to use the Vantage External Function features for C language code, researchers will need to install the MATLAB Min-GW C Compiler Add-On.
Verasonics has recently released the Verasonics Community Script Repository to customers and the tutorial accompanying the extmexDetection example is posted there for all customers to access.
In summary, the external function processing capability is a key to flexible ultrasound development on the Vantage platform. With access to data at all major stages in the processing flow, new imaging modes can be explored in a real-time environment, and by a single developer.