resurfemg.data_connector.converter_functions module¶
Copyright 2022 Netherlands eScience Center and University of Twente Licensed under the Apache License, version 2.0. See LICENSE for details.
This file contains standardized functions to work with various EMG file types from various hardware/software combinations, and convert them down to an array that can be further processed with other modules.
- resurfemg.data_connector.converter_functions.csv_from_jkmn_to_array(file_name)¶
LEGACY FUNCTION This function takes a file from the Jonkman lab in csv format and changes it into the shape the library functions work on. ————————————————————————– :param file_name: Filename of csv files :type file_name: str
- Returns arrayed:
Arrayed data
- Rtype arrayed:
~numpy.ndarray
- resurfemg.data_connector.converter_functions.dvrmn_csv_freq_find(file_name)¶
LEGACY FUNCTION Extract the sampling rate of a Duiverman type csv of EMG. Note this data may be resampled down by a factor of 10. ————————————————————————– :param file_name: Filename of csv file :type file_name: str
- Returns fs:
Sampling frequency
- Rtype fs:
int
- resurfemg.data_connector.converter_functions.dvrmn_csv_to_array(file_name)¶
LEGACY FUNCTION Transform an already preprocessed csv from the Duiverman lab into an EMG in the format our other functions can work on it. Note that some preprocessing steps are already applied so pipelines may need adjusting. ————————————————————————– :param file_name: Filename of csv file :type file_name: str
- Returns:
arrayed
- Return type:
- resurfemg.data_connector.converter_functions.load_csv(file_path, force_col_reading, verbose=True)¶
This function loads a .csv file and returns the data as a pandas DataFrame. The function also returns metadata such as the loaded channels. ————————————————————————– :param file_path: Path to the file to be loaded :type file_path: str :param force_col_reading: Force column reading for row based .csv files :type force_col_reading: bool :param verbose: Print verbose output :type verbose: bool
- Returns data_df:
Pandas DataFrame of the loaded data
- Rtype data_df:
~pandas.DataFrame
- Returns metadata:
Metadata of the loaded data
- Rtype metadata:
dict
- resurfemg.data_connector.converter_functions.load_file(file_path, key_name=None, channels=None, drop_channels=None, force_col_reading=False, verbose=True)¶
This function loads a file from a given path and returns the data as a numpy array. The function can handle .poly5, .mat, .csv, and .npy files. The function can also rename channels and drop channels from the data. ————————————————————————– :param file_path: Path to the file to be loaded :type file_path: str :param key_name: Key name for .mat files :type key_name: str :param channels: List of channel names to rename the loaded channels :type channels: list :param drop_channels: List of channel names or indices to drop :type drop_channels: list :param force_col_reading: Force column reading for row based .csv files :type force_col_reading: bool :param verbose: Print verbose output :type verbose: bool
- resurfemg.data_connector.converter_functions.load_mat(file_path, key_name, verbose=True)¶
This function loads a .mat file and returns the data as a pandas DataFrame. The function also returns metadata such as the sampling rate, loaded channels, and units. ————————————————————————– :param file_path: Path to the file to be loaded :type file_path: str :param key_name: Key name for .mat files :type key_name: str :param verbose: Print verbose output :type verbose: bool
- Returns data_df:
Pandas DataFrame of the loaded data
- Rtype data_df:
~pandas.DataFrame
- Returns metadata:
Metadata of the loaded data
- Rtype metadata:
dict
- resurfemg.data_connector.converter_functions.load_npy(file_path, verbose=True)¶
This function loads a .npy file and returns the data as a numpy array.¶
- param file_path:
Path to the file to be loaded
- type file_path:
str
- param verbose:
Print verbose output
- type verbose:
bool
- returns data_df:
Pandas DataFrame of the loaded data
- rtype data_df:
~pandas.DataFrame
- returns metadata:
Metadata of the loaded data
- rtype metadata:
dict
- resurfemg.data_connector.converter_functions.load_poly5(file_path, verbose=True)¶
This function loads a .Poly5 file and returns the data as a pandas DataFrame. The function also returns metadata such as the sampling rate, loaded channels, and units. ————————————————————————– :param file_path: Path to the file to be loaded :type file_path: str :param verbose: Print verbose output :type verbose: bool
- Returns data_df:
Pandas DataFrame of the loaded data
- Rtype data_df:
~pandas.DataFrame
- Returns metadata:
Metadata of the loaded data
- Rtype metadata:
dict
- resurfemg.data_connector.converter_functions.matlab5_jkmn_to_array(file_name)¶
LEGACY FUNCTION This file reads matlab5 files as produced in the Jonkman laboratory, on the Biopac system and returns arrays in the format and shape our the ReSurfEMG functions work on. ————————————————————————– :param file_name: Filename of matlab5 files :type file_name: str
- Returns arrayed:
Arrayed data
- Rtype arrayed:
~numpy.ndarray
- resurfemg.data_connector.converter_functions.poly5unpad(to_be_read)¶
Converts a Poly5 read into an array without padding. This padding is a quirk in the python Poly5 interface that pads with zeros on the end. ————————————————————————– :param to_be_read: Filename of python read Poly5 :type to_be_read: str
- Returns unpadded:
Unpadded array
- Rtype unpadded:
~numpy.ndarray
- resurfemg.data_connector.converter_functions.poly_dvrman(file_name)¶
LEGACY FUNCTION This is a function to read in Duiverman type Poly5 files, which has 18 layers/pseudo-leads, and return an array of the twelve unprocessed leads for further pre-processing. The leads eliminated were RMS calculated on other leads (leads 6-12). The expected organization returned is from leads 0-5 EMG data, then the following leads # 6 Paw: airway pressure (not always recorded) # 7 Pes: esophageal pressure (not always recorded) # 8 Pga: gastric pressure (not always recorded) # 9 RR: respiratory rate I guess (very unreliable) # 10 HR: heart rate # 11 Tach: number of breath (not reliable) ————————————————————————– :param file_name: Filename of Poly5 Duiverman type file :type file_name: str
- Returns samps:
Arrayed data
- Rtype samps:
~numpy.ndarray