Functions for analyzing features, like particles, fragments, or fibers, in
spectral map oriented OpenSpecy
object.
Usage
collapse_spec(x, ...)
# S3 method for default
collapse_spec(x, ...)
# S3 method for OpenSpecy
collapse_spec(x, ...)
def_features(x, ...)
# S3 method for default
def_features(x, ...)
# S3 method for OpenSpecy
def_features(
x,
features,
shape_kernel = c(3, 3),
img = NULL,
bottom_left = NULL,
top_right = NULL,
...
)
Arguments
- x
an
OpenSpecy
object- features
a logical vector or character vector describing which of the spectra are of features (
TRUE
) and which are not (FALSE
). If a character vector is provided, it should represent the different feature types present in the spectra.- shape_kernel
the width and height of the area in pixels to search for connecting features, c(3,3) is typically used but larger numbers will smooth connections between particles more.
- img
a file location where a visual image is that corresponds to the spectral image.
- bottom_left
a two value vector specifying the x,y location in image pixels where the bottom left of the spectral map begins. y values are from the top down while x values are left to right.
- top_right
a two value vector specifying the x,y location in the visual image pixels where the top right of the spectral map extent is. y values are from the top down while x values are left to right.
- ...
additional arguments passed to subfunctions.
Details
def_features()
accepts an OpenSpecy
object and a logical or
character vector describing which pixels correspond to particles.
collapse_spec()
takes an OpenSpecy
object with particle-specific
metadata (from def_features()
) and collapses the spectra to median
intensities for each unique particle.
It also updates the metadata with centroid coordinates, while preserving the
feature information on area and Feret max.
Examples
data.table::setDTthreads(2)
tiny_map <- read_extdata("CA_tiny_map.zip") |> read_any()
identified_map <- def_features(tiny_map, tiny_map$metadata$x == 0)
collapse_spec(identified_map)
#> wavenumber 1 -88
#> <num> <num> <num>
#> 1: 717.42 -0.3454294 -0.1846190
#> 2: 725.13 -0.3505079 -0.2030258
#> 3: 732.85 -0.3595735 -0.2236059
#> 4: 740.56 -0.3662870 -0.2380186
#> 5: 748.28 -0.3689005 -0.2436821
#> ---
#> 423: 3972.81 -0.4140871 -0.3092059
#> 424: 3980.52 -0.4108835 -0.3107601
#> 425: 3988.24 -0.4105957 -0.3180229
#> 426: 3995.95 -0.4125072 -0.3195935
#> 427: 4003.67 -0.4132366 -0.3126730
#>
#> $metadata
#> x y feature_id area perimeter feret_min feret_max file_name
#> <num> <num> <char> <int> <num> <num> <num> <char>
#> 1: 0 0 1 13 24 1 13 CA small UF.dat
#> 2: 1 0 -88 NA NA NA NA CA small UF.dat
#> license description
#> <char> <char>
#> 1: CC BY-NC Pixel 15, XPos=12549.72, YPos= 589.82, X=12362.22, Y= 614.82
#> 2: CC BY-NC Pixel 15, XPos=12549.72, YPos= 589.82, X=12362.22, Y= 614.82
#> samples lines bands header offset data type interleave
#> <num> <num> <num> <num> <num> <char>
#> 1: 16 13 427 0 4 bip
#> 2: 16 13 427 0 4 bip
#> z plot titles pixel size col_id
#> <char> <char> <char>
#> 1: Wavenumbers (cm-1), Absorbance 0.000025000, 0.000025000 0_0
#> 2: Wavenumbers (cm-1), Absorbance 0.000025000, 0.000025000 0_1
#> session_id
#> <char>
#> 1: 919e3e54e4c2f1b1e4db64651b451179/3a92df223835b9b68f921abdae9a32e7
#> 2: 919e3e54e4c2f1b1e4db64651b451179/3a92df223835b9b68f921abdae9a32e7
#> file_id centroid_x centroid_y first_x first_y
#> <char> <num> <num> <num> <num>
#> 1: 215a0fd7e0dc3b1001799214618ce6eb 0 6 0 0
#> 2: 215a0fd7e0dc3b1001799214618ce6eb 8 6 1 0
#> rand_x rand_y
#> <num> <num>
#> 1: 0 10
#> 2: 14 1