Anatomical datastore
This is the API reference for code that works with the echoSMs anatomical datastore.
echosms.utils_datastore
Utilities for working with the echoSMs anatomical datastore.
dwbaorganism_from_datastore(shape)
Create a DWBAorganism instance from an echoSMs datastore shape.
Converts the centreline and width/height definition of a shape into that required by the echoSMs implementation of the DWBA (centreline, tangential, and radii vectors).
| PARAMETER | DESCRIPTION |
|---|---|
shape
|
The shape to convert, in the echoSMs datastore
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
An instance of DWBAorganism
|
|
Notes
The DWBA simulates a circular shape but the echoSMs datastore shape can store non- circular shapes (via the height and width). This function uses the height information and ignores the width information.
If mass_density_ratio and sound_speed_ratio are present into the shape dict,
these are used. If not, default values are used by DWBorganism().
Source code in src/echosms/utils_datastore.py
krmorganism_from_datastore(shapes)
Create a KRMorganism instance from an echoSMs datastore shape.
Converts the centreline and width/height definition of a shape into that required by the echoSMs implementation of the KRM (straight centreline, width, upper and lower heights from the centreline).
| PARAMETER | DESCRIPTION |
|---|---|
shapes
|
The shapes to convert, in the echoSMs datastore
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
Instances of KRMorganism
|
|
Notes
The shape with name body becomes the main organism body and all other shapes become
inclusions. If there is no shape with name of body, the first shape is used for the body.
The KRM uses just one sound speed and density per shape, but datastore shapes can have values per x-axis value. The mean of the sound speed and density values are used if so.
Datastore shapes can have non-zero y-axis values but these are ignored when creating a KRMorganism instance.
Source code in src/echosms/utils_datastore.py
mesh_from_datastore(shapes)
Create trimesh instances from an echoSMs datastore surface shape.
| PARAMETER | DESCRIPTION |
|---|---|
shapes
|
The shapes to convert, in the echoSMs datastore
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
list[Trimesh]
|
The shapes in trimesh form, in the same order as the input. |
Source code in src/echosms/utils_datastore.py
outline_from_dwba(x, z, radius, anatomical_feature='body', boundary='pressure-release')
Convert DWBA shape to the echoSMs outline shape representation.
| PARAMETER | DESCRIPTION |
|---|---|
x
|
The x values of the centreline
|
z
|
The distance of the centreline from z = 0. Positive values are towards the dorsal surface and negative values towards the ventral surface.
|
radius
|
The radius of the shape at each x coordinate
|
anatomical_feature
|
The anatomical feature for this shape, as per the echoSMs datastore schema.
TYPE:
|
boundary
|
The boundary type for this shape, as per the echoSMs datastore schema.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
An echoSMs outline shape representation.
|
|
Source code in src/echosms/utils_datastore.py
outline_from_krm(x, height_u, height_l, width, anatomical_feature='body', boundary='pressure-release')
Convert KRM shape representation to the echoSMs outline shape representation.
| PARAMETER | DESCRIPTION |
|---|---|
x
|
The x values of the centreline
TYPE:
|
height_u
|
The distance from z = 0 to the upper part of the shape at each x coordinate. Positive values are towards the dorsal surface and negative values towards the ventral surface.
TYPE:
|
height_l
|
The distance from z = 0 to the lower part of the shape at each x coordinate. Positive values are towards the dorsal surface and negative values towards the ventral surface.
TYPE:
|
width
|
The width of the shape at each x coordinate
TYPE:
|
anatomical_feature
|
The anatomical feature for this shape, as per the echoSMs datastore schema.
TYPE:
|
boundary
|
The boundary type for this shape, as per the echoSMs datastore schema.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
An echoSMs outline shape representation.
|
|
Source code in src/echosms/utils_datastore.py
plot_shape_categorised_voxels(s, title='')
Plot the specimen's categorised voxels.
Normally called via plot_specimen().
| PARAMETER | DESCRIPTION |
|---|---|
s
|
The categorised voxel shape data structure as per the echoSMs datastore.
|
title
|
Title for the plot.
DEFAULT:
|
Source code in src/echosms/utils_datastore.py
plot_shape_outline(shapes, axs)
Plot an echoSMs anatomical outline shape.
Normally called via plot_specimen().
| PARAMETER | DESCRIPTION |
|---|---|
shapes
|
Outline shapes to be plotted
TYPE:
|
axs
|
Two matplotlib axes - one for the dorsal view and one for the lateral view
TYPE:
|
Source code in src/echosms/utils_datastore.py
plot_shape_surface(shapes, ax)
Plot an echoSMs anatomical surface shape.
Normally called via plot_specimen().
| PARAMETER | DESCRIPTION |
|---|---|
shapes
|
Surface shapes to be plotted
|
ax
|
A matplotlib axis.
|
Source code in src/echosms/utils_datastore.py
plot_shape_voxels(s, title='')
Plot the specimen's voxels.
Normally called via plot_specimen().
| PARAMETER | DESCRIPTION |
|---|---|
s
|
The voxel shape data structure as per the echoSMs datastore.
|
title
|
Title for the plot.
DEFAULT:
|
Source code in src/echosms/utils_datastore.py
plot_specimen(specimen, dataset_label='', title='', savefile=None, dpi=150)
Plot the specimen shape.
Produces a relevant plot for all echoSMs anatomical datastore shape types.
| PARAMETER | DESCRIPTION |
|---|---|
specimen
|
Specimen data as per the echoSMs anatomical datastore schema.
TYPE:
|
dataset_label
|
Used to form a plot title if
TYPE:
|
title
|
A title for the plot.
TYPE:
|
savefile
|
Filename to save the plot to. If None, generate the plot in the interactive terminal (if that's supported).
TYPE:
|
dpi
|
The resolution of the figure in dots per inch.
TYPE:
|
Source code in src/echosms/utils_datastore.py
surface_from_stl(stl_file, dim_scale=1.0, anatomical_feature='body', boundary='pressure-release')
Create an echoSMs surface shape from an .stl file.
| PARAMETER | DESCRIPTION |
|---|---|
stl_file
|
An .stl file
TYPE:
|
dim_scale
|
Scaling factor applied to the node positions. Use to convert from one length unit to another (e.g., 1e-3 will convert from mm to m).
TYPE:
|
anatomical_feature
|
The anatomical feature for this shape, as per the echoSMs datastore schema.
TYPE:
|
boundary
|
The boundary type for this shape, as per the echoSMs datastore schema.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
dict
|
An echoSMs surface shape representation. |
Notes
This function uses a call to load_mesh() from the trimesh library to read the
.stl file. If there are problems with loading your .stl file, please refer to the
trimesh documentation.
Source code in src/echosms/utils_datastore.py
volume_from_datastore(voxels)
Create a 3D numpy array from nested lists.
| PARAMETER | DESCRIPTION |
|---|---|
voxels
|
The datastore 3D voxel structure (list of list of list)
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
A numpy 3D array.
|
|