Sovereign 8s.is mirror of standardgalactic/age_biomarkers
  • HTML 58.6%
  • Python 41.4%
Find a file
Repository files (latest commit first)
Filename Latest commit message Latest commit date
2026-04-21 14:24:19 +02:00
outputs initial commit 2024-11-13 11:09:38 +01:00
source propensity weighting 2026-01-21 14:45:32 +01:00
.gitignore initial commit 2024-11-13 11:09:38 +01:00
.gitmodules added deepali submodule 2024-11-19 12:27:18 +01:00
README.md Update README.md 2026-04-21 14:24:19 +02:00

Medical Images as Biomarkers for Ageing

This is the source code to the submission with the title "Local and Global Patterns Support Medical Imaging as a Biomarker of Ageing".

We investigate how medical images can be used as biomarkers for ageing and provede the source code to reproduce the training and the analyses.

Structure of this Repository

outputs

The outputs folder is used to save result files of the analyses and figures. It also contains the PheWAS results, which can be used in source/analysis/phewas_interactive_plot.py to run the interactive plot. The phewas results are saved in the files phewas_table.csv (without the explicit names of the fields) and phewas_table2.csv with an additional column indicating the feature name.

source

The source folder contains the main source code components. It contains four sub-directories: analysis, cnn, logs, optimizers

analysis

This folder contains python scripts that can be used to perform the analyses of our work.

  • The file config_diseases.py containas the ICD10 codes and self-reported disease codes we used to filter for specific diseases.
  • The file create_frankenstin.py creates the altered Digital Twin with replaced organs.
  • The file disease_analysis.py contains the code to run the analysis of the subjects with diseases.
  • The environment.yaml file contains the environment parameters.
  • The file linear_correction.py can be used to perform the linear correction of the initial predictions.
  • The paths.py file contains all paths - here replaced with pseudo-paths. If you want to run this code, you need to replace all paths to actual data
  • The file perform_phewas.py can be used to perform the PheWAS analysis. The result of our PheWAS analysis is saved in the outpts folder as phewas_table.csv, which can be used to run the interactive plot.
  • phewas_manhattan_plot.html is the intgeractive Manhattan plot as an html file, which can be opened in the browser.
  • The file predict_frankenstein.py can be used to predict the age of the Frankenstein creations.
  • The file survival.py can be used to analyse the correlation between accelerated ageing and survival.
  • The file utils.py contains utility functions necessary to run the anlayses.

cnn

  • The folder dataset contains all python scripts regarding the datasets
  • The folder model contains all python code regarding the models
  • The file data_info.json contains all paths relevant for training the models including data paths, checkpoint paths and paths to csv files containing the train/test/val subjects.
  • The file predict.py can be used to run the prediction with a trained model.
  • The file train_utils.py contains utility functions for training.
  • The file train.py is the main script to start the training.
  • The file trainer.py is been called by train.py to start the training.

registration

This folder contains the code to perform the affine and deformable registration we use for the assessment pipeline and for creating the "Frankenstein Monsters". It also contains a separate environment file ukbb_reg.yaml which can be used to create a new conda environment for the registration code. (see below how to create conda environments.)

Using the Code Base

1. Create conda env and install packages

conda env create --file environment.yaml
conda env activate age_biomarkers

2. Run the training scripts

The training of the Models can be started using the following command. The segmentation parameter indicates the specific organ (e.g. "liver", "lungs", or "all" for the whole body) and the modality parameter specifies whether you want to use the brain images or the whole-body images.

python cnn/train.py --modality whole_body_3d --segmentation lungs

3. Run the predictions

After training, the predict.py file can be used to generate the predicitons of the train/test/val sets. Here no augmentation is applied. The resutls/predictions are then stored in csv files containing the subject IDs, their actual age, the predicted age.

4. Analyse the results

By running the scripts in the analysis folder, the different analyses can be run.

5. Registration pipeline

For running the registration pipleine, the file registration.py in the registration folder can be executed. The subject IDs that are supposed to be set as reference and moving images as well as the paths to the data need to be customised.