Obtain material properties from material database


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 ?


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)
	# 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.

Hi Haza,

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