Ultrasonography (US) devices are systems largely used to collect medical images useful for visualizing subcutaneous body structures. It is well-known that one of the major drawbacks in US is the limited field of view and lack of spatial information among different images acquired; therefore, to manage this issue, more expensive and time consuming medical image devices, such as MRI and CT, are used. However, in some clinical applications, it could be possible to exploit US as alternative approach, by using a procedure called 3D Freehand ultrasound (3DUS). This approach, initially proposed in the 90s, combines ultrasound images and the corresponding position and orientation of the US transducer with the aim to reconstruct large 3D anatomical parts. The aim of the present work is to customize the 3DUS implementation by pushing on vectorization in NumPy / SciPy along with memory waste avoidance, for speeding up processing as much as possible. These aspects are essential in this context, since for commodity hardware: i) memory resources are relatively limited and 3D volumes involved here can quickly reach large dimensions, ii) computation time can become unrealistic if very large for- or while- loops are used in Python.
A package called Py3DFreeHandUS is therefore provided for this purpose.
The Py3DFreeHandUS package is able to process data acquired simultaneously by US and position+orientation sensors (POS), being as input DICOM and C3D files, respectively. The package is composed of two main parts: US probe calibration and voxel array reconstruction. The probe calibration is an essential step for using the freehand imaging systems for determining the pose of the US images with respect to the POS . Calibration quality assessment was also implemented in terms of repeatability and accuracy. Once to define parameters from calibration, it is possible to apply the voxel array reconstruction, which was performed by positioning the 2D US images in the 3D space by mapping relevant pixel information. A 3D voxel data set is therefore created, containing the grey values of all the repositioned original pixels. The voxel-array (a parallelepipedon) was defined to be the smallest one containing the sequence of realigned scans, to avoid RAM waste. Since gaps can occur in the voxel-array when the voxel size is small compared to the distance between the acquired images, interpolation methods were applied for filling these empty voxels. For optimizing this process, a robust method was used, i.e. convex hull, for restricting the volume containing only the useful information, which will be then filled during interpolation. Finally, data can be exported as VTI file (VTK) and visualized using tools like Paraview.
Py3DFreeHandUS is developed in Python 2.7 and has the following dependencies:
The present package (available here https://github.com/u0078867/Py3DFreeHandUS) has implemented the state-of-the-art algorithms for the 3DUS. Sample data and code are provided in the same repository as well. We'll regularly work on this tool in the coming months to improve architecture, generalize code (e.g. POS type, more general US data readers...), add new features (e.g. image segmentation).
 Hsu PW, Prager RW, Gee AH, Treece GM. Freehand 3D Ultrasound Calibration: A Review. Chapter 3, pages 47-84 in Advanced Imaging in Biology and Medicine, Springer Berlin Heidelberg, Berlin, Heidelberg, 2009.