Skip to content

Working example of EEG-based functional brain age (FBA) predictions

Notifications You must be signed in to change notification settings

brain-modelling-group/functional-brain-age

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

MIT License LinkedIn


Functional Brain Age

Table of Contents
  1. About The Project
  2. Getting Started
  3. Usage
  4. To-Do
  5. Contributing
  6. License
  7. Contact
  8. How to cite
  9. Acknowledgments

About The Project

fba_figure1

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).

(back to top)

Built With

  • python
  • onnx

(back to top)

Getting Started

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.

Prerequisites

  • We have tested this script on: Linux (Ubuntu 22.04 LTS), using python 3.9

Installation

  1. Clone the repo and navigate to the folder
    git clone https://github.com/brain-modelling-group/functional-brain-age
    cd functional-brain-age/
  2. Create python environment, and activate
    conda create -n py39-fba python=3.9
    conda activate py39-fba
  3. Install required libraries to run the example
    pip install -e .

(back to top)

Usage

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.

(back to top)

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.

License

Distributed under the MIT License. See LICENSE.txt for more information.

(back to top)

Contact

  • Nathan Stevenson - nathan dot stevenson at qimrberghofer dot edu dot au
  • Kartik Iyer - kartik dot iyer at qimrberghofer dot edu dot au

(back to top)

Citation

  • 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)

Acknowledgments

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

(back to top)