-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
20 changed files
with
3,609 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,38 @@ | ||
# PF-TKRR | ||
Patient-Finetuned Seizure Detection using Tensor Kernel Ridge Regression | ||
## Intro | ||
|
||
This is the public repository for the paper: Efficient Patient-Finetuned Seizure Detection with Tensor Kernel Ridge Regression. | ||
|
||
## Required packages | ||
### Standard packages | ||
The required python packages can be found in [requirements.txt](requirements.txt). | ||
It is recommended to first create a conda environment to install the packages and required python version. This can be done with the [environment.yml](environment.yml) file, which also installs the conda packages. Note that the remaining packages still need to be installed with pip. | ||
|
||
### Additional packages | ||
|
||
For pre-processing the `seizure_data_processing` package is needed: https://github.com/sderooij/seizure_data_processing/releases/tag/v0.0.1 | ||
|
||
In addition to that also the (self-created) `TensorLibrary` package is required, as it contains the CP-KRR model: https://github.com/sderooij/tensorlibrary/releases/tag/v0.0.1. | ||
|
||
|
||
## Usage | ||
Before running the scripts and notebooks please modify the `src/config.py` file. | ||
The order in which the scripts and notebooks need to be run is as follows: | ||
1. `find_tle_patients.ipynb` | ||
2. `feature_exstraction.py` | ||
3. `create_set.ipynb` | ||
4. `preprocess.py` | ||
5. `classification.py` (or run `classify.sh`) | ||
6. `fine_tune.py` | ||
7. `post_process.py` | ||
8. `visualize_results.py` | ||
9. `convergence.py` | ||
10. `convergence_auc_plot.ipynb` | ||
|
||
Explanation on their usage is (in principle) provided in the respective files. Note that there may be issues with import due to different (working) paths | ||
|
||
## Questions | ||
For any questions you can contact: [email protected] | ||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
#!/bin/bash | ||
|
||
# This script runs the classification.py script and saves the output to a text file | ||
# Global variables | ||
FEATURES_DIR="/path/to/features/" | ||
FEATURE_FILE="${FEATURES_DIR}features_ordered.parquet" | ||
GROUP_FILE="${FEATURES_DIR}val_groups.parquet" | ||
OUTPUT_DIR="data/" | ||
CLASSIFIER="svm" # "svm" or "cpkrr" | ||
CV_TYPE="PS" # "PS" or "PI" | ||
GRID_SEARCH="full" # "full" or "random" or "none" | ||
|
||
# Set variables | ||
HYPERPARAM_FILE="data/hyper_parameters_${CLASSIFIER}.json" | ||
OUTPUT_FILE="${OUTPUT_DIR}results_${CLASSIFIER}_${CV_TYPE}.txt" | ||
MODEL_FOLDER="${FEATURES_DIR}models/${CV_TYPE}/" | ||
SAVE_FILE="${FEATURES_DIR}${CV_TYPE}/results_${CLASSIFIER}" | ||
|
||
source ~/miniconda3/etc/profile.d/conda.sh | ||
conda activate seizure_env | ||
start_time="$(date -u +%s)" | ||
python src/scripts/classification.py --cv_type ${CV_TYPE} --classifier ${CLASSIFIER} --hyper_param ${HYPERPARAM_FILE} --feat_file ${FEATURE_FILE} --group_file ${GROUP_FILE} --grid_search ${GRID_SEARCH} --save_file=${SAVE_FILE} --model_folder=${MODEL_FOLDER} >> ${OUTPUT_FILE} | ||
end_time="$(date -u +%s)" | ||
|
||
elapsed="$(($end_time-$start_time))" | ||
echo "Total of $elapsed seconds elapsed for training" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
,file,side,patient,num_seizures | ||
0,train/02_tcp_le/000/00000077/s001_2003_03_18/00000077_s001.txt,left,77,0 | ||
1,train/02_tcp_le/001/00000107/s001_2003_04_15/00000107_s001.txt,left,107,0 | ||
3,train/02_tcp_le/002/00000244/s003_2004_01_08/00000244_s003.txt,right,244,0 | ||
4,train/02_tcp_le/002/00000254/s001_2003_07_30/00000254_s001.txt,left,254,0 | ||
5,train/02_tcp_le/002/00000281/s001_2003_06_21/00000281_s001.txt,right,281,1 | ||
6,train/02_tcp_le/004/00000404/s002_2003_09_11/00000404_s002.txt,right,404,0 | ||
7,train/02_tcp_le/004/00000427/s001_2003_09_15/00000427_s001.txt,left,427,0 | ||
8,train/02_tcp_le/005/00000526/s002_2003_08_11/00000526_s002.txt,left,526,0 | ||
9,train/02_tcp_le/005/00000529/s001_2003_04_28/00000529_s001.txt,left,529,4 | ||
12,train/02_tcp_le/006/00000609/s001_2003_10_22/00000609_s001.txt,left,609,1 | ||
13,train/02_tcp_le/007/00000705/s001_2003_11_26/00000705_s001.txt,left,705,0 | ||
14,train/02_tcp_le/008/00000820/s003_2004_08_03/00000820_s003.txt,right,820,1 | ||
15,train/02_tcp_le/008/00000827/s001_2003_06_05/00000827_s001.txt,left,827,0 | ||
16,train/02_tcp_le/009/00000908/s001_2003_05_30/00000908_s001.txt,left,908,0 | ||
17,train/02_tcp_le/009/00000922/s001_2003_06_17/00000922_s001.txt,left,922,0 | ||
18,train/02_tcp_le/009/00000940/s001_2003_07_08/00000940_s001.txt,right,940,0 | ||
19,train/02_tcp_le/010/00001006/s004_2003_05_05/00001006_s004.txt,left,1006,4 | ||
20,train/02_tcp_le/010/00001026/s001_2003_05_05/00001026_s001.txt,left,1026,0 | ||
21,train/02_tcp_le/010/00001081/s001_2004_03_16/00001081_s001.txt,left,1081,0 | ||
22,train/02_tcp_le/011/00001169/s001_2004_04_21/00001169_s001.txt,right,1169,0 | ||
23,train/02_tcp_le/012/00001267/s003_2004_09_14/00001267_s003.txt,left,1267,0 | ||
24,train/02_tcp_le/013/00001317/s002_2004_05_25/00001317_s002.txt,left,1317,0 | ||
25,train/02_tcp_le/013/00001349/s002_2004_09_21/00001349_s002.txt,right,1349,0 | ||
26,train/02_tcp_le/015/00001543/s001_2004_07_14/00001543_s001.txt,left,1543,5 | ||
28,train/02_tcp_le/016/00001605/s001_2004_01_09/00001605_s001.txt,right,1605,0 | ||
29,train/02_tcp_le/016/00001698/s001_2004_02_13/00001698_s001.txt,right,1698,0 | ||
30,train/02_tcp_le/017/00001795/s001_2004_08_05/00001795_s001.txt,left,1795,2 | ||
31,train/02_tcp_le/018/00001843/s001_2004_07_29/00001843_s001.txt,left,1843,1 | ||
32,train/02_tcp_le/018/00001891/s001_2004_09_08/00001891_s001.txt,right,1891,1 | ||
34,train/02_tcp_le/020/00002021/s001_2004_10_06/00002021_s001.txt,left,2021,0 | ||
35,train/02_tcp_le/020/00002051/s001_2004_02_26/00002051_s001.txt,right,2051,0 | ||
40,train/02_tcp_le/028/00002806/s003_2004_12_28/00002806_s003.txt,right,2806,28 | ||
41,train/02_tcp_le/030/00003005/s003_2010_01_19/00003005_s003.txt,right,3005,0 | ||
44,train/02_tcp_le/031/00003101/s002_2006_07_13/00003101_s002.txt,left,3101,0 | ||
74,train/02_tcp_le/065/00006514/s019_2010_05_17/00006514_s019.txt,left,6514,16 | ||
78,train/02_tcp_le/068/00006811/s004_2010_07_30/00006811_s004.txt,left,6811,5 | ||
81,dev/02_tcp_le/002/00000258/s001_2003_07_16/00000258_s001.txt,right,258,14 | ||
83,dev/02_tcp_le/006/00000629/s001_2003_07_22/00000629_s001.txt,left,629,0 | ||
84,dev/02_tcp_le/019/00001981/s001_2004_02_20/00001981_s001.txt,left,1981,2 | ||
87,dev/02_tcp_le/019/00001984/s001_2004_02_17/00001984_s001.txt,left,1984,2 | ||
88,dev/02_tcp_le/022/00002289/s001_2005_03_02/00002289_s001.txt,left,2289,0 | ||
94,dev/02_tcp_le/054/00005479/s001_2008_11_14/00005479_s001.txt,left,5479,7 | ||
96,dev/02_tcp_le/059/00005943/s001_2009_06_28/00005943_s001.txt,right,5943,11 |
Oops, something went wrong.