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. Python API
  4. Obtain material properties from material database

Obtain material properties from material database

Scheduled Pinned Locked Moved Python API
python apidatabasematerial
3 Posts 2 Posters 739 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.
  • R Offline
    R Offline
    rediponi
    wrote on last edited by
    #1

    Hi,

    When using the GUI, drag and dropping a ViP model to the material settings automatically creates the tissue properties and assigns entities of the ViP model to each tissue property.

    I am trying to perform the same task through the python API.
    Assuming that I obtained all ViP model entity names, how can we assign automatically the tissue property from the database ?

    thanks
    redi

    1 Reply Last reply
    0
    • M Offline
      M Offline
      montanaro
      wrote on last edited by
      #2

      Redi! Have you tried doing exactly that through the GUI and then right clicking the simulation and selecting 'To Python..' if I remember correctly that shows you how to assign materials to the database.

      Just tried it and I get something like this:

      import s4l_v1.materials.database as database
      
      # Adding a new MaterialSettings
      material_settings = acoustic.MaterialSettings()
      components = [entity__block1]
      mat = database["IT'IS 4.0"]["Brain (Grey Matter)"]
      if mat is not None:
      	simulation.LinkMaterialWithDatabase(material_settings, mat)
      else:
      	# Fallback if material is not found
      	material_settings.Name = "Brain (Grey Matter)"
      	material_settings.MassDensity = 1044.5, Unit("kg/m^3")
      	material_settings.AttenuationCoefficient = 1.2, Unit("Np/m")
      simulation.Add(material_settings, components)
      

      Never tried it with the ViP model but should work.

      1 Reply Last reply
      0
      • R Offline
        R Offline
        rediponi
        wrote on last edited by
        #3

        Hi Haza,

        yes, i managed to get the corresponding material with :
        tissue_X_entity.MaterialName
        Each entity of the anatomical model has this attribute which is visible also through the GUI.
        thanks

        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