# Deep Learning-Based Algorithms for Real-Time Lung Ultrasound Assisted Diagnosis
## 2 Methods
### Dataset
#### 2.2.1 Neural Network Input Data  
The format of the input data has a great impact on the deep learning model definition and performance. A typical ultrasound image with a curved array (like that used in this study) is a circle sector, defined by an aperture angle \(\alpha\), an initial range \(\mathrm{r}_{1}\), and a final range \(\mathrm{r}_{2}\), which is usually framed into a rectangular image with size \(\mathrm{W}\times\mathrm{H}\) pixels (Figure 2 Left). But, in fact, a sector ultrasound image is originally formed by N scan lines usually equally distributed inside the sector area. These lines, containing M samples each, are the output of the beamforming algorithm, and could be interpreted themselves as a rectangular image (Figure 2 Right). The algorithm to obtain the sector image from the B-Scan data is usually called scan-converter, and it is typically implemented by bi-linear interpolation of the acquired samplesover the pixel grid. This process is carried out by the scanner, which gives the user the sector image in W \(\times\) H format. Therefore, a question arises about which image format is more appropriate for implementing the deep learning algorithm aimed at in this work. Sector image has the advantage of being more easily accessible, because it is the typical output format for most ultrasound equipment. Therefore, it maintains the aspect ratio of the structures to be imaged, which eases interpretation by medical professionals. However, accommodating a sector image inside a rectangular grid generates black margins around it, which, besides adding pixels with no information, could potentially introduce a bias in the automated image analysis. Furthermore, the shape and extension of these zones depends on the scanner model and the configuration, hindering the translation of the resultant model between different scanners. On the other hand, rectangular B-scan images have the advantage of providing only useful information (no black margins), while its rectangular format is highly suitable as input for segmentation models. Another important advantage is that each vertical line represents a physical propagation direction of the beam inside the tissue, which is particularly relevant for artifacts like B-Lines, that appear precisely on those directions. Therefore, a B-Line will be always seen in the B-Scan as a vertical artifact, independent of its position on the pleura and of the scanner configuration. Furthermore, scanner configuration parameters like the aperture angle \(\alpha\) or the initial and final range r\({}_{1}\) and r\({}_{2}\) only affect the size M \(\times\) N of the image, which simplifies adapting images acquired with different configurations to the same network, only by vertical and horizontal scaling. On the other hand, these images are not suitable for visual interpretation, as they present a distorted view of the tissue anatomy. Because not all ultrasound equipment provides direct access to B-Scan data, a Sector-Image-to-B-Scan conversion algorithm would be needed. With a similar approach than scan-converter algorithms from B-Scan to sector image, it could be based on a simple bilinear interpolation algorithm after defining a set of beam lines that cover the useful area of the sector image (green lines in Figure 2 Left). In this work, we had access to the B-Scan raw data generated by our system, so no Sector-Image-to-B-Scan process was needed. Figure 2: Possible representations of an ultrasound sector image: (**left**) conventional pixel-based image given by ultrasound scanners; (**right**) B-Scan rectangular image formed by ultrasound samples only, without geometrical information of the probe. Furthermore, for possible future hardware implementations of the proposed models, using B-scan data would be optimal in the sense that it reduces the amount of information to be processed, and uses data in a raw format available at low hardware level. For defining the size of the B-Scan images, the typical number of beams in an ultrasound scanner must be taken into account.