Mensen / swa-matlab

Sleep Wave Analysis - an open source toolbox for matlab to score and analyse various waveforms in sleep EEG data
50 stars 20 forks source link

Can I use your toolbox with my .edf documents? #57

Open JJL2018 opened 6 years ago

JJL2018 commented 6 years ago

I want to use your toolbox to detect spindles automatically. Now I have some EEG documents (.edf). Can I use your toolbox to do that? How can I transmit the edf document to MATLAB, then do the analysis?

Mensen commented 6 years ago

If you have the EEGLAB toolbox in your path, you can use their function to import the EDF file...

For example:

[filename, filepath] = uigetfile('*.edf', 'Choose an edf data file -- pop_biosig()');
EEG = pop_biosig(fullfile(filepath, filename));

Once its in the EEGLAB format (two files .set / .fdt), you can load these into the swa toolbox directly and detect spindles... just follow the steps in the template file in the "SS" folder (swa_SS_template.m)

However, you didn't mention whether these EDF files has been preprocessed already. Do they only contain data from sleep stages NREM 2 and/or 3? Bad channels and time points identified? Rereferenced to either average or linked mastoids? This should all be done before trying to detect spindles (but you can of course run the scripts anyway and see what happens).

But essentially the steps would be:

[Data, Info] = swa_convertFromEEGLAB();

% or if you have previously analysed some data
[Data, Info, SS] = swa_load_previous();

% Spindle Detection %
% ----------------- %
% get the default settings for spindle detection
Info = swa_getInfoDefaults(Info, 'SS');

% calculate the canonical / reference / prototypical / representative / model / illustrative wave
[Data.SSRef, Info]  = swa_CalculateReference(Data.Raw, Info);

% find the spindles in the reference
[Data, Info, SS] = swa_FindSSRef(Data, Info);

% find the waves in all channels
[Data, Info, SS] = swa_FindSSChannels(Data, Info, SS);

% save the data
swa_saveOutput(Data, Info, SS, [], 1, 0)

Good luck with your analysis!

JJL2018 commented 6 years ago

Thank you very much! Now I can use your toolbox to detect sleep spindles. Could you please tell me exactly what method you used to detect the spindles? What are your specific detect steps?