Package 'rPACI'

Title: Placido Analysis of Corneal Irregularity
Description: Analysis of corneal data obtained from a Placido disk corneal topographer with calculation of irregularity indices. This package performs analyses of corneal data obtained from a Placido disk corneal topographer, with the calculation of the Placido irregularity indices and the posterior analysis. The package is intended to be easy to use by a practitioner, providing a simple interface and yielding easily interpretable results. A corneal topographer is an ophthalmic clinical device that obtains measurements in the cornea (the anterior part of the eye). A Placido disk corneal topographer makes use of the Placido disk [Rowsey et al. (1981)]<doi:10.1001/archopht.1981.03930011093022>, which produce a circular pattern of measurement nodes. The raw information measured by such a topographer is used by practitioners to analyze curvatures, to study optical aberrations, or to diagnose specific conditions of the eye (e.g. keratoconus, an important corneal disease). The rPACI package allows the calculation of the corneal irregularity indices described in [Castro-Luna et al. (2020)]<doi:10.1016%2Fj.clae.2019.12.006>, [Ramos-Lopez et al. (2013)]<doi:10.1097%2FOPX.0b013e3182843f2a>, and [Ramos-Lopez et al. (2011)]<doi:10.1097/opx.0b013e3182279ff8>. It provides a simple interface to read corneal topography data files as exported by a typical Placido disk topographer, to compute the irregularity indices mentioned before, and to display summary plots that are easy to interpret for a clinician.
Authors: Darío Ramos-López [aut, cre] , Ana D. Maldonado [aut]
Maintainer: Darío Ramos-López <[email protected]>
License: GPL-3
Version: 0.2.2
Built: 2024-09-07 05:52:04 UTC
Source: https://github.com/dariorlual/rpaci

Help Index


Analysis of a single corneal topography dataset

Description

Analyze a corneal topography dataset (a data.frame in the rPACI format). This function combines the two operations of functions computePlacidoIndices and plotSingleCornea. It assumes a valid rPACI data.set is already available on memory.

Usage

analyzeDataset(dataset, drawplot = TRUE)

Arguments

dataset

A corneal topography dataset, loaded from a file using the function readFile, simulated using simulateData, or by other ways (as long as it meets the dataset requirements).

drawplot

An optional parameter indicating whether a plot of results should be displayed or not (by default, TRUE).

Details

The dataset is checked to verify it matches the rPACI format: it must contain 3 columns: x, y (with the X and Y Cartesian coordinates of data points) and ring index (1, 2, ...). The ring index column must contain positive integer numbers. The dataset must not contain NA values. Finally, all the rings must contain the same number of data points.

More details about supported file formats can be found in vignette("topographersDataFormat", package = "rPACI"), and about using rPACI in vignette("packageUsage", package = "rPACI").

Examples

# Generate a sample dataset
dataset = simulateData(rings = 15, ringRadiiPerturbation = 0.7)

# Analyze this dataset:
analyzeDataset(dataset)

Analysis of repeated measures of the same patient over time

Description

Analyze the evolution of a patient over time. This function returns the Placido irregularity indices per time step and two temporal plots.

Usage

analyzeEvolution(data, fileExtension = "txt")

Arguments

data

Either 1) the path of a folder that contains corneal topography files, as exported by Placido disks corneal topographers, or 2) a list containing properly formatted data (loaded from a file using the function readFile, simulated using simulateData, or by other ways, as long as it meets the dataset requirements).

fileExtension

If data is a path, specify the file extension of the corneal topography files in the folder. It assumes all files with the given extension are corneal topography files of a single patient (by default, "txt").

Details

If the data are loaded from a folder, it will assume that the temporal arrangement is the alphabetical order of the filenames. Therefore, it is advised to use proper file names, for instance using this date format: 'YYYY-MM-DD.txt'.

Moreover, the folder should contain data measures of just one patient, since the function will read all the files (with the given extension) of the specified folder. On the other hand, if the data are stored in a list, it will be assumed that the temporal order corresponds with the index of the dataset in the list.

More details about supported file formats can be found in vignette("topographersDataFormat", package = "rPACI"), and about using rPACI in vignette("packageUsage", package = "rPACI").

Examples

# EXAMPLE 1
# Simulate the patient's measures over time
 dataT1 = simulateData(rings = 12, maximumMireDisplacement = 0.15, mireDisplacementAngle = 10)
 dataT2 = simulateData(rings = 12, maximumMireDisplacement = 0.15, mireDisplacementAngle = 45)
 dataT3 = simulateData(rings = 12, maximumMireDisplacement = 0.2, mireDisplacementAngle = 50)
 
# Create a list containing the data
data = list(
 dataT1 = dataT1,
 dataT2 = dataT2,
 dataT3 = dataT3
)

# Analyze the data over time
analyzeEvolution(data)

# EXAMPLE 2
# Specify a folder path to analyze a patient's evolution over time
analyzeEvolution(system.file("extdata/evolution/", package="rPACI"))

Analysis of a single corneal topography file

Description

Analyze a corneal topography file. This function combines together the three operations performed by the functions readFile, computePlacidoIndices, and plotSingleCornea. The result is a data.frame in the same format given by computePlacidoIndices.

More details about supported file formats can be found in vignette("topographersDataFormat", package = "rPACI"), and about using rPACI in vignette("packageUsage", package = "rPACI").

Usage

analyzeFile(path, drawplot = TRUE)

Arguments

path

A corneal topography file, as exported by a Placido disk corneal topographer.

drawplot

An optional parameter indicating whether a plot of results should be displayed or not (by default, TRUE).

Value

A data.frame containing the Placido irregularity indices as well as the diagnose, with a single row and columns:

Diagnose A text label indicating the diagnose, according to the value of GLPI
NBI The value of NBI index (in the range 0-100).
GLPI The value of GLPI index (in the range 0-100).
PI_1 The value of PI_1 index (usually in the range 0-150).
PI_2 The value of PI_2 index (usually in the range 0-150).
PI_3 The value of PI_3 index (usually in the range 0-150).
SL The value of SL index (usually in the range 0-150).
AR_1 The value of AR_1 index (usually in the range 0-150).
AR_2 The value of AR_2 index (usually in the range 0-150).
AR_3 The value of AR_3 index (usually in the range 0-150).
AR_4 The value of AR_4 index (usually in the range 0-150).
AR_5 The value of AR_5 index (usually in the range 0-150).

Examples

# Read the file, compute the indices and show results in one step with:
results = analyzeFile(system.file("extdata","N01.txt", package="rPACI"))

# The previous command is equivalent to:
dataset = readFile(system.file("extdata","N01.txt", package="rPACI"))
results = computePlacidoIndices(dataset)
# If drawplot=TRUE, then it also performs:
plotSingleCornea(dataset, results)

Analysis of all corneal topography files in a folder

Description

This function analyzes all corneal topography files that are stored in a common folder. It is equivalent to use analyzeFile on each file in the folder, and then binding the results.

Usage

analyzeFolder(
  path,
  fileExtension = "txt",
  individualPlots = FALSE,
  summaryPlot = FALSE
)

Arguments

path

The path of a folder which contains corneal topography files, as exported by Placido disks corneal topographers.

fileExtension

The file extension of the corneal topography files in the folder ("txt" by default).

individualPlots

An optional logical parameter (by default, FALSE) indicating whether the plot for each file should be displayed or not.

summaryPlot

An optional logical parameter (by default, FALSE) indicating whether a summary plot should be displayed or not.

Details

This function assumes all files in the folder that have the extension given by the argument fileExtension ("txt", by default) are corneal topography files and are to be processed. The result is a data.frame in the same format yield by computePlacidoIndices or analyzeFile, but with as many rows as matching files were found in the folder.

More details about supported file formats can be found in vignette("topographersDataFormat", package = "rPACI"), and about using rPACI in vignette("packageUsage", package = "rPACI").

Value

A data.frame containing the Placido irregularity indices as well as the diagnose, with as many rows as data files in the folder, and columns:

Diagnose A text label indicating the diagnose, according to the value of GLPI
NBI The value of NBI index (in the range 0-100).
GLPI The value of GLPI index (in the range 0-100).
PI_1 The value of PI_1 index (usually in the range 0-150).
PI_2 The value of PI_2 index (usually in the range 0-150).
PI_3 The value of PI_3 index (usually in the range 0-150).
SL The value of SL index (usually in the range 0-150).
AR_1 The value of AR_1 index (usually in the range 0-150).
AR_2 The value of AR_2 index (usually in the range 0-150).
AR_3 The value of AR_3 index (usually in the range 0-150).
AR_4 The value of AR_4 index (usually in the range 0-150).
AR_5 The value of AR_5 index (usually in the range 0-150).

Examples

# This analyzes together all the corneal topography example files included in rPACI:
## Not run: 
analyzeFolder(system.file("extdata",package="rPACI"))

## End(Not run)

Compute the Placido irregularity indices of a corneal dataset

Description

This function computes a set of indices or metrics from a data.frame which contains points measured from the cornea. The dataset may have been obtained reading from a corneal topography file with readFile or simulated with simulateData. These indices allow to discriminate between normal and irregular corneas. For more information on the indices and their precise mathematical definitions, see vignette("indicesDefinition", package = "rPACI") or the references below.

Usage

computePlacidoIndices(
  datasetRings,
  truncateIndicesAt150 = TRUE,
  useMaxRings = 15
)

Arguments

datasetRings

A dataset containing data points of a corneal topography, as given by readFile or simulateData.

truncateIndicesAt150

A boolean value (by default TRUE) indicating whether the primary indices should be truncated at 150 (so they are in the range 0-150) or not.

useMaxRings

A positive integer value (by default 15) to choose the maximum number of innermost rings to use (as long as there are enough).

Details

The Placido irregularity indices can be computed from a data.frame in the format given by the functions readFile (also with readCSO or readrPACI) or simulateData.

These irregularity indices can be split into two categories: primary and combined indices. The primary indices are: PI_1, PI_2, PI_3, SL, AR_1, AR_2, AR_3, AR_4, AR_5. They all measure certain geometrical properties of the data distribution. Among these, the first 4 indices are especially important for the detection of keratoconus. Based on them, other combined indices are computed: GLPI (a generalized linear model) and NBI (naive Bayes index).

For more information on these indices and their precise mathematical definitions, see vignette("indicesDefinition", package = "rPACI") or the references below.

They were introduced and validated with real datasets in 3 scientific papers (see the references below). In these papers, all indices demonstrated a good sensitivity for detection of keratoconus, a corneal disease. For more details about corneal topography and keratoconus, see vignette("topographersDataFormat", package = "rPACI")

The results include the values of the indices (0 meaning normal, and a large positive value meaning irregular, check the range for each index) plus a diagnose, which is either "Irregular cornea", "Suspect cornea" or "Normal cornea", depending on the value of the combined index GLPI.

Value

A data.frame containing the Placido irregularity indices as well as the diagnose, with columns:

Diagnose A text label indicating the diagnose, according to the value of GLPI
NBI The value of NBI index (in the range 0-100).
GLPI The value of GLPI index (in the range 0-100).
PI_1 The value of PI_1 index (usually in the range 0-150).
PI_2 The value of PI_2 index (usually in the range 0-150).
PI_3 The value of PI_3 index (usually in the range 0-150).
SL The value of SL index (usually in the range 0-150).
AR_1 The value of AR_1 index (usually in the range 0-150).
AR_2 The value of AR_2 index (usually in the range 0-150).
AR_3 The value of AR_3 index (usually in the range 0-150).
AR_4 The value of AR_4 index (usually in the range 0-150).
AR_5 The value of AR_5 index (usually in the range 0-150).

References

Castro-Luna, Gracia M., Andrei Martinez-Finkelshtein, and Dario Ramos-Lopez. 2020. "Robust Keratoconus Detection with Bayesian Network Classifier for Placido Based Corneal Indices." Contact Lens and Anterior Eye 43 (4): 366-72. doi:10.1016/j.clae.2019.12.006.

Ramos-Lopez, Dario, Andrei Martinez-Finkelshtein, Gracia M. Castro-Luna, Neus Burguera-Gimenez, Alfredo Vega-Estrada, David Pinero, and Jorge L. Alio. 2013. "Screening Subclinical Keratoconus with Placido-Based Corneal Indices." Optometry and Vision Science 90 (4): 335-43. doi:10.1097/opx.0b013e3182843f2a.

Ramos-Lopez, Dario, Andrei Martinez-Finkelshtein, Gracia M. Castro-Luna, David Pinero, and Jorge L. Alio. 2011. "Placido-Based Indices of Corneal Irregularity." Optometry and Vision Science 88 (10): 1220-31. doi:10.1097/opx.0b013e3182279ff8.

Examples

# Read the file 'N02.txt' which is a real corneal topography (from a normal eye)
# that was measured with a CSO device:
dataset = readFile(system.file("extdata","N02.txt", package="rPACI"))

# Compute its Placido irregularity indices with this function:
results = computePlacidoIndices(dataset)
results

Plot the corneal topography and a summary plot of the Placido irregularity indices

Description

Draw a three-part plot summarizing the corneal topography analysis, based on the Placido irregularity indices calculated by the function computePlacidoIndices

Usage

plotSingleCornea(dataset, PlacidoIndices, filename = NULL)

Arguments

dataset

A data.frame containing the corneal topography points, with columns:

x The X Cartesian coordinates of the points
y The Y Cartesian coordinates of the points
ring index Number or index of the ring to which each point belongs
PlacidoIndices

A dataset of results as given by the function computePlacidoIndices or analyzeFile.

filename

An optional character argument, with the file name used to read the data (by default, NULL; if specified, the filename is displayed on the plot).

Details

This function draws a 3-column plot, with the corneal topography in dataset plotted on the left, the value of index GLPI taken from PlacidoIndices on the middle, and a boxplot of some of the Placido indices on the right (with the values of PI_1, PI_2, PI_3 and SL) taken from PlacidoIndices.

For the two latter columns, the ranges of values that should be considered normal, suspect or irregular have been depicted with different colors (green, orange and red respectively). The thresholds for these divisions are 30 (between normal (green) and suspect (orange) zones) and 70 (between suspect (orange) and irregular (red) zones).

The scales for these two plots are in general different, as GLPI ranges from 0 to 100, whereas the primary Placido irregularity indices range from 0 to 150 by default.

Consult more information about the use of rPACI, including the available plots, in vignette("packageUsage", package = "rPACI"),

Examples

# Read a corneal topography from a file
dataset = readFile(system.file("extdata","K03.txt", package="rPACI"))

# Compute the Placido irregularity indices with:
results = computePlacidoIndices(dataset)

# Draw the corneal topography along the results with:
plotSingleCornea(dataset, results)

Read a corneal topography file in CSO format

Description

This function is intended to read external files with a corneal topography in the format that is exported by some Placido disk topographers, especially those from CSO (a commercial brand). In general, we recommend to use the more general wrapper function readFile to read any file format.

Usage

readCSO(
  filepath,
  ringsTotal = 24,
  pointsPerRing = 256,
  ringsToUse = 15,
  onlyCompleteRings = TRUE,
  NAvalues = c(-1, -1000)
)

Arguments

filepath

A file path to a corneal topography file exported by a Placido disk corneal topographer, in the format used by CSO.

ringsTotal

The total (maximum) number of rings that may be available in the measurement (including incomplete rings or missing data; it depends on the particular device; by default 24)

pointsPerRing

The number of points per ring that are digitized in the measurement (it depends on the particular device; by default 256)

ringsToUse

The effective number of innermost rings to use (as long as they are complete if onlyCompleteRings = TRUE, otherwise it will be the actual number of complete rings; by default 15)

onlyCompleteRings

A boolean value indicating whether to use only rings with complete data or not (by default, TRUE)

NAvalues

A numerical value or vector indicating how NA values are codified in the file (by default c(-1, -1000))

Details

A corneal topographer is an ophthalmic clinical device that obtains measurements in the cornea (the anterior part of the eye). A Placido disk corneal topographer makes use of the Placido disk (see references and the vignette linked below), which produce a circular pattern of measurement nodes.

The readCSO function is able to read a raw Placido disk corneal topography from a file that has been exported by certain corneal topographers. It has been especially designed for the file format exported from topographers manufactured by CSO (Firenze, Italy).

This reading function has been designed to be more flexible than the CSO format, allowing to specify different parameters: the amounts of rings available, points per ring, and rings to use, whether to use or not only complete rings, and the value(s) encoding NAs (missing data) in the file. In addition, this function automatically processes the file and identifies the size and the header, without assuming a fixed structure or having to specify its size as a parameter.

This function produces a data.frame in the usual format used by rPACI, i.e., a data frame with three columns (x and y coordinates of each point and its ring index) and a row per data point, according to the function parameters (by default, 24*256 = 6144 rows or data points).

See more details about corneal topographers and the file structure in vignette("topographersDataFormat", package = "rPACI").

Value

A data.frame containing the corneal topography points, with columns:

x The X Cartesian coordinates of sampled points
y The Y Cartesian coordinates of sampled points
ring index Number or index of the ring from which each point is sampled

References

Rowsey, J. James, A. E. Reynolds, and Randy Brown. 1981. "Corneal Topography: Corneascope." Archives of Ophthalmology 99 (6): 1093-1100. doi:10.1001/archopht.1981.03930011093022.

Pinero, D. P. 2015. "Technologies for Anatomical and Geometric Characterization of the Corneal Structure and Anterior Segment: A Review." Seminars in Ophthalmology 30 (3): 161-70. doi:10.3109/08820538.2013.835844.

Samapunphong, Sopit, and Dimitri Azar. 1998. "Placido and Elevation-Based Corneal Topography. A Review." Ophthalmology Clinics of North America 11 (3): 311-29. doi:10.1016/S0896-1549(05)70059-6.

Examples

# Read the example file "N01.txt" included with rPACI (a real CSO exported file)
# It corresponds to a normal eye
datasetN = readCSO(system.file("extdata","N01.txt", package="rPACI"))

# Read the example file "K03.txt" included with rPACI (a real CSO exported file) 
# It corresponds to a keratoconic eye
datasetK = readCSO(system.file("extdata","K03.txt", package="rPACI"))

Read a corneal topography file in any available format (recommended by default)

Description

This function is a general wrapper function, able to read corneal topography files in any format supported by rPACI. Internally, it analyzes the file and detects its format, and then it uses the appropriate specific reading function (by now, two are available: readCSO and readrPACI). This is the reading function recommended by default, as it is able to read any supported file format.

Usage

readFile(filepath, ...)

Arguments

filepath

A file path to a corneal topography file in any supported format.

...

Optional arguments of any of the reading functions.

Details

A corneal topographer is an ophthalmic clinical device that obtains measurements in the cornea (the anterior part of the eye). A Placido disk corneal topographer makes use of the Placido disk (see references and the vignette linked below), which produce a circular pattern of measurement nodes.

This function internally determines the format of the specified file and then applies either readCSO or readrPACI if possible, or else it throws an error (if none can be applied, when the file format does not fit any of these two available formats). All this process is transparent to the user, so that using readFile with one file type or another is done in the same way, and it produces the same results. The readFile function propagates its input parameters. See those functions' documentation for more information about their arguments.

This function produces a data.frame in the usual format used by rPACI, i.e., a list with three columns (x and y coordinates of each point, and its ring index) and a row per data point, according to the function parameters (by default, 24*256 = 6144 rows or data points).

See more details about corneal topographers and the file structure in vignette("topographersDataFormat", package = "rPACI").

Value

A data.frame containing the corneal topography points, with columns:

x The X Cartesian coordinates of the points
y The Y Cartesian coordinates of the points
ring index Number or index of the ring to which each point belongs

The resulting data.frame may also include in its Parameters attribute (attr(result,'Parameters')) the list of parameters used for the simulation (only if it was generated with simulateData and saved with writerPACI).

References

Rowsey, J. James, A. E. Reynolds, and Randy Brown. 1981. "Corneal Topography: Corneascope." Archives of Ophthalmology 99 (6): 1093-1100. doi:10.1001/archopht.1981.03930011093022.

Pinero, D. P. 2015. "Technologies for Anatomical and Geometric Characterization of the Corneal Structure and Anterior Segment: A Review." Seminars in Ophthalmology 30 (3): 161-70. doi:10.3109/08820538.2013.835844.

Samapunphong, Sopit, and Dimitri Azar. 1998. "Placido and Elevation-Based Corneal Topography. A Review." Ophthalmology Clinics of North America 11 (3): 311-29. doi:10.1016/S0896-1549(05)70059-6.

Examples

# Read the example file "N01.txt" (the file is in the CSO file format)
dataset1 = readFile(system.file("extdata","N01.txt", package="rPACI"))

dataset2 = readFile(system.file("extdata","ds2.txt", package="rPACI"))

Read a corneal topography file in rPACI format

Description

This function is intended to read external files with a corneal topography that have been previously exported by rPACI, using writerPACI. The file should have the format used by rPACI, i.e., a list with three columns (x and y coordinates of each point, and its ring index) and a row per data point In general, we recommend to use the more general wrapper function readFile to read any file format.

Usage

readrPACI(filepath, sep = ",")

Arguments

filepath

A file path to a corneal topography dataset exported by a Placido disk corneal topographer.

sep

The character used as column separator in the file (by default, ",").

Details

A corneal topographer is an ophthalmic clinical device that obtains measurements in the cornea (the anterior part of the eye). A Placido disk corneal topographer makes use of the Placido disk (see references and the vignette linked below), which produce a circular pattern of measurement nodes.

The readrPACI function is able to read a Placido disk corneal topography from a file that has been exported previously by rPACI using the function writerPACI. The dataset may have been obtained reading data from a file in other format (e.g. using readFile or readCSO), or by simulation using simulateData.

This file format consists of an optional header of any length (its size is automatically detected) and afterwards, three separated columns (x and y coordinates of each point, and its ring index) and a row per data point.

This function produces a data.frame in the usual format used by rPACI, i.e., a list with three columns (x and y coordinates of each point, and its ring index) and a row per data point, according to the function parameters (by default, 24*256 = 6144 rows or data points).

See more details about corneal topographers and the file structure in vignette("topographersDataFormat", package = "rPACI").

Value

A data.frame containing the corneal topography points, with columns:

x The X Cartesian coordinates of the points
y The Y Cartesian coordinates of the points
ring index Number or index of the ring to which each point belongs

The resulting data.frame may also include in its Parameters attribute (attr(result,'Parameters')) the list of parameters used for the simulation (only if it was generated with simulateData and saved with writerPACI).

References

Rowsey, J. James, A. E. Reynolds, and Randy Brown. 1981. "Corneal Topography: Corneascope." Archives of Ophthalmology 99 (6): 1093-1100. doi:10.1001/archopht.1981.03930011093022.

Pinero, D. P. 2015. "Technologies for Anatomical and Geometric Characterization of the Corneal Structure and Anterior Segment: A Review." Seminars in Ophthalmology 30 (3): 161-70. doi:10.3109/08820538.2013.835844.

Samapunphong, Sopit, and Dimitri Azar. 1998. "Placido and Elevation-Based Corneal Topography. A Review." Ophthalmology Clinics of North America 11 (3): 311-29. doi:10.1016/S0896-1549(05)70059-6.

Examples

# A dataset that was read from a corneal topographer file was later saved in the rPACI format.
# It can be read with:
dataset1 = readrPACI(system.file("extdata","ds1.txt", package="rPACI"))

dataset2 = readrPACI(system.file("extdata","ds2.txt", package="rPACI"))

Simulate data as measured by a Placido disk corneal topographer

Description

The function simulateData permits to simulate a wide variety of datasets that appear in clinical practice, as a result of measuring an individual eye with a Placido disk corneal topographer (see vignette("topographersDataFormat", package = "rPACI")).

Usage

simulateData(
  rings = 15,
  pointsPerRing = 256,
  diameter = 12,
  ringRadiiPerturbation = 0,
  maximumMireDisplacement = 0,
  mireDisplacementAngle = 0,
  mireDisplacementPerturbation = 0,
  ellipticAxesRatio = 1,
  ellipticRotation = 0,
  overallNoise = 0,
  seed = 0
)

Arguments

rings

The total number of rings of mires in the sample (typically in the range 18-30, around 24).

pointsPerRing

The number of points to be sampled in each ring (typically 256 or 360).

diameter

Diameter of the simulated dataset (in mm, typically around 8-12 mm).

ringRadiiPerturbation

Stochastical perturbation of the mires radii distribution (typically between 0 (no perturbation) and 1 (high perturbation)).

maximumMireDisplacement

Mires displacement, drift or off-centering (expressed in mm, and should be a reasonable number according to the diameter used.

mireDisplacementAngle

Direction of mires drift (an angle in degrees, typically in the range 0-360 with 0 meaning positive x direction).

mireDisplacementPerturbation

Stochastical perturbation of the mires drift (typically between 0 (no perturbation) and 1 (high perturbation)).

ellipticAxesRatio

Rate or quotient between the major and minor axes of each ellipse (related to the ellipse eccentricity; 1 means a perfect circle (no eccentricity)).

ellipticRotation

Direction or orientation of the ellipses (an angle in degrees, typically in the range 0-360 with 0 meaning positive x direction).

overallNoise

Random, white noise of a certain magnitude in the Cartesian coordinates of the sampled points (relative to the diameter and the number of rings; 0 means no noise, and 1 large noise).

seed

A seed, included for repeatability when using random perturbations.

Details

This function produces a dataset in the same format as the one read by readCSO from a file, i.e., a list with three columns (x and y coordinates of each point and its ring index) and a row per data point, according to the function parameters (by default, 6144 rows or data points).

See vignette("simulating", package = "rPACI") for additional details. The examples included there show different ways of using simulateData, by adding different transformations or perturbations to the basic circular pattern. Some of the obtained patterns can correlate with certain clinical conditions, such as keratoconus, comma, or others.

The simulated dataset can be later used according to the package workflow explained in the vignette("packageUsage", package = "rPACI").

Value

A data.frame with columns:

x The X Cartesian coordinates of sampled points
y The Y Cartesian coordinates of sampled points
ring index Number or index of the ring from which each point is sampled

The resulting data.frame also includes in its Parameters attribute (attr(result,'Parameters')) the list of parameters used for the simulation.

Examples

# Simulating with default parameters
dataset = simulateData()  
plot(dataset$x,dataset$y)

# Simulating with 20 rings and a diameter of 8 mm
dataset = simulateData(rings = 20, diameter = 8)
plot(dataset$x,dataset$y)

# Simulating with default parameters and 500 points per ring (15x500 points)
dataset = simulateData(pointsPerRing = 500)
plot(dataset$x,dataset$y)

# Simulating an elliptic dataset, with ellipses axis ratio of 0.8 and an orientation of 45 degrees.
dataset = simulateData(ellipticAxesRatio = 0.8, ellipticRotation = 45)
plot(dataset$x,dataset$y)

# To see the parameters used in the simulation, access the 'Parameters' attribute:
attr(dataset,'Parameters')

Save to disk a dataset in the format used by rPACI

Description

Write to disk a corneal topography dataset in the format used by rPACI, in a plain text file. The file format consists of (possibly) a header (only for data that were simulated), followed by three separated columns (x and y coordinates of each point and its ring index) and a row per data point. This format is returned by the functions readFile or simulateData.

Usage

writerPACI(dataset, filename, sep = ",")

Arguments

dataset

A data.frame containing the corneal topography points, with columns:

x The X Cartesian coordinates of the points
y The Y Cartesian coordinates of the points
ring index Number or index of the ring to which each point belongs
filename

A character string naming a file (including the extension).

sep

The field separator string (by default, ',').

Details

This function writes the data from a data.frame to a plain text file. The file will possibly have a header, followed by a block of three separated columns, according to the usual format used by rPACI, i.e., a list with three columns (x and y coordinates of each point, and its ring index) and a row per data point.

If the given data.frame (named dataset) was produced using simulateData, the resulting text file will also include in its header the Parameters attribute (attr(dataset,'Parameters')), i.e., the list of parameters used for the simulation.

A file stored with writerPACI can later be read using the general reader function readFile or the specific reader function readrPACI.

See more details about the file structure in vignette("topographersDataFormat", package = "rPACI"), about the usage of rPACI in vignette("packageUsage", package = "rPACI"), and about simulation parameters in vignette("simulating", package = "rPACI").

Examples

# Simulating an elliptic dataset, with ellipses axis ratio of 0.8 and an orientation 
# of 45 degrees.
dataset = simulateData(rings = 18, pointsPerRing = 300, 
                       ellipticAxesRatio = 0.8, ellipticRotation = 45)

# Now the dataset can be saved to file using 'writerPACI' (check the working directory
# before saving):
## Not run: 
writerPACI(dataset, "datasetFile.txt")

## End(Not run)
# The file will include as a header the parameters used in the simulation