You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+49
Original file line number
Diff line number
Diff line change
@@ -32,3 +32,52 @@ Part of the WFCI data used in this paper is available on PhysioNet. To note, If
32
32
year={2021}
33
33
}
34
34
```
35
+
## Code structure
36
+
```
37
+
└── Scripts
38
+
├── AtlasandIsbrain.mat
39
+
├── AttentionLayer.py
40
+
├── create_tfrecords_over_10s.py
41
+
├── create_tfrecords.py
42
+
├── dataloader_sleep.py
43
+
├── gradcam.py
44
+
├── main.py
45
+
├── model_attention_bilstm.py
46
+
├── mouse_split.json
47
+
├── train_tfrecords.sh
48
+
├── utils.py
49
+
└── visualize_lstm_attention_weights.py
50
+
├── Results
51
+
├── fragmented_sleep.m
52
+
├── overlay_heatmap_gradcam.m
53
+
├── plot_gradcam.m
54
+
├── plot_hypnogram.m
55
+
├── plot_scoring_length.m
56
+
├── tight_subplot.m
57
+
└── visualize_attention_weights.m
58
+
```
59
+
#### In the `Scripts` folder, these are mainly the scripts for training and testing of the bidirectional LSTM model.
60
+
-`main.py`: the main python script to launch the network training, validation, testing, computing the Grad-CAM and extracting the temporal attention weights by defining the parameter `mode` in the config file `train_tfrecords.sh`.
61
+
-`create_tfrecords*.py`: data preprocessing code to create tfrecords from continuous WFCI recordings. When the requested epoch lenghth is large than 10 second, the code takes additional frames in the adjacent epochs to compose the final epoch, eg., take adjacent 5-second in the epoch N-1 and epoch N+1 to compose a 20-second length for epoch N.
62
+
-`dataloader_sleep.py`: the dataloader to create tf.dataset object for network input, need to be modified accordingly.
63
+
-`model_attention_bilstm.py`: code for building the hybrid attention-based bi-lstm model.
64
+
-`AttentionLayer.py`: TensorFlow wrapper functions for building various type of attention module, including the LSTM attention, the spatial [SimAM](http://proceedings.mlr.press/v139/yang21o.html) and [CBAM](https://doi.org/10.48550/arXiv.1807.06521) module.
65
+
-`gradcam.py`: code to compute the [Grad-CAM](https://doi.org/10.48550/arXiv.1610.02391) heatmaps.
66
+
-`visualize_lstm_attention_weights.py`: code to visualize learned attention scores of each time steps in a given 10-s input.
67
+
-`mouse_split.json`: config file to define the train/validation/test split.
68
+
#### In the `Results` folder, these are mainly the MATLAB codes to analyze the sleep scoring results.
69
+
-`plot_hypnogram.m`: cpde to ploy color-coded hypnogram.
70
+
-`plot_gradcam.m`: overlay Grad-CAM heatmap on a selected frame with the help of function `overlay_heatmap_gradcam.m`.
71
+
-`fragmented_sleep.m`: code to calculate the number of sleep transitions and the average length in each of the sleep states.
72
+
-`visualize_attention_weights.m`: visualize the color-coded attention weights.
73
+
## Running the Code
74
+
- The main setup for running the code is running:
75
+
```
76
+
./train_tfrecords.sh
77
+
```
78
+
by setting the `mode` as `train` for training the network, `gradcam` for generating the Grad-CAM heatmap for given inputs and `attention_weights` for extacting the temporal attention scores.
79
+
## Citations
80
+
If you use our codes to investigating the functional brain network in WFCI, and/or the example data in your research, the authors of this software would like you to cite our paper and/or conference proceedings in your related publications.
0 commit comments