ImageData-class {Cardinal} | R Documentation

## ImageData: Class containing arrays of imaging data

### Description

A container class for holding imaging data, designed to contain one or more arrays in an immutable environment. It is assumed that the first dimension of each array corresponds to the features.

Note that only visible objects (names not beginning with '.') are checked for validity; however, all objects are copied if any elements in the `data` slot are modified when `data` is an "immutableEnvironment".

### Usage

    ## Instance creation
    ImageData(...,
        data = new.env(parent=emptyenv()),
        storageMode = c("immutableEnvironment",
            "lockedEnvironment", "environment"))

    ## Additional methods documented below

### Arguments

`...` | Named arguments that are passed to the `initialize` method for instantiating the object. These must be arrays or array-like objects with an equal number of dimensions. They will be assigned into the environment in the `data` slot.
`data` | An environment in which to assign the previously named variables.
`storageMode` | The storage mode to use for the `ImageData` object for the environment in the `data` slot. This must be one of `"immutableEnvironment"`, `"lockedEnvironment"`, or `"environment"`. See documentation on the `storageMode` slot below for more details.

### Slots

`data`:

  An `environment` which may contain one or more arrays with an equal number of dimensions. It is assumed that the first dimension corresponds to the features.

`storageMode`:

  A `character` which is one of `"immutableEnvironment"`, `"lockedEnvironment"`, or `"environment"`. The values `"lockedEnvironment"` and `"environment"` behave as described in the documentation of `AssayData`. An `"immutableEnvironment"` uses a locked environment while retaining R's typical copy-on-write behavior. Whenever an object in an immutable environment is modified, a new environment is created for the `data` slot, and all objects copied into it. This allows usual R functional semantics while avoiding copying of large objects when other slots are modified.

`.__classVersion__`:

  A `Versions` object describing the version of the class used to created the instance. Intended for developer use.

### Extends

`Versioned`

### Creating Objects

`ImageData` instances are usually created through `ImageData()`.

### Methods

Class-specific methods:

`storageMode(object)`, `storageMode(object)<-`:

  Return or set the storage mode. See documentation on the `storageMode` slot above for more details.

Standard generic methods:

`initialize`:

  Initialize an `ImageData` object. Called by `new`. Not to be used by the user.

`validObject`:

  Validity-check that the arrays in the `data` slot environment are all of equal number of dimensions, and the storage mode is a valid value.

`combine(x, y, ...)`:

  Combine two or more `ImageData` objects. All elements must have matching names, and are combined with calls to `combine`. Higher dimensional arrays are combined using the same rules as for matrices. (See `combine` for more details.)

`annotatedDataFrameFrom(object)`:

  Returns an `IAnnotatedDataFrame` with columns for the dimensions of the elements of `data`. All dimensions must be named (determined by the `rownames(dims(object))`). It is assumed that the first dimension corresponds to the features, and is not used as a dimension in the returned `IAnnotatedDataFrame`. Additional arguments (`byrow`, ...) are ignored.

`dims`:

  A matrix with each column corresponding to the dimensions of an element in the `data` slot.

`names(x)`, `names(x)<-`:

  Access or replace the array names of the elements contained in the `data` slot environment.

`ImageData[[name]]`, `ImageData[[name]] <- value`:

  Access or replace an element named `"name"` in the environment in the `data` slot.

### Author(s)

Kylie A. Bemis

### See Also

`AssayData`, `SImageData`, `SImageSet`, `MSImageSet`

### Examples

    ## Create an ImageData object
    ImageData()

    idata <- ImageData(data0=matrix(1:4, nrow=2))
    idata[["data0"]]

    # Immutable environments in ImageData objects
    storageMode(idata) <- "lockedEnvironment"
    try(idata[["data0"]][,1] <- c(10,11)) # Fails

    storageMode(idata) <- "immutableEnvironment"
    try(idata[["data0"]][,1] <- c(10,11)) # Succeeds

    # Test copy-on-write for immutable environments
    idata2 <- idata
    idata2[["data0"]] <- matrix(5:8, nrow=2)
    idata[["data0"]] == idata2[["data0"]] # False

[Package Cardinal version 2.4.0 Index]