I'm looking for Mathlab code for extracting some features such as (Log energy entropy, Norm entropy) from raw EEG signal using Wavelet packet decomposition or any other method. please help.
It seems that a faculty wrote the codes and there are 12 positives rating on it. Thus, it might be functional. Also, there is an email you can perhaps contact to get some functional/original workspaces to test it or prepare yours upon that.
That set aside, it should be rather simple to make it work:
- download the codes (which seems to include three .m files);
- it seems to have two functions: GETMSWPFEAT and mswpd;
- it seems to also have a few lines helps;
- you might need to paste the codes in the same directory as your own codes;
- then, you would probably need to call these two functions and that's it;
- each of these two functions seems to have 4 inputs. Find out what they are, array, vector, constant, string, or object;
- then, prepare those inputs exactly as they should be with your own data, (this part requires special attention to make it work);
I would not trust the codes, nor the math, and I would double check that as well, if you are interested in the method. Otherwise, you can design your own feature extraction methods that fits your data.
- An example of Matlab code for EEG feature extraction is linked below.
- Depending on your application, many ways exist to extract features from EEGs. For instance, it can be as basic as (a) signal segmentation; (b) wavelet decomposition; (c) standard deviation of wavelet coefficients (FEATURE); and (d) exit/threshold criteria to select features of interest.
✪✪✪✪✪✪✪✪✪✪✪✪✪✪✪✪✪✪✪✪✪✪✪✪✪✪✪✪✪✪✪✪
Imagine, an EEG dataset recorded from 3 channels (sensors). A feature extraction pseudo-code may look like something similar to:
Thank you all for help. Dear J. Rafiee I have used the link that you posted (a feature extraction code using the Wavelet Packet Transform (WPT)and found very useful. I have read about WPT but still didn't have clear understanding. After using this code on my dataset I got a good accuracy but still wondering if I'm going on the right direction. I have raw EEG single channel, first I remove the noise and then I used this code to extract the features as follow:
Features1 = getmswpfeat(x,51,32,5,'matlab');
FeaturesN = getmswpfeat(x,51,32,5,'matlab'); X is the EEG signal, window size of 51 at 32 increments, and 5 decomposition levels.
I did this for all EEG record in the dataset and then put the collected features randomly in two matrixes for training and testing the model. each EEG is (1, 4079), when used this code of WPT I got 63 features and 172 samples for each record. But I read the code instruction and not sure what these features. My question " is it correct to use the output of this code directly" or I should work with this output to extract specific features such as (Log energy entropy, Norm entropy). Please help. Thanks in advance
- My answer to your last question: If you test your model and the performance of your system is satisfactory (for example using confusion matrix in MatLab or your own defined performance equation), compared to your training model (which could be a machine learning method, deep/regular neural network, AI-based system, or any other simple statistical or computational algorithms), then you are doing great. Otherwise, you may try to design other mathematical features (make sure your data acquisition processes are rather okay.)
- While it's not clear to me what your classification system is, if any, I guess you are designing a neural network. In that case, one way is that you denoise, extract feature (reduce the data), then feed your matrix (object) to input neurons of neural networks, then see if you could make it converge, which seems to me thats what you are doing.
- In my opinion, there is no rule or right/wrong when it comes to "feature extraction". You may do almost anything mathematically meaningful based on statistics and transformations of various types to find patterns of interests in your data. If it would work, you model is most likely right and that's pretty much it.
- The more precise your system behave with larger datasets, the more advanced system you have designed.
- The base of EEG signal processing is simple: there are two major factors of time and frequency domain data or analytics architectures for such signal preprocessing, in addition to a third dimension of channels (sensors).
- Just as a side for additional understanding, you may perform a sole frequency spectrum analysis to see where your EEG frequencies spike (which basically does not consider the time data).
- If you/your team also collect or find large datasets, you may implement some deep learning methods (which is trending) on your data in addition to wavelet pre-processing.
- Overall, It seems to me you are doing well! So, you may dig a bit more so that you would design novel high-performance features.
Thank you all for help. Dear Dr. J. Rafiee . Thank you very much for your useful explanation. Until now I'm still working to improve the performance of my prediction model as the maximum accuracy I got is 93%. I have used a feature extraction code that you posted using the Wavelet Packet Transform (WPT)).
My question " is how to use this toolbox to extract specific features such as (mean, energy, Log energy entropy, Norm entropy). Please help, I have tried without any success. I would be really grateful if you didn't mind to help me in this context. could you please give a simple example.
It seems that a faculty wrote the codes and there are 12 positives rating on it. Thus, it might be functional. Also, there is an email you can perhaps contact to get some functional/original workspaces to test it or prepare yours upon that.
That set aside, it should be rather simple to make it work:
- download the codes (which seems to include three .m files);
- it seems to have two functions: GETMSWPFEAT and mswpd;
- it seems to also have a few lines helps;
- you might need to paste the codes in the same directory as your own codes;
- then, you would probably need to call these two functions and that's it;
- each of these two functions seems to have 4 inputs. Find out what they are, array, vector, constant, string, or object;
- then, prepare those inputs exactly as they should be with your own data, (this part requires special attention to make it work);
I would not trust the codes, nor the math, and I would double check that as well, if you are interested in the method. Otherwise, you can design your own feature extraction methods that fits your data.
In fact, ΔQ/T can not be turned into dQ/T. That is, the so-called "entropy " doesn't exist at all.
It is well known that calculus has a definition.
Any theory should follow the same principle of calculus; thermodynamics, of course, is no exception, for there's no other calculus at all, this is common sense.
Based on the definition of calculus, we know:
to the definite integral ∫T f(T)dQ, only when Q=F(T), ∫T f(T)dQ=∫T f(T)dF(T) is meaningful.
As long as Q is not a single-valued function of T, namely, Q=F( T, X, …), then,
∫T f(T)dQ=∫T f(T)dF(T, X, …) is meaningless.
1) Now, on the one hand, we all know that Q is not a single-valued function of T, this alone is enough to determine that the definite integral ∫T f(T)dQ=∫T 1/TdQ is meaningless.
2) On the other hand, In fact, Q=f(P, V, T), then
∫T 1/TdQ = ∫T 1/Tdf(T, V, P)= ∫T dF(T, V, P) is certainly meaningless. ( in ∫T , T is subscript ).
We know that dQ/T is used for the definite integral ∫T 1/TdQ, while ∫T 1/TdQ is meaningless, so, ΔQ/T can not be turned into dQ/T at all.
that is, the so-called "entropy " doesn't exist at all.
You can use wentropy function in Matlab, it provide various entropies implementation , including: SURE entropy, threshold entropy, norm entropy, log energy entropy.
These entropies can computing from signal ior their spectrum.
I am also working on my undergraduate project and I am trying to extract features using wavelet transform(I am also not sure if I have to use the wavelet packet decomposition or the wavelet transform code ), I see the code that Rafiee posted here, I read the tutorial but I'm stuck in some points.
I am using CHB MIT data set (23 channels x 921600 samples) sampled on 256 Hz.
I am not sure about how to specify the winsize and wininc in this:
feat = getmswtfeat(x,winsize,wininc,SF)
I am trying to put feat = getmswtfeat(X(:,1),256,32,256) but it gives me an error.
I'm not sure what error you might be getting. But, it is most likely about how to call that function and I just quickly looked into the function, which seems to require the 5 following vars: getmswpfeat(x,winsize,wininc,J,toolbox).
If you use elder versions of Matlab, you would easily used "ent()" code to extract entropy. You also can type ans enter "wavemenu" in command window to access wavelet GUI.