Git Product home page Git Product logo

seizure-detection's Introduction

Seizure Detection

This repository contains the winning submission for UPenn and Mayo Clinic's Seizure Detection Challenge on Kaggle.

http://www.kaggle.com/c/seizure-detection

This README and repository modelled on https://www.kaggle.com/wiki/ModelSubmissionBestPractices

##Hardware / OS platform used

  • 15" Retina MacBook Pro (Late 2013) 2.7GHz Core i7, 16GB RAM
  • OS X Mavericks

##Dependencies

###Required

###Optional (to try out various data transforms)

  • pywt (for Daubechies wavelet)
  • scikits talkbox (for MFCC)

##Train the model and make predictions

Obtain the competition data and place it in the root directory of the project.

seizure-data/
  Dog_1/
    Dog_1_ictal_segment_1.mat
    Dog_1_ictal_segment_2.mat
    ...
    Dog_1_interictal_segment_1.mat
    Dog_1_interictal_segment_2.mat
    ...
    Dog_1_test_segment_1.mat
    Dog_1_test_segment_2.mat
    ...

  Dog_2/
  ...

The directory name of the data should match the value in SETTINGS.json under the key competition-data-dir.

Then simply run:

./train.py

One classifier is trained for each patient, and dumped to the data-cache directory.

data-cache/classifier_Dog_1_fft-with-time-freq-corr-1-48-r400-usf-gen1_rf3000mss1Bfrs0.pickle
data-cache/classifier_Dog_2_fft-with-time-freq-corr-1-48-r400-usf-gen1_rf3000mss1Bfrs0.pickle
...
data-cache/classifier_Patient_8_fft-with-time-freq-corr-1-48-r400-usf-gen1_rf3000mss1Bfrs0.pickle

Although using these classifiers outside the scope of this project is not very straightforward.

More convenient is to run the predict script.

./predict.py

This will take at least 2 hours. Feel free to update the classifier's n_jobs parameter in seizure_detection.py.

A submission file will be created under the directory specified by the submission-dir key in SETTINGS.json (default submissions/).

Predictions are made using the test segments found in the competition data directory. They are iterated over starting from 1 counting upwards until no file is found.

i.e.

seizure-data/
  Dog_1/
    Dog_1_test_segment_1.mat
    Dog_1_test_segment_2.mat
    ...
    Dog_1_test_segment_3181.mat

To make predictions on a new dataset, simply replace these test segments with new ones. The files must numbered sequentially starting from 1 otherwise it will not find all of the files.

This project uses a custom task system which caches task results to disk using hickle format and falling back to pickle. First a task's output will be checked if it is in the data cache on disk, and if not the task will be executed and the data cached.

See seizure/tasks.py for the custom tasks defined for this project. More specifically the MakePredictionsTask depends on TrainClassifierTask, which means predict.py will train and dump the classifiers as well as make predictions.

Run cross-validation

./cross_validation.py

Cross-validation set is obtained by splitting on entire seizures. For example if there are 4 seizures, 3 seizures are used for training and 1 is used for cross-validation.

SETTINGS.json

{
  "competition-data-dir": "seizure-data",
  "data-cache-dir": "data-cache",
  "submission-dir": "./submissions"
}
  • competition-data-dir: directory containing the downloaded competition data
  • data-cache-dir: directory the task framework will store cached data
  • submission-dir: directory submissions are written to

Model documentation

Available at https://github.com/MichaelHills/seizure-detection/raw/master/seizure-detection.pdf

seizure-detection's People

Contributors

michaelhills avatar

Watchers

James Cloos avatar Kumari Shalini avatar

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.