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 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 helper_functions or other modules.

resurfemg.data_connector.converter_functions.csv_from_jkmn_to_array(file_name)

This function takes a file from the Jonkman lab in csv format and changes it into the shape the library functions work on.

Parameters:

file_name (str) – Filename of csv files

Returns:

arrayed

Return type:

ndarray

resurfemg.data_connector.converter_functions.dvrmn_csv_freq_find(file_name)

This is means to extract the frequency of a Duiverman type csv of EMG. Note this data may be resampled down by a factor of 10.

Parameters:

file_name (str) – Filename of csv file

Returns:

freq

Return type:

int

resurfemg.data_connector.converter_functions.dvrmn_csv_to_array(file_name)

This transformed 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.

Parameters:

file_name (str) – Filename of csv file

Returns:

arrayed

Return type:

ndarray

resurfemg.data_connector.converter_functions.matlab5_jkmn_to_array(file_name)

This file reads matlab5 files as produced in the Jonkman laboratory, on the Biopac system and returns arrays in the format and shape our functions, those in helper_functions work on.

Parameters:

file_name (str) – Filename of matlab5 files

Returns:

arrayed

Return type:

ndarray

resurfemg.data_connector.converter_functions.poly5unpad(to_be_read)

This function converts a Poly5 read into an array without padding. Note there is a quirk in the python Poly5 interface that pads with zeros on the end.

Parameters:

to_be_read (str) – Filename of python read Poly5

Returns:

unpadded array

Return type:

ndarray

resurfemg.data_connector.converter_functions.poly_dvrman(file_name)

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)

Parameters:

file_name (str) – Filename of Poly5 Duiverman type file

Returns:

samps

Return type:

ndarray

resurfemg.data_connector.converter_functions.save_j_as_np(file_directory, made, force=False)

This is an implementation of the save_j_as_np_single function in the same module which can be run from the commmand-line cli module.

Parameters:
  • file_directory (str) – the directory with EMG files

  • processed (str) – the output directory

  • our_chosen_leads (list) – the leads selected for the pipeline to run over

resurfemg.data_connector.converter_functions.save_j_as_np_single(file_name)

This function takes a file in csv format where teh sequence is top to bottom and changes it into the shape the library functions work on, then saves it as a numpy file

Parameters:

file_name (str) – Filename of csv files

Returns:

arrayed

Return type:

ndarray