USD Anatomy Tools

Specialized tools for anatomical structure handling in USD.

Module Reference

This module contains the USDAnatomyTools class, which is used to enhance the anatomy meshes in a USD file.

Extensibility

The default OmniSurface look for each anatomy group/organ lives in the module-level DEFAULT_RENDER_PARAMS dict. A new segmenter that introduces a new group (e.g. "brain", "tumor") can register a matching look in one of three ways:

  1. Globally, before instantiating any USDAnatomyTools:

    from physiomotion4d.usd_anatomy_tools import DEFAULT_RENDER_PARAMS
    DEFAULT_RENDER_PARAMS["brain"] = {"name": "Brain", ...}
    

    Every subsequent USDAnatomyTools instance picks up the new entry.

  2. Per-instance, after construction:

    tools = USDAnatomyTools(stage)
    tools.render_params["brain"] = {"name": "Brain", ...}
    
  3. By subclassing, overriding __init__ to populate self.render_params with project-specific defaults.

Group lookup falls back to render_params["other"] when a group has no registered entry, so any group present in the segmenter’s physiomotion4d.AnatomyTaxonomy will still render something.

class physiomotion4d.usd_anatomy_tools.USDAnatomyTools(stage, log_level=20)[source]

Apply OmniSurface materials to anatomy mesh prims in a USD stage.

The instance attribute render_params is initialized from the module-level DEFAULT_RENDER_PARAMS (deep copy per instance, so in-place edits stay local). See the module docstring for how to add new groups/organs.

__init__(stage, log_level=20)[source]

Initialize USDAnatomyTools.

Parameters:
  • stage (Any) – USD stage to work with. May be None when the instance is only used for color look-ups (e.g. via get_anatomy_diffuse_color()).

  • log_level (int | str) – Logging level (default: logging.INFO).

get_anatomy_types()[source]

Return list of registered render-param keys (groups + organ overrides).

Return type:

list[str]

get_anatomy_diffuse_color(anatomy_type)[source]

Return the diffuse reflection RGB color for the given group/organ.

This accessor does not require a USD stage and may be called on an instance created with stage=None purely for color look-up purposes.

Parameters:

anatomy_type (str) – A registered render-params key (e.g. "heart", "lung", "liver").

Return type:

tuple[float, float, float]

Returns:

RGB tuple of floats in [0, 1].

Raises:

ValueError – If anatomy_type is not registered.

apply_anatomy_material_to_mesh(mesh_path, anatomy_type)[source]

Apply an anatomic OmniSurface material to a single mesh prim by type.

Parameters:
  • mesh_path (str) – USD path to the mesh prim (e.g. “/World/Meshes/MyMesh”).

  • anatomy_type (str) – A registered render-params key (group or organ override). See get_anatomy_types().

Raises:

ValueError – If mesh_path is invalid or anatomy_type is not registered.

Return type:

None

apply_anatomy_material_to_prim(prim, material_params)[source]

Corrected material application with Omniverse-specific fixes

Return type:

None

enhance_meshes(segmentator)[source]

Apply per-organ OmniSurface materials to every matching mesh prim.

Walks the segmenter’s AnatomyTaxonomy and applies a material to each mesh prim whose leaf name matches an organ name in any group. An organ-level entry in render_params (e.g. "liver", "spleen", "kidney_left") takes precedence over the entry for the containing group.

Anatomy grouping is performed upstream by ConvertVTKToUSD, which writes labeled prims under /World/{basename}/{type}/{label_name}. This method only needs to apply materials; it does not move prims.

Parameters:

segmentator (Any) – A SegmentAnatomyBase instance whose taxonomy attribute holds the group/organ structure.

Return type:

None

Navigation

USD Tools | USD Generation Modules | VTK to USD Conversion