Configuration¶
Each pipeline reads one of these models from JSON with from_json(). Unknown keys are rejected. LabelMapBrep and BrepMesh hold the settings every structure shares, and a section for each kind of implemented structure holds its own settings. Keys of labels, label_maps, and breps must be names from Structure.
- pydantic model kneemesh.config.LabelMapAssembly[source]
Bases:
BaseConfigSettings for assembling single-label LabelMaps into one multilabel LabelMap.
Structures get label values 1, 2, … in the order of label_maps.
- Fields:
interpolator (kneemesh.segmentation.Interpolator)label_maps (Annotated[dict[Literal['lateral_meniscus', 'medial_meniscus', 'patellar_cartilage', 'femoral_cartilage', 'lateral_tibial_cartilage', 'medial_tibial_cartilage', 'femur', 'tibia', 'patella'], pathlib.Path] | None, pydantic.functional_validators.BeforeValidator(func=kneemesh.config._json_from_text, json_schema_input_type=PydanticUndefined)])output (pathlib.Path)padding (int)
- field label_maps: Annotated[dict[Literal['lateral_meniscus', 'medial_meniscus', 'patellar_cartilage', 'femoral_cartilage', 'lateral_tibial_cartilage', 'medial_tibial_cartilage', 'femur', 'tibia', 'patella'], Path] | None, BeforeValidator(func=_json_from_text, json_schema_input_type=PydanticUndefined)] = None
Single-label LabelMaps to assemble, by structure name, as JSON such as {“tibia”: “tibia.nii”}. Each file’s nonzero voxels are its structure
- Constraints:
func = <function _json_from_text at 0x78ddbc84cfe0>
json_schema_input_type = PydanticUndefined
- field interpolator: Interpolator = 'label_gaussian'
Resampling interpolator for assembling label_maps: label_gaussian or nearest_neighbor
- field padding: int = 4
Background voxels around the assembled label_maps on each side
- Constraints:
ge = 0
- field output: Path = PosixPath('label_map.nrrd')
Multilabel LabelMap to write: .nii, .nrrd, or .mhd, with its labels in <stem>_labels.json beside it
- pydantic model kneemesh.config.LabelMapBrep[source]
Bases:
_StructureSectionsSettings for building a B-rep of every structure in a segmented LabelMap.
The segmentation is either one multilabel LabelMap, label_map, with labels naming its values, or several single-label LabelMaps, label_maps, that are assembled onto one grid. Give one or the other. Each structure named in labels or label_maps is built by its own pipeline, with the settings of its section such as meniscus, or its own such as lateral_meniscus, and written to <output_directory>/<structure><output>. Bones, including those named only to orient their cartilage, are written as surfaces with their own section’s output, such as femur.output, instead.
- Fields:
assembled_label_map (Annotated[pathlib.Path | None, pydantic.functional_validators.BeforeValidator(func=kneemesh.config._none_from_text, json_schema_input_type=PydanticUndefined)])cartilage (kneemesh.config.CartilageBrep)femoral_cartilage (kneemesh.config.FemoralCartilageBrep)femur (kneemesh.config.BoneBrep)interpolator (kneemesh.segmentation.Interpolator)label_map (Annotated[pathlib.Path | None, pydantic.functional_validators.BeforeValidator(func=kneemesh.config._none_from_text, json_schema_input_type=PydanticUndefined)])label_maps (Annotated[dict[Literal['lateral_meniscus', 'medial_meniscus', 'patellar_cartilage', 'femoral_cartilage', 'lateral_tibial_cartilage', 'medial_tibial_cartilage', 'femur', 'tibia', 'patella'], pathlib.Path] | None, pydantic.functional_validators.BeforeValidator(func=kneemesh.config._json_from_text, json_schema_input_type=PydanticUndefined)])labels (Annotated[dict[Literal['lateral_meniscus', 'medial_meniscus', 'patellar_cartilage', 'femoral_cartilage', 'lateral_tibial_cartilage', 'medial_tibial_cartilage', 'femur', 'tibia', 'patella'], int] | None, pydantic.functional_validators.BeforeValidator(func=kneemesh.config._json_from_text, json_schema_input_type=PydanticUndefined)])lateral_meniscus (kneemesh.config.MeniscusBrep | None)lateral_tibial_cartilage (kneemesh.config.CartilageBrep | None)medial_meniscus (kneemesh.config.MeniscusBrep | None)medial_tibial_cartilage (kneemesh.config.CartilageBrep | None)meniscus (kneemesh.config.MeniscusBrep)output (str)output_directory (pathlib.Path)overclosure (kneemesh.config.OverclosureBrep)padding (int)patella (kneemesh.config.BoneBrep)patellar_cartilage (kneemesh.config.CartilageBrep | None)tibia (kneemesh.config.BoneBrep)
- field label_map: Annotated[Path | None, BeforeValidator(func=_none_from_text, json_schema_input_type=PydanticUndefined)] = None
Multilabel LabelMap to read: .nii, .nrrd, or .mhd
- Constraints:
func = <function _none_from_text at 0x78dd51ffae80>
json_schema_input_type = PydanticUndefined
- field labels: Annotated[dict[Literal['lateral_meniscus', 'medial_meniscus', 'patellar_cartilage', 'femoral_cartilage', 'lateral_tibial_cartilage', 'medial_tibial_cartilage', 'femur', 'tibia', 'patella'], int] | None, BeforeValidator(func=_json_from_text, json_schema_input_type=PydanticUndefined)] = None
Label value of each structure in label_map by name, as JSON such as {“tibia”: 1, “medial_tibial_cartilage”: 2}
- Constraints:
func = <function _json_from_text at 0x78ddbc84cfe0>
json_schema_input_type = PydanticUndefined
- field label_maps: Annotated[dict[Literal['lateral_meniscus', 'medial_meniscus', 'patellar_cartilage', 'femoral_cartilage', 'lateral_tibial_cartilage', 'medial_tibial_cartilage', 'femur', 'tibia', 'patella'], Path] | None, BeforeValidator(func=_json_from_text, json_schema_input_type=PydanticUndefined)] = None
Single-label LabelMaps to assemble instead of label_map, by structure name, as JSON such as {“tibia”: “tibia.nii”}. Each file’s nonzero voxels are its structure
- Constraints:
func = <function _json_from_text at 0x78ddbc84cfe0>
json_schema_input_type = PydanticUndefined
- field interpolator: Interpolator = 'label_gaussian'
Resampling interpolator for assembling label_maps: label_gaussian or nearest_neighbor
- field padding: int = 4
Background voxels around the assembled label_maps on each side
- Constraints:
ge = 0
- field assembled_label_map: Annotated[Path | None, BeforeValidator(func=_none_from_text, json_schema_input_type=PydanticUndefined)] = None
Where to write the multilabel LabelMap assembled from label_maps, with its labels in <stem>_labels.json beside it. None does not write it
- Constraints:
func = <function _none_from_text at 0x78dd51ffae80>
json_schema_input_type = PydanticUndefined
- field output: str = '.brep'
Suffix of each B-rep file, appended to its structure’s name, such as _hex.brep for lateral_meniscus_hex.brep
- field output_directory: Path = PosixPath('.')
Directory to write the output files in, created if missing
- field meniscus: MeniscusBrep [Optional]
Settings for the lateral and medial menisci, but one with its own section
- field cartilage: CartilageBrep [Optional]
Settings for the lateral and medial tibial and the patellar cartilage, but one with its own section
- field lateral_meniscus: MeniscusBrep | None = None
Settings of the lateral meniscus alone, in place of meniscus. Fields it leaves out take meniscus’s values; None takes meniscus as it is
- field medial_meniscus: MeniscusBrep | None = None
Settings of the medial meniscus alone, in place of meniscus. Fields it leaves out take meniscus’s values; None takes meniscus as it is
- field lateral_tibial_cartilage: CartilageBrep | None = None
Settings of the lateral tibial cartilage alone, in place of cartilage. Fields it leaves out take cartilage’s values; None takes cartilage as it is
- field medial_tibial_cartilage: CartilageBrep | None = None
Settings of the medial tibial cartilage alone, in place of cartilage. Fields it leaves out take cartilage’s values; None takes cartilage as it is
- field patellar_cartilage: CartilageBrep | None = None
Settings of the patellar cartilage alone, in place of cartilage. Fields it leaves out take cartilage’s values; None takes cartilage as it is
- field femoral_cartilage: FemoralCartilageBrep [Optional]
Settings for the femoral cartilage
- field femur: BoneBrep [Optional]
Settings for the femur, whose output is a surface
- field tibia: BoneBrep [Optional]
Settings for the tibia, whose output is a surface
- field patella: BoneBrep [Optional]
Settings for the patella, whose output is a surface
- field overclosure: OverclosureBrep [Optional]
Settings for moving overlapping structures apart after they are all built
- pydantic model kneemesh.config.BrepMesh[source]
Bases:
_StructureSectionsSettings for meshing the B-rep of each structure.
Each structure in breps is meshed by its own pipeline, with the settings of its section such as meniscus, or its own such as lateral_meniscus, and written to <output_directory>/<structure><output>. Bones are meshed from their surfaces with their own section’s element_type, such as femur.element_type. Every other structure takes element_type unless element_types gives it its own, and the element_shape, element_order, and second_order_incomplete properties describe element_type itself; use for_structure for a structure’s settings.
- Fields:
assembled_mesh (Annotated[pathlib.Path | None, pydantic.functional_validators.BeforeValidator(func=kneemesh.config._none_from_text, json_schema_input_type=PydanticUndefined)])breps (Annotated[dict[Literal['lateral_meniscus', 'medial_meniscus', 'patellar_cartilage', 'femoral_cartilage', 'lateral_tibial_cartilage', 'medial_tibial_cartilage', 'femur', 'tibia', 'patella'], pathlib.Path] | None, pydantic.functional_validators.BeforeValidator(func=kneemesh.config._json_from_text, json_schema_input_type=PydanticUndefined)])cartilage (kneemesh.config.CartilageMesh)element_type (Literal['hex8', 'hex20', 'hex27', 'tet4', 'tet10'])element_types (Annotated[dict[Literal['lateral_meniscus', 'medial_meniscus', 'patellar_cartilage', 'femoral_cartilage', 'lateral_tibial_cartilage', 'medial_tibial_cartilage', 'femur', 'tibia', 'patella'], Literal['hex8', 'hex20', 'hex27', 'tet4', 'tet10']] | None, pydantic.functional_validators.BeforeValidator(func=kneemesh.config._json_from_text, json_schema_input_type=PydanticUndefined)])femoral_cartilage (kneemesh.config.FemoralCartilageMesh)femur (kneemesh.config.BoneMesh)lateral_meniscus (kneemesh.config.MeniscusMesh | None)lateral_tibial_cartilage (kneemesh.config.CartilageMesh | None)medial_meniscus (kneemesh.config.MeniscusMesh | None)medial_tibial_cartilage (kneemesh.config.CartilageMesh | None)meniscus (kneemesh.config.MeniscusMesh)output (str)output_directory (pathlib.Path)patella (kneemesh.config.BoneMesh)patellar_cartilage (kneemesh.config.CartilageMesh | None)tibia (kneemesh.config.BoneMesh)
- field breps: Annotated[dict[Literal['lateral_meniscus', 'medial_meniscus', 'patellar_cartilage', 'femoral_cartilage', 'lateral_tibial_cartilage', 'medial_tibial_cartilage', 'femur', 'tibia', 'patella'], Path] | None, BeforeValidator(func=_json_from_text, json_schema_input_type=PydanticUndefined)] = None
B-rep file of each structure to mesh, or .stl surface of each bone, by structure name, as JSON such as {“medial_meniscus”: “medial_meniscus.brep”, “tibia”: “tibia.stl”}
- Constraints:
func = <function _json_from_text at 0x78ddbc84cfe0>
json_schema_input_type = PydanticUndefined
- field element_type: Literal['hex8', 'hex20', 'hex27', 'tet4', 'tet10'] = 'tet4'
Element shape and node count: hex8, hex20, or hex27 hexahedra, or tet4 or tet10 tetrahedra, for every structure element_types does not name. Bones use their own, such as femur.element_type
- field element_types: Annotated[dict[Literal['lateral_meniscus', 'medial_meniscus', 'patellar_cartilage', 'femoral_cartilage', 'lateral_tibial_cartilage', 'medial_tibial_cartilage', 'femur', 'tibia', 'patella'], Literal['hex8', 'hex20', 'hex27', 'tet4', 'tet10']] | None, BeforeValidator(func=_json_from_text, json_schema_input_type=PydanticUndefined)] = None
Element type of individual structures in place of element_type, by structure name, as JSON such as {“medial_meniscus”: “hex8”, “patellar_cartilage”: “tet10”}. Bones are set in their own sections, such as femur.element_type
- Constraints:
func = <function _json_from_text at 0x78ddbc84cfe0>
json_schema_input_type = PydanticUndefined
- field output: str = '_{element_type}.msh'
Suffix of each mesh file, appended to its structure’s name, where {element_type} is replaced by the element type, a bone’s own for bones. .vtu and .vtkhdf hold the mesh’s node and element sets; gmsh infers other formats from the extension
- field output_directory: Path = PosixPath('.')
Directory to write the output files in, created if missing
- field assembled_mesh: Annotated[Path | None, BeforeValidator(func=_none_from_text, json_schema_input_type=PydanticUndefined)] = None
Where to also write every structure’s mesh as one, with nodes, elements, and sets numbered on through the structures and sets named <structure>_<set>: .vtu for one grid, or .vtkhdf for a multiblock of the structures. None does not
- Constraints:
func = <function _none_from_text at 0x78dd51ffae80>
json_schema_input_type = PydanticUndefined
- field meniscus: MeniscusMesh [Optional]
Settings for the lateral and medial menisci, but one with its own section
- field cartilage: CartilageMesh [Optional]
Settings for the lateral and medial tibial and the patellar cartilage, but one with its own section
- field lateral_meniscus: MeniscusMesh | None = None
Settings of the lateral meniscus alone, in place of meniscus. Fields it leaves out take meniscus’s values; None takes meniscus as it is
- field medial_meniscus: MeniscusMesh | None = None
Settings of the medial meniscus alone, in place of meniscus. Fields it leaves out take meniscus’s values; None takes meniscus as it is
- field lateral_tibial_cartilage: CartilageMesh | None = None
Settings of the lateral tibial cartilage alone, in place of cartilage. Fields it leaves out take cartilage’s values; None takes cartilage as it is
- field medial_tibial_cartilage: CartilageMesh | None = None
Settings of the medial tibial cartilage alone, in place of cartilage. Fields it leaves out take cartilage’s values; None takes cartilage as it is
- field patellar_cartilage: CartilageMesh | None = None
Settings of the patellar cartilage alone, in place of cartilage. Fields it leaves out take cartilage’s values; None takes cartilage as it is
- field femoral_cartilage: FemoralCartilageMesh [Optional]
Settings for the femoral cartilage
- field femur: BoneMesh [Optional]
Settings for the femur
- field tibia: BoneMesh [Optional]
Settings for the tibia
- field patella: BoneMesh [Optional]
Settings for the patella
Meniscus¶
The meniscus sections apply to both lateral_meniscus and medial_meniscus.
- pydantic model kneemesh.config.MeniscusBrep[source]
Bases:
SurfaceBrepSettings for building the lateral and medial meniscus B-reps, with the defaults of each step.
- Fields:
cap (Literal['none', 'planar', 'smooth'])cap_offset (Annotated[float | None, pydantic.functional_validators.BeforeValidator(func=kneemesh.config._none_from_text, json_schema_input_type=PydanticUndefined)])groove_ratio (float)hex_blocks (bool)hex_design (kneemesh.config.MeniscusHexDesign)inner_clip_height (Annotated[float | None, pydantic.functional_validators.BeforeValidator(func=kneemesh.config._none_from_text, json_schema_input_type=PydanticUndefined)])inner_clip_ratio (Annotated[float | None, pydantic.functional_validators.BeforeValidator(func=kneemesh.config._none_from_text, json_schema_input_type=PydanticUndefined)])points_per_slice (int)spacing (float)spline_order (int)
- field spacing: float = 5.0
Arc-length distance between slices along the centerline, in physical units
- field points_per_slice: int = 32
Points on each slice contour
- field spline_order: int = 3
Polynomial degree of the B-spline geometry
- field cap: Literal['none', 'planar', 'smooth'] = 'planar'
How to close the ends; hex_blocks are always planar
- field cap_offset: Annotated[float | None, BeforeValidator(func=_none_from_text, json_schema_input_type=PydanticUndefined)] = None
Apex offset of smooth caps in physical units. None is a quarter of the equivalent radius
- Constraints:
func = <function _none_from_text at 0x78dd51ffae80>
json_schema_input_type = PydanticUndefined
- field hex_blocks: bool = False
Build a solid for hexahedral meshing, as hex_design says, with planar caps
- field inner_clip_height: Annotated[float | None, BeforeValidator(func=_none_from_text, json_schema_input_type=PydanticUndefined)] = None
Height in physical units at which to cut the sections’ thin inner edge off straight, making the cut’s top and bottom feature edges, or None to use inner_clip_ratio
- Constraints:
ge = 0
func = <function _none_from_text at 0x78dd51ffae80>
json_schema_input_type = PydanticUndefined
- field inner_clip_ratio: Annotated[float | None, BeforeValidator(func=_none_from_text, json_schema_input_type=PydanticUndefined)] = None
Height at which to cut the sections’ thin inner edge off straight, as a fraction of the mean of the sections’ greatest heights, measured across the direction from each section’s centroid to its inner edge, so near its outer side. None is 0.25 for swept_quads hex_blocks and 0, no cut, otherwise. Each cut is at most half its section’s greatest height
- Constraints:
ge = 0
func = <function _none_from_text at 0x78dd51ffae80>
json_schema_input_type = PydanticUndefined
- field groove_ratio: float = 0.25
Depth, as a fraction of its width, up to which a concavity of a section is treated as noise and filled in to the section’s convex hull, partly filled up to twice that. The real menisci’s grooves are at most 0.15 of their width deep, at most 1.1 mm. 0 keeps every concavity
- Constraints:
ge = 0
- field hex_design: MeniscusHexDesign = 'butterfly'
With hex_blocks, which hexahedra the solid is for: butterfly, five blocks of structured hexahedra, whose regular layout makes the more simulation-ready mesh, or swept_quads, the lofted solid, whose cross-section is meshed with unstructured quadrilaterals swept along it. Swept quadrilaterals optimized to higher scaled Jacobians and lower aspect ratios on the real menisci, with a quarter of the elements
- pydantic model kneemesh.config.MeniscusMesh[source]
Bases:
StructureMeshSettings for meshing the lateral and medial meniscus B-reps, with the defaults of each meshing function.
Hexahedral element types need B-reps with planar caps, which hex_blocks gives: a lofted solid is swept with unstructured quadrilaterals, and butterfly blocks are meshed with structured hexahedra (see hex_design).
- Fields:
aspect_weight (float)circumferential_size (float)optimize (bool)transverse_size (float)warp_weight (float)
- field transverse_size: float = 1.0
Target edge length of the hexahedra across the meniscus, in physical units: the swept cross-section’s quadrilaterals at its largest section, smaller toward the horns, or a quarter of a butterfly’s middle perimeter per cap edge
- Constraints:
gt = 0
- field circumferential_size: float = 2.0
Target edge length of the hexahedra along the meniscus, in physical units, through its sections’ centroids
- Constraints:
gt = 0
- field optimize: bool = True
Move hexahedral mesh nodes to raise the elements’ scaled Jacobians after meshing; ignored for tetrahedra. Swept hexahedra can start inverted
- field aspect_weight: float = 0.02
Weight of the elements’ squared Frobenius aspect ratios against 1 / scaled Jacobian when optimizing. 0 optimizes the scaled Jacobian alone, which stretched the real menisci’s elements near the horns to aspect ratios of 90
- Constraints:
ge = 0
- field warp_weight: float = 50.0
Weight, per boundary quadrilateral, of its warp out of plane against 1 / scaled Jacobian when optimizing. Tuned for the default butterfly blocks: at 50 the real menisci’s 99th percentile of surface warp fell from 20-33 degrees to 17-23 at the same or higher minimum scaled Jacobians, the mean falling at most 0.025; from 100 the mean falls faster. Swept hexahedra were tuned at 30. 0 leaves the surface crumpled where the sections change shape
- Constraints:
ge = 0
Tibial and patellar cartilage¶
The cartilage sections apply to lateral_tibial_cartilage, medial_tibial_cartilage, and patellar_cartilage.
- pydantic model kneemesh.config.CartilageBrep[source]
Bases:
SurfaceBrepSettings for building the B-reps of the lateral and medial tibial and the patellar cartilage, with the defaults of each step.
Each is a sheet over the plane normal to its thinnest direction, between its articular side and the side against its bone, within a smooth perimeter. Defaults left as None depend on hex_blocks. Either way the B-rep is one solid, which hexahedral meshing partitions itself.
- Fields:
hex_blocks (bool)hole_thickness (float)min_thickness (Annotated[float | None, pydantic.functional_validators.BeforeValidator(func=kneemesh.config._none_from_text, json_schema_input_type=PydanticUndefined)])perimeter_inset (float)perimeter_radius (Annotated[float | None, pydantic.functional_validators.BeforeValidator(func=kneemesh.config._none_from_text, json_schema_input_type=PydanticUndefined)])side_cosine (float)
- field side_cosine: float = 0.3
Cosine between a surface normal and the direction away from the bone beyond which a point is on the articular or bone side. Higher values cut off more of the steep rim between them
- Constraints:
gt = 0
lt = 1
- field perimeter_radius: Annotated[float | None, BeforeValidator(func=_none_from_text, json_schema_input_type=PydanticUndefined)] = None
Smallest radius of curvature of the perimeter and hole outlines, in physical units. None is 3.0 for hex_blocks, enough for hexahedra to follow the real lateral tibial cartilage’s notch, and 1.0 otherwise
- Constraints:
gt = 0
func = <function _none_from_text at 0x78dd51ffae80>
json_schema_input_type = PydanticUndefined
- field perimeter_inset: float = 0.0
How far inside the overlap of the two sides to put the perimeter, in physical units
- Constraints:
ge = 0
- field min_thickness: Annotated[float | None, BeforeValidator(func=_none_from_text, json_schema_input_type=PydanticUndefined)] = None
Minimum thickness as a fraction of the mean; thinner regions are thickened by lowering the bone side. None is 0.2 for hex_blocks and 0.1 otherwise
- Constraints:
gt = 0
lt = 1
func = <function _none_from_text at 0x78dd51ffae80>
json_schema_input_type = PydanticUndefined
- field hole_thickness: float = 0.05
Thickness as a fraction of the mean below which the sheet gets a hole, as do regions with no cartilage. Ignored for hex_blocks, which are only thickened; 0 makes no holes
- Constraints:
ge = 0
lt = 1
- field hex_blocks: bool = False
Build the solid for hexahedral meshing: the perimeter rounded more, thin regions thickened more, and no holes
- pydantic model kneemesh.config.CartilageMesh[source]
Bases:
StructureMeshSettings for meshing the B-reps of the lateral and medial tibial and the patellar cartilage.
Hexahedra are a quadrilateral mesh of one side of the sheet, stacked elements_through deep along straight columns to the other side.
- Fields:
aspect_weight (float)element_size (float)elements_through (int)quad_algorithm (kneemesh.mesh.sheet.QuadAlgorithm)save_partition (bool)
- field element_size: float = 2.0
Target size of the hexahedra along the sheet, in physical units
- Constraints:
gt = 0
- field elements_through: int = 3
Hexahedra through the thickness
- Constraints:
ge = 1
- field quad_algorithm: QuadAlgorithm = 'quasi_structured'
gmsh algorithm for the quadrilaterals on the sheet’s side: quasi_structured aligns them with a cross field, leaving few irregular nodes, but varies their size, down to 0.3 of element_size on the real patellar cartilage, and takes longer; frontal_delaunay keeps their size closest to element_size and optimizes to slightly better metrics, but leaves many irregular nodes
- field save_partition: bool = False
Also write the blocks the hexahedral mesh’s irregular nodes partition the sheet into, one volume each, to <output_directory>/<structure>_partition.brep. quasi_structured gives about 10 to 30 blocks; frontal_delaunay gives hundreds, mostly single elements
- field aspect_weight: float = 0.5
Weight of the elements’ squared Frobenius aspect ratios against 1 / scaled Jacobian when optimizing. 0 optimizes the scaled Jacobian alone, which can stretch elements
- Constraints:
ge = 0
Femoral cartilage¶
The femoral_cartilage sections apply to femoral_cartilage. Its B-rep settings extend the other cartilage’s.
- pydantic model kneemesh.config.FemoralCartilageBrep[source]
Bases:
CartilageBrepSettings for building the femoral cartilage’s B-rep, with the defaults of each step.
It is a sheet over the cylinder its bone side wraps, unrolled into a U-shaped domain, between its articular side and the side against the femur. Defaults left as None depend on hex_blocks, as for the other cartilage.
- Fields:
- pydantic model kneemesh.config.FemoralCartilageMesh[source]
Bases:
CartilageMeshSettings for meshing the femoral cartilage’s B-rep.
Hexahedra are made as for the other cartilage, and tetrahedra default to element_size.
- Fields:
max_size (Annotated[float | None, pydantic.functional_validators.BeforeValidator(func=kneemesh.config._none_from_text, json_schema_input_type=PydanticUndefined)])
- field max_size: Annotated[float | None, BeforeValidator(func=_none_from_text, json_schema_input_type=PydanticUndefined)] = None
Largest tetrahedron size in physical units. None is element_size: the default from the oriented bounding box, which the wrapped cartilage makes about 30 mm across, gave nearly flat tetrahedra
- Constraints:
func = <function _none_from_text at 0x78dd51ffae80>
json_schema_input_type = PydanticUndefined
Bones¶
The femur, tibia, and patella sections each hold one bone’s settings. A bone’s geometry is its closed, triangulated surface, written as .stl, rather than a B-rep, and it is meshed with its own element_type: triangles or quadrilaterals on its surface, or tetrahedra, never hexahedra.
- pydantic model kneemesh.config.BoneBrep[source]
Bases:
SurfaceBrepSettings for building a bone’s surface, with the defaults of each step: the femur, tibia, and patella each have a section.
A bone’s geometry is not a B-rep but its closed, triangulated surface, written as .stl: the isocontour of its label with cavities filled, smoothed, and decimated. gmsh reparametrizes it when meshing.
- Fields:
output (str)shaft_cut_fraction (float)triangle_size (float)
- field shaft_cut_fraction: float = 0.0
Fraction of the bone’s length along each shaft the scan cuts off, such as the femur’s and tibia’s, to remove from that end, cut square in the voxel map, making the mesh smaller. 0 keeps the shaft as scanned
- Constraints:
ge = 0
lt = 1
- field triangle_size: float = 1.0
Edge length the surface’s triangles are decimated to, in physical units. At 1 the real bones move at most 0.02
- Constraints:
gt = 0
- field output: str = '.stl'
Suffix of each bone’s surface file, appended to its name, such as _surface.stl for femur_surface.stl
- pydantic model kneemesh.config.BoneMesh[source]
Bases:
BaseConfigSettings for meshing a bone’s surface, which gmsh reparametrizes: the femur, tibia, and patella each have a section.
Bones are meshed on their surface with triangles or quadrilaterals, or through their volume with tetrahedra, by their own element_type; the mesh’s element_type does not apply to them. Bones are not meshed with hexahedra.
- Fields:
algorithm_2d (kneemesh.tet_meshing.Algorithm2D)algorithm_3d (kneemesh.tet_meshing.Algorithm3D)cancellous_grad (float)cortical_distance (float)cortical_element_size (float)element_size (float)element_type (Literal['tri3', 'tri6', 'quad4', 'quad8', 'quad9', 'tet4', 'tet10'])max_size (float)
- field element_type: Literal['tri3', 'tri6', 'quad4', 'quad8', 'quad9', 'tet4', 'tet10'] = 'tri3'
Element shape and node count: tri3 or tri6 triangles or quad4, quad8, or quad9 quadrilaterals on the surface, or tet4 or tet10 tetrahedra through the volume
- field element_size: float = 2.0
Target edge length of surface elements, in physical units; tetrahedra use the cortical sizes
- Constraints:
gt = 0
- field cortical_element_size: float = 1.0
Edge length of tetrahedra within cortical_distance of the surface, the surface’s triangles included, in physical units
- Constraints:
gt = 0
- field cortical_distance: float = 3.0
Depth below the surface of the shell of cortical_element_size tetrahedra
- Constraints:
ge = 0
- field cancellous_grad: float = 0.5
Growth of the tetrahedra’s edge length per unit of depth beyond cortical_distance, up to max_size; smaller makes a smoother transition
- Constraints:
gt = 0
- field max_size: float = 4.0
Largest edge length of tetrahedra, deep in the cancellous bone
- Constraints:
gt = 0
- field algorithm_2d: Algorithm2D = Algorithm2D.FRONTAL_DELAUNAY
gmsh surface algorithm for triangles
- field algorithm_3d: Algorithm3D = Algorithm3D.DELAUNAY
gmsh volume algorithm for tetrahedra
Overclosure¶
The overclosure section of LabelMapBrep moves structures apart where their geometry overlaps, once every structure is built. It is off by default. The GUI’s Resolve overclosures runs it on the structures with geometry at any time.
- pydantic model kneemesh.config.OverclosureBrep[source]
Bases:
BaseConfigSettings for removing overclosure: moving built structures apart where their geometry overlaps.
After every structure is built, each is moved out of the structures that rank above it in priority. Cartilage is thin, so it ranks above every meniscus and bone and never moves for them. Where two cartilages overlap, both articular sides are lowered toward their bones, each by its share of the two local thicknesses, whatever their order. A meniscus moves its contour points out within their slice planes and is lofted again, keeping its caps and hexahedral blocks; a bone moves its surface’s vertices.
- Fields:
clearance (float)enabled (bool)priority (Annotated[list[Literal['lateral_meniscus', 'medial_meniscus', 'patellar_cartilage', 'femoral_cartilage', 'lateral_tibial_cartilage', 'medial_tibial_cartilage', 'femur', 'tibia', 'patella']], pydantic.functional_validators.BeforeValidator(func=kneemesh.config._json_from_text, json_schema_input_type=PydanticUndefined)])
- field enabled: bool = False
Move overlapping structures apart after building them all
- field clearance: float = 0.0
Gap left between structures moved apart, in physical units. 0 leaves them touching
- Constraints:
ge = 0
- field priority: Annotated[list[Literal['lateral_meniscus', 'medial_meniscus', 'patellar_cartilage', 'femoral_cartilage', 'lateral_tibial_cartilage', 'medial_tibial_cartilage', 'femur', 'tibia', 'patella']], BeforeValidator(func=_json_from_text, json_schema_input_type=PydanticUndefined)] [Optional]
Every structure, from the one kept in place first to the one moved first, as JSON such as [“femoral_cartilage”, …, “patella”]. Each is moved out of those before it. Cartilage must come before every other structure
- Constraints:
func = <function _json_from_text at 0x78ddbc84cfe0>
json_schema_input_type = PydanticUndefined