phal-shape is a repository of MATLAB code (MathWorks.com) cited in the article, "Shape and sound analyses of the human ear-canal geometry," by Douglas H. Keefe, Heather L. Porter, and Denis F. Fitzpatrick, which is published in J. Acoust. Soc. Am. 157, 3638-3654, 2025.
The input to the code is a Surface Triangle Language (STL) file that digitally encodes the wall-boundary surface of the ear canal and other structures of the external ear. The code voxelizes the data in the STL file to enable numerical analyses of the shape of the ear-canal surface in 3D space. The other external-ear structures (such as the concha and cymba) are manually edited by the from the image so as to obtain an image of ear-canal shape alone, which is saved as a MATLAB MAT file. This MAT file is an input to the code to calculate the 3D geometry of the curved ear canal. The geometry is modeled by calculating the curved centerline of the canal from the entrance to more medial points, and then fitting each 2D slice of image data by a model ellipse. The 1D curved centerline is parameterized by its curvature and torsion in 3D space. Please refer to the published article for further information.
-
STLAnalysis_JASA: to run this MATLAB code, add it and its subfolders to the MATLAB path. Other MATLAB code developed in this project is found in the Utilities subfolder.
-
The script Shape_Part1.m for Part 1 of the code requires the Image Processing Toolbox from the MathWorks.
The code in subfolderPart 1 analyzes and plots ear-canal shape data based on reading a STL file from a digital scan of the external ear and ear canal. See comments in code for additional details.
The volumeSegmenter app from the Image Processing Toolkit is used in an intermediate processing step. Please refer especially to comments in the file Utilities/do12_JASA.m beginning on line 107 for detailed instructions on how to use this app. Also refer to official Matlab documentation for this app.
The main output files from this script are a,
- MAT file (saved in folder matFiles_JASA) that stores the imaging results from processing the input STL file,
- and a multi-page PDF file (saved in PDF_JASA) that saves the contents of each MATLAB figure generated by Shape_Part1.m.
An intermediate output is also stored as a labels.mat file, which is saved by the volumeSegmenter app in its final step.
-
The script Shape_Part2.m for Part 2 of the code requires the Image Processing Toolkit and the Curve Fitting Toolbox from the MathWorks. The input to Part 2 is one of the MAT files in the folder matFiles_JASA. Part 2 analyses and plots ear-canal shape functions including the area function and ellipse eccentricity of each 2D slice along the centerline, and the curvature and torsion of the centerline curved in 3D. See comments in code for additional details.
-
-
Subfolders of MATLAB code: These subfolders from external sites contain MATLAB code used in Part 1 or Part 2 of the above code. These subfolders are: extrema and gridtrimesh with their corresponding license files, and gridtrimesh, which was obtained from the MATLAB Central file exchange (https://www.mathworks.com/matlabcentral/fileexchange/14646-gridtrimesh).
-
STLs_JASA: contains the STL files acquired for each test ear. The relevant fields in each named file, e.g., A001_Ax_002R_20210414_1030_training.training_L3DS-19-0043_5.2.0.801_Mo1.stl, include the first field (A001) which gives the subject identifier, and the last letter of the third field (002R), which is either an R for the right ear or L for the left ear.
-
matFiles_JASA: contains the MATLAB MAT files analyzed for each test ear, as obtained by the authors from each respective STL file. Any MAT file of ear results obtained by a user who runs Shape_Part1.m will over-write the existing MAT file of the same name in this folder. Users may wish to archive the original set of MAT files in this folder stored on Github. Any MAT file in this folder may be used as input to Shape_Part2.m.
-
PDF_JASA: This empty folder in the repository will hold any PDF file generated by a user who runs Shape_Part1.m.