Skip to content

Commit 1ae0dd0

Browse files
authored
Uploaded files
1 parent 3f1e7f6 commit 1ae0dd0

15 files changed

Lines changed: 3009 additions & 2 deletions

LICENSE

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
MIT License
22

3-
Copyright (c) 2026 Neil Oxtoby
3+
Copyright (c) 2023 Neil Oxtoby
44

55
Permission is hereby granted, free of charge, to any person obtaining a copy
66
of this software and associated documentation files (the "Software"), to deal
@@ -18,4 +18,4 @@ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
1818
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
1919
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
2020
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21-
SOFTWARE.
21+
SOFTWARE.

README.md

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
# Goldilocks DPM
2+
3+
A Disease Progression Modelling (DPM) implementation of the Goldilocks framework for data-driven model configuration.
4+
5+
Goldilocks (conference paper: [Oxtoby, AAIC 2024](https://doi.org/10.1002/alz.092363)) is a framework for helping users ensure that their data-driven model of choice is configured "just right" for the available data. Conceptually, Goldilocks informs on feature selection and hyperparameter tuning, with respect to signal in the data. This complements work in the field of explainable AI.
6+
7+
![Goldilocks Zone for synthetic ADNI-like data](./in_the_zone.png)
8+
9+
## Contents
10+
11+
1. [goldilocks\_dpm](goldilocks_dpm): python module for implementing the Goldilocks framework within data-driven DPM.
12+
1. [demos](goldilocks_dpm/demos): folder containing demo implementations of various DPMs.
13+
1. [README](goldilocks_dpm/demos/README.md): describes the `goldilocks-dpm` workflow
14+
1. [goldilocks-pysustain.py](goldilocks_dpm/demos/goldilocks-pysustain.py): **Su**btype and **Sta**ge **In**ference
15+
1. Calls [plot\_SuStaIn\_model\_arbitrarycolours.py](goldilocks_dpm/demos/plot_SuStaIn_model_arbitrarycolours.py) which demos how to use arbitrary colours in SuStaIn model plotting (thanks to Alex Young for help with this).
16+
1. **TODO**. [goldilocks\_ebm.py](): Event-Based Model (GMM, KDE, Ordinal Scored Events)
17+
1. [ADNIMERGE2023_synthetic.csv](goldilocks_dpm/demos/ADNIMERGE2023_synthetic.csv): Data mimicking [ADNI](https://adni.loni.usc.edu) data based on ADNIMERGE.csv downloaded in May 2023.
18+
1. [synthetic_data.ipynb](goldilocks_dpm/demos/synthetic_data.ipynb): Jupyter notebook for generating the above, FYI (don't try to run it unless you have an ADNIMERGE CSV to feed into it).
19+
20+
21+
## Workflow
22+
23+
See [goldilocks-pysustain.py](goldilocks_dpm/demos/goldilocks-pysustain.py) for a worked example using ZScoreSustain.
24+
25+
```
26+
## 1. Prepare your data
27+
28+
## 2. Create a Goldilocks DPM object and run the framework
29+
30+
## ZScoreSuStaIn
31+
from goldilocks_dpm import goldilocks_ZscoreSustain
32+
33+
gdpm = goldilocks_ZscoreSustain(
34+
classes = y,
35+
dpmData = X,
36+
output_folder = "path/to/output_folder",
37+
robust_zscores = False,
38+
case_label = 1,
39+
ctrl_label = 0,
40+
direction_abnormal = direction_abnormal,
41+
biomarker_labels = biomarkers
42+
)
43+
44+
gdpm.run_goldilocks()
45+
46+
## 3. Interrogate the resulting output.
47+
print(gdpm.Z_vals)
48+
print(gdpm.Z_max)
49+
50+
```
51+
52+
## Licence
53+
54+
MIT.

goldilocks_dpm/__init__.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# Authors: Neil Oxtoby <github:noxtoby>
2+
# License: MIT
3+
4+
from .goldilocks_dpm import *
5+
from .goldilocks_ZscoreSustain import *

goldilocks_dpm/demos/ADNIMERGE2023_synthetic.csv

Lines changed: 889 additions & 0 deletions
Large diffs are not rendered by default.

goldilocks_dpm/demos/README.md

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
# Goldilocks DPM Demos
2+
3+
Demonstrations of the [Goldilocks-DPM](../) framework for data-driven **D**isease **P**rogression **M**odel configuration.
4+
5+
## Contents
6+
7+
1. [goldilocks-pysustain.py](./goldilocks-pysustain.py): **Su**btype and **Sta**ge **In**ference ([Young et al., Nature Communications 2018](https://doi.org/10.1038/s41467-018-05892-0))
8+
1. Future feature (**TODO**): [goldilocks-ebm.py](): Event-Based Model ([Fonteijn, et al., NeuroImage 2012](https://doi.org/10.1016/j.neuroimage.2012.01.062))
9+
10+
### Workflow for Z-Score SuStaIn
11+
12+
See [goldilocks-pysustain.py](./goldilocks-pysustain.py) for a worked example, but here's a conceptual overview.
13+
14+
* Import the module:
15+
16+
```
17+
from goldilocks_dpm import goldilocks_ZscoreSustain
18+
```
19+
20+
<br/>
21+
22+
* Prepare your data.
23+
- SuStaIn: see examples in [pySuStaIn](https://github.com/ucl-pond/pySuStaIn) for inspiration and guidance.
24+
- EBM: see [kde_ebm](https://github.com/ucl-pond/kde_ebm) and [disease-progression-modelling.github.io](https://disease-progression-modelling.github.io) for inspiration and guidance.
25+
26+
<br/>
27+
28+
* Create a goldilocks ZScoreSustaIn object including your data matrix `X` and vector `y` labelling cases and controls (controls are used to z-score your data):
29+
30+
```
31+
output_folder = Path.cwd() # or wherever you want the output to go
32+
33+
gdpm = goldilocks_ZscoreSustain(
34+
dpmData = X,
35+
classes = y,
36+
output_folder = output_folder,
37+
robust_zscores = False,
38+
case_label = 1,
39+
ctrl_label = 0,
40+
direction_abnormal = direction_abnormal,
41+
biomarker_labels = biomarkers
42+
)
43+
```
44+
45+
<br/>
46+
47+
* Run the goldilocks zone calculation
48+
49+
```
50+
gdpm.run_goldilocks(
51+
plot = True,
52+
plot_format = "png",
53+
verbose = False
54+
)
55+
```
56+
57+
<br/>
58+
59+
* Your `goldilocks_ZscoreSustain` object will now contain the z-scored X data, and goldilocks-suggested pySuStaIn hyperparameters `Z_vals` and `Z_max`
60+

goldilocks_dpm/demos/__init__.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# Authors: Neil Oxtoby <github:noxtoby>
2+
# License: MIT
3+
4+
from .goldilocks_dpm import *
5+
from .goldilocks_ZscoreSustain import *

0 commit comments

Comments
 (0)