BIAPT / EEGsonic

3 stars 1 forks source link

Issue where it stops sending messages if the inputs aren't defined correctly #51

Closed jamiecwebber closed 4 years ago

jamiecwebber commented 4 years ago

Following EEG recordings on Wednesday morning November 13, we converted the data to .set using EEGlab and then used "Convert EEG Data" in EEGsonic using the default settings.

When the resulting folders are selected with "Select Replay Directory", none of the items on the right side are checked by default and the sensors have to be selected manually each time you open a new folder (not sure if this is the intended behaviour or I missed selecting a preset somewhere).

Opening a folder with "Select Replay Directory" gives errors in the console:

Error using matlab.ui.control.internal.model.AbstractNumericComponent/set.Value (line 185)
'Value' must be a double scalar within the range of 'Limits'.

Error in EEGsonic_app/update_gui (line 370)
            app.TDFrequencyEditField.Value = app.parameters.td.frequency;

Error in EEGsonic_app/SelectReplayDirectoryButtonPushed (line 1011)
               update_gui(app);

Error using matlab.ui.control.internal.controller.ComponentController/executeUserCallback (line 335)
Error while evaluating Button PrivateButtonPushedFcn.

The help files have a list of electrodes to select for the signals that only use a subset of the EEG. However, with the dPLI when using the default settings from the help file, it looks like it is trying to run the code on an empty array of electrodes, causing an error where there is an invalid value put into a randi function. When no channel are selected, it correctly warns you that "No channels were selected." But selecting only a single channel gives an error:

Error using randi
First input must be a positive scalar integer value IMAX, or two integer values [IMIN IMAX] with IMIN less than or equal to IMAX.

Error in d_PhaseLagIndex_surrogate (line 11)
splice = randi(length(X));  % determines random place in signal where it will be spliced

Error in dpli (line 23)
        surrogates_dpli(index,:,:) = d_PhaseLagIndex_surrogate(eeg_data);

Error in fp_dpli (line 24)
    left_midline_dpli = dpli(left_midline_eeg,eeg_info,parameters);

Error in time_fp_dpli (line 23)
    fp_dpli(fp_dpli_data,eeg_info,parameters.fp_dpli,boolean_mask.fp_dpli);

Error in EEGsonic_app/FrontoparietaldPLICheckBoxValueChanged (line 941)
                   time = time_fp_dpli(app.information, app.parameters);

Error using matlab.ui.control.internal.controller.ComponentController/executeUserCallback (line 378)
Error while evaluating CheckBox PrivateValueChangedFcn.
jamiecwebber commented 4 years ago

I seems like you get that error when any of the 4 signals (right/left * medial/lateral) has a null set of channels, and the program stops sending its messages after the error. Changing the randi on line 11 of d_PhaseLagIndex_surrogate to randi(size(X, 1)) allowed it to continue sending messages, but some of the dPLI signals were being sent with value NaN. I'm also not sure if it's an equivalent calculation.

I was able to get the desired behaviour by selecting a longer list of electrodes, those used in the eegsonic_dynamic_ranges/joe_stress folder. The electrodes are as follows:

wPLI and dPLI: E 4, 10, 11, 16, 18, 19, 27, 33, 34, 51, 58, 59, 61, 62, 67, 72, 77, 78, 96, 97, 101, 116, 122, 123 PAC: E 4, 10, 11, 16, 18, 19, 61, 62, 67, 72, 77, 78 PE: E 9, 11, 22, 24, 52, 62, 70, 75, 83, 92, 124

yacineMahdid commented 4 years ago

There is a problem with the converter, it is using an older version of the data structure.