resurfemg.config.config module

Copyright 2022 Netherlands eScience Center and Twente University. Licensed under the Apache License, version 2.0. See LICENSE for details.

This file contains one method to let the user configure all paths for data instead of hard-coding them, as well as methods to check data integrity, and create synthetic data. The data integrity can be checked because this file contains hash functions to track data. Synthetic data can be made with several methods.

class resurfemg.config.config.Config(location=None)

Bases: object

This class allows configuration on the home computer or remote workspace, of a file setup for data, which is then processed into a variable. Essentially by setting up and modifying a .json file in the appropriate directory users can avoid the need for any hardcoded paths to data.

default_layout = {'models': '{}/models', 'output': '{}/output', 'preprocessed': '{}/preprocessed', 'root_emg_directory': '{}'}
default_locations = ('./config.json', '/home/runner/.resurfemg/config.json', '/etc/resurfemg/config.json')
get_directory(directory, value=None)
load(location)
required_directories = ['root_emg_directory']
usage()

This is essentally a corrective error message if the computer does not have paths configured or files made so that the data paths of config.json can be used

validate()
resurfemg.config.config.hash_it_up_right_all(origin_folder1, file_extension)

Hashing function to check files are not corrupted or to assure files are changed.

Parameters:
  • origin_folder1 (str) – The string of the folder with files to hash

  • file_extension (str) – File extension

Returns:

Dataframe with hashes for what is in folder

Return type:

DataFrame

resurfemg.config.config.make_realistic_syn_emg(loaded_ecg, number)

This function makes realistic synthetic respiratory EMG data. :param loaded_ecg: synthetic emg/s as numpy array :type loaded_ecg: np.array

Returns:

list_emg

Return type:

list

resurfemg.config.config.make_realistic_syn_emg_cli(file_directory, number, made)

This function works with the cli module to makes realistic synthetic respiratory EMG data through command line.

Parameters:
  • file_directory (str) – file directory where synthetic ecg are

  • number (int) – file directory where synthetic ecg are

  • made (str) – file directory where synthetic emg will be put

resurfemg.config.config.make_synth_emg(long, max_abs_volt, humps)

Function to create a synthetic EMG, not to add longer expirations (relatively flat) the results can be fed to another function.

Parameters:
  • long (int) – The legnth in samples of synth EMG created

  • max_abs_volt (float) – desired abs voltage maximum

  • humps (int) – desired number of inspiratory waves

Returns:

signal

Return type:

array

resurfemg.config.config.simulate_emg_with_occlusions(occs_times_vals, t_start=0, t_end=420, emg_sample_rate=2048, rr=22, ie_ratio=0.5, tau_mus_up=0.3, tau_mus_down=0.3, emg_amp=5, drift_amp=100, noise_amp=2)

This function simulates an surface respiratory emg with no ecg component but with occlusion manuevers. An ECG component can be added and mixed in later.

resurfemg.config.config.simulate_ventilator_with_occlusions(occs_times_vals, t_start=0, t_end=420, fs_vent=2048, rr=22, ie_ratio=0.5, p_mus_max=5, tau_mus_up=0.3, tau_mus_down=0.3, c=0.05, r=5, peep=5, dp=5)

This function simulates ventilator data with occlusion manuevers.