UltrasoundManager.cs - UF-CSSALT/SMARTS-SDK-Unity-Asset-Package GitHub Wiki
The UltrasoundManager, as the name implies, handles all ultrasound processes. It manages ultrasound rendering, scanning plane generation, transducer mechanics, and noise and attenuation effects. It provides users with fields for creating custom ultrasound transducers or varying widths, measurement depths, angles, and beam widths. The scanning plane is dynamically modified to reflect these changes upon rebuild which provides an excellent visual representation of the field being scanned by the ultrasound.
The user interface provides easily scalable components useful when developing user interfaces designed around the principles of reactive design. All attenuation effects, and ultrasound blur effects, and others are simple to toggle on and off to allow for versatile use of the ultrasound screen. The default resolution of 256x256 can be modified and has been optimized for optimal rendering performance. However, resolutions above 512x512 result in visibly poorer rendering performance despite the optimization of the process.
Namespace
SMARTS_SDK.Ultrasound
To use the UltrasoundManager.cs script and access its functionality, any scripts must be using the SMARTS_SDK.Ultrasound namespace.
Static Fields
UltrasoundManager.ME
This is the singleton reference of the UltrasoundManager.cs script. It provides simple access to any external scripts using the SMARTS_SDK namespace.
Public Fields
bool rebuild (Inspector Only)
The rebuild button reconstructs the entire ultrasound system including scanning plane, screen resolution, and other settings to reflect runtime modifications made to fields including, but not limited to, depth, width, angle, resolution, beamThickness, etc. It destroys the previously rendered scanning plane, and rebuilds it, along with all ultrasound related textures.
int width (Inspector Only)
The rebuild button reconstructs the entire ultrasound system including scanning plane, screen resolution, and other settings to reflect runtime modifications made to fields including, but not limited to, depth, width, angle, resolution, beamThickness, etc. It destroys the previously rendered scanning plane, and rebuilds it, along with all ultrasound related textures.
int depth (Inspector Only)
The width field takes in user defined input (in world units, generally mm)and uses it to define the depth of the ultrasound’s scanning plane. This is the maximum depth the transducer can measure at. This is value has no enforced range, but should be positive and greater than 0.
bool angle (Inspector Only)
The angle field defines the angle at which the scanning plane deviates from the direction perpendicular to the probe’s contacting surface. An angle of zero creates a perfectly normal scanning plane, and angles nearer to 90 create almost completely fanned out ultrasound scanning planes. More about this will be added later. For now, editing this value at runtime and rebuilding the plane will provide the most useful visual aids.
int resolution (Inspector Only)
The resolution defines the resolution of the ultrasound texture generated. The default resolution is 256x256. Currently only perfectly square resolutions are supported
bool beamThickness (Inspector Only)
No ultrasound’s transducer produces a perfect scanned plane of zero thickness. This value defines the thickness of the generated ultrasound plane. This value is 1 by default. A value of 0 creates a perfect scanning plane. The rendered texture is generated randomly along the plane within this beamThickness.
Color backgroundColor (Inspector Only)
The background color determines the color of the ultrasound image that is not rendered by any other objects. If the ultrasound probe is held in the air, and the scanning plane does not intersect with any other anatomies or objects, this is the default render color.
Color attenuationColor (Inspector Only)
The attenuationColor is the color to which the ultrasound image degrades with increased depth. Typically this color is simply Color.black.
Color edgeColor (Inspector Only)
When the ultrasound’s angle is non-zero, when the image is not perfectly vertical, the color of the black space not rendered as ultrasound texture is defined by this color. This color is typically Color.black, however, it can be made any color for stylistic purposes.
Gradient texture1ColorGradient (Inspector Only)
This gradient defines the gradient used to render the first noise texture field.
float divisorX1 (Inspector Only)
Skews the first generated noise field in the x direction. Larger values (those greater than 1) limit the effect of movement along the x axis on noise pattern changes, whereas smaller values (less than 1) increase the effect of movement on the noise’s change.
float divisorY1 (Inspector Only)
Skews the first generated noise field in the y direction. Larger values (those greater than 1) limit the effect of movement along the y axis on noise pattern changes, whereas smaller values (less than 1) increase the effect of movement on the noise’s change
float divisorZ1 (Inspector Only)
Skews the first generated noise field in the z direction. Larger values (those greater than 1) limit the effect of movement along the z axis on noise pattern changes, whereas smaller values (less than 1) increase the effect of movement on the noise’s change.
float dampener1 (Inspector Only)
Decreases the contrast between extreme ends of the texture1ColorGradient. The greater the dampener, the more gradual the color shift in the noise texture becomes.
Gradient texture2ColorGradient (Inspector Only)
This gradient defines the gradient used to render the first noise texture field.
float divisorX2 (Inspector Only)
Skews the second generated noise field in the x direction. Larger values (those greater than 1) limit the effect of movement along the x axis on noise pattern changes, whereas smaller values (less than 1) increase the effect of movement on the noise’s change.
float divisorY2 (Inspector Only)
Skews the second generated noise field in the y direction. Larger values (those greater than 1) limit the effect of movement along the y axis on noise pattern changes, whereas smaller values (less than 1) increase the effect of movement on the noise’s change.
float divisorZ2 (Inspector Only)
Skews the second generated noise field in the z direction. Larger values (those greater than 1) limit the effect of movement along the z axis on noise pattern changes, whereas smaller values (less than 1) increase the effect of movement on the noise’s change.
float dampener2 (Inspector Only):
Decreases the contrast between extreme ends of the texture1ColorGradient. The greater the dampener, the more gradual the color shift in the noise texture becomes.
bool renderSimpleScanningPlane (Inspector Only):
When false, the visible scanning plane will be rendered to exactly match the scanning plane used to generate the ultrasound image. When true, the displayed scanning plane will be generated with 1/10th the vertices of the ideal scanning plane, and for most applications, this lower resolution mesh is acceptable. The CSSALT default state is true.
bool blur (Inspector Only):
Ultrasound images are not flawless in real life. Generally the images rendered are not perfectly crisp, and there is a large amount of “fuzziness” to the image. To replicate this, the blur toggle can be turned on. When false, the rendered ultrasound image is a precise image of the rendered anatomy.
bool depthAttenuation (Inspector Only):
With increased depth in ultrasound generally comes decreased resolution. The deeper a transducer has to register, the darker the resulting image becomes. To replicate this phenomenon, the depthAttenuation toggle can be used to obscure objects at greater depth.
Texture 2D ultrasoundTexture (Inspector Only):
This texture is the pure rendered ultrasound image. It is visible in the inspector, along with other textures to give an idea of how the rendering process works. Will not be exposed in later updates.
Texture 2D attenuationOverlayTexture (Inspector Only):
This texture is the attenuation overlay field. It is visible in the inspector, along with other textures to give an idea of how the rendering process works. Will not be exposed in later updates.
Texture 2D edgeOverlayTexture (Inspector Only):
This texture is the generated edge overlay. In all but perfectly vertical (zero angle) ultrasound configurations, the edges of the ultrasound texture are not completely covered by the ultrasound image. This texture overlay modifies the ultrasound’s image to account for this un-rendered segment. It is visible in the inspector, along with other textures to give an idea of how the rendering process works. Will not be exposed in later updates.
GameObject scanningPlane (Inspector Only):
This is a reference to the visible ultrasound scanning plane. The scanning plane is recreated during every rebuild of the ultrasound, and a reference to it is provided and dynamically updated on rebuild to provide users with a constant reference to the object.
GameObject ultrasoundProbe (Inspector Only):
This is a reference to the “Ultrasound Probe” GameObject. It is set by default when loading in objects using the CSSALT editor button. It should not be edited unless creating a custom ultrasound probe.
GameObject probeCenterPoint (Inspector Only):
This is a reference to the “Ultrasound Probe Center Point” GameObject. It is set by default when loading in objects using the CSSALT editor button. It should not be edited unless creating a custom ultrasound probe.
GameObject renderedUltrasoundTexture (Inspector Only):
This is a reference to the “Rendered Ultrasound Texture” GameObject. It is set by default when loading in objects using the CSSALT editor button. It should not be edited under any circumstances and is only displayed in the inspector for convenient reference.
GameObject attenuationOverlay (Inspector Only):
This is a reference to the “Attenuation Overlay” GameObject. It is set by default when loading in objects using the CSSALT editor button. It should not be edited under any circumstances and is only displayed in the inspector for convenient reference. It will not be exposed in later updates.
GameObject ultrasoundTextureCamera (Inspector Only):
This is a reference to the “Ultrasound Texture Camera” GameObject. It is set by default when loading in objects using the CSSALT editor button. It is perfectly aligned for optimal operation. It should not be edited under any circumstances and is only displayed in the inspector for convenient reference. It will no longer be exposed in later updates.