Giter VIP home page Giter VIP logo

cnns-on-chb-mit's Introduction

CNNs-on-CHB-MIT

The project is about applying CNNs to EEG data from CHB-MIT to predict seizure. It's a group project assigned at UNIVERSITA' DI CAMERINO for computer science bachelor. The objective of the project was to try to replicate the result obtained in the paper: Truong, Nhan Duy, et al. "Convolutional neural networks for seizure prediction using intracranial and scalp electroencephalogram." Neural Networks 105 (2018): 104-111.

The algorithm consist to create spectograms of the data and than use them with a CNN model to predict seizure.

More information are in presentazione.pdf and relazione.pdf. The two file are respectively the presentation and the relation of the work in italian language.

Getting Started

Prerequisites

In the project anaconda was used to managed the packages. Packages required:

  • keras 2.2.2
  • python 3.6.6
  • tensorflow 1.10.0
  • matplotlib
  • numpy
  • pyedflib
  • scipy

For the evaluation of the network, training and testing, the GPU is used to have a fast evaluation. By using the CPU the training time is a lot more slowly than using GPU. Packages required for GPU:

  • tensorflow-GPU

For the using of the GPU this link was very useful to install all the driver for Ubuntu 18.04 LTS https://medium.com/@naomi.fridman/install-conda-tensorflow-gpu-and-keras-on-ubuntu-18-04-1b403e740e25 (Note that the GPU used was GTX 850M so I can't ensure that the guide linked will work for different hardware).

Installing

Download or clone the repository on your computer and set the parameters:

  • PARAMETERS_DATA_EDITING.txt: contain the parameters for the creation of the spectograms:

    • pathDataSet: path of the folder containing the dataset;
    • FirstPartPathOutput: path of the folder where spectograms will be saved;
  • PARAMETERS_CNN.txt: contain the parameters for the use of CNN:

    • PathSpectogramFolder: Path of the folder containing the spectograms;
    • OutputPath: file where to save the results;
    • OutputPathModels: where to save the CNN models.

Recovering data

The dataset is downloadable from this site: https://archive.physionet.org/pn6/chbmit/. To get all the data it's suggested to use this command:

wget -r --no-parent https://archive.physionet.org/pn6/chbmit/

In the code only patients 1, 2, 5, 19, 21, 23 are used, the others are discarded for problems in the data. NOTE: For the patient 19 replace the summary file(chb19-summary.txt) with the one in this repository inside the folder summaryChanged.

Running

After setted all the parameters run the code.

python DataserToSpectogram.py #Creation of the spectograms
python CNN.py #Creation of the CNN and evaluation of the model on the spectograms
python TestThreshold.py #Search the best thresold for each patient

Contributing

Please read CONTRIBUTING.md for details on our code of conduct, and the process for submitting pull requests to us.

Authors

License

This project is licensed under the GNU GENERAL PUBLIC LICENSE - see the LICENSE.md file for details

cnns-on-chb-mit's People

Contributors

a311987 avatar hirethehero avatar ritwikmishra avatar smorettini avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

cnns-on-chb-mit's Issues

why signalsBlock.shape[0] == 50 save

in DataserToSpectogram.py line 205
if (signalsBlock.shape[0] == 50):
saveSignalsOnDisk(signalsBlock, nSpectogram)

What does 50 mean, is it 50 times of 30 seconds sampling, or is it something else that I don't understand, please forgive me for being a beginner. Thank you very much for your reply

CNN's training data

Actually I have some questions about your code:
1- In the training why did you choose that it be be for each patient apart I mean why didn't you collect the spectrograms for all patients and use it as input for CNN. .
2- How could I know the number of the training data used?

nan

训练19号病人损失为nan,前边的没问题,不知道是什么问题

About generating spectrogram shapes

Hello @ritwikmishra ,
Thank you very much for providing such excellent code, I have a question to ask you .
I check the spectrogram generated in the first part of the code and get ”shape: (50, 21, 59, 114)“, what should I do to make the shape generate three-dimensional ?I would be grateful if you could provide some suggestions and look forward to receiving your reply .

threshold

hi
Why don't consider all 13 patients?
and
what are the threshold?

What does the "real preictal" mean?

What does the "real preictal" mean? I didn't find anything about it in the paper.When you train the CNN,what data will be used? preictal data or real preictal data ?I am really confused. Thank you

Creation of the CNN and evaluation of the model on the spectograms - python CNN.py

while running this code in google colab I am getting this error.


InvalidArgumentError Traceback (most recent call last)

in ()
311
312 if name == 'main':
--> 313 main()
314

3 frames

/usr/local/lib/python3.7/dist-packages/tensorflow/python/eager/execute.py in quick_execute(op_name, num_outputs, inputs, attrs, ctx, name)
53 ctx.ensure_initialized()
54 tensors = pywrap_tfe.TFE_Py_Execute(ctx._handle, device_name, op_name,
---> 55 inputs, attrs, num_outputs)
56 except core._NotOkStatusException as e:
57 if name is not None:

InvalidArgumentError: Graph execution error:


![Capture](https://user-images.git

The full error is attached in the text file below. Please help me to understand this issue.

CNN_training_Error.txt
hubusercontent.com/100077429/169679398-ea893a4a-f382-43a0-a50c-5bd18c4573fa.PNG)

threhold

threhold 中的 secondsInterictalInTest 的数值是怎么得到的

ask for the final result

as for the result of codes, is it normal about chb05:sens=77,FPR=2.8;CHB19:sens=79,fpr=4?The result I got was not good,FPR is very far from zero.May I know your final results?thanks!!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.