maaghia / working-on-N2001-EMG-lab-dataset

1 stars 1 forks source link

The Dataset #5

Open O-Memis opened 1 year ago

O-Memis commented 1 year ago

How we can get the dataset, the EMGLab website is not available now, it's not working. Can you share the dataset also?

maaghia commented 1 year ago

Hi, I have uploaded all the signals from the VM muscle to my kaggle account (can be found here: https://www.kaggle.com/datasets/mariatoubal/emglab-vm) My partner has uploaded the signals from the BB muscle (can be found here: https://www.kaggle.com/datasets/lydialoubar/emglab) I still have the full dataset It contains some signals with nan values but I can provide a code to remove them. plz suggest a way of sharing if you need the whole dataset (couldn't upload on github, kaggle and drive)

O-Memis commented 1 year ago

Hi , thank you very much for your share. When I tried to explore the data, I saw that the signal values are extremely small and shows nothing like EMG, its kind a weird. Infinitesimally small positive values, relatively much bigger negative values, nans. Non-nan values are weird. It is a possibility that I have made a serious mistake, here below I wanted to show my code:

import matplotlib.pyplot as plt import numpy as np import os

folder_path = 'C:/Users/CASPER/Desktop/VM'

Initialize a list to hold each signal as a separate numpy array

data_list = []

Loop through each file in the folder

for filename in os.listdir(folder_path): if filename.endswith('.bin'):

Create the full file path

    file_path = os.path.join(folder_path, filename)

    # Load the binary data from the file, reshape it to a 1D array and append it to the list
    data_list.append(np.fromfile(file_path, dtype=np.float64).reshape(-1, 1))

Stack all arrays vertically, so each signal has its own row

VMdataset1 = np.hstack(data_list).T

Print the shape of the result array for verification

print(VMdataset1.shape)

loop through each row (signal) of the data

for i in range(VMdataset1.shape[0]): VMdataset1[i]= np.nan_to_num(VMdataset1[i],nan=0)

aaaa= VMdataset1[2,:]

plt.plot(aaaa)

maaghia commented 1 year ago

This is the code I used to read the dataset, you can also try to look for the physionet dataset I left the link below

from IPython.display import display import matplotlib.pyplot as plt %matplotlib inline import numpy as np import os import shutil import posixpath import wfdb

Demo 1 - Read a WFDB record using the 'rdrecord' function into a wfdb.Record object.

Plot the signals, and show the data.

record = wfdb.rdrecord('C:/Users/lenovo/OneDrive/Documents/working-on-N2001-EMG-labdataset/dataset/N2001A03BB/N2001A03BB51/N2001A03BB51') #here change the path to the one of the dataset on your pc wfdb.plot_wfdb(record=record, title='N2001M01TF52') display(record.dict)

Can also read the same files hosted on PhysioNet

https://physionet.org/content/challenge-2015/1.0.0 in the /training/ database subdirectory.

record2 = wfdb.rdrecord('a103l', pn_dir='challenge-2015/training/')

O-Memis commented 1 year ago

Thank you for your return " ModuleNotFoundError: No module named 'wfdb' " Actually I downloaded it from pip but it gives error in both Spyder and Jupyter notebook. Also I need only EMG dataset, the ECG in physionet is not useful for me.

Additionally, this is an example of signals in the BB and VM datasets :

Figure 2023-11-10 011053

Are BIN files not compatible with numpy and only works with wfdb ? Can you share another version?

O-Memis commented 4 months ago

Okay I solved the WFDB issue. I imported, than used related part of your Kaggle code. Downloading the library and the user guide can be reached by here: https://wfdb.readthedocs.io/en/latest/ And related articles & documents.

However, the acquisition of some of the EMG signals done by the authors are inaccurate and has high variance, in the dataset. This reduces the metric scores of my model. Paying attention to re-selection of data is important I guess. I will be appreciating your suggestions, thanks.