sig2bin: Reads input signal(s) from a data frame and returns them in...

View source: R/sig2bin.R

sig2binR Documentation

Reads input signal(s) from a data frame and returns them in binary format

Description

Saves the given data (signals) in binary form. Input signal(s) must be a data frame: rows = samples for all channels, columns = channels. The function is used internally in the empi.execute() function. The binary data are floating-point values in the byte order of the current machine (no byte-order conversion is performed). For multichannel signals, first come the samples for all channels at t=0, then for all channels at t=\Deltat and so forth. In other words, the signal should be written in column-major order (rows = channels, columns = samples).

Usage

sig2bin(data, write.to.file = FALSE)

Arguments

data

Data frame with the input signal(s).

write.to.file

If TRUE the bin file will be created and saved in the cache directory.

Value

Input signal returned as the raw. If write.to.file=TRUE, the .bin file will additionally be created and saved in the current directory.

Note

The user does not work directly with .bin files. Binary files are used only in the empi.execute() function. The external program (Enhanced Matching Pursuit Implementation, or EMPI for short) executed inside this function requires binary data as input. Moreover, the ability to convert text files to binary form may be useful if someone wants to work with EMPI independently of the R environment.

Examples

file <- system.file("extdata", "sample3.csv", package = "MatchingPursuit")
out <- read.csv.signals(file)

signal.bin <- sig2bin(data = out$signal, write.to.file = FALSE)

# We have 3 channels. The first 4 time points.
head(out$signal, 4)

# The same elements of the signal in binary (floats are stored in 4 bytes).
head(signal.bin, 48)


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