Function Reference: visualize_CrossSections

csg-toolkit: visualize_CrossSections (bone_id)
csg-toolkit: visualize_CrossSections (bone_id, mode)
csg-toolkit: CS_Geometry = visualize_CrossSections (bone_id)
csg-toolkit: CS_Geometry = visualize_CrossSections (bone_id, mode)
csg-toolkit: [CS_Geometry, SMoA] = visualize_CrossSections (...)
csg-toolkit: [CS_Geometry, SMoA, polyline] = visualize_CrossSections (...)

Plot cross sectional contours and their CSG properties for a given sample.

visualize_CrossSections reads the respective $geometry-$$.csv, $inertia-$$.csv, $polyline2D-$$.csv, and $polyline3D-$$.csv files available in the working directory, where $$ is the bone_id char string for the required bone and $ denotes the mode of bone analysis, and plots the 2D cross sectional polygons from proximal (top) to distal (bottom) along with certain information regarding cross sectional area, perimeter, and second moments of area.

When called with a single input argument, visualize_CrossSections reads the files produced with the longbone_Analysis function, i.e. it reads the Dgeometry-bone_id.csv, Dinertia-bone_id.csv, Dpolyline2D-bone_id.csv, and Dpolyline3D-bone_id.csv files associated with bone_id. Optionally, if called with a second argument, mode, then the function reads the files generated by the respective function as shown below.

modeFunctionCSV Files
"default"longbone_GeometryDgeometry-bone_id.csv
Dinertia-bone_id.csv
Dpolyline2D-bone_id.csv
"custom"longbone_CustomGeometryCgeometry-bone_id.csv
Cinertia-bone_id.csv
Cpolyline2D-bone_id.csv
"fragment"longbone_FragmentGeometryFgeometry-bone_id.csv
Finertia-bone_id.csv
Fpolyline2D-bone_id.csv

In default mode, visualize_CrossSections produces 5 plots with the cross sections at 20%, 35%, 50%, 65%, and 80% of the longbone’s max distance, whereas in "custom" and "fragment" modes, it produces an arbitrary number of plots according to the cross sections contained in the associated files. All four CSV files corresponding to bone_id must be present in the working directory.

The centroid of each cross section is centered at origin and the x-axis of the plots represents the frontal axis of the bone from left to right side, whereas the y-axis is aligned to the sagital axis with the top pointing towards the front side (anterior). Both axes retain equal size so that the actual shape of the cross sectional area is preserved. However, each figure has a different scaling factor. Consequently, size may not be visually proportional among different figures, but the axes in each figure preserve the values of the actual size for the displayed cross section.

If output arguments are defined, then visualize_CrossSections returns up to three structures with the following fields, containing the data retrieved from the CSV files. The number of elements of each structure correspond to the number of cross sections generated by the respective longbone_ function.

StructureFieldData
CS_GeometryCSThe ratio of the cross section’s distance from the proximal end to the bone’s maximum length or the ordered index of the sectioning point for bone fragments.
AreaThe cross sectional aera measured in mm^2.
PerimeterThe perimeter of the cross section measured in mm.
CentroidThe x, y, z coordinates of the cross sectional centroid.
Section_nThe x, y, z coordinates of the cross sectional plane’s normal.
Coronal_nThe x, y, z coordinates of the normal of the bone’s Coronal plane.
SMoAIxThe 2nd moment of area with respect to the x axis, which is collinear with the intersection of the coronal plane and the sectioning plane, measured in mm^4.
IyThe 2nd moment of area with respect to y axis, which is collinear with the intersection of the sagital plane and the sectioning plane, measured in mm^4.
IxyThe product of the 2nd moment of area measured in mm^4.
IminThe minimum 2nd moment of area measured in mm^4.
ImaxThe maximum 2nd moment of area measured in mm^4.
thetaThe angle of rotation of the principal axis of 2nd moment of area with respect to x axis, measured in degrees.
polylinepoly2DAn N×2 matrix with the x, y coordinates of the cross section, ordered counter-clockwise, on the 2D local axes of the sectioning plane.
poly3DAn N×3 matrix with the x, y, z coordinates of the cross section, ordered counter-clockwise, in the original 3D space of the bone’s 3D model.

If mode is defined as "fragment", then Coronal_n field is not available in CS_Geometry and the fields Ixy, Iy, theta are missing from SMoA.

See also: inspect_CSG, longbone_Analysis, longbone_CustomGeometry, longbone_FragmentGeometry

Source Code: visualize_CrossSections