Gain Engine

Early Software (2.x - 3.x)
This page gives a brief overview of the gain systems within the Ultrasonix engine.

Analog TGC
There are 4 parameters that adjust the TGC in the Ultrasonix engine.


 * TGC Analog (B)
 * This is the system gain curve that is used, assuming the parameters below are not applied.
 * TGC Max
 * This is a curve that ensures that the analog gain does not go beyond a certain limit. This is useful in removing saturations that can occur by overgaining, especially in the near-field.
 * User TGC
 * This is the slider control on the console that can also be programmed through software.
 * Gain (B)
 * This parameter is the overall offset that adjusts the TGC curve.
 * Gn Curve Depth (B)
 * This is the maximum depth that the gain curve is applied to. At greater depths the image is adjusted to the last point in the curve.

Internally, the gain range is from 0 to 3000. The parameters described above work together to create a table of a certain length, where each point is within the gain range. The TGC Analog (B) parameter is the starting point, this is a UTX_CURVE variable, and its values are interpolated to be within the gain range. The number of vertical values depends on the Gn Curve Depth (B) parameter. The User TGC sliders range from 0 to 255, with an output range from -500 to 500 (programmable internally), this parameter, along with the Gain (B) general offset parameter get applied to the gain table created from the TGC Analog (B) parameter.

Here is some pseudo code for programming the gainTable: numpoints = calculate from Gn Curve Depth (B) tgcA = Interpolate TGC Analog (B) curve to gain range within numpoints tgcU = Interpolate User TGC to user range within numpoints

for(i = 0 to numpoints) {   gainTable[i] = tgcA[i] + tgcU[i] + genOffset check min and max on gainTable[i] }

load gainTable to hardware

Lateral Gain Curve
The lateral gain curve is applied across the image in a digital manner. It does not program the analog components, but rather applies an offset to an entire line of data once it arrives on the FPGA. The range of this parameter is 0 to 2000 (programmable internally), and on-screen, is represented as the curve for half of the image, the other half is mirrored symmetrically in the computations. The name of the parameter is TGC Lateral, and it is a UTX_CURVE variable.

TGC Response
On the Sonix RP, the TGC is implemented by the VCA2612 component, a variable gain amplifier by Texas Instruments. The gain is interpolated into values ranging from 0 to 3000, which corresponds linearly to 24dB to 45 dB gain. An example in Texo SDK would be to call addTGC(0.5) to get a linear curve, which implies that the TGC curve is flat at 50% of the gain range, which would correspond to a value of 1500. This in turn results in about 34.5dB gain.

Experimentally, the following curve was obtained while scanning a aluminum block at 5 MHz and power level 10.



The exact energy level may differ from measurement to measurement, but the curve shows a non linear relationship in the energy content as TGC is increased, though the software does not compensate for this. This may be something to keep in mind while designing experiments.

Parameters
The parameters affecting tgc calculations are as follows:
 * b-tgc
 * b-gn curve depth
 * gain curve
 * b-gain
 * tgcMaxDigitalValue
 * tgcDigitalGainMinAmp
 * tgcDigitalGainRange
 * b-tgc lateral

Construction of Analog and Digital TGC
A combination of analog and digital tgc is applied internally on the image.
 * The analog tgc is based on the user tgc, internal tgc, and overall gain offset.
 * The analog tgc is mapped to the range of analog input.
 * The Digital TGC has the same shape as the analog TGC but mapped to the preferred digital range.

TGC = analog tgc + user tgc + gain Offset

Analog TGC

 * Is defined as the parameter 'b-tgc' (which is a curve as part of the imaging parameters in preset files).
 * This curve uses the b-gn curve depth parameter and if b-gn curve depth < number of samples, the last value gets applied up to the number of samples.
 * The four points in this curve parameter (eg. "[C] 1, 51, 51, 30") represents the positions along the curve x1, x2, x3, and y2 respectively (refer to the image below)

User TGC

 * Is defined as gain curve (curve in preset)
 * This curve gets applied up to the number of samples in the image depth

Gain offset

 * [b-gain –(3000)] / [3000- (-3000)] x 200 – 100;

Final Analog TGC

 * Va = TGC x TGCAnalogRange

Digital TGC

 * tgcdb = TGC x TGCDigitalGainRange
 * Vd = 10^(tgcdb/20) x 10^(tgcDigitalGainMinAmp/20)
 * Vd = min(Vd, tgcMaxDigitalValue)

Where tgcMaxDigitalValue, tgcDigitalGainMinAmp, tgcDigitalGainRange are values specified in the preset or imaging.set.xml file

TGCAnalogRange is hardware dependant where:
 * TGCAnalogRange for HW2 = 3000
 * TGCAnalogRange for HW3 = 1638
 * TGCAnalogRange for HW4 = 1228

Lateral TGC

 * Set with the parameter b-tgc lateral
 * This parameter is used for phased array probes only. If the curve is defined in the preset, it gets applied laterally to compensate for the bright middle region.

Parameter Ranges

 * The overall gain range is -3000 to 3000 internally.
 * The TGC sliders range from 0 to 255.
 * Lateral gain curve is still 100% digital 0 to 2000.