Finite element model from surfaces with default mesh sizeΒΆ

Another method that can be used to generate the mesh and that is more broadly used is to provide the boundary surfaces for the tissues.

As for the generation from labels, we start by declaring the model and giving it a name.

[ ]:
from shamo import FEM

model = FEM("fem_from_surfaces_lc-default", "../../derivatives")

First, we must create a dictionary containing the name of the tissues as keys and the corresponding path to the surface meshes as values.

[ ]:
from pathlib import Path

data_path = Path("../../rawdata/surfaces")
tissues = {
    f"tissue_{i}": data_path / f"surfaces_tissue{i}.stl" for i in range(1, 8)
}

Next, and this is the tricky part, we have to define how each surface is included in others. To do so, we create a nested list where each string represents a tissue and must be one of the keys of the previously instantiated dictionary. In this example, we consider a model with seven tissues and here is how it can be thought of:

  • Tissue 1 is the root.

  • Tissue 3 > Tissue 2 > Tissue 1

  • Tissue 5 > Tissue 4 > Tissue 1

  • Tissue 7 > Tissue 6 > Tissue 4 > Tissue 1

In this configuration, the first tissue must englobe all the others.

[ ]:
structure = [
    "tissue_1", [
        ["tissue_2",
            ["tissue_3"]
        ],
        ["tissue_4", [
            ["tissue_5"],
            ["tissue_6",
                ["tissue_7"]
            ]
        ]]
    ]
]

Then, we can generate the mesh using the mesh_from_surfaces() method.

[ ]:
model.mesh_from_surfaces(tissues, structure)