You can reach me also here:
ORC-iD | 0000-0002-9050-9040 |
ResearchGate | Simon Kern |
@skjerns | |
Website | skjerns.de |
An open-source sleep stage classification Python package
License: GNU Affero General Public License v3.0
You can reach me also here:
ORC-iD | 0000-0002-9050-9040 |
ResearchGate | Simon Kern |
@skjerns | |
Website | skjerns.de |
Hi,
It's really a good project(not flattering, it's really fantastic).
In your thesis, you compared the accuracy of different input channel selection such as eeg, eeg+emg, eeg+eog, and all.
But the coed itself requires all channels?
I wonder how can I run the AutoSleepScorer with only eeg channel?
Sincerely
Liu
Hi there, great project, I'm personally looking into whether any consumer electronics can create the EDF files that you would use in the algorithm, I have a Muse headband device and they seem to have all the requisite sensors but I'm not sure if access to raw data is available for anything but EEG. Any ideas on this front, thanks!
Hi Simon, may I know what is the function of these lines? I had dissect to understand its purpose, but turn out no where. Appreciate if you can shed some light
Especially, the need of the pool.apply and RawArray here. I had read the documentation, but still unable to relate why you used it here.
xx=np.stack([eeg]) # I am able to run even w/o stack vv=mne.create_info(1, self.sfreq, 'eeg') res_eeg = pool.apply_async( mne.io.RawArray(xx, vv, first_samp=0, verbose=0).resample,args=(100.,))
Hi Simon
There is no error in the code running, how can the running result not be found, it is in the folder ./weights in the file?
I am trying to run the example code you posted in README.md. But, when loading the model hdf5 file, it shows an error.
File "h5py/h5f.pyx", line 78, in h5py.h5f.open
OSError: Unable to open file (file signature not found)
It seems like the model files are corrupted when I try to run "h5debug cnn.hdf5".
HDF5-DIAG: Error detected in HDF5 (1.8.16) thread 139994803136256:
#000: ../../../src/H5F.c line 604 in H5Fopen(): unable to open file
major: File accessibilty
minor: Unable to open file
#1: ../../../src/H5Fint.c line 1087 in H5F_open(): unable to read superblock
major: File accessibilty
minor: Read failed
#2: ../../../src/H5Fsuper.c line 277 in H5F_super_read(): file signature not found
major: File accessibilty
minor: Not an HDF5 file
cannot open file
Could you check the model files again?
FYI, I am running your code in Ubuntu 16.04 with python3
How can we get the accuracy and confusion matrix of this model?
Hi Simon
Just want to ask can I get the hypnogram image which contain both human and cnn+lstm as you have paste image in your introduction part just because as I am getting only edf file image
ok !! But I have installed the new version than where I should run the code with the old version of keras , tensorflow and h5py!! How could I install the older version !!
One more that the dropbox link that you have shared if I just click on that link it shows the files are deleted !! Does it affect the code !!
Secondly how will I get the hypnogram so either it will be downloaded or show directly after the successfull execution of code!!
I have found both your code and your masters thesis to be incredibly helpful in doing so. Very recently I was testing your scorer and datasets with a precision marker, and received 55% precision rather than 80%. It is very possible that I made a mistake, so if you have a module/function that computes the accuracy, that will be great. Thank you so much.
Hello, skjerns
I'm Guo, a student in China, and I'm trying to reproduce this code, but I'm having some problems.
When I run the function Scorer() I need to download the model weights from the website "http://cloud.skjerns.de/index.php/s/X3iTwBrRy5qzEtg/download/cnn.hdf5", but the kerncloud website says " The document could not be found on the server. This share may have been deleted or expired." Did you change to another site?
My email is [email protected]
Hi Simon
I'm Jim, a student of China. I'm learning your code. Can you share the hypnograms files of your thesis because of edfx database has been updated, so I can't run the edfx_database.py correctly. My e-mail address is [email protected]. Thanks a lot!
Hello, author.To run AutoSleepScorerDev How much memory do i need? My memory is 16G .Every time there is a memory overflow
Hi Simon
Like how can we create a confusion matrix from our dataset ?
Hi Simon
For Plotting a confusion matrix we require a square matrix but like how can we make a square matrix from the dataset as the data are in the csv format and they are very long entries data so do you apply any code for making matrix or you have just done mannualy or you have done in excel ?
Hi Simon
I am just getting a error
TypeError: 'float' object does not support item assignment
when I am taking the dataset of ST7022JM-Hypnogram.edf or any other hypnogram.edf from physionet in sleep telemetry while converting into csv file format
How do I resolve it !!
Hi, if I download the dataset, how can I to train the model ?
Hi Simon
I have a question for you,I always have such problems when I run code:ModuleNotFoundError: No module named'Scorer',If you have the time, can you answer this question?I would appreciate it if you write back soon.
Hi Simon,
I am starting to train the CNN/RNN on other sleep databases, and the 1st one is the SHHS database, but I have a doubt about the way to set the channels that are used (channels) and I did this:
sleep.available_channels
['SaO2', 'H.R.', 'EEG(sec)', 'ECG', 'EMG', 'EOG(L)', 'EOG(R)', 'EEG', 'THOR RES', 'ABDO RES', 'POSITION', 'LIGHT', 'NEW AIR', 'OX stat']
channels = {'EEG':['EEG(sec)','EEG'], 'EMG':'EMG', 'EOG':['EOG(L)','EOG(R)']} # set channels that are used: EEG(sec) = C3/A2 & EEG = C4/A1
Is it the correct way to retain the two available EEG channels 'EEG(sec)' and 'EEG' ? I ask because the script/training is running, so it has recognized/infered the EEG channel(s), but it missed the EOG channels.
Jeff
hi,There are some problems with your open source project. The address "https://www.dropbox.com/s/87jcp2zdqx833dd/cnn.hdf5? Dl=1" can not be found. can you give me some help?
when training different models (with short kernels & deep architectures for example)... you may want to give a try to:
https://colab.research.google.com
(up to 11.3GB of GPU RAM currently available on my session)
Hi Simon, I'm getting this error.
main.py", line 50, in
if os.path.isdir(path):
TypeError: _isdir: path should be string, bytes or os.PathLike, not NoneType
Could you please help in identifying the reason why the path is inaccessible?
Hi there,
I have successfully run the sleep scorer training part (AutoSleepScorerDev) and generated new cnn & rnn weights:
RuntimeError:
An attempt has been made to start a new process before the
current process has finished its bootstrapping phase.
This probably means that you are not using fork to start your
child processes and you have forgotten to use the proper idiom
in the main module:
if __name__ == '__main__':
freeze_support()
...
The "freeze_support()" line can be omitted if the program
is not going to be frozen to produce an executable.
I use Python 3.6.6, tensorflow 1.10.0, tensorflow-gpu 1.10.0, Keras 2.2.2: did you experiment such runtime errors ?
Take care,
Jean-François Baure
PS) Thanks so much skjerns, your code is very interesting.
Hi Simon
I am just getting an error
Value Error:-Found unexpected instance while processing input tensors for keras functional model. Expecting KerasTensor which is from tf.keras.Input() or output from keras layer call(). Got: 0
How to resolve it !!
From README:
# create a SleepData object
from sleepscorer import Scorer, SleepData
file = SleepData('sample-psg.edf', start = 2880000, stop = 5400000,
channels={'EEG':'EEG Fpz-Cz', 'EMG':'EMG submental',
'EOG':'EOG horizontal'}, preload=False)
# Create and run Scorer
scorer = Scorer([file], hypnograms=True, demo=True)
scorer.run()
# this will only work if you have matplotlib set-up
tools.show_sample_hypnogram('sample-psg.groundtruth.csv', start=960, stop=1800)
Predicting...
100%|█████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 4/4 [00:11<00:00, 2.91s/it]
Still rolling, I should fix that.
Predictions saved to sample-psg.edf.csv
assuming 0=W, 1=S1, 2=S2, 3=SWS, 4=REM
Traceback (most recent call last):
File "start.py", line 8, in <module>
scorer.run()
File "C:\Users\Igoncharov\Anaconda3\envs\env36\lib\site-packages\sleepscorer\sleepscorer.py", line 103, in run
tools.plot_hypnogram(preds, title ='Predictions for {}'.format( os.path.basename(filename)))
File "C:\Users\Igoncharov\Anaconda3\envs\env36\lib\site-packages\sleepscorer\tools.py", line 302, in plot_hypnogram
plt.yticks([0,-1,-2,-3,-4,-5], ['W','REM', 'S1', 'S2', 'SWS' ])
File "C:\Users\Igoncharov\Anaconda3\envs\env36\lib\site-packages\matplotlib\pyplot.py", line 1719, in yticks
labels = ax.set_yticklabels(labels, **kwargs)
File "C:\Users\Igoncharov\Anaconda3\envs\env36\lib\site-packages\matplotlib\axes\_base.py", line 63, in wrapper
return get_method(self)(*args, **kwargs)
File "C:\Users\Igoncharov\Anaconda3\envs\env36\lib\site-packages\matplotlib\cbook\deprecation.py", line 451, in wrapper
return func(*args, **kwargs)
File "C:\Users\Igoncharov\Anaconda3\envs\env36\lib\site-packages\matplotlib\axis.py", line 1796, in _set_ticklabels
return self.set_ticklabels(labels, minor=minor, **kwargs)
File "C:\Users\Igoncharov\Anaconda3\envs\env36\lib\site-packages\matplotlib\axis.py", line 1718, in set_ticklabels
"The number of FixedLocator locations"
ValueError: The number of FixedLocator locations (6), usually from a call to set_ticks, does not match the number of ticklabels (5).
pip install git+https://github.com/skjerns/AutoSleepScorer
Collecting git+https://github.com/skjerns/AutoSleepScorer
Cloning https://github.com/skjerns/AutoSleepScorer to c:\users\igoncharov\appdata\local\temp\pip-req-build-_opres_k
Running command git clone -q https://github.com/skjerns/AutoSleepScorer 'C:\Users\Igoncharov\AppData\Local\Temp\pip-req-build-_opres_k'
Resolved https://github.com/skjerns/AutoSleepScorer to commit 5fa890a81c3ccbc0cab4ebcf87f4acf67311608a
Collecting keras==2.0.6
Using cached Keras-2.0.6.tar.gz (228 kB)
ERROR: Could not find a version that satisfies the requirement tensorflow==1.3.0 (from sleepscorer) (from versions: 2.5.0rc0, 2.5.0rc1, 2.5.0rc2, 2.5.0rc3, 2.5.0, 2.5.1, 2.6.0rc0, 2.6.0rc1, 2.6.0rc2, 2.6.0)
ERROR: No matching distribution found for tensorflow==1.3.0
hello,I run the run_sample.py, but it occurs a error like thess:
File "C:\Users\bc\Desktop\AutoSleepScorerDev-master\keras_utils.py", line 689, in cv
train_data = [data[j] for j in train_idx]
File "C:\Users\bc\Desktop\AutoSleepScorerDev-master\keras_utils.py", line 689, in
train_data = [data[j] for j in train_idx]
IndexError: index 46139 is out of bounds for axis 0 with size 45242
the error occured when the model build the cv dataset, the train index is out of bound.
Hi Simon
I have doubt that how you have calculated the values of accuracy and confusion matrix using certain channel like eeg , eeg+eog and eeg+emg as your model predict all the three channel collectively.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.