read.ijdata: Read ImageJ zip file containing several ROI files and extract...

View source: R/read.ijdata.R

read.ijdataR Documentation

Read ImageJ zip file containing several ROI files and extract coordinate information.

Description

A wrapper function, which reads an ImageJ zip file containing a collection of ROI files and outputs a list of data frames ready for convert.ijdata function.

Usage

read.ijdata(
  X,
  spots = NULL,
  gbs = NULL,
  main = NULL,
  growth = NULL,
  names = "generate.invalid",
  spot.names = NULL,
  gbs.names = NULL,
  main.name = "main",
  sample.name = NULL,
  scale = 1,
  unit = NULL
)

Arguments

X

a character string defining the name (including extension) or file path of an ImageJ zip file. Alternatively an ijzip object.

spots, gbs

optional. Sample spots and growth lines, respectively. One of the following options:

  • NULL (default). Type of the ROI object will be chosen automatically. Leads to selection of "point" and "polyline" objects as sample spots and growth lines.

  • numeric or character vector specifying the order or the names of elements of ROI objects that should be assigned as the corresponding type. Might be useful in debugging.

  • a character string specifying the type of ROI objects that should be considered as the corresponding type. This option is included for package development and backwards compatibility.

main

optional. Main (measurement) axis. Same options than for spots,gbs. Only one measurement axis per ImageJ .zip file is allowed. Defaults to "line".

growth

optional. A character string specifying the name of the "polyline" ROI that was used as a growth axis. Only if one was used, otherwise use NULL.

names

optional. A character argument specifying how the names of spots and gbs should be generated. These names will be used in further functions (convert.ijdata, spot.dist). In general, it is adviced to use simple ROI names without special characters (for example - is not allowed in a ROI name; see 'Details'). Possible names options are:

  • "generate.invalid" (default). Uses the ROI object names, except when they are not valid data.frame column names. In the latter case sequential names will be generated.

  • "generate". Generates sequential names for all elements.

  • "keep". Uses the ROI object names, except when they are not valid data.frame column names. In the latter case make.names function will be used to generate data.frame combatible column names.

  • "force.keep". Uses the ROI object names as they are in the .zip file. Using this option might cause problems in consequent functions and is not recommended.

  • "manual". Names for spots and gbs are searched from spot.names and gbs.names arguments, respectively. If these arguments are not NULL and have the same length than spots or gbs, the given names are used for the elements. If the condition is not true, the names are generated following "generate.invalid".

spot.names, gbs.names

optional. A character vector of equal length to spots/gbs defining the names of sample spot sequences/growth bands.

main.name

optional. A character string defining the name of the measurement axis (main). If main.name = "keep", the ROI object name will be used (not recommended, see "Details"). Otherwise the name will be taken from the argument. Defaults to "main".

sample.name

optional. A character string defining the name of the sample. File name without the extension or alternatively ijzip object name is used when NULL (default).

scale

optional. A numeric value defining the scale of photograph in pixels / unit. Defaults to 1.

unit

optional. A charater string defining the unit of measurements. See scale.

Details

In order to minimize the amount of text to be typed by a user, ROI objects of type "point" (this includes the "Multi-point Tool" points) are considered as sample spot sequences (spots) by default. Further, all "polyline" objects are assumed as growth bands (gbs) and "line" objects as the measurement axis (main) resulting to that only one "line" object is allowed per .zip file using the default settings. Alternatively, the user can specify the spots, gbs, and main objects manually using the order of the ImageJ .zip file with the exception that only one measurement axis is allowed per rawDist or spotDist object.

Punctuation characters other than _ or . should not be used as names of spots or gbs, because they tend to confuse the internal grep functions in spot.dist function. Hence it is adviced to use one of the options renaming invalid names of spots and gbs ("generate.invalid", "generate", "keep").

Custom growth axis, if different from main, can be defined by using one named "polyline" in the ROI file and typing the name to growth argument. In such case, main is used to define the direction of growth, while the growth axis is used in growth measurements and sample spot alignment (distances are projected first to the growth axis and then transfered to the main axis).

Value

Returns an "IJDATA" object, which is a list of data frames containing the x and y coordinates for sampling spot sequences (spots.x and spots.y), growth bands (gbs.x and gbs.y), measurement axis (main.x and main.y) and growth axis (growth.x and growth.y) together with sample name, scaling factor and unit of measurement.

Author(s)

Mikko Vihtakari

See Also

order.ijdata for ordering and subsetting read.ijdata output.

convert.ijdata for converting the coordinate information to spatstat point patterns.

spot.dist for aligning sample spot sequences.

read.ijroi and read.ijzip for reading ImageJ ROI and .zip files.

Examples

# Locate the example zip file
path <- file.path(system.file("extdata", package = "sclero"), "shellspots.zip")

# You can replace 'path' by 'Your_file_name.zip'
dat <- read.ijdata(path)
summary(dat)

## Works also for IJZIP objects
dat2 <- read.ijzip(path)
dat2 <- read.ijdata(dat2)
dat[!(dat %in% dat2)] # Only the sample name differs

MikkoVihtakari/sclero documentation built on March 21, 2023, 11:48 a.m.