Structuring and analytics of EMG data from MYO armbands. Work by IAESTE intern Markus Hoff Skudal, summer 2021.
			
		
		| __pycache__ | ||
| .idea | ||
| .vscode | ||
| data | ||
| logs | ||
| .DS_Store | ||
| .gitignore | ||
| Handle_emg_data.py | ||
| mfcc_data_hard.json | ||
| mfcc_data_soft.json | ||
| Neural_Network_Analysis.py | ||
| Present_data.py | ||
| README.md | ||
| Signal_prep.py | ||
| Test_functions.py | ||
Analysis of Keystroke EMG data for identification
EMG data handling and Neural Network analysis
Scripts to handle CSV files composed by 2 * 8 EMG sensors(left & right) devided into sessions per subject. The raw data is organised in a CSV_handler object with Handle_emg_data.py. Processing of data can take the further form of:
- Preprocessing with Signal_prep.py - FFT, MFCC, Wavelet db4
 - Storage for Neural Network analysis with NN_handler(Handle_emg_data.py) - combined EMG DataFrame, combined MFCCs DataFrame
 - Neural Network analysis in Neural_Network_Analysis.py - LSTM NN, etc.
 
Technologies used
- Common libs: Numpy, Pandas, Pathlib, Sklearn, Scipy, Matplotlib, Tensorflow, Keras
 - Community libs: Python_speech_features, PyWavelets
 
Challanges in the module
- The CSV handlig requires a specific data file structure. Se "How to use it"
 - Preprocessing is still limited in Signal_prep.py
 - NB: 
get_samplerate()is configured for a sampling bug. See comment above function in Handle_emg_data.py 
Credits for insporational code
- Kapre: Keunwoochoi
 - Audio-Classification: seth814
 - DeepLearningForAudioWithPyhton: musikalkemist
 - PyWavelets reference: Gregory R. Lee, Ralf Gommers, Filip Wasilewski, Kai Wohlfahrt, Aaron O’Leary (2019). PyWavelets: A Python package for wavelet analysis. Journal of Open Source Software, 4(36), 1237, https://doi.org/10.21105/joss.01237.
 
Table of Contents
| File and classes | Description and help functions | 
|---|---|
| Handle_emg_data.py: * Data_container * CSV_handler * NN_handler  | 
Handles, manipulates, and stores data for analysis.  * Data_container is a class that describes the data for each subject in the experiment. * CSV_handler takes data from CSV files and places it in Data_container for each subject. Use load_data() to load csv data into data containers and add the containers to the CSV_handler's 'data_container_dict', indexed by subject number. Use get_data() to retrieve specific data. * NN_handler prepares data for further analysis in Neural Networks. This class has storage for this data and/or can save it to a json file.  | 
| Signal_prep.py | Does mapping to data and contains various functions. Among others, this contains wavelet,  MFCC, cepstrum and normalization.  | 
| Present_data.py | Contains plot and case functions. Case functions combines many elements from the code and  presents some results described.  | 
| Neural_Network_Analysis.py | Contains functions to load, build and execute analysis with Neural Networks. Main functions are  load_data_from_json(), build_model(), and main()  | 
How to use it
- Clone the repo
 - Place the data files in the working directory
 - Place the data files within the 
data-folder as data is shown originally (format:/data/<datatype>/<subject-folder+ID>/<session-folder>/<left/right-CSV-files>) - Assuming NN analysis:
- Create a 
CSV_handlerobject - Load data with 
load_data(CSV_handler, <datatype>, <filename_type>) - Create 
NN_handlerobject withCSV_handleras input - Load MFCC data into the 
NN_handlerwithstore_mfcc_samples() - Run 
save_json_mfcc()to save samples in json - Run 
Neural_Network_Analysis.pywith desired config 
 - Create a