Skip to content
  • Search
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse

ZMT zurich med tech

  1. Home
  2. Sim4Life
  3. CAD Modeling
  4. How to get spatial coordinate information of an anatomical structure?

How to get spatial coordinate information of an anatomical structure?

Scheduled Pinned Locked Moved CAD Modeling
2 Posts 2 Posters 207 Views 2 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • Y Offline
    Y Offline
    yiyang
    wrote last edited by
    #1

    Hello,

    I am using a script to place electric dipoles within specific structures in an anatomical model, such as the gastrointestinal (GI) tract (including the stomach, small intestine, etc.). The question is, how can I get the coordinates of the space occupied by the model of the GI tract, or in other words, how can I verify that the electric dipoles I place are inside the tissue of the GI tract? Thanks for your help!

    1 Reply Last reply
    0
    • brynB Offline
      brynB Offline
      bryn
      ZMT
      wrote last edited by bryn
      #2

      To get the bounding box of some tissues, say

      • Large_intestine_lumen
      • Large_intestine_wall

      and test if some points are inside these tissues you can use the GetEntityPointDistance API, e.g., something like this:

      import numpy as np
      import s4l_v1.model as s4l_model
      
      Vec3 = s4l_model.Vec3
      
      def sample_box(p1: Vec3, p2: Vec3) -> list[Vec3]:
          xs = np.linspace(p1[0], p2[0], 10)
          ys = np.linspace(p1[1], p2[1], 10)
          zs = np.linspace(p1[2], p2[2], 10)
      
          X, Y, Z = np.meshgrid(xs, ys, zs, indexing="ij")
          points = np.vstack([X.ravel(), Y.ravel(), Z.ravel()]).T
          return [Vec3(p) for p in points]
      
          
      def find_entities(root_group: s4l_model.EntityGroup, names: list[str]):
          entities = s4l_model.CollectEntities([root_group])
          entities = [e for e in entities if e.Name in names]
          return entities
          
          
      if __name__ == "__main__":
          model_group = s4l_model.AllEntities()["Thelonious_6y_m_v3.1b02_posable"]
          entities = find_entities(model_group, ["Large_intestine_lumen", "Large_intestine_wall"])
          p1, p2 = s4l_model.GetBoundingBox(entities)
          points = sample_box(p1, p2)
          
          inside_gi_tract = np.zeros(len(points), dtype=np.uint8)
          for entity in entities:
              distance = s4l_model.GetEntityPointDistance(entity, points)
              
              for idx, dist in enumerate(distance):
                  # note: negative distance means inside the closed surface
                  if dist.Distance <= 0.0:
                      inside_gi_tract[idx] = True
      
      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Search