Reads a binary file generated by Parmay Tech Matrix devices, processes its header and packet data, validates data integrity using CRC32 checksums, and outputs structured sensor data and quality check information.
readParmayMatrix(filename, output = c("all", "sf", "dynrange")[1],
start = 1, end = NULL,
desiredtz = "", configtz = NULL, interpolationType = 1,
read_acc = TRUE, read_gyro = FALSE,
read_temp = TRUE, read_heart = FALSE)A list containing the following elements (when output = "all"):
QClog: A data frame with quality control information, including
checksum validation and data gaps.
output: A data frame with resampled sensor data, including:
timeTimestamps of the recordings.
acc_x, acc_y, acc_zResampled accelerometer data.
gyro_x, gyro_y, gyro_zResampled gyroscope data.
bodySurface_temp, ambient_tempResampled temperature data.
hr_raw, hrResampled heart rate data.
remarksRemarks extracted from the file header.
header: A list with the following elements:
sfSampling frequency of the accelerometer data.
acc_dynrangeDynamic range of the accelerometer.
starttimeStart time of the first packet in POSIXct format.
lastchunk: Logical, indicating if the processed data includes the last packet in the file.
If output = "sf", the function returns only the sampling frequency.
If output = "dynrange", it returns the dynamic range of the accelerometer.
Character. Path to the binary file to be read.
Character. Specifies the type of output. Options include:
Returns the full processed data.
Returns the sampling frequency of the accelerometer data.
Returns the dynamic range of the accelerometer.
Integer. The index of the starting packet to process. Default is 1.
Integer. The index of the ending packet to process. Default is NULL, which means all packets are processed.
Character. Time zone for the returned timestamps. Default is an empty string, which uses the system's default time zone.
Character. Time zone specified in the file's configuration. Default is NULL, which means that it uses desiredtz.
Integer. Specifies the type of interpolation
(see resample) to use when resampling data: 1 for Linear interpolation,
2 for Nearest-neighbor interpolation.
Logical. Indicates whether accelerometer data should be read.
Logical. Indicates whether gyroscope data should be read.
Logical. Indicates whether temperature data should be read.
Logical. Indicates whether heart rate data should be read.
Jairo H Migueles <jairo@jhmigueles.com>
Matrix devices store binary data in packets, with varying lengths depending on the number of sensor recordings in each packet. The function processes the file's header to extract metadata such as the total number of packets and sensor ranges, validates data integrity using CRC32 checksums, and interpolates data to a consistent sampling frequency.
Header Information:
Remarks: Bytes 1-512.
Header string: Bytes 513-516. If not "MDTC", the file is considered corrupt.
Total packets: Bytes 517-520.
Accelerometer dynamic range: Bytes 521-522.
Gyroscope range: Bytes 523-524.
Packet Structure:
Each packet contains accelerometer, gyroscope, temperature, and heart rate data.
8-byte package header.
4-byte CRC32 indicator.
4-byte start timestamp.
4-byte end timestamp.
4-byte number of accelerometer recordings in packet.
4-byte number of gyroscope recordings in packet.
4-byte number of temperature recordings in packet.
4-byte number of heart rate recordings in packet.
Sensor data for accelerometer, gyroscope, temperature, and heart rate.
For more details on Matrix devices', see: https://www.matrixwearable.net/ For additional details on Matrix bin/BIN files structure, please contact manufacturer: https://www.matrixwearable.net/#!/contact
resample for resampling sensor data.
if (FALSE) {
# Example usage:
binfile = system.file("testfiles/mtx_12.5Hz_acc.BIN", package = "GGIRread")
# Read full data and process all packets
result <- readParmayMatrix(binfile)
# Get sampling frequency only
sf <- readParmayMatrix(binfile, output = "sf")
# Get accelerometer dynamic range
dynrange <- readParmayMatrix(binfile, output = "dynrange")
# Process a subset of packets
result_subset <- readParmayMatrix(binfile, start = 10, end = 20)
}
Run the code above in your browser using DataLab