empi2tf: Creates a time-frequency map using atoms from the Matching...

View source: R/empi2tf.R

empi2tfR Documentation

Creates a time-frequency map using atoms from the Matching Pursuit algorithm

Description

Creates a time-frequency map using atoms from the Matching Pursuit algorithm. The created map can be: 1) displayed on the screen, 2) saved in .png file, or 3) saved as an .RData object.

Usage

empi2tf(
  db.file = NULL,
  db.list = NULL,
  channel,
  mode = "sqrt",
  freq.divide = 1,
  increase.factor = 1,
  shortening.factor.x = 2,
  shortening.factor.y = 2,
  display.crosses = TRUE,
  display.atom.numbers = FALSE,
  display.grid = FALSE,
  crosses.color = "white",
  palette = "my custom palette",
  rev = TRUE,
  out.mode = "plot",
  path = NULL,
  file.name = NULL,
  size = c(512, 512),
  draw.ellipses = FALSE,
  plot.signals = TRUE,
  write.atoms = FALSE
)

Arguments

db.file

The SQLite file created after executing the empi.execute() function. In this case, the db.list parameter must be NULL.

db.list

The list created after executing the empi.execute() function. In this case, the db.file parameter must be NULL.

channel

Channel from the SQLite file to process.

mode

"sqrt", "log", or "linear". It determines the intensity with which the so-called blobs are displayed on the T-F map.

freq.divide

Specifies how many times the displayed frequency in the T-F map should be decreased. For example, if the sampling frequency is f=256Hz, the maximum frequency in the T-F map will be f/2/freq.divide (f/2 is the Nyquist rule).

increase.factor

Factor of increasing the number of pixels in the f-axis, the most sensible are non-negative integers (e.g. 2, 4, 5, 8).

shortening.factor.x

Usually, for better visualization of atoms, a value of 2 will be appropriate.

shortening.factor.y

Usually, for better visualization of atoms, a value of 2 will be appropriate.

display.crosses

Whether small crosses should be displayed in the canters of atoms.

display.atom.numbers

Whether atom numbers should be displayed in the canters of atoms.

display.grid

Whether to draw grid lines.

crosses.color

Colour of small crosses.

palette

Palette from the list returned by hcl.pals() function or the string "my custom palette".

rev

rev param in hcl.colors() function.

out.mode

One of the following:

  • "plot" - draws a T-F map on the screen.

  • "file" - saves a T-F map to file file.name (as png file).

  • "RData" - saves the T-F map of size in the file.name (as R's matrix), resampling is performed using the function imager::resize() function.

  • "RData2" - saves the T-F map of size in the file.name (as R's matrix), resampling is performed using the function using raster::resample() function.

path

Path where png, RData or pdf files will be written. If NULL, files will be written to the cache directory.

file.name

Name of the png file (if out.mode="file}) or name of the \code{RData} file (if \code{out.mode="RData"} or \code{out.mode="RData2)

size

png file size in pixels (if out.mode="file") or size of the T-F matrix (if out.mode="RData" of out.mode="RData2").

draw.ellipses

Only for testing. User can set it to TRUE to see the effect. Works properly only if out.mode="plot".

plot.signals

Whether the original and reconstructed signals should also be displayed.

write.atoms

If TRUE, writes all atom plots into Atoms.pdf file (to the cache directory or user specified one - depending on path variable)

Value

Depending on the out.mode parameter the function returns:

  • Time-Frequency map plotted on the screen

  • Time-Frequency map saved in a .png file

  • Time-Frequency map saved as .RData file

Regardless of the above, the function returns the following:

  • all the Gabor functions

  • reconstructed signal

  • original signal

  • sampling frequency

  • grid size in t axis

  • grid size in f axis

  • epoch size in samples

  • length of the signal in seconds

  • time-frequency map

  • time-frequency map after resampling (if out.mode="RData" or if out.mode="RData2", otherwise, NULL is returned)

  • channel number processed

  • frequency divide

Examples

file <- system.file("extdata", "sample1.db", package = "MatchingPursuit")

out <- empi2tf(
  db.file = file,
  channel = 1,
  mode = "sqrt",
  freq.divide = 4,
  increase.factor= 4,
  display.crosses = TRUE,
  display.atom.numbers = FALSE,
  out.mode = "plot",
)


MatchingPursuit documentation built on April 9, 2026, 9:08 a.m.