4rooms commited on
Commit
fc362d1
·
verified ·
1 Parent(s): 9107657

Add protosleepnet-gagliardi and protosleeptransformer-gagliardi (multi-dataset PSN/PST)

Browse files
README.md CHANGED
@@ -24,6 +24,10 @@ All models follow the AASM 5-class standard: **W, N1, N2, N3, REM**.
24
  | `seqsleepnet-phan` | BiLSTM + Attention | Sleep-EDF | 0.810 | 0.758 | 0.742 | 659K | Phan et al. 2019 |
25
  | `chambon2018` | Braindecode CNN | MASS SS3 | 0.826 | 0.731 | 0.736 | 29K | Chambon et al. 2018 |
26
  | `tsinalis-2016` | 2-layer CNN | Sleep-EDF | 0.773 | 0.661 | 0.683 | 145K | Tsinalis et al. 2016 |
 
 
 
 
27
 
28
  ## Usage
29
 
@@ -37,6 +41,15 @@ from physioex.models import load_embeddings
37
  path = load_embeddings("sleeptransformer-phan", "hmc", verbose=True)
38
  ```
39
 
 
 
 
 
 
 
 
 
 
40
  ## Pre-extracted Embeddings
41
 
42
  | Model | HuggingFace Repo | Datasets |
 
24
  | `seqsleepnet-phan` | BiLSTM + Attention | Sleep-EDF | 0.810 | 0.758 | 0.742 | 659K | Phan et al. 2019 |
25
  | `chambon2018` | Braindecode CNN | MASS SS3 | 0.826 | 0.731 | 0.736 | 29K | Chambon et al. 2018 |
26
  | `tsinalis-2016` | 2-layer CNN | Sleep-EDF | 0.773 | 0.661 | 0.683 | 145K | Tsinalis et al. 2016 |
27
+ | `protosleeptransformer-gagliardi` | Prototype-based Transformer | 28 sites (multi-dataset) | 0.880 | 0.797 | 0.829 | 4.0M | Gagliardi et al. |
28
+ | `protosleepnet-gagliardi` | Prototype-based BiLSTM + Attention | 28 sites (multi-dataset) | 0.872 | 0.780 | 0.818 | 792K | Gagliardi et al. |
29
+
30
+ The two `*-gagliardi` models are trained jointly on 28 sites; ACC / F1 / κ in this table are on the SHHS test subjects (842). Per-site test metrics for every training site are in each model folder (`metrics.json`) and on the [documentation page](https://guidogagl.github.io/physioex/pages/train/networks/protosleepnet.html). These sites were seen in training (other subjects), so the numbers are not an external validation.
31
 
32
  ## Usage
33
 
 
41
  path = load_embeddings("sleeptransformer-phan", "hmc", verbose=True)
42
  ```
43
 
44
+ ### ProtoSleepNet and ProtoSleepTransformer
45
+
46
+ ```python
47
+ model = load_from_pretrained("protosleeptransformer-gagliardi", verbose=True) # L=21; "protosleepnet-gagliardi" has L=20
48
+ # input (batch, L, 3, 29, 129): log-power spectrograms of EEG, EOG, EMG; output (batch, L, 5) logits W/N1/N2/N3/REM
49
+ ```
50
+
51
+ Interpretable, prototype-based sleep staging ([paper and code](https://github.com/guidogagl/protosleepnet), npj Digital Medicine). These checkpoints are the multi-dataset models; they contain no prototype codebook (`quantize=True` needs one learned after training, see the paper repository). Research use only; not a medical device.
52
+
53
  ## Pre-extracted Embeddings
54
 
55
  | Model | HuggingFace Repo | Datasets |
protosleepnet-gagliardi/config.json ADDED
@@ -0,0 +1,67 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "model_class": "physioex.models.protosleepnet:ProtoSleepNet",
3
+ "factory": "from_seq_sleep_net",
4
+ "factory_kwargs": {
5
+ "n_channels": 3,
6
+ "use_channel_mixer": true,
7
+ "cdropout": 0.5,
8
+ "cm_n_heads": 4,
9
+ "cm_d_ff": 256,
10
+ "cm_n_layers": 1
11
+ },
12
+ "training": {
13
+ "backbone": "seq",
14
+ "dataset": "multi-dataset",
15
+ "sites": [
16
+ "alzheimers_hc",
17
+ "dcsm",
18
+ "hmc",
19
+ "hpap",
20
+ "mass_ss01",
21
+ "mass_ss02",
22
+ "mass_ss03",
23
+ "mass_ss04",
24
+ "mass_ss05",
25
+ "mesa",
26
+ "mros",
27
+ "parkinsons_night_hoa",
28
+ "shhs",
29
+ "sleepedf",
30
+ "stages_BOGN",
31
+ "stages_GSBB",
32
+ "stages_GSDV",
33
+ "stages_GSLH",
34
+ "stages_GSSA",
35
+ "stages_GSSW",
36
+ "stages_MSMI",
37
+ "stages_MSNF",
38
+ "stages_MSQW",
39
+ "stages_MSTH",
40
+ "stages_MSTR",
41
+ "stages_STLK",
42
+ "stages_STNF",
43
+ "wsc"
44
+ ],
45
+ "channels": [
46
+ "EEG",
47
+ "EOG",
48
+ "EMG"
49
+ ],
50
+ "pipeline_preset": "seqsleepnet",
51
+ "sequence_length": 20,
52
+ "step": 161500,
53
+ "epoch": 17,
54
+ "max_epochs": 20,
55
+ "epoch_size": 300000,
56
+ "batch_size": 32,
57
+ "lr": 0.0001,
58
+ "weight_decay": 0.0,
59
+ "cdropout": 0.5,
60
+ "scheduler": "plateau",
61
+ "seed": 42,
62
+ "val_subjects_per_site": 30,
63
+ "n_parameters": 792843,
64
+ "model_pt_sha256": "1156a3fe18d3bc8a83a775bcc8e1a1ba08c0c4624b3415a4fc07982e907136db"
65
+ },
66
+ "reference": "Gagliardi et al. - Prototype-based interpretable sleep staging with physiologically meaningful sub-stage pattern discovery (npj Digital Medicine); ProtoSleepNet with a SeqSleepNet epoch encoder"
67
+ }
protosleepnet-gagliardi/metrics.json ADDED
@@ -0,0 +1,158 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "dcsm": {
3
+ "accuracy": 0.8669193387031555,
4
+ "f1_score": 0.7735686242580414,
5
+ "cohen_kappa": 0.8085136413574219,
6
+ "n_subjects": 26
7
+ },
8
+ "hmc": {
9
+ "accuracy": 0.8137681484222412,
10
+ "f1_score": 0.7843350291252136,
11
+ "cohen_kappa": 0.754386842250824,
12
+ "n_subjects": 15
13
+ },
14
+ "hpap": {
15
+ "accuracy": 0.847312867641449,
16
+ "f1_score": 0.8011698484420776,
17
+ "cohen_kappa": 0.790353536605835,
18
+ "n_subjects": 25
19
+ },
20
+ "mass_ss01": {
21
+ "accuracy": 0.8113972544670105,
22
+ "f1_score": 0.760994303226471,
23
+ "cohen_kappa": 0.7239391803741455,
24
+ "n_subjects": 5
25
+ },
26
+ "mass_ss02": {
27
+ "accuracy": 0.9103608727455139,
28
+ "f1_score": 0.8373631477355957,
29
+ "cohen_kappa": 0.8577286601066589,
30
+ "n_subjects": 2
31
+ },
32
+ "mass_ss03": {
33
+ "accuracy": 0.8884488344192505,
34
+ "f1_score": 0.8440731763839722,
35
+ "cohen_kappa": 0.8354583382606506,
36
+ "n_subjects": 6
37
+ },
38
+ "mass_ss04": {
39
+ "accuracy": 0.8713385462760925,
40
+ "f1_score": 0.8337583422660828,
41
+ "cohen_kappa": 0.8140228390693665,
42
+ "n_subjects": 4
43
+ },
44
+ "mass_ss05": {
45
+ "accuracy": 0.8910866379737854,
46
+ "f1_score": 0.8205164313316345,
47
+ "cohen_kappa": 0.8412991166114807,
48
+ "n_subjects": 3
49
+ },
50
+ "mesa": {
51
+ "accuracy": 0.8415964245796204,
52
+ "f1_score": 0.7709669828414917,
53
+ "cohen_kappa": 0.7755186557769775,
54
+ "n_subjects": 206
55
+ },
56
+ "mros": {
57
+ "accuracy": 0.8590859174728394,
58
+ "f1_score": 0.7569057703018188,
59
+ "cohen_kappa": 0.7947317361831665,
60
+ "n_subjects": 219
61
+ },
62
+ "shhs": {
63
+ "accuracy": 0.8721997737884521,
64
+ "f1_score": 0.7802436530590058,
65
+ "cohen_kappa": 0.8181514143943787,
66
+ "n_subjects": 842
67
+ },
68
+ "sleepedf": {
69
+ "accuracy": 0.8423321843147278,
70
+ "f1_score": 0.7936996340751648,
71
+ "cohen_kappa": 0.7777798175811768,
72
+ "n_subjects": 15
73
+ },
74
+ "stages_BOGN": {
75
+ "accuracy": 0.8653397560119629,
76
+ "f1_score": 0.8055032849311828,
77
+ "cohen_kappa": 0.7999787330627441,
78
+ "n_subjects": 8
79
+ },
80
+ "stages_GSBB": {
81
+ "accuracy": 0.8141167759895325,
82
+ "f1_score": 0.6905997812747955,
83
+ "cohen_kappa": 0.7291826605796814,
84
+ "n_subjects": 3
85
+ },
86
+ "stages_GSDV": {
87
+ "accuracy": 0.8038463592529297,
88
+ "f1_score": 0.6973017871379852,
89
+ "cohen_kappa": 0.6794775724411011,
90
+ "n_subjects": 19
91
+ },
92
+ "stages_GSLH": {
93
+ "accuracy": 0.8122743964195251,
94
+ "f1_score": 0.7400574326515198,
95
+ "cohen_kappa": 0.7323593497276306,
96
+ "n_subjects": 3
97
+ },
98
+ "stages_GSSA": {
99
+ "accuracy": 0.8259979486465454,
100
+ "f1_score": 0.6725034892559052,
101
+ "cohen_kappa": 0.6955694556236267,
102
+ "n_subjects": 5
103
+ },
104
+ "stages_GSSW": {
105
+ "accuracy": 0.8364912271499634,
106
+ "f1_score": 0.7105811983346939,
107
+ "cohen_kappa": 0.7221176028251648,
108
+ "n_subjects": 8
109
+ },
110
+ "stages_MSMI": {
111
+ "accuracy": 0.8399351239204407,
112
+ "f1_score": 0.7874741137027741,
113
+ "cohen_kappa": 0.764193058013916,
114
+ "n_subjects": 6
115
+ },
116
+ "stages_MSNF": {
117
+ "accuracy": 0.8536977767944336,
118
+ "f1_score": 0.7420601010322571,
119
+ "cohen_kappa": 0.7350186705589294,
120
+ "n_subjects": 4
121
+ },
122
+ "stages_MSQW": {
123
+ "accuracy": 0.8049342632293701,
124
+ "f1_score": 0.7340189278125763,
125
+ "cohen_kappa": 0.7112038135528564,
126
+ "n_subjects": 15
127
+ },
128
+ "stages_MSTH": {
129
+ "accuracy": 0.8230452537536621,
130
+ "f1_score": 0.7710439085960388,
131
+ "cohen_kappa": 0.7448060512542725,
132
+ "n_subjects": 3
133
+ },
134
+ "stages_MSTR": {
135
+ "accuracy": 0.8494215607643127,
136
+ "f1_score": 0.7995543360710144,
137
+ "cohen_kappa": 0.7792340517044067,
138
+ "n_subjects": 29
139
+ },
140
+ "stages_STLK": {
141
+ "accuracy": 0.8020937442779541,
142
+ "f1_score": 0.7044362127780914,
143
+ "cohen_kappa": 0.7082521319389343,
144
+ "n_subjects": 16
145
+ },
146
+ "stages_STNF": {
147
+ "accuracy": 0.6911861300468445,
148
+ "f1_score": 0.6302476167678833,
149
+ "cohen_kappa": 0.5907843112945557,
150
+ "n_subjects": 49
151
+ },
152
+ "wsc": {
153
+ "accuracy": 0.8327528834342957,
154
+ "f1_score": 0.7292141616344452,
155
+ "cohen_kappa": 0.7345144748687744,
156
+ "n_subjects": 235
157
+ }
158
+ }
protosleepnet-gagliardi/model.pt ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:1156a3fe18d3bc8a83a775bcc8e1a1ba08c0c4624b3415a4fc07982e907136db
3
+ size 3185744
protosleeptransformer-gagliardi/config.json ADDED
@@ -0,0 +1,67 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "model_class": "physioex.models.protosleepnet:ProtoSleepNet",
3
+ "factory": "from_sleep_transformer",
4
+ "factory_kwargs": {
5
+ "n_channels": 3,
6
+ "use_channel_mixer": true,
7
+ "cdropout": 0.5,
8
+ "cm_n_heads": 4,
9
+ "cm_d_ff": 256,
10
+ "cm_n_layers": 1
11
+ },
12
+ "training": {
13
+ "backbone": "st",
14
+ "dataset": "multi-dataset",
15
+ "sites": [
16
+ "alzheimers_hc",
17
+ "dcsm",
18
+ "hmc",
19
+ "hpap",
20
+ "mass_ss01",
21
+ "mass_ss02",
22
+ "mass_ss03",
23
+ "mass_ss04",
24
+ "mass_ss05",
25
+ "mesa",
26
+ "mros",
27
+ "parkinsons_night_hoa",
28
+ "shhs",
29
+ "sleepedf",
30
+ "stages_BOGN",
31
+ "stages_GSBB",
32
+ "stages_GSDV",
33
+ "stages_GSLH",
34
+ "stages_GSSA",
35
+ "stages_GSSW",
36
+ "stages_MSMI",
37
+ "stages_MSNF",
38
+ "stages_MSQW",
39
+ "stages_MSTH",
40
+ "stages_MSTR",
41
+ "stages_STLK",
42
+ "stages_STNF",
43
+ "wsc"
44
+ ],
45
+ "channels": [
46
+ "EEG",
47
+ "EOG",
48
+ "EMG"
49
+ ],
50
+ "pipeline_preset": "seqsleepnet",
51
+ "sequence_length": 21,
52
+ "step": 129000,
53
+ "epoch": 13,
54
+ "max_epochs": 20,
55
+ "epoch_size": 300000,
56
+ "batch_size": 32,
57
+ "lr": 0.0001,
58
+ "weight_decay": 0.0,
59
+ "cdropout": 0.5,
60
+ "scheduler": "plateau",
61
+ "seed": 42,
62
+ "val_subjects_per_site": 30,
63
+ "n_parameters": 3975947,
64
+ "model_pt_sha256": "08d0fbc806fc08dc7d0167e1c2b81b0e2b4f5495bad2c1e5dda6bde14972e603"
65
+ },
66
+ "reference": "Gagliardi et al. - Prototype-based interpretable sleep staging with physiologically meaningful sub-stage pattern discovery (npj Digital Medicine); ProtoSleepNet with a SleepTransformer epoch encoder (ProtoSleepTransformer)"
67
+ }
protosleeptransformer-gagliardi/metrics.json ADDED
@@ -0,0 +1,158 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "dcsm": {
3
+ "accuracy": 0.8702830672264099,
4
+ "f1_score": 0.7813203930854797,
5
+ "cohen_kappa": 0.814110517501831,
6
+ "n_subjects": 26
7
+ },
8
+ "hmc": {
9
+ "accuracy": 0.8149487376213074,
10
+ "f1_score": 0.7894913554191589,
11
+ "cohen_kappa": 0.7542371153831482,
12
+ "n_subjects": 15
13
+ },
14
+ "hpap": {
15
+ "accuracy": 0.8568612933158875,
16
+ "f1_score": 0.8123102903366088,
17
+ "cohen_kappa": 0.8033641576766968,
18
+ "n_subjects": 25
19
+ },
20
+ "mass_ss01": {
21
+ "accuracy": 0.8099777102470398,
22
+ "f1_score": 0.7662928938865662,
23
+ "cohen_kappa": 0.7229146361351013,
24
+ "n_subjects": 5
25
+ },
26
+ "mass_ss02": {
27
+ "accuracy": 0.899495542049408,
28
+ "f1_score": 0.8326705098152161,
29
+ "cohen_kappa": 0.8409970998764038,
30
+ "n_subjects": 2
31
+ },
32
+ "mass_ss03": {
33
+ "accuracy": 0.8935643434524536,
34
+ "f1_score": 0.8462500929832458,
35
+ "cohen_kappa": 0.8430709838867188,
36
+ "n_subjects": 6
37
+ },
38
+ "mass_ss04": {
39
+ "accuracy": 0.8704115748405457,
40
+ "f1_score": 0.8285602331161499,
41
+ "cohen_kappa": 0.8123855590820312,
42
+ "n_subjects": 4
43
+ },
44
+ "mass_ss05": {
45
+ "accuracy": 0.8880821466445923,
46
+ "f1_score": 0.8241837739944458,
47
+ "cohen_kappa": 0.8376818895339966,
48
+ "n_subjects": 3
49
+ },
50
+ "mesa": {
51
+ "accuracy": 0.8423029184341431,
52
+ "f1_score": 0.7783137679100036,
53
+ "cohen_kappa": 0.7777889370918274,
54
+ "n_subjects": 206
55
+ },
56
+ "mros": {
57
+ "accuracy": 0.8716872930526733,
58
+ "f1_score": 0.76549391746521,
59
+ "cohen_kappa": 0.8110989928245544,
60
+ "n_subjects": 219
61
+ },
62
+ "shhs": {
63
+ "accuracy": 0.8797802329063416,
64
+ "f1_score": 0.7969330906867981,
65
+ "cohen_kappa": 0.8292210102081299,
66
+ "n_subjects": 842
67
+ },
68
+ "sleepedf": {
69
+ "accuracy": 0.8419311046600342,
70
+ "f1_score": 0.7802790582180024,
71
+ "cohen_kappa": 0.7753002047538757,
72
+ "n_subjects": 15
73
+ },
74
+ "stages_BOGN": {
75
+ "accuracy": 0.8734385967254639,
76
+ "f1_score": 0.8174633622169495,
77
+ "cohen_kappa": 0.8110359311103821,
78
+ "n_subjects": 8
79
+ },
80
+ "stages_GSBB": {
81
+ "accuracy": 0.8277900815010071,
82
+ "f1_score": 0.7078808963298797,
83
+ "cohen_kappa": 0.7492383718490601,
84
+ "n_subjects": 3
85
+ },
86
+ "stages_GSDV": {
87
+ "accuracy": 0.7771223187446594,
88
+ "f1_score": 0.6878511548042298,
89
+ "cohen_kappa": 0.6485589742660522,
90
+ "n_subjects": 19
91
+ },
92
+ "stages_GSLH": {
93
+ "accuracy": 0.7902125716209412,
94
+ "f1_score": 0.6977275252342224,
95
+ "cohen_kappa": 0.699348509311676,
96
+ "n_subjects": 3
97
+ },
98
+ "stages_GSSA": {
99
+ "accuracy": 0.8213919997215271,
100
+ "f1_score": 0.6764142096042634,
101
+ "cohen_kappa": 0.6922687292098999,
102
+ "n_subjects": 5
103
+ },
104
+ "stages_GSSW": {
105
+ "accuracy": 0.812491238117218,
106
+ "f1_score": 0.6743945777416229,
107
+ "cohen_kappa": 0.6745665073394775,
108
+ "n_subjects": 8
109
+ },
110
+ "stages_MSMI": {
111
+ "accuracy": 0.8343757390975952,
112
+ "f1_score": 0.7943509340286254,
113
+ "cohen_kappa": 0.7625976800918579,
114
+ "n_subjects": 6
115
+ },
116
+ "stages_MSNF": {
117
+ "accuracy": 0.8530546426773071,
118
+ "f1_score": 0.7574287533760071,
119
+ "cohen_kappa": 0.742588996887207,
120
+ "n_subjects": 4
121
+ },
122
+ "stages_MSQW": {
123
+ "accuracy": 0.8185931444168091,
124
+ "f1_score": 0.7487448275089263,
125
+ "cohen_kappa": 0.7301760315895081,
126
+ "n_subjects": 15
127
+ },
128
+ "stages_MSTH": {
129
+ "accuracy": 0.8234567642211914,
130
+ "f1_score": 0.762702202796936,
131
+ "cohen_kappa": 0.743338942527771,
132
+ "n_subjects": 3
133
+ },
134
+ "stages_MSTR": {
135
+ "accuracy": 0.8437274098396301,
136
+ "f1_score": 0.795867669582367,
137
+ "cohen_kappa": 0.7728587985038757,
138
+ "n_subjects": 29
139
+ },
140
+ "stages_STLK": {
141
+ "accuracy": 0.8119391798973083,
142
+ "f1_score": 0.7170879185199738,
143
+ "cohen_kappa": 0.7238086462020874,
144
+ "n_subjects": 16
145
+ },
146
+ "stages_STNF": {
147
+ "accuracy": 0.7204012274742126,
148
+ "f1_score": 0.67246994972229,
149
+ "cohen_kappa": 0.6321213245391846,
150
+ "n_subjects": 49
151
+ },
152
+ "wsc": {
153
+ "accuracy": 0.8454704284667969,
154
+ "f1_score": 0.7394338309764862,
155
+ "cohen_kappa": 0.7503787875175476,
156
+ "n_subjects": 235
157
+ }
158
+ }
protosleeptransformer-gagliardi/model.pt ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:08d0fbc806fc08dc7d0167e1c2b81b0e2b4f5495bad2c1e5dda6bde14972e603
3
+ size 15935623