Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions src/mri2mesh/mesh/idealized_brain.py
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,12 @@ def add_arguments(parser):
action="store_true",
help="Manifold surface",
)
parser.add_argument(
"--scale-factor",
type=float,
default=1.0,
help="Scale factor",
)


def main(
Expand Down Expand Up @@ -171,6 +177,7 @@ def main(
use_floodfill: bool = False,
smooth_open_boundary: bool = False,
manifold_surface: bool = False,
scale_factor: float = 1.0,
) -> None:
logger.info("Generating idealized brain surface")
from ..surface.idealized_brain import main as main_surface
Expand All @@ -189,6 +196,7 @@ def main(
skull_y1=skull_y1,
skull_z0=skull_z0,
skull_z1=skull_z1,
scale_factor=scale_factor,
)
from .basic import create_mesh, CSGTree, convert_mesh_dolfinx

Expand Down
15 changes: 12 additions & 3 deletions src/mri2mesh/surface/idealized_brain.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,12 @@ def add_arguments(parser: argparse.ArgumentParser) -> None:
default=0.154949,
help="Skull z1",
)
parser.add_argument(
"--scale-factor",
type=float,
default=1.0,
help="Scale factor",
)


def main(
Expand All @@ -104,6 +110,7 @@ def main(
skull_y1: float = 0.173221,
skull_z0: float = 0.001,
skull_z1: float = 0.154949,
scale_factor: float = 1.0,
) -> None:
import pyvista as pv

Expand All @@ -113,10 +120,10 @@ def main(
z = np.array([0, 0, 1])
skull = pv.Box((skull_x0, skull_x1, skull_y0, skull_y1, skull_z0, skull_z1))
c = skull.center_of_mass()
par = pv.Sphere(r * parenchyma_factor, center=c)
LV = pv.Sphere(r * lv_factor, center=c)
par = pv.Sphere(radius=r * parenchyma_factor, center=c)
LV = pv.Sphere(radius=r * lv_factor, center=c)
V34 = pv.Cylinder(
c - v34_center_factor * r * z,
center=c - v34_center_factor * r * z,
direction=z,
height=r * v34_height_factor,
radius=v34_radius_factor * r,
Expand All @@ -127,6 +134,7 @@ def main(
[V34, LV, par, skull, ventricles],
["V34", "LV", "parenchyma_incl_ventr", "skull", "ventricles"],
):
s.scale(scale_factor, inplace=True)
pv.save_meshio(outdir / f"{n}.ply", s)

from .. import __version__
Expand All @@ -148,6 +156,7 @@ def main(
"skull_z1": skull_z1,
"version": __version__,
"timestamp": datetime.datetime.now().isoformat(),
"scale_factor": scale_factor,
},
indent=2,
)
Expand Down
Loading