Fit the sclera, cornea and the lens

The approach was to create a sphere that is approximately the same size as the object (for example, the lens) to be fitted, then data points are projected onto the surface of this sphere from the digitised points, and these become the landmark points. Then host mesh fitting is used, to fit the landmark points to the target points (those digitised points) as the host is deformed.

You can download the files that I have referenced within the text, at the bottom of the page.

** Steps are as follows:**

Read in the digitised data. E.g. lens.exdata

Run perl script that generates the sphere with approximate centre of axis and centre coordinates. This results in a new exnode and exelem file of the sphere.

(1_spheroidal_layer_mesh_sclera.pl creates a sphere with a certain layer thickness, whereas 1_spheroidal_mesh_sclera.pl creates a volume mesh, see below. In the following, I'm using the layer mesh.)

Compare the digitised data and the sphere to ensure that the points will be projected to the closest and correct face. (2_draw_mesh_sclera_layer.com)

Run com.file that converts the sphere.exnode and sphere.exelem file to ipcoor, ipbase, ipnode and ipelem file. (3_convert_mesh_sclera_layer.com)

Create an ippara file.

Run cm (4_input_cm_sclera.com) file to import new ip files and export new exnode and exlem file of the sphere. These are compared with the initial exnode and exelem file. They should be the same. Except that the numbers are aligned better.

Run perl script (5_exnode2ipdata.pl) to convert the exdata (those digitised points) into ipdata file. I have two sets of exdata I want to fit at the same time, so I had to use: "cat sclera.exdata cornea.exdata | perl 5_exnode2ipdata.pl > sclera_cornea.ipdata"

Run perl script (1_host_mesh_sclera.pl) to generate a host mesh that completely embeds the object. Export host.exnode and host.exelem.

Run cmgui to check that the host completely embedes the object. (2_check_host_sclera.com)

Run cm (4_projectdata_sclera.com) file that projects the data points (digisted) onto the sphere to generate new data points (landmark points). Projection error is calculated and landmark.ipdata is generated.

Run cmgui to error check that the points are projected to the correct surface.

Run perl script that converts the host.exnode and host.exelem file to ipcoor, ipbase, ipnode and ipelem file. (5_exnode2ipdata.pl)

Create ipfit and ippara file.

Create fitting.com, reads in the target points (digitised points), the landmark points (projected points) and the host.ipfiles. Deforms the host mesh to fit the landmark points to the target points. List out the host_fitted_error.exdata, host_fitted.exnode and host_fitted.exelem. (6_fitting_sclera.com)

Create update_slave_mesh.com. (8_update_slave_mesh.com) Need to create 2 new files, a region file (.ipregi) and a new coordinate file for region 2, region2.ipcoord. First reads in the host and the slave mesh as region 1 and 2 respectively. Then, calculate the slave nodal positions with respect to the host. Now read in the nodal position of the fitted_host and update the slave nodal parameters with respect to the deformed host. This updates the slave_mesh, which is the object we are trying to fit. Export results in ipfiles and exfiles.

NB: a note, when fitting the sphere mesh with host mesh, move the host mesh so that the centre lines does NOT align with the centre of the sphere mesh. When it does, it won't fit properly.

** Fit Sclera with surfacefit **

Once the host mesh fitting was completed for the sclera/cornea mesh, the shape of cornea is lost as the host mesh method fitted the sclera and cornea at the same time. To fit the cornea better, a surface mesh was performed.

Surface fitting on the sclera was performed. (10_surf_fitting_sclera) Different weights were applied on the two ends of the sphere compared to the overall sphere, 5 fits were performed.