## page was renamed from Specifications/ModelParametrization #acl +All:read Default #format wiki #language en <> = Target Outcome = This specification deals with transforming a fully realistic specimen-specific model into a realistic partially specific subject-specific model using parametrization of the model geometry. = Protocols = === Required Infrastructure === * <> * <> * <> === Inputs === * A model based on MRI segmentation, preferably in stl format [[Specifications/GeometryGeneration|Geometry Generation]] * [[Specifications/InVitroTesting#measurements|In vitro testing]] corresponding to the MRI segmentation * [[Specifications/InVivoTesting#measurements|In vivo testing]] measurements covering a larger population set === Description === Starting from a surface model, the in vitro measurement points need to be located in the model's coordinate system. These point will be used as the control points in the model parametrization. The model will then be stretched to the location of measurement from the various in vivo subjects using Gaussian radial basis functions. The morphed model will then be saved under a new systematic name, that has yet to be determined. As an illustrative example of this functionality a femur is morphed much further than will be necessary for this study. The first image shows the guide points (in red), the second image shows the adjusted guide point locations relative to the original femur, and the final shows the morphed femur geometry. {{attachment:Femur_Guide_Points.png|Original Guide Points}} {{attachment:Femur_Adjusted_Points.png|Adjusted Guide Points}} {{attachment:Morphed_Femur.png|Morphed Femur}} === Procedure === Use the python script [[attachment:MultisMeshMorphing.py]] * Reading from the in vitro test file the ultrasound probe positions and probe direction are gathered for location on the limb. * Instead of assuming that these probe positions are in contact with the skin stl obtained from segmentation, the vector of the probe is tested for intersection with the stl. These are the control points. * Thickness data for each ultrasound measurement can be read and combined with probe data to locate in vitro experimental bone location. * Again for the model the bone stl and probe data can be used to find bone intersection. * Sometimes these points work well as is. Sometimes they work better when projected into the same z-plane as all of our limb geometries are essentially aligned along the Z-axis. The script user can adjust this by changing the zPlane input from True to False. * Using thickness data from an in vivo subject will allow these measurements to find the projected points, ie morphed points for the simulated subject model. * The bone points remains the same as the decision was made not to morph the bone because our attempts caused the bone to become wavy. * The morph points are calculated by reversing the probe direction and apply the in vivo thickness. Even though we are only interested in the Central location the proximal and distal locations are used as well to prevent numerical issues that occur if the points are nearly coplanar. * Using the original control points and the newly calculated morph points the PyGeM library uses radial basis functions to adjust every point in the stl and a new stl file is produced as output. * The morphed stl’s thicknesses can be calculated using similar methods. The model circumference is no longer used in morphing, nor is the resulting circumference reported. {{attachment:Morphed_Leg.png|Morphed Leg|width=850}} === Output === Morphed representation of tissue of interest in Stl format in MRI coordinate system. This Stl will be used in [[Specifications/MeshGeneration|Mesh Generation]]. === Cropped Morphing === The cropped morphing method starts with the cropped leg model in MED format. Then running the python script will: 1. Using meshio read the cropped med file. 1. Read in the data from in-vivo and in-vitro experimentation. This is similar to the other morphing procedure. 1. Turn layer thickness from ultrasound into total thicknesses. The cropped vtk model no longer distinguishes between layers. 1. Probe position is assumed to be surface of the model, even though it isn’t in the test case. 1. Bone location is determined from the probe point + total thickness * probe direction 1. The four bottom corners, plus a “center point” approximating the intersection of the probe direction vector and the bottom plane of the model are found. 1. These bottom points plus the probe location and probe bone location are the control points of the morph. 1. The only point that is moved for morphing is the probe point. 1. It is moved along the direction of the probe based off the thickness change of between the original and the morphing subject. 1. Morph is calculated. 1. Assign the morphed point to the meshio mesh 1. Write the new meshio mesh into a new morphed med.