Learn R Programming

visualFields (version 1.0.7)

vfdesc: Visual field dataset

Description

The main object of the visualFields package is a table with a specific format and fields that are mandatory for their management and processing (mainly statistical analysis). Each record (row) in the table contains data for a single visual field test. The mandatory fields specify subject (by its ID code), eye, and test date and time. There are required fields statistical and reliability analyses (e.g., age for the determination of total-deviation and pattern-deviation values, and for global indices and fpr, fnr, fl for the proportion of false positives, false negative, and fixation losses). The rest of mandatory fields are sensitivity or deviation data for each visual field test location. (The number of fields for tested locations varies with the location map, 54 for the 24-2, 76 for the 30-2, 68 for the 10-2, etc.). Check section Structure of visual fields data below for details about the required structure of the table contatining the visual fields datasets.

The following functions carry out analysis on visual fields data:

  • vfdesc descriptive summary of a visual field dataset

  • vfsort sort visual field data

  • vfisvalid check if a table with visual field data is properly formatted and valid for analysis

  • vfread read a csv file with visual field data

  • vfwrite write a csv file with visual field data

  • vfjoin joins two visual field datasets

  • vffilter filters elements from a visual field dataset with matching conditions. This function is just a wrapper for dplyr's function filter

  • vfselect select visual field data by index or the first or last n visits per subject and eye

  • gettd computes total-deviation (TD) values and probability values

  • gettdp computes total-deviation (TD) probability values

  • getpd computes pattern-deviation (PD) values

  • getpdp computes pattern-deviation (PD) probability values

  • getgh computes the general height (GH) from the TD tables

  • getgl computes visual fields global indices

  • getglp computes computes visual fields global indices probability values

Usage

vfdesc(vf)

vfsort(vf, decreasing = FALSE)

vfisvalid(vf)

vfread(file, dateformat = "%Y-%m-%d", eyecodes = c("OD", "OS", "OU"), ...)

vfwrite( vf, file, dateformat = "%Y-%m-%d", eyecodes = c("OD", "OS", "OU"), ... )

vfjoin(vf1, vf2)

vffilter(vf, ...)

vfselect(vf, sel = "last", n = 1)

gettd(vf)

gettdp(td)

getpd(td)

getpdp(pd)

getgh(td)

getgl(vf)

getglp(g)

Value

vfdesc returns descriptive statistics of a visual field dataset

vfsort returns a sorted visual field dataset

vfisvalid returns TRUE or FALSE

vfread returns a visual field dataset

vfwrite No return value

vfjoin returns a visual field dataset

vffilter returns a visual field dataset

vfselect returns a visual field dataset

gettd returns a visual field dataset with total deviation values

gettdp returns a visual field dataset with total deviation probability values

getpd returns a visual field dataset with pattern deviation values

getpdp returns a visual field dataset with pattern deviation probability values

getgh returns the general height of visual fields tests

getgl returns visual fields global indices

getglp returns probability values of visual fields global indices

Arguments

vf

visual field data

decreasing

sort decreasing or increasing? Default is increasing, that is decreasing = FALSE

file

the name of the csv file where to write the data

dateformat

format to be used for date. Its default value is %Y-%m-%d

eyecodes

codification for right and left eye, respectively. By default in visualField uses `OD` and `OS` for right and left eye respectively, but it is common to receive csv files with the codes `R` and `L`. The code `OU` for both eyes is also allowed eyecodes should be equal to `c("OD", "OS")` or `c("R", "L")`. By default it is `eyecodes = c("OD", "OS", "OU")`

...

arguments to be passed to or from methods

vf1, vf2

the two visual field data objects to join or merge

sel

it can be two things, an array of indices to select from visual field data or a string with the values `first` or `last` indicating that only the first few n visits per subject `id` and `eye` are to be selected. Default is `last`.

n

number of visits to select. Default value is 1, but it is ignored if sel is an index array

td

total-deviation (TD) values

pd

pattern-deviation (PD) values

g

global indices

Structure of visual fields data

Visual fields data is the central object used in visualFields. It is a table of visual field data collected with the same perimeter, background and stimulus paradigm (e.g., static automated perimetry or frequency-doubling perimetry), stimulus size (e.g., Goldmann size III), grid of visual field test locations (e.g., 24-2), and psychophysical testing strategy (e.g., SITA standard). Normative values can be obtained from appropriate datasets with data for healthy eyes and these normative values can then be used to generate statistical analyses and visualizations of data for patients with retinal or visual anomalies.

Each record correspond to a specific test for an eye of a subject taken on a specific date at a specific time. Visual field data must have the following columns

  • id an id uniquely identifying a subject. This field is mandatory

  • eye should be "OD" for right eye or "OS" for left eye. This field is mandatory

  • date test date. This field is mandatory

  • time test time. This field is mandatory

  • age age of the patient on the test date. This field is required to obtain total-deviation, pattern-deviation values, and other age-dependent local and global indices

  • type type of subject, Could be a healthy subject (ctr for control) or a patient with glaucoma (pwg) or a patient with idiopatic intraocular hypertension (iih) or other. This field is no required for management or statistical analysis.

  • fpr false positive rate. This field is no required for management or statistical analysis.

  • fnr false negative rate. This field is no required for management or statistical analysis.

  • fl fixation losses. This field is no required for management or statistical analysis.

  • l1..ln sensitivity, total-deviation, or pattern-deviation values for each location. For analysis with visualFields there should be as many columns as coordinates in the location map set in the visualFields environment. These fields are mandatory.

Details

  • vfselect when selecting the last or first few visual fields per subject and eye, if that subject and eye has fewer than n visits, then all visits are returned

Examples

Run this code
# get dataset description from visual field table
vfdesc(vfctrSunyiu24d2)
# sort dataset
vfsort(vfctrSunyiu24d2[c(5, 4, 10, 50, 30),])
# check if a visualField is valid
vf <- vfctrSunyiu24d2
vfisvalid(vf) # valid visual field data
vf$id[5] <- NA
vfisvalid(vf) # invalid visual field data
# write and read visual field data
vf <- vfctrSunyiu24d2
tf <- tempfile("vf")
vfwrite(vf, file = tf) # save current locmap in a temp file
head(vfread(tf)) # read the temp file
# join visual fields datasets
vfjoin(vfctrSunyiu24d2, vfpwgRetest24d2)
# visual field subselection
vffilter(vf, id == 1) # fields corresponding to a single subject
vffilter(vf, id == 1 & eye == "OD") # fields for a single subject's right eye
unique(vffilter(vf, eye == "OS")$eye) # only left eyes
vffilter(vfjoin(vfctrSunyiu24d2, vfpwgRetest24d2), type == "ctr") # get only controls
vffilter(vfjoin(vfctrSunyiu24d2, vfpwgRetest24d2), type == "pwg") # get only patients
# select visual fields by index
vfselect(vfctrSunyiu24d2, sel = c(1:4, 150))
# select last few visual fields per subject and eye
vfselect(vfpwgRetest24d2, sel = "last")
# select first few visual fields per subject and eye
vfselect(vfpwgRetest24d2, sel = "first")
vfselect(vfpwgRetest24d2, sel = "first", n = 5) # get the last 5 visits
# compute visual field statistics
vf  <- vfpwgSunyiu24d2
td  <- gettd(vf)  # get TD values
tdp <- gettdp(td) # get TD probability values
pd  <- getpd(td)  # get PD values
pdp <- getpdp(pd) # get PD probability values
gh  <- getgh(td)  # get the general height
g   <- getgl(vf)  # get global indices
gp  <- getglp(g)  # get global indices probability values

Run the code above in your browser using DataLab