otoolej / qEEG_feature_set

NEURAL: a neonatal EEG feature set in Matlab
BSD 3-Clause "New" or "Revised" License
36 stars 23 forks source link

Unable to run the code for amplitude features, connectivity features and spectral features #2

Closed sivahari1 closed 4 years ago

sivahari1 commented 4 years ago

Dear experts,

I am working on EEG data analysis for the classification tasks. I am looking for a feature extraction technique for classification. I found your paper "NEURAL: quantitative features for newborn EEG using Matlab". It is very interesting and I want to work on it. I have EEG data and I want to calculate quantitative features for classification.

I have downloaded your code but unfortunately, I am not able to run the code. I got the following error message

Struct contents reference from a non-struct array object.

Error in spectral_features (line 47) freq_bands=params_st.freq_bands;

I am working on 62 channel EEG data. it is in form 62*30200 for one trail. Please tell me how to work on your code with this kind of data.

Thank you very much

otoolej commented 4 years ago

Have you modified the 'neural_parameters.m' file? And if so, could you please paste in the file (or changes) here? Thanks.

sivahari1 commented 4 years ago

No, I didn't modify the file. I am using EEG data from 62 (10-20 electrode system) channels, I don't understand the way to modify the file. However, I tried something. LP_fc = 60; % low-pass filter cut-off Fs_new = 256; % down-sample to Fs_new (Hz) (sampling rate 256 Hz) Montage bipolar montage for NICU babies: BI_MONT = {{'F4','C4'},{'F3','C3'},{'C4','T4'},{'C3','T3'},{'C4','Cz'},{'Cz','C3'}, ... {'C4','O2'},{'C3','O1'}}; this is given in your code. Please tell me how to modify this information.

otoolej commented 4 years ago

What version of Matlab are you using? And what operating system?

Also, did you try to run the example before any modifications? e.g. from the README:

% generate EEG-like data (coloured Gaussian noise)
data_st=gen_test_EEGdata(5*60,64,1);

% define feature set (or can define in neural_parameters.m):
feature_set={'spectral_relative_power','rEEG_SD', 'connectivity_BSI'};

% estimate features:
feat_st=generate_all_features(data_st,[],feature_set);
sivahari1 commented 4 years ago

I am using MATLAB 9.0.0.341360 (R2016a) version. Operating system windows10. Also, I run the demo code and got the following error:

Undefined function 'contains' for input arguments of type 'char'.

Error in channel_hemisphere_pairs (line 73) if(contains(ch_left, ch1) || contains(ch_left, ch2))

Error in connectivity_features (line 82) ipairs = channel_hemisphere_pairs(ch_labels);

Error in generate_all_features (line 178) feats_epochs(e,:)=connectivity_features(x_ep,Fs,feat_set{n},[], ...

otoolej commented 4 years ago

Seems like the contains function was introduced in R2016b (see docs). I'll add a fix for this but may be difficult to maintain backwards compatibility for everything, as Matlab is pretty awful for this.

otoolej commented 4 years ago

Can you try replacing

if(contains(ch_left, ch1) || contains(ch_left, ch2))

with

if ~isempty(strfind(ch_left, ch1)) || ~isempty(strfind(ch_left, ch2))

There might be other issues with R2016a too.

sivahari1 commented 4 years ago

Yes, I am able to run the demo code. Please tell me how to modify the neural_parameters.m file for 62 channel EEG data.

otoolej commented 4 years ago

Use the generate_all_features function to generate the features. You can pass either a data structure of the form:

data_st = 

  struct with fields:

           Fs: 64
     eeg_data: [8x19200 double]
    ch_labels: {'C3-O1'  'C4-O2'  'Cz-C3'  'C4-Cz'  'C3-T3'  'C4-T4'  'F3-C3'  'F4-C4'}

as an input argument or the file name to a .mat file containing a similar structure. The fact that you have 64 channels instead of 8 here shouldn't be a problem (or bipolar, i.e. can be monopolar). Set the parameters for the features in neural_parameters.m, or just use the default options.

Pass the features you want to generate as a cell array, as in the demo in the previous post. See help generate_all_features for more details on this function.

sivahari1 commented 4 years ago

Ok,

I will try to work as per your suggestion.

Now I tried with some random data, ex: x=rand(1,10000) and supplied as input, it is giving four numbers of spectral features or amplitude features however we change the data. Is there any standard that the code will give us only four number of features.

otoolej commented 4 years ago

Each of those 4 numbers is for each frequency band. You can change the frequency bands in neural_parameters.m. So for example, using the previous data structure data_st generated previously,


feature_set = {'spectral_relative_power',  'rEEG_SD',   'FD'};
feat_st = generate_all_features(data_st, [], feature_set);

then the features are:

feat_st = 

  struct with fields:

    spectral_relative_power: [0.8710 0.0629 0.0293 0.0354]
                    rEEG_SD: [12.7904 3.1765 2.4088 1.8136]
                         FD: 1.4857

i.e. 4 values for relative spectral power and SD of rEEG for the 4 frequency bands and 1 for fractal dimension (FD) because it is estimated over 1 frequency band, set in neural_parameters.m (as feat_params_st.FD.freq_bands).

Maybe helpful to see Section 5.2 from the arXiv paper.

If that answers your questions then I'll close this thread. If you find other bugs or have any more questions then please open another thread. Thanks.

sivahari1 commented 4 years ago

Dear John, I am really clear with your response and it is really great interaction with you. I think I will get some good results. I want to apply this code for emotion recognition using EEG.

Please allow me to interact with you in the future. I want to do some good work on EEG and fMRI data analysis.

You are really awesome and thank you very much once again.

otoolej commented 4 years ago

You're most welcome, thank you. And again, bugs and questions always appreciated.