edf.batch: Batch process EDF files

View source: R/utilities.R

edf.batchR Documentation

Batch process EDF files

Description

edf.batch is useful for processing a bunch of EDF files at once and saving the resulting data

Usage

edf.batch(EDFfiles = NULL, pattern = NULL, samples = FALSE,
  do.plot = TRUE, save.plot = FALSE, save.files = NA, outdir = NULL,
  plot.theme = "black", plot.res = NULL)

Arguments

EDFfiles

a character vector of EDF files OR a directory where EDF files can be found

pattern

a regular expression for matching file names of EDFs (e.g., '*.edf'). Only needed if a directory is specified instead of a list of files.

samples

a logical specifying whether samples should be included (default=FALSE)

do.plot

a logical indicating whether to produce a plot for each EDF (uses edf.plot)

save.plot

a logical indicating whether a PDF of the plot should be saved (must specify outdir)

save.files

format for saving output files, either 'R' or 'matlab' (requires package R.matlab), or set to NA if you do not want to save files (default=NA)

outdir

a string specifying an output directory where to save the files. Required if save.plot or save.files are used

plot.theme

either "black" or "white" specifying the style of plot used in edf.plot

plot.res

an array specifying the screen resoluion (e.g., c(1024, 768), used for edf.plot

Details

This function takes either a list of EDF file names, or a directory and search pattern for files, then imports each one and (optionally) saves te data (either as .RData or .mat for matlab)

Value

a list of all trial data that was imported. WARNING: if you import samples and try to save this as 1 file it will be extremely large. It is better to use save.files='R' instead. All data will include a column ID that correponds to only the numeric parts of the EDF file name. This is useful for concatenating all the data together

Author(s)

Jason Hubbard, hubbard3@uoregon.edu

Examples

## Not run: 

#import a list of named EDF files, don't save anything
#ID variable will be 1 for the first file, and 2 for the second
alldata <- edf.batch(c('/path/to/EDF1.edf',/path/to/EDF2.edf'),samples=F,do.plot=T,plot.theme='white',plot.res=c(1024,768)


#import all EDFs from basedir, and save all the output for R
basedir <- '~/Desktop/edfs'
alldata <- edf.batch(basedir,pattern='*.edf',samples=T,do.plot=T,save.plot=T,save.files='R',outdir='~/Desktop/output',plot.res=c(1024,768))

#save for matlab, if you prefer (requires the package R.matlab):
alldata <- edf.batch(basedir,pattern='*.edf',samples=T,do.plot=T,save.plot=T,save.files='matlab',outdir='~/Desktop/output',plot.res=c(1024,768))


## End(Not run)

jashubbard/edfR documentation built on Aug. 4, 2022, 5:18 p.m.