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. Anatomical Models
  4. Importing anatomical models in the python script

Importing anatomical models in the python script

Scheduled Pinned Locked Moved Anatomical Models
2 Posts 2 Posters 55 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.
  • M Offline
    M Offline
    mypi
    wrote last edited by
    #1

    Hi,

    It seems overly straight forward to import, e.g. the Duke to a model:

    model.Import(r"C:\...\Sim4life\model\Duke (Posable) 3.1.1b02\Duke_34y_m_v3.1.1_b02_posable.sab")
    subject = model.AllEntities()["Duke_34y_m_v3.1.1b02_posable"]
    

    But importing the Duke to the simulation is causing trouble at the voxeling stage. Can anyone help?

    I currently have this

    def add_duke_to_EM_sim(simulation):
        duke_group = model.AllEntities()["Duke_34y_m_v3.1.1b02_posable"]
        components = list(duke_group.Entities)  
        material_settings = fdtd.MaterialSettings()
        automatic_voxeler_settings = fdtd.AutomaticVoxelerSettings()
        voxeler = automatic_voxeler_settings
        voxeler.Name = "Duke EM Voxels"
        simulation.Add(voxeler, components)
        simulation.Add(material_settings, components)
    
        simulation.UpdateAllMaterials()
    
    1 Reply Last reply
    0
    • brynB Offline
      brynB Offline
      bryn
      ZMT
      wrote last edited by bryn
      #2

      What does it mean "causing trouble"? Do you get an error message, or it generates unexpected results?

      1. You probably already know, but you can generate a script by setting up the simulation in the GUI, selecting it and running "To Python" in the context menu.

      2. Your script is incorrect. You use only one material settings for all tissues in Duke. However, different tissues (fat, muscle, bone, blood, lung, etc.) have very different properties. To replicate what the GUI does, you probably would want to group all entities with the same material tag (entity.MaterialName), get the material from the database, and create linked material settings:

          material_settings = emfdtd.MaterialSettings()
          components = [e for e in xcm.CollectEntities(duke_group.Entities) if e.MaterialName == "Muscle"]
          mat = database["IT'IS 4.2"]["Muscle"]
          simulation.LinkMaterialWithDatabase(material_settings, mat)
          simulation.Add(material_settings, components)
      
      1. Your script may also be wrong, because duke_group.Entities contains a sub-group "Bones". To recursively collect all entities in duke use CollectEntities:
      import XCoreModeling as xcm
      duke_all_entities = xcm.CollectEntities(duke_group.Entities)
      
      1. You also want to create ManualGridSettings (with specified grid spacing), or AutomaticGridSettings, and assign the entities. You can then run UpdateGrid
      simulation.UpdateAllMaterials()
      simulation.UpdateGrid()
      simulation.CreateVoxels()
      
      1 Reply Last reply
      0
      • brynB bryn referenced this topic
      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