Skip to contents

Finds and imports metadata from spectra files in a given location.

Usage

lr_get_metadata(
  where = getwd(),
  ext = "ProcSpec",
  sep = NULL,
  subdir = FALSE,
  subdir.names = FALSE,
  ignore.case = TRUE
)

Arguments

where

Folder in which files are located (defaults to current working directory).

ext

File extension to be searched for, without the "." (defaults to txt). You can also use a character vector to specify multiple file extensions.

sep

Column delimiting characters to be considered in addition to the default (which are: tab, space, and ";")

subdir

Should subdirectories within the where folder be included in the search? (defaults to FALSE).

subdir.names

Should subdirectory path be included in the name of the spectra? (defaults to FALSE).

ignore.case

Should the extension search be case insensitive? (defaults to TRUE)

Value

A data.frame containing one file per row and the following columns:

  • name: File name (without the extension)

  • user: Name of the spectrometer operator

  • datetime: Timestamp of the recording (ISO 8601 format)

  • spec_model: Model of the spectrometer

  • spec_ID: Unique ID of the spectrometer

  • white_inttime: Integration time of the white reference (in ms)

  • dark_inttime: Integration time of the dark reference (in ms)

  • sample_inttime: Integration time of the sample (in ms)

  • white_avgs: Number of averaged measurements for the white reference

  • dark_avgs: Number of averaged measurements for the dark reference

  • sample_avgs: Number of averaged measurements for the sample

  • white_boxcar: Boxcar width for the white reference

  • dark_boxcar: Boxcar width for the dark reference

  • sample_boxcar: Boxcar width for the sample reference

Details

You can customise the type of parallel processing used by this function with the future::plan() function. This works on all operating systems, as well as high performance computing (HPC) environment. Similarly, you can customise the way progress is shown with the progressr::handlers() functions (progress bar, acoustic feedback, nothing, etc.)

Warning

white_inttime, dark_inttime and sample_inttime should be equal. The normalised data may be inaccurate otherwise.

References

White TE, Dalrymple RL, Noble DWA, O'Hanlon JC, Zurek DB, Umbers KDL. Reproducible research in the study of biological coloration. Animal Behaviour. 2015 Aug 1;106:51-7 (doi:10.1016/j.anbehav.2015.05.007 ).

Examples

# \donttest{
lr_get_metadata(system.file("testdata", "procspec_files",
                            package = "lightr"),
                ext = "ProcSpec")
#> 4 files found; importing metadata:
#> Warning: PCDATA invalid Char value 1 [9]
#> Warning: Could not import one or more files:
#> /usr/lib/R/site-library/lightr/testdata/procspec_files/OceanOptics_badencode.ProcSpec
#>                  name       user            datetime spec_model    spec_ID
#> 1   OceanOptics_Linux       hugo 2016-03-16 13:18:31    USB4000 USB4C00008
#> 2 OceanOptics_Windows doutrelant 2015-12-04 10:29:14     JazUSB   JAZA2982
#> 3            whiteref      gomez 2018-08-02 15:56:19    USB4000 USB4C00008
#>   white_inttime dark_inttime sample_inttime white_avgs dark_avgs sample_avgs
#> 1           200          200            200          5         5           5
#> 2            60           60             60         15        15          15
#> 3           500          500            500          5         5           5
#>   white_boxcar dark_boxcar sample_boxcar
#> 1            0           0             0
#> 2            0           0             0
#> 3            0           0             0
# }