extract.data {NCStats}R Documentation

Converts a file of X-Y pixel coordinates to X-Y measurements.

Description

This function takes a file containing the X-Y pixel coordinates and converts them to actual X-Y measurements according to the scales on the original figure. This function, in conjunction with an image analysis program (from ImageJ for example) is used to extract “data” from a published figure.

Usage

extract.data(df1,pt1,pt2,xname="X",yname="Y",xdec=NULL,ydec=NULL,
             group=NULL,groupname="Group",app.df=NULL,filename=NULL)

Arguments

df1 The data frame X-Y pixel coordinates. See details for specific format structure.
pt1 The actual coordinates for the first orientation point. See details.
pt2 The actual coordinates for the second orientation point. See details.
xname An optional string for naming the extracted data on the x-axis.
yname An optional string for naming the extracted data on the x-axis.
xdec A numeric indicating the number of decimals to round the x-values to.
ydec A numeric indicating the number of decimals to round the y-values to.
group An optional string used to label each point. See details.
groupname An optional string for naming the group label set in group.
app.df An optional data frame to be column appended to the extracted measurements. The number of rows must match the number of extracted points.
filename A string containing the path and name of a file to write the results to. The file will be tab-delimited and without rownames.

Details

The X-Y pixel file must be arranged in a very specific format. This format is the format returned by the ListSelectionCoordinates macro of the ImageJ image analysis program. This file will contain four columns – an ID, X coordinate, Y coordinate, and length. The ID and length columns are not used but are expected to be in the file. The file must start with the coordinates of a point in the upper-left corner of the figure, followed by a point in the lower right corner of the figure. These are called the orientation points and are used to set the scale of conversion from pixes to actual measurements. These points must be in this order and the real coordinates on the figure must be noted and sent to this function in the pts1 and pts2 arguments. The remained of the file contains the coordinates for the points on the original figure, except that the last row contains dummy data (according to ImageJ's macro).

The above file is created by scanning a figure to a digital (i.e., computer) file (.jpg works well), opening the file in ImageJ, installing the LineSelectionCoordinates macros, using the segmented line selection tool to select the two orientation points and all of the points on the graph making sure to RIGHT CLICK on the last point (this ends the segmented line selection), running the LineSelectionCoordinates macro, and then saving the resulting file to a text file. The header line of the text file must be altered to include a name for the first column before reading the file into R. The file should then be read into a data frame object in R and submitted to the extract.data function along with the actual coordinates of the two orientation points, and any of the other arguments as needed. The function will return a data frame of the coordinates on the same scales as the axes of the original figure.

The group option is used to create a column that will serve as a group factor level for all of the points. This argument is an efficient way to label the level of all the points by simply including the labeling string to the group argument. Note that this argument assumes that all extracted points should be given the same label. If points will be extracted for more than one level then the group factor level variable should be entered into a dataframe and sent to this function in the app.df argument.

Value

A data frame of extracted values.

Author(s)

Derek H. Ogle, dogle@northland.edu.


[Package NCStats version 0.0-12 Index]