Table of Contents
The code in this repository estimates the 'age' of a segment of EEG recording from a paediatric population. This EEG based estimate of age is referred to as the function brain age (FBA). This code relates to the following publication with a Python and Matlab version available.
Inputs:
- (1) EEG file in EDF format (a segment of N2 sleep).
- (2) The age of the subject of EEG recording (expressed in years).
- (3) The prediction algorithm used:
- training dataset: D1, D2 or D1&D2,
- number of channels: 2 or 18,
- algorithm type: neural netowrks or Gaussian process regression [Matlab version only]
Outputs:
- (1) Functional Brain Age (expressed in years).
- (2) Centile from Growth Chart based on our data.
- (3) FBA corrected to align with growth chart.
- (4) Predicted age difference (PAD).
This script is an example of how you may use our trained network. To get a local copy up and running follow the steps below.
- We have tested this script on: Linux (Ubuntu 22.04 LTS), using python 3.9
- Clone the repo and navigate to the folder
git clone https://github.com/brain-modelling-group/functional-brain-age cd functional-brain-age/
- Create python environment, and activate
conda create -n py39-fba python=3.9 conda activate py39-fba
- Install required libraries to run the example
pip install -e .
To see how this works with the default dataset in Python, montage and trained NN, you can simply do:
python demo.py
You should see the following outputs:
Empirical Age is 5 years.
Predicted Functional Brain Age (FBA) is 4.987 years.
Estimated centile from Growth Chart is 38.5%.
Corrected Functional Brain Age (FBA) is [5.6094] years.
Predicted Age Difference (PAD) is: [0.60938]
If you want to use a different NN with 2 channels you can do:
python demo.py --num_channels 2 --onnx_filename fba/data/onnx/D1D2_2ch_model_Opset12.onnx
For usage in MATLAB (tested on 2022a), montage and trained NN, you can simply do the following, where 'path' is the full folder directory where the data is stored and 'filename' is the full name of the .edf file (e.g. 'subject1.edf')
[data,predictFBA,cFBA,centile,pad] = FBA(path,filename,5,'bipolar',[],'NN','D1_NN_18ch_model');
In the MATLAB command window, you should see a similar read out to the Python implementation.
Test runs of NN models executed within 10 seconds on either Python or MATLAB implementations on a Windows PC running an Intel(R) Xeon(R) W-1290P CPU @ 3.70GHz and 64 GB of RAM. 64-bit Operating system.
Distributed under the MIT License. See LICENSE.txt
for more information.
- Nathan Stevenson - nathan dot stevenson at qimrberghofer dot edu dot au
- Kartik Iyer - kartik dot iyer at qimrberghofer dot edu dot au
- If you use this code, please cite:
Iyer, K.K., Roberts, J.A., Waak, M., Vogrin, S.J., Kevat, A., Chawla, J., Haataja, L.M., Lauronen, L., Vanhatalo, S. and Stevenson, N.J., 2024. A growth chart of brain function from infancy to adolescence based on EEG. EBioMedicine, 102. (https://www.thelancet.com/journals/ebiom/article/PIIS2352-3964(24)00096-3/fulltext)
The study was supported by an NHMRC Grant no. 2002135, the HUS Children’s Hospital/HUS diagnostic center research funds, Finnish Academy (335788, 332017), Finnish Pediatric Foundation (Lastentautiensäätiö), Sigrid Juselius Foundation