We decided to develop a set of tools to make spectral analysis easier and in order to achieve our research objectives. A description with examples can be found:
Also, I have received many questions about spectral analysis from researchers within and adjacent to the sleep field. I would ask if you have a question about spectral analysis or the software above, that you post it in this forum. The questions and answers will be used to update the documentation and to improve the software.
I have a few questions about reading/loading edf file:
How do I check the contents of an EDF file
How do I load an EDF file?
How do I load staging information
What is the type of information available and where is it stored?
These are great questions!
I will answer in a new topic.
I'd like to check stage using Alpha, Beta, Theda, Delta Bandwidth
so i want separate eeg raw data to separated band width
do you thinks is it possible with Spectral analysis?
The answer to this is yes! Alpha, beta, theta and delta band values are computed automatically with the SpectralTrainFig. The spectral bands by which SpectralTrainFig summarizes the frequency spectrum can be set by uploading a band setting file, which can be found in the programs release section. The instructions for the 'Set Bands' function can be found in the readme associated with the source code.
Thanks for taking the time to respond to forum comments and I'm writing because I keep encountering an error message when I try to run SpectralTrainFig in Matlab 2011. (I know the program calls for 2013 and I did try to download both 2014 and then 2013 but they both require MacOSx of 10.7 or greater which I don't have. But that is a system requirements issue). Anyway I keep getting the following error message below. I was wondering if anyone has had this problem or if you might have an idea of what is going on just from the error.
??? Assignment has more non-singleton rhs dimensions than non-singleton
Error in ==> GetMatchedSleepFiles at 73
splitFileListCellwLabels(2:end, 1) = num2cell([1:1:numMatchedFiles]');
Error in ==> SpectralTrainClass>SpectralTrainClass.computeSpectralTrain at 583
Error in ==> SpectralTrainFig>pb_fig_go_Callback at 275
stcObj = stcObj.computeSpectralTrain;
Error in ==> gui_mainfcn at 96
Error in ==> SpectralTrainFig at 71
Error in ==>
??? Error while evaluating uicontrol Callback
Thank you for posting your question. The run is failing at the data check level. We see these errors during the data check step. My colleague Mike Morical is developing a guide for data checking. For now we need to put on our detective hat when these errors occur. It isn't clear from your post, whether you are using your own data or the test data. Let's continue the conversation by email and then we can post the solution to the forum once you are up an running.
Bridgette and I exchanged several emails. She was able to get the spectral program to run on a Windows machine. We have not tested or run the Spectral program on a Macintosh computer. In theory, all of the functionality in the spectral program can work on a Macintosh platform. If you do your analysis on a Macintosh platform and want to update the code. There are two areas that need to be reviewed. The first is file access commands, which in the past differed across platforms. This should be relatively easy to do. The second area is saving the generated figures as a power point files. Currently, a window mechanism is used. There is no reason a more cross platform approach couldn't be used. Please send me a note if you are interested in using the spectral program on a MAC, so we can proceed accordingly.
Goal: Turn EDF into XML
I've been sent several EDF files to run in Spectral Fig and I believe I need to turn a copy of them into an XML dummy file as seen in the "source code" demo and place those both into my Data folder. Do you know of a simple way to do this conversion or would I need another program to help me do this?
Not exactly. The program requires two types of inputs per subject. The first input is the signal information which is stored in the EDF. The second type of input is the technician scored sleep stages which can be stored in an XML file. Thus, you need an accompanied XML file. I would suggest that you start by looking at the XML file in the SpectralTrainFig release. You will need an XML file with scored sleep stages. I would recommend that you make an XML file with a text editor (not MS Word). On the first step, you want to get the program to get to the point where the XML file is loaded. All of the figures and EXCEL outputs are configured to look for NREM and REM epochs. Getting the program to run all the way through may take a little editing. Email me if there are specific bugs that arise or your not sure how to get the program to run all the way through.
Here are some questions you should direct at your preceptor if you are unclear of the EDF contents: Does the EDF contain sleep and wake data? If the EDF contains sleep data is the scoring data available. If there is sleep data, you will approach editing of the program differently. If NREM and REM doesn't make complete sense, look them up in Wikipedia to start.
I would like to venture into Matlab to bring my invention for EEG sleep/wake analysis outside of the sleep vendor systems that I have been using up to now. REMbrandt, Compumedics. A colleague has written a z-ratio component for me in his EDF Browser http://www.teuniz.net/edfbrowser/.
I wish to show how z-ratio is impervious to differing power analysis routines. So I would like to perform different power analysis (FFT, Wavelet, etc) on the same EDF fle under Matlab and then perform z-ratio independently on the resulting power analyses output.
Any help appreciated.
The project you described is likely quite substantial. How to proceed is dependent on your programming skill level. I am assuming you have a limited programming background. If true, it will take some work to complete the project as described. I would recommend that you find a student that finds the work interesting. If you want to invest your own time, start small and build on successes. Good Luck!
Hello Dennis and Forum Members!
In case anyone has experienced errors trying to open an EDF+ formatted file in the EDF_View Matlab function, Manish Gupta has a quick solution:
-->In Line 431:
digMinStr(end-length(phyMinValueStr)+1:end) = phyMinValueStr;
-->Modify this to:
digMinStr(end-length(digMinValueStr)+1:end) = digMinValueStr;
Save the file, and that should work fine. This should work for both EDF and EDF+ files.
Also a question for Dennis:
I am trying to work with an EDF+ file that was scored in 20 second epochs instead of 30 sec epochs. The coding in your Spectral Train Fig program is written for 30 sec epochs and I keep encountering an error when I try to run the data. This time difference might also affect my creation of a matching XML file so I am curious to know how to remedy the issue. Would a small change in the STFig code do the trick or is reformatting the actual data necessary? I appreciate any help you can provide, thanks!
Thank you for posting how to open EDF+ files!!!
The instructions will allow many more researchers to access their data with the MATLAB tools that we have made available.
Thanks again for looking in to extending the spectral analysis program to analyze data scored with 20 second epochs (variable fixed width epoch). The epoch width is set with the variable 'epochWidth = 30;' at line 647. Coherence epoch is set with the variable epoch at line 2054. Adding two public properties to [epochWidth and epoch] should allow the change to migrate through the program. I try hard to use variables; but, can't promise that some manual editing might not be required. There are two ways that you might want to add the epoch length configuration. The simplest way is to add a functional popup menu to the SpectralTrainFig.fig with guide, (the MATLAB interface editor). Alternatively, there is an entry in the Compumedics XML file that can be changed. SpectralTrainClass.m and the Compumedics XML loader would have to be modified for this approach. Let's switch the discussion to email. Good luck with the edits!
I am trying to use the tool to perform a spectral analysis on awake eeg data.
Is there any quick hack to generate an XML file devoid of sleep stage markers etc?
Is anyone doing this already?
I am sure there are quick hacks. Most of the staging lines could be commented out.
I am personally a fan of adding functionality and keeping the staging information. It would be nice to have one program that can analyze data across wake and sleep. I generally recommend adding an XML file with with the stages set to wake. The XML format is straight forward to generate. The summary and plotting functions are structured around sleep stages. I would recommend adding a section for summarizing or plotting wake data.
There are a couple of people using the spectral program to analyze wake data. It isn't clear if there efforts are ready for release yet.
Dennis thanks for replying. It has been a while sinceI revisited the forum. I come today because I am finding it difficult to get the software running. The instructions for the EDF viewer call for:
1) Make sure you have installed the prerequiste 8.5 Matlab Compile Runtime.
2) Download the compiled application from: https://github.com/nsrr/edf-viewer
3) Unzip the file and place SleepPortalViewer.exe in the desired folder.
I done the first two steps but there is SleepPortalViewer.exe file. There is a file called "SleepPortalViewerR2014bWin64.prj" And help appreciated. And what does "desired folder" mean? Is this the folder containing the EDF files (subfolders)?
I want separate the delta , alpha bands from edf data that I have from https://physionet.org/physiobank/database/sleep-edf/.
I am new to this, so wanted to know what to do next?
Excuse me,I am a freshman,How to understand this database ?
Many of the datasets hosted on the NSRR come with a Dataset Introduction. For example, you can find the one for the Sleep Heart Health Study here: https://sleepdata.org/datasets/shhs/pages/3-dataset-introduction.md
Each of the datasets has public documentation you can read through and you can use the following links as a starting place:
Additionally, you can browse through variables for each dataset, and take a look at the files available for download. For example the SHHS files found here.
Hope that helps!